-
Notifications
You must be signed in to change notification settings - Fork 256
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
Support managed package assets for C++ UWP projects #5292
Comments
It looks like this is from a UWP C++ project using packages.config. Install will look in the Managed C++ scenarios are not currently supported in NuGet. |
tagging @anangaur and @karann-msft for clarity on the need for this. |
@mathisloge can you provide the repro steps for that error. What type of project were you trying to install the package to? |
@karann-msft |
As all C++/CLI issues were closed as duplicates of this one, I assume it's fine to continue the general "C++/CLI project-support-discussion" here. Not only C++ UWP projects might need .net NuGet packages, we also have certain managed wrappers for our own C++ code base which need references to libraries from NuGet (e.g. NLog for logging or Newtonsoft.Json for some serializations). We just lately moved to the new-style csprojs for our solution and it became now even harder referencing NuGet packages from C++ projects. With the old csprojs you at least have the DLLs in the packages folder and you could reference manually the assemblies from there (not perfect but a workaround as long as you are careful with your versioning). But now as all NuGet packages are caches in It would be great if Managed C++ projects can finally install .net packages. I would not mind manually adding a special override property like Reproduction Steps:
The output will be:
|
I have exact the same problem. Thank you @Danielku15 for the tip with the other c# project. |
The issue is still there. |
I've managed to sort of make Add these targets: <Target Name="AddNetFxTfnToTargetFrameworks" AfterTargets="_GetRestoreTargetFrameworksOutput">
<ItemGroup>
<_RestoreTargetFrameworksOutputFiltered Include="$(NuGetTargetMoniker)" />
</ItemGroup>
</Target>
<Target Name="AddNetFxTfnToPackageReferences" AfterTargets="_GenerateProjectRestoreGraphPerFramework">
<ItemGroup>
<_RestoreGraphEntryCrossJoin Include="@(_RestoreGraphEntry)">
<OriginalId>%(PackageReference.Identity)</OriginalId>
<IsManaged>%(PackageReference.IsManaged)</IsManaged>
<TargetFrameworks>$(NuGetTargetMoniker)</TargetFrameworks>
</_RestoreGraphEntryCrossJoin>
<_RestoreGraphEntryDependencies Include="@(_RestoreGraphEntryCrossJoin)" Condition=" '%(Type)' == 'Dependency' " />
<_RestoreGraphEntryPackageOnly Include="@(_RestoreGraphEntryDependencies)" Condition=" '%(OriginalId)' == '%(Id)' and '%(IsManaged)' == 'true' " />
<_RestoreGraphEntry Remove="@(_RestoreGraphEntryPackageOnly)" />
<_RestoreGraphEntry Include="@(_RestoreGraphEntryPackageOnly)" />
</ItemGroup>
</Target>
Usage: <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" IsManaged="true" />
</ItemGroup> Caveats:
I've also put the package references in a separated I think this is something that could be easily made a fully supported scenario. |
It really works, great thank you @aelij |
@aelij Thank you for the solution. When I run |
@slater1 The Restore target is built-in, so I don't know why it's not working of you. Haven't used this solution in a while, so might not be compatible with every version. |
Copied from JamesNK/Newtonsoft.Json#1285 by @mathisloge
Das Paket "Newtonsoft.Json 10.0.2" konnte nicht installiert werden. Sie versuchen, dieses Paket in ein Projekt zu installieren, das sich auf "native,Version=v0.0" bezieht, das Paket enthält aber keine Assemblyverweise oder Inhaltsdateien, die mit diesem Framework kompatibel sind. Wenden Sie sich an den Paketersteller, um weitere Informationen zu erhalten.
The above error message comes, when trying to install this package with nuget and a windows uwp app.
Using Visual Studio 2017.
The text was updated successfully, but these errors were encountered: