Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing referenced assembly PDB and XML files copied to output

People also ask

How do I exclude a PDB file?

If you want to disable pdb file generation, you need to use the "Advanced build settings" dialog available in project properties after clicking the "Advanced..." button" located in the lower part of the Build tab. Set Output - Debug info: to None for release build configuration and no pdb files will be generated.

Are PDB files required?

No, you don't have to deploy the . pdb file. To quote from MSDN, "A PDB file is created when you build with /debug (Visual Basic/C#).", so it shouldn't be creating the debug database when compiling for release.


I wanted to be able to add and remove referenced assemblies in my primary application while avoiding the the need to maintain which files I needed to delete or exclude.

I dug through Microsoft.Common.targets looking for something that would work and found the AllowedReferenceRelatedFileExtensions property. It defaults to .pdb; .xml so I explicitly defined it in my project file. The catch is that you need something (whitespace is not sufficient) otherwise it will still use the default.

<Project ...>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    ...
    <AllowedReferenceRelatedFileExtensions>
      <!-- Prevent default XML and PDB files copied to output in RELEASE. 
           Only *.allowedextension files will be included, which doesn't exist in my case.
       -->
      .allowedextension
    </AllowedReferenceRelatedFileExtensions> 
  </PropertyGroup>

You can also specify this via the command line:

MsBuild.exe build.file /p:AllowedReferenceRelatedFileExtensions=none

You can add a Post Build event command similar to del "$(TargetDir)YourAssembly*.xml", "$(TargetDir)YourAssembly*.pdb"


This is a rather old question, but since there is no answer about how to turn off generating PDB and XML files via UI, i figured that it should be here for completeness.

In Visual Studio 2013: in project properties, under compile tab, uncheck "Generate XML documentation file", then click on "Advanced Compile Options" below that and change "Generate debug info" to "None", and that will do the trick.