Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

How to publish XML files from a NuGet package to an ASP.NET Core 2.1 application

$
0
0

I have an ASP.NET Core 2.1 application (say, MyWebApiApp) that references a NuGet package (say, MyPackage), which contains models used in a Web API. These models are documented using XML comments, and the resulting XML file is published along with the NuGet package (in lib\netstandard2.0\MyPackage.xml).

I want to use the XML documentation in Swagger, so I add the following to my SwaggerGenOptions in Startup.cs:

c.IncludeXmlComments(Path.ChangeExtension(typeof(MyPackage.MyModel).Assembly.Location, ".xml"));

So far, so good. When I run the application from Visual Studio 2017, it successfully locates the XML documentation file in the NuGet package cache and generates the Swagger documentation.

Now I want to publish the web site. When I publish the web site:

  • The XML documentation file for application (MyWebApiApp.xml) is copied to the publish folder (I have included <GenerateDocumentationFile>true</GenerateDocumentationFile> in MyWebApiApp.csproj).
  • But the XML documentation file from my NuGet package (MyPackage.xml) is not copied.

I've tried adding the incantation from this blog post to MyWebApiApp.csproj, without success.


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>