JuniorIncanter
JuniorIncanter

Reputation: 1579

Nuget Package Installs Via Console But No Reference Added For C++ Project

I am trying to install the NuGet package detailed on this webpage: https://learn.microsoft.com/en-us/azure/storage/storage-c-plus-plus-how-to-use-blobs

For reference, the instructions are:

Windows: In Visual Studio, click Tools > NuGet Package Manager > Package Manager Console. Type the following command into the NuGet Package Manager console and press ENTER.

This works... kind of. The package is downloaded locally, but the reference isn't being added to my project. When I install the package manually or from the PM Console, no reference is added.

Instructions I've been able to find (such as here) just insist that the references will be automagically added. Which is great when it works, but it provides no debug reference point or how to add them manually.

Are there other options I'm missing?

Thanks.

Upvotes: 0

Views: 889

Answers (2)

JuniorIncanter
JuniorIncanter

Reputation: 1579

For those that stumble onto the question, there is no working solution. The issue arose because I was creating a UAP app, and the given Nuget package does not have UAP support. At that point, in order to continue I must download the source code for the Nuget package and recompile it with the -ZW flag.

See here: https://msdn.microsoft.com/en-us/library/mt186162.aspx

If you have source code for the DLL or static library, you can recompile with /ZW as a UWP project.

Upvotes: 0

Leo Liu
Leo Liu

Reputation: 76700

the reference isn't being added to my project. When I install the package manually or from the PM Console, no reference is added

That is because NuGet cannot directly add references to native projects, the ‘native’ target framework is not recognized within the \lib folder. For the detail information, you can refer to the Support for Native Projects.

Besides, after installed the wastorage package, you will notice that the blob.h and storage_account.h were added to External Dependencies:

enter image description here

Then you can add the following include statements to the top of the C++ file successfully where you want to use the Azure storage APIs to access blobs:

#include <was/storage_account.h>
#include <was/blob.h>

Update: According to the JuniorIncanter comment, add the .targets, and .props file in the .vcxproj:

  <ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\cpprestsdk.v120.windesktop.msvcstl.dyn.rt-dyn.2.9.1\build\native\cpprestsdk.v120.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\packages\cpprestsdk.v120.windesktop.msvcstl.dyn.rt-dyn.2.9.1\build\native\cpprestsdk.v120.windesktop.msvcstl.dyn.rt-dyn.targets')" />
<Import Project="..\packages\cpprestsdk.v140.windesktop.msvcstl.dyn.rt-dyn.2.9.1\build\native\cpprestsdk.v140.windesktop.msvcstl.dyn.rt-dyn.targets" Condition="Exists('..\packages\cpprestsdk.v140.windesktop.msvcstl.dyn.rt-dyn.2.9.1\build\native\cpprestsdk.v140.windesktop.msvcstl.dyn.rt-dyn.targets')" />
<Import Project="..\packages\wastorage.v120.3.0.0\build\native\wastorage.v120.targets" Condition="Exists('..\packages\wastorage.v120.3.0.0\build\native\wastorage.v120.targets')" />
<Import Project="..\packages\wastorage.v140.3.0.0\build\native\wastorage.v140.targets" Condition="Exists('..\packages\wastorage.v140.3.0.0\build\native\wastorage.v140.targets')" />

Upvotes: 1

Related Questions