sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Xml documentation file not created by MSBuild

Open davkean opened this issue 9 years ago • 15 comments

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:

image

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

capture4

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

image

or from a command line:

capture2

the xml doc file isn't generated:

capture3

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:

capture1

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:

manual_build.txt

Copied from original issue: dotnet/roslyn-project-system#1793

davkean avatar Mar 20 '17 04:03 davkean

Ah, thought this was not occurring when building though VS, however, it is. I'll move this to the SDK.

davkean avatar Mar 20 '17 04:03 davkean

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.

DaveSlinn avatar Mar 28 '17 22:03 DaveSlinn

Yep, I believe this is a dup of #795.

livarcocc avatar Apr 24 '17 17:04 livarcocc

I am having the exact same issue generating the XML documentation file using TFS when it builds the solution. Any fix?

beinguam avatar Sep 06 '17 20:09 beinguam

@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?

dasMulli avatar Sep 06 '17 23:09 dasMulli

It is actually a WebAPI on the full .NET framework (4.5.2) not .NET Core. What additional details do you need?

beinguam avatar Sep 12 '17 14:09 beinguam

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)

dasMulli avatar Sep 12 '17 15:09 dasMulli

Nope , it is a classic web api, my mistake. let me look around

beinguam avatar Sep 12 '17 18:09 beinguam

I have the similar issue, was this issue resolved? Any help would be appreciated. Thanks

SandeepApsingekar avatar Mar 27 '19 19:03 SandeepApsingekar

got the same issue, .net api classic + azure build. (I think the standard VS publish do it too)

forX01 avatar Apr 02 '20 19:04 forX01

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

Jasonlhy avatar Apr 20 '20 06:04 Jasonlhy

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/

dasMulli avatar Apr 20 '20 12:04 dasMulli

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 true

Anyone got any ideas of how to resolve this?

KvnSearle avatar Jan 06 '23 17:01 KvnSearle

@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 avatar Jan 06 '23 17:01 baronfel

@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.

KvnSearle avatar Jan 10 '23 12:01 KvnSearle