This is the opposite problem from what I usually read, these are people trying to get the files included in the NuGet package. I am trying to disconnect a file automatically.
I am creating a library of pre-compiled MVC view templates (using RazorGenerator.Mvc), .less files and JavaScript to support them as needed. The idea is that these are the main things that go into all of our sites.
By default, nuget pack includes any files marked as “Build action: content in your project” that will have any newly created view, .less file or script. There seems to be no way to override this behavior. In this question, the presented solution of the empty <files> node in .nuspec to stop everything includes , but I want to include some files, only the ones that I select.
Now, as a period of time, I can go through, explicitly establish that everything is not Content ("No" is used instead), and then explicitly configure the files that I make and do not want to copy, and where I want them to be copied using the .nuspec file. However, if another developer appears, for example, my future, and forgets this step, then the newly added files will be copied to the package, and then to the destination project during the next installation or update.
I found OctoPack and this will include nothing by default once it detects the <files> node in .nuspec , but I do not use anything from TeamCity, and rewrite the scripts of my build server to figure out how to call OctoPack instead of nuget pack does not make me a great option. OctoPack also has limitations; dependencies must be listed manually, replacement tokens for the .nuspec file must be passed on the command line (instead of reading from AssemblyInfo.cs ), and it just doesn't seem like the tool was intended for this use - they even say: "OctoPack should only be installed the projects you’re about to deploy are console application projects, Windows Service projects, and ASP.NET web applications. Unit tests, class libraries, and other supporting projects will not be selected. " ( OctoPack Documentation )
The following alternative I tried was to use msbuild to simply destroy the Content group during the BeforeBuild event:
<Target Name="BeforeBuild"> <ItemGroup> <Content Remove="**\*.*" /> <None Include="**\*.*" /> </ItemGroup> <Message Text="Content files: @(Content)" Importance="High" /> </Target>
The message verifies that the content group is empty, but the nuget pack does not seem to care; it includes all the files anyway.
Someone has successfully created such a package, without having to manually flag everything. Build action: no, and without using OctoPack?