How to exclude files from package with Build Action Content

Oct 31, 2011 at 8:52 PM

We have a project (DotSpatial.Data.Rasters.GdalExtension32) that includes dll files as content. This is great when running locally, but these files end up being packaged into the content folder when we pack:

nuget.exe pack  "C:\dev\DotSpatial\DotSpatial.Data.Rasters.GdalExtension32\DotSpatial.Data.Rasters.GdalExtension32.csproj"


We're able to get copies of the dlls into the lib folder by adding a files section in our .nuspec.

    <file src="..\Debug\bin\Data Extensions\GDAL\*.dll" target="lib\net40" />
    <file src="..\Debug\bin\Data Extensions\GDAL\*.pdb" target="lib\net40" />

However, we are left with copies in the content folder.

Is there a way to 1) pack using the command line and 2) prevent all of the warnings related to assemblies in the content folder?

Issue: Assembly outside lib folder.Description: The assembly 'content\xerces-c_2_8.dll' is not inside the 'lib' folder and hence it won't be added as reference when the package is installed intoa project.Solution: Move it into 'lib' folder.

Oct 31, 2011 at 9:14 PM

Those warnings are harmless. You can just ignore them. If you want to turn the analysis off, you can pass the -NoPackageAnalysis flag to the pack command. Note, however, that it will also suppress all other analysis rules. We're also considerting allowing turning off specific rule.


Oct 31, 2011 at 9:27 PM

Great to know.

We're left with copies of the files in two locations, though.

During build the files are dropped into 

\Debug\bin\Data Extensions\GDAL\

Then, during packaging, one copy goes to 


as specified and another goes to "content" auto magically (based on the csproj file settings). How do we prevent that second copy from going to content while allow local builds to work?

Oct 31, 2011 at 9:40 PM
Edited Oct 31, 2011 at 9:45 PM

The pack command has an -Exclude parameter which you can use to exclude those files. You can type "nuget.exe help pack" to know more about all the parameters of pack command.

Nov 1, 2011 at 5:03 PM

After reading, I thought the following command would work (in conjunction with the files section in the nuspec) but I'm not having any luck, yet.

nuget.exe pack  "C:\dev\DotSpatial\DotSpatial.Data.Rasters.GdalExtension32\DotSpatial.Data.Rasters.GdalExtension32.csproj" -Exclude **\*.dll

With this command, I end up with only DotSpatial.Data.Rasters.GdalExtension.pdb in the lib/net40 folder.

Nov 1, 2011 at 6:25 PM

It looks like the solution is to set Build Action to 'None' and Copy to Output Directory to 'Copy if newer'