The generated package indeed includes the XML file next to the DLL file, however, when using the package from another project, the documentation is never copied to output directory.
Here are the relevant bits on how the package is generated:
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
...
</PropertyGroup>
Tried the suggested answers in the following questions but without success:
- NuGet package XML documentation not visible in .NET Core 2.2 app
- Documentation disappears in NuGet package
- include the XML documentation from a NuGet package
Also tried to clear the packages cache and restarting Visual Studio but that didn't have any effect.
Question:
How does one get the XML documentation to be copied to output directory for a .NET 6 package?
I saw this solution, or variations of it, in similar questions. It worked for me using .Net 8.
Add the below code to your
csprojfileNote that it will copy all corresponding xml files, if they exist. If you don't want this, you may have to play around with the condition.
Note also that you may have to add it to some test project files as well. In my case I was consuming doc header for swagger and all my integration tests failed because the xml file I needed wasn't in the test project's bin folder