<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Nuget Archives - Blog IT</title>
	<atom:link href="https://blogit.create.pt/category/dotnet/nuget/feed/" rel="self" type="application/rss+xml" />
	<link>https://blogit.create.pt/category/dotnet/nuget/</link>
	<description>Create IT blogger community</description>
	<lastBuildDate>Thu, 10 Jan 2019 12:46:09 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>How to add your custom content files into a nuget package (for Visual Studio)</title>
		<link>https://blogit.create.pt/gustavobrito/2018/01/12/how-to-add-your-custom-content-files-into-a-nuget-package-for-visual-studio/</link>
					<comments>https://blogit.create.pt/gustavobrito/2018/01/12/how-to-add-your-custom-content-files-into-a-nuget-package-for-visual-studio/#comments</comments>
		
		<dc:creator><![CDATA[Gustavo Brito]]></dc:creator>
		<pubDate>Fri, 12 Jan 2018 15:49:08 +0000</pubDate>
				<category><![CDATA[Nuget]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[$rootnamespace$]]></category>
		<category><![CDATA[add files]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[cml]]></category>
		<category><![CDATA[content]]></category>
		<category><![CDATA[contentFiles]]></category>
		<category><![CDATA[custom]]></category>
		<category><![CDATA[customfiles]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[external]]></category>
		<category><![CDATA[external files]]></category>
		<category><![CDATA[nupkg]]></category>
		<category><![CDATA[nuspec]]></category>
		<category><![CDATA[package]]></category>
		<category><![CDATA[packaging]]></category>
		<category><![CDATA[pp]]></category>
		<category><![CDATA[targets]]></category>
		<category><![CDATA[transform]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[visual studio nuget]]></category>
		<category><![CDATA[xdt]]></category>
		<category><![CDATA[XML]]></category>
		<guid isPermaLink="false">http://blogit.create.pt/gustavobrito/?p=1214</guid>

					<description><![CDATA[<p>Yesterday, I was assigned to fix a nuget package solution that was not packing all the needed files. I had a bad time searching online for answers, and had to dig in by myself. After I discovered how to include the files that I needed, I decided to create a simple tutorial that has it [&#8230;]</p>
<p>The post <a href="https://blogit.create.pt/gustavobrito/2018/01/12/how-to-add-your-custom-content-files-into-a-nuget-package-for-visual-studio/">How to add your custom content files into a nuget package (for Visual Studio)</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Yesterday, I was assigned to fix a nuget package solution that was not packing all the needed files. I had a bad time searching online for answers, and had to dig in by myself. After I discovered how to include the files that I needed, I decided to create a simple tutorial that has it all!</p>
<p>This tutorial will show you how to include your non-compilable items into a nuget package (nupkg). This steps apply to any type of file.</p>
<p><span id="more-1214"></span></p>
<p><strong>DISCLAIMER: You must have a nuspec file and a targets file. If you don&#8217;t have one yet, download one from somewhere and change the metadata accordingly.</strong></p>
<p><strong>Let&#8217;s start!</strong></p>
<ol>
<li>Open up your solution in Visual Studio</li>
<li>Open your solution&#8217;s nuspec file and look for <strong>&lt;files&gt;</strong> tag</li>
<li>You need to reference <strong>all folders and all files</strong> that you want to include in your nuget. Example below:</li>
</ol>
<blockquote>
<pre class="brush: xml; title: ; notranslate">
&lt;files&gt;
    &lt;file src=&quot;lib\net452\your_compiled_assembly.dll&quot; target=&quot;lib\net452&quot; /&gt;
    &lt;file src=&quot;Your_Folder\*.pp&quot; target=&quot;content\Your_Folder&quot;/&gt;
    &lt;file src=&quot;Your_Folder\Your_Sub_Folder\*.*&quot; target=&quot;content&quot; /&gt;
    &lt;file src=&quot;*.xdt&quot; target=&quot;content&quot; /&gt;
 &lt;/files&gt;
</pre>
</blockquote>
<p>4.  After you added all files into nuspec config, now you can open your targets file. Don&#8217;t forget to import targets into your csproj file like the example below</p>
<pre class="brush: xml; title: ; notranslate">
&lt;Import Project=&quot;your_targets_file.targets&quot; Condition=&quot;Exists('your_targets_file.targets')&quot; /&gt;
</pre>
<p>5. Now to targets file, you must index <strong>ALL </strong>files that you want to add to your nuget. <strong>This step is very important</strong></p>
<div>
<pre class="brush: xml; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;Project ToolsVersion=&quot;14.0&quot; DefaultTargets=&quot;Build&quot; xmlns=&quot;http://schemas.microsoft.com/developer/msbuild/2003&quot;&gt;
 &lt;TargetName=&quot;CreatePackage&quot;&gt;
   &lt;PropertyGroup&gt;
   &lt;Configuration&gt;Release&lt;/Configuration&gt;
   &lt;PackageSource&gt;bin\$(Configuration)\Package&lt;/PackageSource&gt;
   &lt;NuSpecPath&gt;$(MSBuildProjectName).nuspec&lt;/NuSpecPath&gt;
   &lt;/PropertyGroup&gt;
   &lt;RemoveDirDirectories=&quot;$(PackageSource)&quot;/&gt;
   &lt;MSBuildProjects=&quot;$(MSBuildProjectFullPath)&quot; Targets=&quot;Rebuild&quot;Properties=&quot; TargetFrameworkVersion=v4.0; OutputPath=bin\$(Configuration)\net40;Configuration=$(Configuration)&quot; BuildInParallel=&quot;$(BuildInParallel)&quot;/&gt;


   &lt;Copy SourceFiles=&quot;bin\$(Configuration)\net40\$(AssemblyName).dll&quot; DestinationFolder=&quot;$(PackageSource)\lib\net40&quot;/&gt;
   &lt;Copy SourceFiles=&quot;$(NuSpecPath)&quot; DestinationFolder=&quot;$(PackageSource)&quot;/&gt;
   &lt;Copy SourceFiles=&quot;Your_Folder\Your_Class_File.cs.pp&quot; DestinationFolder=&quot;$(PackageSource)\Your_Folder&quot;/&gt;
   &lt;Copy SourceFiles=&quot;Your_Folder\Yet_Another_Class.cs.pp&quot; DestinationFolder=&quot;$(PackageSource)\Your_Folder&quot;/&gt;
   &lt;Copy SourceFiles=&quot;Your_Folder\Your_Sub_Folder\A_Class.cs.pp&quot; DestinationFolder=&quot;$(PackageSource)\Your_Folder\Your_Sub_Folder&quot;/&gt;
   &lt;Copy SourceFiles=&quot;Your_Images_Folder\Your_Image.jpeg&quot; DestinationFolder=&quot;$(PackageSource)\Your_Images_Folder&quot;/&gt;
   &lt;Copy SourceFiles=&quot;Your_root_file.xml&quot; DestinationFolder=&quot;$(PackageSource)&quot;/&gt;
 &lt;/Target&gt;
&lt;/Project&gt;
</pre>
</div>
<p>6. After you added all your source files into your targets file, you are ready to pack it!!</p>
<p><strong>File extensions for Transformations and generated classes:</strong></p>
<ol>
<li>A <strong>pp </strong>file extension is a class that&#8217;s generated when a nuget is installed in any solution. Usually, the class namespace is replaced by &#8220;<strong>$rootnamespace$&#8221;</strong> (without quotes) and the extension is added (yourclass.cs<strong>.pp</strong>)</li>
<li>A <strong>xdt </strong>file extension is a <a href="https://msdn.microsoft.com/en-us/library/dd465326(v=vs.110).aspx">XML Transformation procedure</a>.</li>
</ol>
<p>Example of a <strong>*.pp </strong>class ready to be packed into a nuget:</p>
<pre class="brush: csharp; title: ; notranslate">
namespace $rootnamespace$.App_Start
{
 using System;
 using System.Collections.Generic;
 using System.Configuration;
 using System.Linq;
...
}
</pre>
<p>That&#8217;s all folks!</p>
<p>The post <a href="https://blogit.create.pt/gustavobrito/2018/01/12/how-to-add-your-custom-content-files-into-a-nuget-package-for-visual-studio/">How to add your custom content files into a nuget package (for Visual Studio)</a> appeared first on <a href="https://blogit.create.pt">Blog IT</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blogit.create.pt/gustavobrito/2018/01/12/how-to-add-your-custom-content-files-into-a-nuget-package-for-visual-studio/feed/</wfw:commentRss>
			<slash:comments>7</slash:comments>
		
		
			</item>
	</channel>
</rss>
