You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Make the PackageReference support general purpose for all languages #2491
We added support for <PackageReference /> this release, but other languages/project types are interested in consuming it including C++, MSIX deployment and NuGetizer.
The work required, that I can see is:
General purpose the PackageRestoreInitiator and make it work for all project types. Done - works via PackageReferences capability (16.1)
General purpose the ProjectAssetsFileWatcher and make it work for all project types. Done - works via PackageReferences capability (16.1)
Figure out how all these project types pick up the NuGet SDK tasks/targets that produce assets (references, copy to output items, etc) for consumption during build and assets that are used to populate the DependenciesTree.
Move PackageRestore code to CPS -or- install .NET Project System in all the same places as CPS
Without this, Package Restore code would not light up if we weren't installed.
Reacted by Nirmal Guru, jp2masa, Mark Adamson, Daniel Cazzulino, Dhanvi Kapila, quasarea, Kai Nadler, Scott Jones, Juho Hanhimäki, Jeff Kluge and 16 more
Is there an update on when the "Microsoft.PackageDependency.Sdk` will ship
@kzu our most recent discussions on this have focused on refactoring these tasks because of performance concerns. The SDK team has already made changes to the command line build to avoid this code path because it was too expensive. For the dependencies tree, we are considering several options including perhaps bypassing MSBuild to improve the performance profile. /cc @nguerrera@livarcocc
I don't have any other updates yet, but will post something as our plans unfold.
Is there an update on this issue? We have a custom project system for which we really need to support PackageReference. We'd be happy to require the latest shipping VS version as the minimal version, but it's not clear if support is yet available.
If CPS doesn't support this for custom project types, then its an adoption blocker & lot of overhead for developers who intend to quickly use this to build project systems. Would love to get this prioritized or hear about a workaround that can be easily removed once the support comes back.
Since it's a blocker for sfproj supporting SDK-style, shouldn't this be triaged a bit higher than 'Unknown/Backlog'?
Reacted by Alexander Batishchev, Bill King, Andrii Tretiak, Matthew Asplund, Ivan Alekseev, aL3891, Nirmal Guru, Akvenkat, George Helyar and Sumit Bhardwaj
Is any of this documented / stable enough? I couldn't find any docs on this on my cursory search so I worry about relying on implementation details that could change. @rainersigwald ?
@asklar After a quick test, I have found that the ExcludeRestorePackageImports property is apparently unneeded; I have removed it, and both restore and build still work. The ResolveNuGetPackages property is required to disable this task, which is the source of @JunielKatarn’s error. While I agree there are no hits on docs for this property, I do not believe that this property is actually an implementation detail, for three reasons. First, I have been using this property across several versions of VS (including some that predate proper C++ PackageReference IDE support), and have never run into any problems. Second, the name does not start with an underscore, which is the MSBuild convention for denoting implementation details. Third, the fact that there is this easy a way to bypass that task in the first place suggests that the property is public API; disabling private targets usually entails much more work. Hope this helps!
I should also note that setting TargetFrameworkMoniker in VS2022 appears to break ConfigurationType=Makefile projects, as the GetReferenceAssemblyPaths target fails. Normally for C++ projects it's prevented from being executed by Microsoft.CppBuild.targets unsetting TargetFrameworkMoniker within the relevant target scope.
Hi all, is anyone having issues referencing a C++/CLI with package references from a C# project ?
My C++/CLI project compiles ok with .NETFramework 4.8, but I get the following issue from the C# project that references it:
error NU1201: Project MyCppCLIProject is not compatible with net48 (.NETFramework,Version=v4.8). Project MyCppCLIProject supports: native (native,Version=v0.0)
Can someone please post a guide how to get Packagereference work for .vcxproj (native and c++/cli) with visual studio?
I have seen various different hacks, but nothing worked for me.
One of the new features for C++ developers in Visual Studio 2022 version 17.3 is NuGet PackageReference support for C++/CLI MSBuild projects that target .NET Core and .NET 5 or higher. More specifically, this impacts CLR Class Library (.NET) and CLR Empty Project (.NET) project templates. This functionality allows you to manage NuGet packages while bringing the benefits of PackageReference support to your dependencies. This feature is on by default for new projects. To enable this feature for your existing projects, add the following property to your project file:
For native C++ projects, we recommend using vcpkg for both C++ open-source and closed source libraries.
So, PackageReference should "just work" for C++/CLI projects, if you're using a recent version of VS2022 and you're targeting .NET (Core). It's unclear what happens if you're using C++/CLI and still targeting .NET Framework.
Yes, i know. But we have native C++ Nugets and C++/CLI Nugets using .NET Framework. So I am interested in the existing workaround, which may not be officially supported.
I hope, Microsoft will some day understand, that only supporting C++/CLI on .NET (Core) won't help in many use cases on mixed environments.
Activity
kzu commentedon Feb 5, 2018
Is there an update on when the "Microsoft.PackageDependency.Sdk` will ship @natidea?
I'm on 15.6 Preview 3 but it's not there yet :(
natidea commentedon Feb 12, 2018
@kzu our most recent discussions on this have focused on refactoring these tasks because of performance concerns. The SDK team has already made changes to the command line build to avoid this code path because it was too expensive. For the dependencies tree, we are considering several options including perhaps bypassing MSBuild to improve the performance profile. /cc @nguerrera @livarcocc
I don't have any other updates yet, but will post something as our plans unfold.
kfertitta commentedon Oct 9, 2018
Is there an update on this issue? We have a custom project system for which we really need to support
PackageReference. We'd be happy to require the latest shipping VS version as the minimal version, but it's not clear if support is yet available.Thanks in advance.
kzu commentedon Dec 5, 2018
Ditto, would love to see this happen 👍
DevKumar4Git commentedon Mar 28, 2019
We are providing guidance to package build tools as NuGet & use package reference to pull it down while using build/restore.
https://docs.microsoft.com/en-us/nuget/create-packages/creating-a-package#including-msbuild-props-and-targets-in-a-package
If CPS doesn't support this for custom project types, then its an adoption blocker & lot of overhead for developers who intend to quickly use this to build project systems. Would love to get this prioritized or hear about a workaround that can be easily removed once the support comes back.
amis92 commentedon Apr 24, 2019
Since it's a blocker for sfproj supporting SDK-style, shouldn't this be triaged a bit higher than 'Unknown/Backlog'?
20 remaining items
wjk commentedon Jul 7, 2021
@JunielKatarn My apologies, I forgot a step. Add this to the .targets file, above the MSBuildExtensionsPath import.
asklar commentedon Jul 7, 2021
Is any of this documented / stable enough? I couldn't find any docs on this on my cursory search so I worry about relying on implementation details that could change. @rainersigwald ?
wjk commentedon Jul 7, 2021
@asklar After a quick test, I have found that the
ExcludeRestorePackageImportsproperty is apparently unneeded; I have removed it, and both restore and build still work. TheResolveNuGetPackagesproperty is required to disable this task, which is the source of @JunielKatarn’s error. While I agree there are no hits on docs for this property, I do not believe that this property is actually an implementation detail, for three reasons. First, I have been using this property across several versions of VS (including some that predate proper C++ PackageReference IDE support), and have never run into any problems. Second, the name does not start with an underscore, which is the MSBuild convention for denoting implementation details. Third, the fact that there is this easy a way to bypass that task in the first place suggests that the property is public API; disabling private targets usually entails much more work. Hope this helps!JunielKatarn commentedon Jul 7, 2021
@wjk That worked. Thanks a bunch.
bbrachaczek commentedon Dec 8, 2021
For anyone interested, I needed to use one more hack to make the PackageReference C++ NuGet restore work in VS2022, as described in this comment:
JunielKatarn commentedon Dec 8, 2021
@beevvy We use that configuration too in react-native-windows.
I believe it's required for mixed C++ and C# interoperability.
bbrachaczek commentedon Dec 17, 2021
I should also note that setting
TargetFrameworkMonikerin VS2022 appears to break ConfigurationType=Makefile projects, as theGetReferenceAssemblyPathstarget fails. Normally for C++ projects it's prevented from being executed by Microsoft.CppBuild.targets unsettingTargetFrameworkMonikerwithin the relevant target scope.matlemuzic commentedon Jan 24, 2022
Hi all, is anyone having issues referencing a C++/CLI with package references from a C# project ?
My C++/CLI project compiles ok with .NETFramework 4.8, but I get the following issue from the C# project that references it:
error NU1201: Project MyCppCLIProject is not compatible with net48 (.NETFramework,Version=v4.8). Project MyCppCLIProject supports: native (native,Version=v0.0)
Schniefel commentedon Nov 29, 2024
Can someone please post a guide how to get Packagereference work for .vcxproj (native and c++/cli) with visual studio?
I have seen various different hacks, but nothing worked for me.
zivkan commentedon Dec 2, 2024
https://devblogs.microsoft.com/cppblog/announcing-nuget-packagereference-support-for-c-cli-msbuild-projects-targeting-net-core/
and later in the blog post
So, PackageReference should "just work" for C++/CLI projects, if you're using a recent version of VS2022 and you're targeting .NET (Core). It's unclear what happens if you're using C++/CLI and still targeting .NET Framework.
PackageReference for native C++ isn't supported.
Schniefel commentedon Dec 2, 2024
Yes, i know. But we have native C++ Nugets and C++/CLI Nugets using .NET Framework. So I am interested in the existing workaround, which may not be officially supported.
I hope, Microsoft will some day understand, that only supporting C++/CLI on .NET (Core) won't help in many use cases on mixed environments.
ekalchev commentedon Oct 28, 2025
I am fighting with C++ WINRT project and this is big problem for us