NuGet: include .pdb files and exclude the "Content" folder

12,517

Solution 1

Unfortunately, I don't think you'll be able to both exclude the content files and include the .pdb files while packing via the project. You could do one or the other.

First, make a nuspec file (the nuget spec command makes this quick) and put it in the same location as your project. When you pack your project, NuGet.exe will treat the spec as a supplement to your project's info.

To eliminate the content folder, when packing a project that also has a .nuspec file, an empty <files /> node in the spec will indicate that you don't want any content files, even if they exist in the project.

To include the debug files, add something like this to your spec:

  <files>
    <file src="bin\*.pdb" target="lib\net35\" />    
  </files>

but that would tell the tool that you do have content, and then it would add all the other files, as well. You could, perhaps, make a symbol package for your project, instead.

Another option would be to build exclusively from the spec (nuget pack Test.nuspec), and specify exactly the files you want to include. It's more time consuming, but it gives you complete control over the package's contents.

Solution 2

On the content files that you don't want to package, do you need them to have a Build Action of "Content" in your project (in the properties window of the file in Visual Studio, if that is your IDE)?

If it is acceptable to change the Build Action to "None" (or anything else), then it won't end up in the content folder.

Share:
12,517
David
Author by

David

Updated on June 20, 2022

Comments

  • David
    David almost 2 years

    I've incorporated the following line in the CI-build to create a private NuGet package on each build:

    nuget pack C:\Projects\Test\Test.vbproj -OutputDirectory \\nas1\NuGet 
    

    The AssemblyInfo is read (including the version number) and a NuGet package is created.
    I'd like the package to include the .pdb files and not contain a "Content" folder (so only the 'lib').

    How can I change the command to do that?

  • brainiac10
    brainiac10 over 12 years
    After giving this some more thought, I suppose it's technically possible to do this through the command line by including the .pdb through the spec (as above) and then using the -Exclude flag to omit file types that you don't want. But you would have to exclude every single file type that's not a dll or pdb that would be included in "content", which may or may not be practical for you. For example, this would exclude config, xml, and transform files from the package (and include pdb files, since they're set in the .nuspec): nuget pack -Exclude **\*.config;**\*.xml;**\*.transform
  • Rick Mohr
    Rick Mohr almost 11 years
    +1 for eliminating the content folder with an empty <files \> node.
  • Luiz Henrique Martins Lins Rol
    Luiz Henrique Martins Lins Rol over 7 years
    The empty <files/> solution is not working anymore for me.