Home: Cannot install managed packages into C++/CLR project

Created on 5 Jun 2019  路  4Comments  路  Source: NuGet/Home

Details about Problem

NuGet product used (NuGet.exe | VS UI | Package Manager Console | dotnet.exe): NA

NuGet version (x.x.x.xxx): whatever comes with VS 2019

dotnet.exe --version (if appropriate): NA

VS version (if appropriate): Visual Studio Enterprose 2019 v16.1.1

OS version (i.e. win10 v1607 (14393.321)): Windows 10 v1809 (OS Build 17763.529)

Worked before? If so, with which NuGet version: never worked, see https://github.com/NuGet/Home/issues/3171, https://github.com/NuGet/Home/issues/1121

Detailed repro steps so we can see the same problem

  1. Create new C++ Console application using the "Console App" template

  2. Right click on project, Properties, "Common Language Runtime Support" - set to "Common Language Runtime Support (/clr)", ".NET Target Framework Version" - set to "4.7.2", OK

  3. Right click on References, Manage Nuget Packages, browse to "Newtonsoft.Json", Install

Error Could not install package 'Newtonsoft.Json 12.0.2'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Restore C++ Backlog 2 Feature

Most helpful comment

I am currently using the workaround, which works OK for packages.config, download and update of packages due to the fact that NuGet and/or VS does not actually care for the targetFramework in these situations (you specify native, you get the package dowloaded even if not native).
However from this point onwards everything becomes messy: you have to add references manually, you have to add all dependencies manually (and add references to the dependencies manually), you have to adjust all of them manually when performing an update... Far from ideal.
Support for non-native packages in C++/CLI projects is really long overdue.

All 4 comments

I have been developing in C++ CLR .Net Core against VS 2019 latest Preview. I can't call this a blocker issue for that work, but I can argue that NET Core CLR projects are not going to qualify as fully supported without this being resolved.

Is there any possibility the priority of this to be escalated? Most just asking that we can depend on this to be resolved with the release of NET Core CLR development.

I'm getting the same problem trying to nuget System.Numerics.Vectors (4.5.0) into a C++/CLR project with NET Target Framework Version v4.7.2 in Microsoft Visual Studio Professional 2019 Version 16.4.3:
Could not install package 'System.Numerics.Vectors 4.5.0'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

I'm getting the same problem trying to nuget System.Numerics.Vectors (4.5.0) into a C++/CLR project with NET Target Framework Version v4.7.2 in Microsoft Visual Studio Professional 2019 Version 16.4.3:
Could not install package 'System.Numerics.Vectors 4.5.0'. You are trying to install this package into a project that targets 'native,Version=v0.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

There seems to be workaround: https://stackoverflow.com/questions/18694947/how-can-i-make-my-managed-nuget-package-support-c-cli-projects

I am currently using the workaround, which works OK for packages.config, download and update of packages due to the fact that NuGet and/or VS does not actually care for the targetFramework in these situations (you specify native, you get the package dowloaded even if not native).
However from this point onwards everything becomes messy: you have to add references manually, you have to add all dependencies manually (and add references to the dependencies manually), you have to adjust all of them manually when performing an update... Far from ideal.
Support for non-native packages in C++/CLI projects is really long overdue.

Was this page helpful?
0 / 5 - 0 ratings