我有一个包含 XML 文档文件的 nuget 包。
packages/MyPackage.1.0.0/lib/net472/MyPackage.xml
但是,当我构建项目时,我想在输出中包含此 xml 文件。
所以当我:
dotnet MyProj.csproj -c Release
我想得到:
> ls bin/Release/net472
MyProj.dll
MyPackage.dll
MyPackage.xml
然而它永远不会出现。我怎么才能得到它?
Posting 弗拉德的回答 https://stackoverflow.com/a/64006774 here.
如果您想从所有包中复制 xml,这是比 Snede 更好的方法,因为它通常可以工作,不需要在每个包的路径上指定 .net 版本。
<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)