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