我的问题是我在nuget包中有一个非托管库,我想将其复制到嵌入它的API的发布文件夹中。
这是一个StackoverFlow帖子,我认为它可以工作,因为最终目标似乎与我相同: Include Unmanaged DLL from Nuget package to web Deploy package 这就是我尝试使其适应我的项目的方式:
<Target Name="AfterBuild" DependsOnTargets="CopyFilesToOutputDirectory">
<ItemGroup>
<MyPackageSourceFile Include="$(SolutionDir)Assemblies\libwkhtmltox\64 bits\libwkhtmltox.dll" />
</ItemGroup>
<Copy SourceFiles="@(MyPackageSourceFile)" DestinationFolder="$(OutputPath)" />
<Copy SourceFiles="@(MyPackageSourceFile)" DestinationFolder="$(ProjectDir)UnmanagedDll" />
</Target>
<Target Name="AddUnmanagedDll" AfterTargets="AfterBuild">
<ItemGroup>
<Content Include="UnmanagedDll\*.dll" />
</ItemGroup>
</Target>
但是它什么也没做。
我以一种更常见的方式尝试了这种方法:
<ItemGroup>
<None Remove="Assemblies\libwkhtmltox\32 bits\libwkhtmltox.dll" />
<None Remove="Assemblies\libwkhtmltox\64 bits\libwkhtmltox.dll" />
</ItemGroup>
<ItemGroup>
<ContentWithTargetPath Include="Assemblies\libwkhtmltox\32 bits\libwkhtmltox.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>Assemblies\libwkhtmltox\32 bits\libwkhtmltox.dll</TargetPath>
</ContentWithTargetPath>
<ContentWithTargetPath Include="Assemblies\libwkhtmltox\64 bits\libwkhtmltox.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<TargetPath>Assemblies\libwkhtmltox\64 bits\libwkhtmltox.dll</TargetPath>
</ContentWithTargetPath>
</ItemGroup>
也许指定所有项目都在 C#.NET CORE 2.1
中可能很重要请告诉我是否需要任何进一步的信息。