title: NuGet Pack: ignore default includes
body: <p>This is the opposite problem from what I usually read about, which is people trying to get files included in the NuGet package. I'm trying to <em>stop</em> file from being included automatically.</p>
  
  <p>I'm creating a library of pre-compiled MVC view templates (using RazorGenerator.Mvc), <code>.less</code> files, and JavaScript to support these as needed. The idea is that these are basic things that go into all of our sites. </p>
  
  <p>By default, <code>nuget pack</code> includes any files marked Build Action: <em>Content</em> in your project, which any newly-created view, <code>.less</code> file, or script would be. <strong>There seems to be no option to override this behavior.</strong> A related question here presented a solution of an <a href="https://stackoverflow.com/a/9121513">empty <code>&lt;files&gt;</code> node in the <code>.nuspec</code> to stop all includes</a>, but I want to include <strong>some</strong> files, just only the ones I choose.</p>
  
  <p>Now, as a stopgap, I can go through, explicitly set everything not to be <em>Content</em> (using <em>None</em> instead), then explicitly setup which files I do and don't want copied and where I want them copied to using the <code>.nuspec</code> file. However, if another developer comes along, such as my future self, and forgets this step, then the newly-added files will be copied into the package, and then into the destination project during the next install or update. </p>
  
  <p>I found <strong>OctoPack</strong>, and that will including nothing by default as soon as it detects a <code>&lt;files&gt;</code> node in the <code>.nuspec</code>, but I'm not using anything else from TeamCity, and rewriting my build server scripts to understand how to invoke OctoPack instead of nuget pack doesn't strike me as a great option. OctoPack also has limitations; the dependencies have to be listed manually, the replacement tokens for the .nuspec file have to be passed in on command line (instead of read from <code>AssemblyInfo.cs</code>), and it just doesn't seem like the tool was intended for this use--they even say "OctoPack should only be installed on projects that you are going to deploy - that means the console application projects, Windows Service projects, and ASP.NET web applications. Unit tests, class libraries, and other supporting projects wouldn't be selected." (<a href="http://docs.octopusdeploy.com/display/OD/Using+OctoPack%20(OctoPack%20documentation)" rel="nofollow noreferrer">OctoPack Documentation</a>)</p>
  
  <p>The next alternative I tried was using <code>msbuild</code> to simply wipe out the Content group during the <code>BeforeBuild</code> event:</p>
  
  <pre><code>&lt;Target Name="BeforeBuild"&gt;
      &lt;ItemGroup&gt;
        &lt;Content Remove="**\*.*" /&gt;
        &lt;None Include="**\*.*" /&gt;
      &lt;/ItemGroup&gt;
    &lt;Message Text="Content files: @(Content)" Importance="High" /&gt;
  &lt;/Target&gt;
  </code></pre>
  
  <p>The message verifies that the Content group is empty, but <code>nuget pack</code> doesn't seem to care; it still includes all the files anyway.</p>
  
  <p>Has anyone successfully created a package like this, without having to manually mark everything Build Action: <em>None</em> and without using OctoPack?</p>