I have a nuget package that includes an XML documentation file.
packages/MyPackage.1.0.0/lib/net472/MyPackage.xml
However when I build my project, I want to include this xml file in the output.
So when I:
dotnet MyProj.csproj -c Release
I want to get:
> ls bin/Release/net472
MyProj.dll
MyPackage.dll
MyPackage.xml
However it never comes along. How can I get it?
From the menu bar, choose Tools > Options to open the Options dialog box. Then, navigate to Text Editor > C# (or Visual Basic) > Advanced. In the Editor Help section, look for the Generate XML documentation comments option.
Package references, using <PackageReference> MSBuild items, specify NuGet package dependencies directly within project files, as opposed to having a separate packages. config file. Use of PackageReference doesn't affect other aspects of NuGet; for example, settings in NuGet.
The location of the default global packages folder. The default is %userprofile%\. nuget\packages (Windows) or ~/. nuget/packages (Mac/Linux).
Posting Vlad's answer here.
If you want to copy xml from all packages, this is a better method than Snede's, since it works generically without requiring to specify .net version on path for each package.
<Project>
<!-- ... -->
<ItemGroup>
<PackageReference Include="Example.SomePkg" Version="1.0.0" />
</ItemGroup>
<!-- ... -->
<Import Project="$(MSBuildToolsPath)/Microsoft.CSharp.targets" />
<!-- Add this -->
<Target Name="_ResolveCopyLocalNuGetPkgXmls" AfterTargets="ResolveReferences">
<ItemGroup><!-- Copy XML files from all PackageReferences to output dir -->
<ReferenceCopyLocalPaths Include="@(ReferenceCopyLocalPaths->'%(RootDir)%(Directory)%(Filename).xml')"
Condition="'%(ReferenceCopyLocalPaths.NuGetPackageId)'!='' and Exists('%(RootDir)%(Directory)%(Filename).xml')" />
</ItemGroup>
</Target>
</Project>
I find one solution: Please find it at https://snede.net/add-nuget-package-xml-documentation-to-swagger/?unapproved=168&moderation-hash=14dbe7e7ca3d8affb6ace2bfdb7ff581
This is actually a problem to copy files from nuget package to out dir or publish dir.
Just modify csproj file to copy file from package's path after run build or publish.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With