Search code examples
c++.netmsbuildnuget

How do I create a nuget package from a managed C++ library?


I have a library written in native c++, and then a second library which links to the first in managed c++ (sorry if I am misusing terms, hopefully you get what I am talking about). I can build both, and the second I can reference from my .net application and use perfectly fine. I want to pack the second into a nuget package.

What is the process for this? Linked tutorials or other answers are wonderful, though I feel like I have tried them all and run into problems or they are for different use cases. I'd prefer to do this by the command line using msbuild as I want to make this part of our github workflow, but I'd settle for doing this in visual studio so I can have some semblance of a victory and mental respite.

This is for .Net Framework 4.7.2 (not in my control)

Thanks!


Solution

  • I approached this from a different angle and built the libraries normally and then packaged the dll's into a nuget package using the Nuget CLI rather then the msbuild pack functionality.

    This was the tutorial I referenced.

    You need to make a relatively simple .nuspec file specifying which DLLs to package and then you can simply run the pack command like so:

    nuget.exe pack my-file.nuspec