Zulander
Zulander

Reputation: 814

Include DLL and other file during publishing in visual studio

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

Upvotes: 1

Views: 1728

Answers (1)

René
René

Reputation: 3711

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:

  • 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:

  • 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.

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

Upvotes: 1

Related Questions