Creating a NuGet package for building C ++ / CLI (mixed)

I created a C ++ / CLI assembly (mixed) that has a managed wrapper class around some unmanaged C ++ code. The managed part is for .NET 4.6.1, I received a file entry.cppwith only this line:

[assembly:System::Runtime::Versioning::TargetFrameworkAttribute(L".NETFramework,Version=v4.6.1", FrameworkDisplayName = L".NET Framework 4.6.1")];

When I now manually include the compiled assembly in my .NET 4.6.1 project, I can use the managed class as expected.

This project can be created in four ways: x86 or x64 as a debug or release. It has no managed dependencies.

Now I want one (or, if required, several) NuGet packages that I can upload to my channel, and it's easy to use the wrapper assembly in every project that is compatible with .NET 4.6.1. How to achieve this?


So far I have tried two approaches:

First, I created a file .autopkgthat matches this blog post to provide my own DLLs. The section of filesthis file is as follows:

files {
  // include: { *.h }; 
  [x86,v120,release] {
     symbols: { ..\Release\*.pdb; }
     bin:     { ..\Release\*.dll; }
  };
  [x86,v120,debug] {
     symbols: { ..\Debug\*.pdb; }
     bin:     { ..\Debug\*.dll; }
  };
};

This process leads to three files .nupkgthat I can upload to my channel. But when I try to install this package in .NET 4.6.1, I get this error message:

Failed to install package 'MyCppCliWrapper.redist 1.0.0.2'. You are trying to install this package in a project that targets ".NETFramework, Version = v4.6.1," but the package does not contain references to assemblies or content files that are compatible with this infrastructure. For more information, contact the author of the package.


, , .nupkg, , . .nuspec ( nuget spec) . :

nuget pack MyCppCliWrapper.nuspec -Prop Configuration=Release -Prop Platform=x86 -Build

, , zip .

, .

(, #), :

, nuspec, project.json ,

++, .vcxproj, -, NuGet ( NuGet 3.5.0.1938).

files .nuspec? , , DLL- .NET Framework ?

<file src="bin\**\*.dll" target="lib" />

, , nuget, .vcxproj, .nuspec:

<?xml version="1.0"?>
<package >
  <metadata>
  ...
  </metadata>
  <files>
    <file src="readme.txt" target="" />
    <file src="bin\Win32\Release\*.dll" target="lib\net461" />
    <file src="bin\Win32\Release\*.pdb" target="lib\net461" />
  </files>
</package>

.

: , : 32- 64- - ( ) (- 32 )?

+4

Source: https://habr.com/ru/post/1662429/


All Articles