thims
thims

Reputation: 335

Packaging WinForms application along with native DLL

Trying to figure out how to package the following solution with Visual Studio 2017 Desktop Bridge (Application Packaging Project):

  1. .NET Library DLL.
  2. WinForms executable referencing 1.
  3. Native C++ DLL exporting some functions used by 1 and 2 with [DllImport].

I added project 2 to Applications section of a package and buit it. In the target folder I have EXE (from project 2) and DLL (from project 1).

And the question is: how to correctly add the project 3 (native c++ library) to a package? I have x86 and x64 project configurations for this DLL.

Upvotes: 2

Views: 2328

Answers (1)

Stefan Wick  MSFT
Stefan Wick MSFT

Reputation: 13850

Here is how to do it - see screenshots below for illustration:

1) create a folder in your Winforms project as the target for your native DLL(s)

2) add a post-build event step to copy the native DLL to that folder

3) in that folder, mark the DLL as part of the project

4) Make sure properties are set to "Content" and "Copy to output"

5) now the packaging project will pick up the native DLL and include it in the package

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

Upvotes: 2

Related Questions