【问题标题】:error MSB3027: Could not copy "/src/libwkhtmltox.dll" to "/app/build/libwkhtmltox.dll"错误 MSB3027:无法将“/src/libwkhtmltox.dll”复制到“/app/build/libwkhtmltox.dll”
【发布时间】:2021-07-29 11:55:43
【问题描述】:
我正在使用 DinkToPdf 在 .net core 中生成 pdf 文档,必须将 these files 添加到项目中,当我在 jenkins 中运行 dotnet build . -c Release -o /app/build 时,我收到此错误 error MSB3027: Could not copy "/src/libwkhtmltox.dll" to "/app/build/libwkhtmltox.dll"
我尝试在 csproj 文件中使用 <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> 修复错误,但仍然无法正常工作
【问题讨论】:
标签:
c#
asp.net-core
.net-core
dinktopdf
【解决方案1】:
除非您想支持所有平台,否则不必全部添加。
- Linux 也是如此
- dll 适用于 Windows
- dylib 适用于 Mac
接下来要复制,我们必须加载这些非托管库到程序集
接下来将这些复制到输出路径,在项目设置中,添加
<ItemGroup>
<None Update="wkhtmltox\v0.12.4\32 bit\libwkhtmltox.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="wkhtmltox\v0.12.4\32 bit\libwkhtmltox.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="wkhtmltox\v0.12.4\32 bit\libwkhtmltox.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="wkhtmltox\v0.12.4\64 bit\libwkhtmltox.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
<None Update="wkhtmltox\v0.12.4\64 bit\libwkhtmltox.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="wkhtmltox\v0.12.4\64 bit\libwkhtmltox.so">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>