How can I make my managed NuGet package support C++/CLI projects?

后端 未结 7 1745
暗喜
暗喜 2020-12-04 14:03

I have made a NuGet package that works well when I use it from a C# project. It contains a DLL in the lib/net40 directory, and the DLL gets added as a reference

7条回答
  •  囚心锁ツ
    2020-12-04 14:33

    As mentioned in the answer to this port (Nuget won't install Entity Framework into C++/CLI project), NuGet will not make the changes to a C++/CLI project for you. It will however download and unpackage the dependency for you. We use it from the command line as part of our make dependencies. The command line will look something like this:

    /.NuGet/NuGet.exe
          Install 
          -NonInteractive 
          -ConfigFile $ENV{SRC_ROOT}/.nuget/NuGet.config 
          -OutputDirectory $ENV{SRC_ROOT}/packages 
          $ENV{SRC_ROOT}/packages.config
    

    Note that the command line areguments are separated one to a line to make reading easier. Also we decided to check NuGet into our source control un the .NuGet folder. The goal was to make it easier to setup a build machine for our various environments (not all of which use Visual Studio). Once you have run this command for the first time, you must manually add the dependencies to your C++/CLI project.
    Hope that helps.

提交回复
热议问题