Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] How to use NuGet packages in a C++/CLI project? #10653

Closed
levicki opened this issue Mar 11, 2021 · 1 comment
Closed

[QUESTION] How to use NuGet packages in a C++/CLI project? #10653

levicki opened this issue Mar 11, 2021 · 1 comment

Comments

@levicki
Copy link

levicki commented Mar 11, 2021

I have a C++/CLI project which uses both native and managed code.

It is a common pattern where you have a native class implementation with core functionality, and a managed class exposed to external C# code. This managed class needs to use .Net NuGet packages, not native ones.

In Visual Studio 2019 16.9.0 when I try to add a NuGet package such as PCSC or NLog or Newtonsoft.Json to a C++/CLI project I am getting an error:

Could not install package 'PCSC 5.0.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.

In the project I am already providing the correct target for managed code:

image

Is there a way to override NuGet behavior for C++/CLI projects, apart from installing/restoring the package manually as a pre-build step using command line, and then specifying the package reference in the .vcxproj file (either manually or by using Add reference -> Browse):

<Reference Include="PCSC">
<HintPath>..\packages\PCSC.5.0.0\lib\net40\PCSC.dll</HintPath>
</Reference>

If there is no way to do that, then this issue should be considered a feature request instead of a question.

@levicki levicki changed the title [QUESTION] How to use Nuget packages in C++/CLI project? [QUESTION] How to use NuGet packages in a C++/CLI project? Mar 11, 2021
@zkat
Copy link
Contributor

zkat commented Mar 18, 2021

This is something we're actively working on. Closing as duplicate of #10194, which you can track for more details (and discuss further if needed)

@zkat zkat closed this as completed Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants