2

I have a .Net Standard project which references a C++ dll

For now I'm using DllImport to get it to work.

I want to create a Nuget package which ships with the relevant dlls for all targets.

I presume I'll have to build the C++ library for all targets (Windows x64, Windows x86, Linux, etc). Fine.

Now I need to somehow package them all up in a nuget package, and I am unsure how to do this)

How to add C++ library in a .NET Core project is similiar, but the answer is not correct for .Net Standard projects, which have a new style csproj, and use the dotnet cli rather than the nuget cli. Also it doesn't explain how this works with multiple targets.

Also, do I keep my DllImports, or do i need to change them? For now I'm using the absolute file-path of the dll as so:

internal const string DLL = "D:\\filepath\\mydll.dll";

[DllImport(DLL)]
internal static extern int MyMethod();
Yair Halberstadt
  • 5,733
  • 28
  • 60
  • What about Create Multiple Target in .csproj file and write an MSBuild script to call all target so you will get the dll compiled for the different platform in the place wherever you want them for nuget – Anirudha Gupta Jan 03 '19 at 10:20

1 Answers1

0

You can create nuget packages for multiple targets like this and add the c++ dll-s as content so it will be copied during compile to the build output folder and you can use the DLLImport.

cviktor
  • 88
  • 5