How to exclude xml doc files from msbuild

2020-08-09 06:44发布

问题:

I used a number of third party assemblies in my C# projects. Many of them include xml document files that I believe give me intellisense? Anyway, when I build my projects those xml files end up in the bin folder. Is there any way to exclude them so that they do not get deployed with my app (beside removing them from the location I reference the assembly in)?

This problem has always bugged me but never enough to pursue. Now I seem to have 4MB worth of XML files in my deployment folder and it bothering me enough to seek a solution.

回答1:

You can also specify this via the command line:

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


回答2:

You can edit your csproj in notepad and add the section <AllowedReferenceRelatedFileExtensions > within the <PropertyGroup >of the desired configuration (I didn't managed to do it in visual studio csproj properties windows...)
For exemple if you add .pdb in this section, only .pdb files will be copied in bin folder. I set it to .none to have only assemblies in my deployment



回答3:

If you are using Visual Studio, select properties on the file and select "Copy to Output Directory" = "Do not Copy"



标签: xml msbuild