Xml documentation file not created by MSBuild
From @gmsDave on March 20, 2017 3:35
I have an asp.net core web api project that I have recently converted from project.json to .csproj. I am using Swashbuckle to generate a Swagger UI which relies on the generated xml documentation file. In project.json, this was created using and "xmlDoc": "true" element in the "buildOptions". In .csproj, it looks like this was converted to a GenerateDocumentationFile element in a PropertyGroup xml. All seems well - when I build and run the project through VS2017, the file is created and the swagger UI works as expected:

Taking a look at the bin folder and the expected .xml file exists

When I run a build, either through TFS (on-prem) using the Visual Studio Build task:

or from a command line:
the xml doc file isn't generated:

I'm wondering if this is a bug or if there is a switch or option that I need to enable. Here is a snippet of my .csproj file:
Note that I am targeting the full .net framework - not sure if that matters. Here is the build log from the TFS task:
6_Build solution CIMS.NETCIMS.sln.txt
and here is from the manual one I did from the command line:
Copied from original issue: dotnet/roslyn-project-system#1793
Ah, thought this was not occurring when building though VS, however, it is. I'll move this to the SDK.
Duplicate of https://github.com/dotnet/sdk/issues/795? Also, this blog post (https://tattoocoder.com/dont-lose-your-swagger-with-dotnet-build) from Shayne Boyer offers some help as well.
Yep, I believe this is a dup of #795.
I am having the exact same issue generating the XML documentation file using TFS when it builds the solution. Any fix?
@beinguam are you using the 2.0.0 SDK? This version has the code to publish the documentation file. If that doesn't work for you, can you share more detail on your setup / csproj file?
It is actually a WebAPI on the full .NET framework (4.5.2) not .NET Core. What additional details do you need?
An ASP.NET Core "web api" project or classic web api? if classic, that's not an issue with any of the components in this repo. (microsoft/msbuild maybe but I don't know)
Nope , it is a classic web api, my mistake. let me look around
I have the similar issue, was this issue resolved? Any help would be appreciated. Thanks
got the same issue, .net api classic + azure build. (I think the standard VS publish do it too)
I had this problem as well and I spent a few hours to understand why. The problem is xml extension files are excluded in the publish stage.
You can check the target file at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VisualStudio\v16.0\Web\Microsoft.Web.Publishing.targets
<!-- This will control whether XML files from ResolveAssemblyReference is published, default is true (to exclude) -->
<ExcludeXmlAssemblyFiles Condition=" '$(ExcludeXmlAssemblyFiles)'=='' ">true</ExcludeXmlAssemblyFiles>
Solution: Make this to false to copy all xml file or add a custom task after publish to copy the required files.
<PropertyGroup>
<ExcludeXmlAssemblyFiles>false</ExcludeXmlAssemblyFiles>
</PropertyGroup>
Last but not least: dotnet sdk publish and MSBuild publish use different target settings. This only work for classic .NET framework .NET SDK have different property settings
Yes this issue is purely for ASP.NET Core and the .NET SDK, you can file requests for other VS components at https://developercommunity.visualstudio.com/
I'm having this issue with a .Net6 application developed using MSVS2022.
We upgraded the application from .Net Core 3.1 to .net 6 recently and I am wondering if this has caused the change.
If I publish the files locally using visual studio the xml file is created.
However it's missing from the zip file artefact created by the devops build pipeline.
I added the following to the csproj file but this has not helped
Anyone got any ideas of how to resolve this?
@KvnSearle you may want to get an https://aka.ms/binlog of your DevOps build pipeline and compare it to the binlog of your local publish using Visual Studio. Without that raw data, we can't really dig into the why with any accuracy.
@baronfel, thanks for the feedback.
I found a solution for this which was more prosaic..
In the build pipeline I set the build configuration to be 'Release' and the build platform to be 'Any CPU' and the xml files were generated.
I originally created the YAML file for the build pipeline by dynamically generating the YAML from an existing classic build pipeline.
It did not include either the build configuration or build platform setting so I took it that it wasn't needed.
The API had been working fine (as far as I am aware) it was only the need to view it in swagger that highlighted the problem.