1

我正在使用 DinkToPdf 在 .net core 中生成 pdf 文档,必须将这些文件添加到项目中,当我dotnet build . -c Release -o /app/build在 jenkins 中运行时出现此错误error MSB3027: Could not copy "/src/libwkhtmltox.dll" to "/app/build/libwkhtmltox.dll" 我尝试使用<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>csproj 文件修复错误但仍然无法正常工作

4

1 回答 1

0

除非您想支持所有平台,否则不必全部添加。

  • 对于 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>
于 2021-12-03T15:54:31.387 回答