在 Visual Studio 中发布期间包含 DLL 和其他文件 [英] Include DLL and other file during publishing in visual studio

查看:46
本文介绍了在 Visual Studio 中发布期间包含 DLL 和其他文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用这个库 https://github.com/rdvojmoc/DinkToPdf 但是,库需要这两个文件在bin libwkhtmltox.dll 和libwkhtmltox.so那么如何保证发布时复制的文件呢?Visual Studio 2017 社区版,项目ASP Core 2.0

I am using this library https://github.com/rdvojmoc/DinkToPdf however, the library requires these two file in the bin libwkhtmltox.dll and libwkhtmltox.so So how do ensure that the files copied during publishing? Visual Studio 2017 community edition, the project ASP Core 2.0

推荐答案

您可以将这些文件添加到项目的根文件夹中,并在其属性中将复制到输出目录"设置为始终复制".然后您的文件将被复制到 bin 文件夹 - 但是...

You can add those files to the root folder of your project and in their Properties set "Copy to Output Directory" to "Copy always". Your files will then be copied to the bin folder - but ...

...这可能还不够,因为:

... this is probably not sufficient because:

  • 如果您已通过 nuGet 添加 DinkToPdf,则在本地启动项目时,将不会在 bin 文件夹中查找这两个文件.相反,它们将在 C:\Users\\.nuget\packages\dinktopdf\1.0.8\lib\netstandard1.6 中查找.如果您将文件复制到那里,就会找到它们.
  • 这些文件有两个不同的版本:32 位和 64 位.您必须为您的系统复制正确的版本(本地可能是 64 位,但如果您在 azure 上发布,则默认为 32 位).
  • If you've added DinkToPdf via nuGet, the two files will not be looked for in the bin folder when you start your project locally. Instead they will be looked for in C:\Users\<yourUsername>\.nuget\packages\dinktopdf\1.0.8\lib\netstandard1.6. If you copy the files there, they will be found.
  • There are two different versions of those files: 32bit and 64bit. You have to copy the correct version for your system (locally it's probably 64bit but if you publish on azure it is 32bit by default).

我正在为我的项目按以下方式处理它:

I'm handling it the following way for my project:

  • 我将 DinkToPdf nuGet 包添加到了我的 .net 核心项目中.
  • 我在此处下载了 libwkhtmltox 文件(它们位于v0.12.4"文件夹中).
  • 我将 64 位文件复制到 C:\Users\\.nuget\packages\dinktopdf\1.0.8\lib\netstandard1.6
  • 我没有将文件添加到项目中,因为我发布到 azure 并且在那里 64 位文件不起作用.
  • 我通过 FTP 将 32 位文件上传到我的 azure 网络应用程序的根文件夹.
  • I added the DinkToPdf nuGet package to my .net core project.
  • I downloaded the libwkhtmltox files here (they are in the "v0.12.4" folder).
  • I copied the 64bit files to C:\Users\<myUsername>\.nuget\packages\dinktopdf\1.0.8\lib\netstandard1.6
  • I DID NOT add the files to the project, because I publish to azure and there the 64bit files would not work.
  • I uploaded the 32bit files to the root folder of my azure web application via FTP.

这样 DinkToPdf 既适用于我的开发机器,也适用于我的 azure Web 应用程序.

This way DinkToPdf works on my development machine as well as in my azure web application.

这篇关于在 Visual Studio 中发布期间包含 DLL 和其他文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆