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
VC Project not support nuget PackageReference style #8874
VC Project not support nuget PackageReference style
NuGet product used VS UI:
NuGet version 5.3.1.6268
VS version 16.3.10
OS version Windows 7 SP1 x64
As we all know, packages.xml easily leads to wasted space and a large number of IO copy operations. So I hope that nuget can support VC++ to support PackageReference style.
After research, vs itself does not provide PackageReference for VC++, but nuget can directly call MSBuild API to modify "ItemGroup/PackageReference" node to implement VC++ PackageReference style.
The modified work looks great and has fewer changes.
I also provided PR, and hope to get everyone's approval. After all, it is almost 2020, Nuget still does not support PackageReference for VC++.
@mingkuang-Chuyu - Are you suggesting, that if we call msbuild APIs from NuGet code, we can fix this for nuget command line scenarios and VS scenarios too?
Did you test your PR in all those scenarios?
This issue needs more details than you have provided so far.
@rrelyea Yes, I have tested nuget in all scenarios I know.
nuget.exe restore
result : is OK
nuget restore "I:\Visual Studio 2013\Projects\PluginsMgr\Cons
oleApplication1\ConsoleApplication1.vcxproj"
Log
MSBuild auto-detection: using msbuild version '16.3.2.50909' from 'C:\Program Fi
les (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\bin'.
Restoring packages for I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplicat
ion1\ConsoleApplication1.vcxproj...
Committing restore...
Generating MSBuild file I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplica
tion1\obj\ConsoleApplication1.vcxproj.nuget.g.props.
Generating MSBuild file I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplica
tion1\obj\ConsoleApplication1.vcxproj.nuget.g.targets.
Writing assets file to disk. Path: I:\Visual Studio 2013\Projects\PluginsMgr\Con
soleApplication1\obj\project.assets.json
Restore completed in 606.35 ms for I:\Visual Studio 2013\Projects\PluginsMgr\Con
soleApplication1\ConsoleApplication1.vcxproj.
NuGet Config files used:
C:\Users\xupengjie\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
I:\NuGet\PackageTmp
I:\NuGet\Soucre
https://api.nuget.org/v3/index.json
msbuild.exe restore
result : is OK msbuild -restore -p:Configuration=Release;Platform=Win32 "I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\ConsoleApplication1.vcxproj"
Log
用于 .NET Framework 的 Microsoft (R) 生成引擎版本 16.3.2+e481bbf88
版权所有(C) Microsoft Corporation。保留所有权利。
生成启动时间为 2019/12/6 10:47:44。
项目“I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\ConsoleApplication1.vcxproj”在节点 1 上(Restore 个目标)。
Restore:
正在还原 I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\ConsoleApplication1.vcxproj 的包...
正在提交还原...
正在生成 MSBuild 文件 I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\obj\ConsoleApplication1.vcxproj.nuget.g.props。
正在生成 MSBuild 文件 I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\obj\ConsoleApplication1.vcxproj.nuget.g.targets。
将资产文件写入磁盘。路径: I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\obj\project.assets.json
I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\ConsoleApplication1.vcxproj 的还原在 537.21 ms 内完成。
使用的 NuGet 配置文件:
C:\Users\xupengjie\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
使用的源:
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
I:\NuGet\PackageTmp
I:\NuGet\Soucre
已完成生成项目“I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\ConsoleApplication1.vcxproj”(Restore 个目标)的操作。
Restoring packages for I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\ConsoleApplication1.vcxproj...
Installing VC-LTL-v142 4.0.2.14.
Committing restore...
Generating MSBuild file I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\obj\ConsoleApplication1.vcxproj.nuget.g.props.
Writing assets file to disk. Path: I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\obj\project.assets.json
Successfully installed 'VC-LTL-v142 4.0.2.14' to ConsoleApplication1
Executing nuget actions took 540.35 ms
Time Elapsed: 00:00:28.1483594
========== Finished ==========
1>------ 已启动生成: 项目: ConsoleApplication1, 配置: Release Win32 ------
1>
1>正在生成代码
1>0 of 147 functions ( 0.0%) were compiled, the rest were copied from previous compilation.
1> 0 functions were new in current compilation
1> 0 functions had inline decision re-evaluated but remain unchanged
1>已完成代码的生成
1>ConsoleApplication1.vcxproj -> I:\Visual Studio 2013\Projects\PluginsMgr\Release\ConsoleApplication1.exe
1>已完成生成项目“ConsoleApplication1.vcxproj”的操作。
Sorry I should have been cleared a C++/CLI project that is built with /clr and therefore produces IL. At present projects like that can consume "native" nuget packages but I have never found a way to make them consume .NET packages.
I'll try to support this feature (that C++/CLI project use .NET nuget package ).
Sorry I should have been cleared a C++/CLI project that is built with /clr and therefore produces IL. At present projects like that can consume "native" nuget packages but I have never found a way to make them consume .NET packages.
Sorry NuGet does not support TargetFramework Fallblack, so I cannot support them at the same time. Even if I provide PR, but there are many changes, I am afraid that Microsoft's urine is difficult to accept.
Hello and thank you for the contribution! I work on the C++ team. First I want to apologize for the delay in responding - we have been actively monitoring PackageReference feedback as well as this PR, and we should have been more communicative.
From our side, here is the situation:
We are working on plans to improve the C++ package management story. Specifically, we want to extend the features of our existing C++ package manager, vcpkg: https://github.com/microsoft/vcpkg, and improve build system integration, but across multiple build systems, not just MSBuild. We also want vcpkg to be able to support existing NuGet-packaged libraries in some way.
Our concern with going all in on PackageReference is that it an MSBuild-specific concept, which would not be extensible to CMake projects or other external build systems. Within the next year or less, we want to provide the means to attach any C++ library to any of the project systems we support. We are also considering ways to provide MSVC toolsets and other build-time tools as NuGet packages, and are determining that we would want something more powerful than PackageReference to accomplish this (and again we would want to be build system agnostic).
If we accept this PR and do any additional work required on the IDE side to unblock PackageReference usage for C++, the work would be rendered obsolete in the future when we move to the build system agnostic model. Our concern there is that if developers do the work to migrate to C++ PackageReference, they would later realize that we don't intend to provide ongoing support and want them to move to something else. I expect that would be a frustrating experience.
So our team is not decided on whether or not to add broad PackageReference support right now. If we do, we would be resolving the issue more quickly for the many people who are looking for this feature. But we would see the solution more like a band-aid solution than a complete one, and the NuGet C++ experience would still suffer in a few ways, as it does today for packages.config:
Automatic restore on project load would not work
Our project caching system would not work at the time a NuGet restore is done (impacts solution load times)
Both of those issues could be fixed in theory, but we would likely shift our resources instead to the bigger solution we have been planning as it would benefit more developers.
For now, we are definitely committing to PackageReference support for C++/CLI projects targeting .NET Core, as there are cases there where developers are required to pull in NuGet packages in a workflow where packages.config no longer works at all.
I am continuing conversations with my team to determine if broader PackageReference support makes sense as a path and will keep you posted.
Given this, we're closing that PR, and keeping this issue open while the C++ teams conversations continue.'
Activity
xspeed1989 commentedon Dec 4, 2019
nice !
rrelyea commentedon Dec 5, 2019
@mingkuang-Chuyu - Are you suggesting, that if we call msbuild APIs from NuGet code, we can fix this for nuget command line scenarios and VS scenarios too?
Did you test your PR in all those scenarios?
This issue needs more details than you have provided so far.
mingkuang-Chuyu commentedon Dec 6, 2019
@rrelyea Yes, I have tested nuget in all scenarios I know.
nuget.exe restore
result : is OK
nuget restore "I:\Visual Studio 2013\Projects\PluginsMgr\Cons
oleApplication1\ConsoleApplication1.vcxproj"
Log
msbuild.exe restore
result : is OK
msbuild -restore -p:Configuration=Release;Platform=Win32 "I:\Visual Studio 2013\Projects\PluginsMgr\ConsoleApplication1\ConsoleApplication1.vcxproj"
Log
rrelyea commentedon Dec 6, 2019
And in visual studio? What is the behavior? (Without running a Commandline restore ever on that project)
mingkuang-Chuyu commentedon Dec 6, 2019
nuget.exe, msbuild.exe and VS NuGet UI, all works fine.
mingkuang-Chuyu commentedon Dec 6, 2019
in VS UI Build
Log
mingkuang-Chuyu commentedon Dec 6, 2019
And Build log : )
karann-msft commentedon Dec 6, 2019
What version of Visual Studio did you test this with? Logs suggest 2013.
mingkuang-Chuyu commentedon Dec 6, 2019
@karann-msft Hi, VS2019 version is 16.3.10.
: )
mingkuang-Chuyu commentedon Dec 6, 2019
But VS2017 also works.
13 remaining items
mingkuang-Chuyu commentedon Jan 30, 2020
I'll try to support this feature (that C++/CLI project use .NET nuget package ).
mingkuang-Chuyu commentedon Feb 4, 2020
Sorry NuGet does not support TargetFramework Fallblack, so I cannot support them at the same time. Even if I provide PR, but there are many changes, I am afraid that Microsoft's urine is difficult to accept.
rrelyea commentedon Jul 16, 2020
@AugP from Microsoft's C++ team commented on a related PR (NuGet/NuGet.Client#3145 (comment)):
Given this, we're closing that PR, and keeping this issue open while the C++ teams conversations continue.'
Note...the C++ is most engaged on this developer community item about this same topic. See https://developercommunity.visualstudio.com/idea/351636/use-packagereference-in-vcxproj.html
nkolev92 commentedon May 19, 2026
This has been implemented in Visual Studio.
https://devblogs.microsoft.com/cppblog/nuget-packagereference-for-c-projects-in-visual-studio/