Install-Package : 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.
At line:1 char:1
+ Install-Package Newtonsoft.Json
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.
Instal

- 2,400
- 4
- 18
- 32

- 15
- 1
- 4
-
1make sure the console window is pointing to correct solution. – Pandiyan Cool Oct 28 '19 at 08:58
-
Hi, what's your project type? C++/CLI project? – LoLance Oct 28 '19 at 10:32
-
See [Github/nuget/#8195](https://github.com/NuGet/Home/issues/8195#issue-452574911)... This is expected behavior if you're trying to install one nuget package into CLL/ClI project since this scenario is not supported now :( – LoLance Oct 28 '19 at 10:40
1 Answers
Cause of the error:
This error always occurs when you try to install one nuget package into C++/CLI
project. Though C++/CLI
project is managed code, for now Nuget
doesn't support this scenario.
There's one open issue in Github/Nuget, see #8195, you can track this issue to get notifications if there's any update.
Workarounds:
You can try Daniel's answer, it helps many members with similar issue.
For me, since a nuget package is actually a
xx.zip
file which contains assemblies and some files. We can download thexx.nupkg
(nuget package) file here.
Then you'll get one xx.nupkg
file, rename it to xx.zip
and extract it. You can now see a lib
folder which includes assemblies for different target framework. If your C++/CLI project targets .net framework 4.5 and above, choose the net45
folder. If your project targets .net framework 4.0, choose the net40
folder...
We can copy the Newtonsoft.Json.dll
and Newtonsoft.Json.xml
to project directory or any local folder. Then right-click project=>Add reference=>browse=> to add that reference manually. After that, type using namespace Newtonsoft
to check if Intellisense can recognize this reference well.
If you meet error C4199 when compiling and building this project like me, try this.
Hope all above helps :)

- 25,666
- 1
- 39
- 73
-
Thanks. I fixed the error using Daniel's answer. But I got another error as state here [link](https://stackoverflow.com/questions/58595826/erroring-about-using-push-back-function-in-visual-studio-2019-for-azure-kinect). Could you see whether you could help me with that – kk133 Oct 28 '19 at 17:43