C++ nuGet packages in vscode - c++

How do I install nuGet packages for c++ in vs code? I've tried installing allegro library using nuGet plugin, but is seems to only work for c# projects, and says that it didn't find any .csproj files in the project.

Related

Visual Studio 2019 C++ project with NuGet package installing failds

I want to import some package through NuGet into my C++ Visual Studio 2019 project(of couse, packages available in C++).
All packakges I tried to install is from "nuget.org" source.
But all package installation fails with following reasons:
Install-Package : Could not install package 'SomePackage'.
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 think it occurs because I trying to install NuGet package in C++ project.
What is "native,Version=v0.0" means? How can I fix it?

How do I fix LNK2019 errors after adding libpng to a VS2019 C++ project through Nuget?

I am creating a solution that requires the use of libpng. I installed this library and its dependencies through Visual Studio 2019's Nuget Package Manager, and including <png.h> and using functions and macros from the library does not lead to errors. However, should I try building the solution, I get one LNK2019 error per every reference to the library function or variable. It seems to me that NuGet failed to add the library locations to the linker properties. I have found where are the .lib files located, but I'm lost as to which settings do I adjust so that the Studio looks for, and finds, these files in the NuGet directory.
The issue why the automatic nuget cannot add the lib dependencies into the Linker is that the c++ nuget is for v140 and v120 build tool. And if your project is created by VS2019, VS uses v142 build tool(for VS2019) by default.
You can check the targets file(Methods to import lib automatically) from the nuget package <solution_folder>\packages\libpng.1.6.28.1\build\native\libpng.targets.
So this file cannot find V140 and V120,(your VS2019 uses V142) make the condition to false, so that auto import lib fails forever. That is the reason.
V140 is VC++2015 build tool while V120 is VC++ 2013 build tool.
If your PC has installed VS2015 and VS2013, you can change build tool for VS0219 by right-click on the project Properties-->Configuration Properties-->General--> change Platfrom Toolset to Visual Studio 2015(v140).
For a better solution
And if your PC only has VS2019 and also for a better workaround,
You should install libpng-v142 nuget package instead and it is for VS2019 VC++.

Cannot install packages using Nuget

I am unable to install any packages to my Unity UWP project ouput in visual stuio using nuget(VS solution is in C++).
I get
"Could not install package 'xxxxx'. 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."
I have unity version 2019 and Visual studio 2019 installed.
so the sentence "but the package does not contain any assembly references or content files that are compatible with that framework" says all...

Visual Studio could not install packages

I installed the first time Visual Studio Community on my Mac an created a Project for an Android App and after I tried to add the "Tweedsharp" package I've got this error. I tried to add other packages or a new or an otherwise Projekt, but I couldn't add any package.
Could not install package 'TweetSharp-Unofficial 2.3.1.2'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v7.1', 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.

Adding Casablanca Dependency VS2017

I recently upgraded to VS2017 and I'm looking to start doing more C++ work. I've not used VS or C++ in a good while (and even at that I was a C++ novice).
I'm trying to install Casablanca, aka CPPRestSdk (https://github.com/Microsoft/cpprestsdk) but I can't seem to manage it.
I've tried installing it through NuGet but I'm not sure exactly what I've to link to my project, and I've tried vcpkg - to which I've downloaded via the instructions but I have no clue what to do there.
All the materials I find for this apply to earlier VS editions and don't appear to work when I try them. Has anyone had such luck with getting this to work? If not, is there an alternative that I can use that has clear installation instructions?
Thanks
I recently moved a C++ REST SDK based project from the older NuGet package to the recent VCPKG based 2.10.1 release. Apart from Visual Studio 2017 with the C++ for Desktop workload make sure you have Git for Windows installed. Clone the VCPKG repo from GitHub with
git clone https://github.com/Microsoft/vcpkg
I'd recommend using a directory not having any spaces in its path, otherwise some builds might fail. Change into the VCPKG directory and run the bootstrap script:
.\bootstrap-vcpkg.cmd
This will compile the package manager itself. Afterwards you can install the C++ REST SDK with
.\vcpkg install cpprestsdk cpprestsdk:x64-windows
This will download all required libraries and takes quite a while. For usage in Visual Studio you have to enable the system wide integration with
.\vcpkg integrate install
This requires elevated privileges the first time but afterwards the C++ REST SDK is available in any Visual Studio C++ project. Follow the instructions for getting started. As soon as you include a C++ REST SDK header into your project the linking is taking care of automatically by Visual Studio.
For consumption in a CMake project you have to pass the VCPKG toolchain file to the CMake command, e.g.
cmake -DCMAKE_TOOLCHAIN_FILE=C:\vcpkg\scripts\buildsystems\vcpkg.cmake
Referencing the C++ REST SDK from CMake is described in the project repo's README.