Skip to content

Make the PackageReference support general purpose for all languages #2491

Description

@davkean

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:

Activity

  1. added this to the 15.5 milestone on Jul 12, 2017
  2. modified the milestones: 15.5, 15.7 on Sep 25, 2017
  3. kzu commented on Feb 5, 2018

    @kzu

    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 :(

  4. natidea commented on Feb 12, 2018

    @natidea
    Contributor

    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.

  5. modified the milestones: 15.7, on Mar 21, 2018
  6. kfertitta commented on Oct 9, 2018

    @kfertitta

    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.

  7. kzu commented on Dec 5, 2018

    @kzu

    Ditto, would love to see this happen 👍

  8. added
    Triage-Approved
    on Jan 14, 2019
  9. DevKumar4Git commented on Mar 28, 2019

    @DevKumar4Git

    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.

  10. amis92 commented on Apr 24, 2019

    @amis92

    Since it's a blocker for sfproj supporting SDK-style, shouldn't this be triaged a bit higher than 'Unknown/Backlog'?

  11. 20 remaining items

  12. wjk commented on Jul 7, 2021

    @wjk
    Contributor

    @JunielKatarn My apologies, I forgot a step. Add this to the .targets file, above the MSBuildExtensionsPath import.

    <PropertyGroup>
      <ResolveNuGetPackages>false</ResolveNuGetPackages>
    </PropertyGroup>
  13. asklar commented on Jul 7, 2021

    @asklar

    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 ?

  14. wjk commented on Jul 7, 2021

    @wjk
    Contributor

    @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!

  15. JunielKatarn commented on Jul 7, 2021

    @JunielKatarn

    @wjk That worked. Thanks a bunch.

  16. modified the milestones: 16.8, 17.x on Nov 29, 2021
  17. bbrachaczek commented on Dec 8, 2021

    @bbrachaczek

    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:

    <AssetTargetFallback>$(AssetTargetFallback);native</AssetTargetFallback>
    <TargetFrameworkMoniker>native,Version=v0.0</TargetFrameworkMoniker>
    
  18. JunielKatarn commented on Dec 8, 2021

    @JunielKatarn

    @beevvy We use that configuration too in react-native-windows.

    I believe it's required for mixed C++ and C# interoperability.

  19. bbrachaczek commented on Dec 17, 2021

    @bbrachaczek

    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.

  20. matlemuzic commented on Jan 24, 2022

    @matlemuzic

    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)

  21. Schniefel commented on Nov 29, 2024

    @Schniefel

    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.

  22. zivkan commented on Dec 2, 2024

    @zivkan
    Member

    https://devblogs.microsoft.com/cppblog/announcing-nuget-packagereference-support-for-c-cli-msbuild-projects-targeting-net-core/

    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:

    <PropertyGroup Label="Globals">

    <EnableManagedPackageReferenceSupport>true</EnableManagedPackageReferenceSupport> </PropertyGroup>

    and later in the blog post

    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.

    PackageReference for native C++ isn't supported.

  23. Schniefel commented on Dec 2, 2024

    @Schniefel

    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.

  24. ekalchev commented on Oct 28, 2025

    @ekalchev

    I am fighting with C++ WINRT project and this is big problem for us

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Triage-Approved

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions