Preventing referenced assembly PDB and XML files copied to output
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.
top 2 answers didn't work for me. I found a solution in this link which worked for me. http://kitsula.com/Article/How-to-exclude-xml-doc-files-from-msbuild.
Just in case, the above link is not working:
-
Unload project in Solution Explorer
-
Right click the project and click 'edit *.csproj'
-
Add next lines in the PropertyGroup section of each environment.
-
Reload and rebuild project.
<AllowedReferenceRelatedFileExtensions> *.pdb; *.xml </AllowedReferenceRelatedFileExtensions>