-
Notifications
You must be signed in to change notification settings - Fork 258
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
VC Project not support nuget PackageReference style #8874
Comments
nice ! |
@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? |
@rrelyea Yes, I have tested nuget in all scenarios I know. nuget.exe restoreresult : is OK nuget restore "I:\Visual Studio 2013\Projects\PluginsMgr\Cons Log
msbuild.exe restoreresult : is OK Log
|
And in visual studio? What is the behavior? (Without running a Commandline restore ever on that project) |
nuget.exe, msbuild.exe and VS NuGet UI, all works fine. |
in VS UI Build
|
And Build log : )
|
What version of Visual Studio did you test this with? Logs suggest 2013. |
@karann-msft Hi, VS2019 version is 16.3.10. : ) |
But VS2017 also works. |
For .NET projects, PackageReference works by using MSBuild to find the full list of PackageReferences not only for the current project, but also transitive PackageReferences from project-to-project references (although c++ projects can use ProjectReference, it's unclear to me what this does other than specify build order). It restores the packages (and their dependencies) to the global packages folder, then it writes a project.assets.json file which specifies all the compile and runtime assets, consumed by the project system, but also writes a .g.props and .g.targets so that the props/targets files from packages can be discovered, also consumed by the project system. So, when you propose that NuGet uses MSBuild APIs to modify ItemGroup/PackageReference, how exactly will it be modified, what is going to be put into the project? Is it adding package assets, or props/targets files, or both? Is it saving the changes to the vcproj to disk, like packages.config does, or just modifying it in memory? Without project system support, how do packages that bring props/targets file have those props/targets files evaluated, given the project has already been evaluated before the packages were restored? In .NET projects, packages.config allows files from the package to be added to the project using the In .NET projects, PackageReference separates the concept of compile-time assets from runtime assets. Does the same distinction make sense for native/c++ projects? In .NET, the package's runtime folder uses a RID to use different assets depending on the runtime (linux vs mac vs windows, even ubutu vs redhat, 64-bit vs 32 bit vs arm). RIDs are concepts that cannot be evaluated at NuGet restore time, or package add time, as a project may multi-target. How does this fit into c++ projects, particularly without c++ project system support? Those are all the features of PackageReference that I can think of, but there may be other things. I really do appriciate anyone spending their effort contributing, but once the NuGet team ships something, we have to support it, so it needs to be well designed. |
@zivkan , .g.props/ .g.targets is ok(nuget,msbuild, vs nuget ui). contentFiles,I'm not sure. I'll give you an answer tomorrow. I have provided logs to prove that they work properly. Thanks for your support. |
@zivkan contentFiles is not work. Do you know where the "project.assets.json" generated code is? Thanks |
contentFiles is ok. This is the test configuration <package>
<metadata minClientVersion="3.3.0">
<id>VC.contentFiles.Test</id>
<version>1.0.4</version>
<authors>nuget</authors> <!-- The NuGet team authored this package -->
<owners>nuget</owners> <!-- The NuGet team owns this package -->
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A content v2 example package.</description>
<tags>contentv2 contentFiles</tags>
<!-- Build actions for items in the contentFiles folder -->
<contentFiles>
<!--C++ Srorce File-->
<files include="cpp/**/*.cpp" buildAction="ClCompile" />
<!--C Srorce File-->
<files include="cpp/**/*.c" buildAction="ClCompile" />
<!--asm Srorce File-->
<files include="cpp/**/*.asm" buildAction="MASM" />
<!--Resource File-->
<files include="cpp/**/*.rc" buildAction="ResourceCompile" />
<!--Interface Definition Language File-->
<files include="cpp/**/*.ild" buildAction="Midl" />
</contentFiles>
</metadata>
<files>
<!--pp file-->
<file src="ExamplePP.cpp.pp" target="contentFiles\cpp\any" />
<file src="ExampleC++.cpp" target="contentFiles\cpp\any" />
<file src="ExampleC.c" target="contentFiles\cpp\any" />
<file src="ExampleASM.asm" target="contentFiles\cpp\any" />
<file src="ExampleRC.rc" target="contentFiles\cpp\any" />
<file src="ExampleMIDL.idl" target="contentFiles\cpp\any" />
</files>
</package> |
ncie |
RID is ok. This is the test configuration. wimgapi ,10.0.18362.1. win-x86,win-x64,win-arm,win-arm64 <package>
<metadata minClientVersion="3.3.0">
<id>Wimgapi</id>
<version>10.0.18362.1</version>
<authors>nuget</authors> <!-- The NuGet team authored this package -->
<owners>nuget</owners> <!-- The NuGet team owns this package -->
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A content v2 example package.</description>
<tags>Wimgapi native</tags>
<contentFiles>
<files include="cpp/**" buildAction="None" copyToOutput="true"/>
</contentFiles>
</metadata>
<files>
<file src="SDKs\Wimgapi\**" target="build\native"/>
<file src="amd64\DISM\wimgapi.dll" target="runtimes\win-x64\native\wimgapi.dll"/>
<file src="amd64\DISM\wimmount.sys" target="runtimes\win-x64\native\wimmount.sys"/>
<file src="amd64\DISM\wimmountadksetupamd64.exe" target="runtimes\win-x64\native\wimmountadksetupamd64.exe"/>
<file src="amd64\DISM\wofadk.sys" target="runtimes\win-x64\native\wofadk.sys"/>
<file src="arm\DISM\wimgapi.dll" target="runtimes\win-arm\native\wimgapi.dll"/>
<file src="arm\DISM\wimmount.sys" target="runtimes\win-arm\native\wimmount.sys"/>
<file src="arm\DISM\wimmountadksetuparm.exe" target="runtimes\win-arm\native\wimmountadksetuparm.exe"/>
<file src="arm\DISM\wofadk.sys" target="runtimes\win-arm\native\wofadk.sys"/>
<file src="arm64\DISM\wimgapi.dll" target="runtimes\win-arm64\native\wimgapi.dll"/>
<file src="arm64\DISM\wimmount.sys" target="runtimes\win-arm64\native\wimmount.sys"/>
<file src="arm64\DISM\wimmountadksetuparm64.exe" target="runtimes\win-arm64\native\wimmountadksetuparm64.exe"/>
<file src="arm64\DISM\wofadk.sys" target="runtimes\win-arm64\native\wofadk.sys"/>
<file src="x86\DISM\wimgapi.dll" target="runtimes\win-x86\native\wimgapi.dll"/>
<file src="x86\DISM\wimmount.sys" target="runtimes\win-x86\native\wimmount.sys"/>
<file src="x86\DISM\wimmountadksetupx86.exe" target="runtimes\win-x86\native\wimmountadksetupx86.exe"/>
<file src="x86\DISM\wofadk.sys" target="runtimes\win-x86\native\wofadk.sys"/>
<file src="amd64\DISM\de-de\wimgapi.dll.mui" target="contentFiles\cpp\native\de-de\wimgapi.dll.mui"/>
<file src="amd64\DISM\en-us\wimgapi.dll.mui" target="contentFiles\cpp\native\en-us\wimgapi.dll.mui"/>
<file src="amd64\DISM\es-es\wimgapi.dll.mui" target="contentFiles\cpp\native\es-es\wimgapi.dll.mui"/>
<file src="amd64\DISM\fr-fr\wimgapi.dll.mui" target="contentFiles\cpp\native\fr-fr\wimgapi.dll.mui"/>
<file src="amd64\DISM\it-it\wimgapi.dll.mui" target="contentFiles\cpp\native\it-it\wimgapi.dll.mui"/>
<file src="amd64\DISM\ja-jp\wimgapi.dll.mui" target="contentFiles\cpp\native\ja-jp\wimgapi.dll.mui"/>
<file src="amd64\DISM\ko-kr\wimgapi.dll.mui" target="contentFiles\cpp\native\ko-kr\wimgapi.dll.mui"/>
<file src="amd64\DISM\pt-br\wimgapi.dll.mui" target="contentFiles\cpp\native\pt-br\wimgapi.dll.mui"/>
<file src="amd64\DISM\ru-ru\wimgapi.dll.mui" target="contentFiles\cpp\native\ru-ru\wimgapi.dll.mui"/>
<file src="amd64\DISM\zh-cn\wimgapi.dll.mui" target="contentFiles\cpp\native\zh-cn\wimgapi.dll.mui"/>
<file src="amd64\DISM\zh-tw\wimgapi.dll.mui" target="contentFiles\cpp\native\zh-tw\wimgapi.dll.mui"/>
<file src=".\Wimgapi.targets" target="build\native\Wimgapi.targets" />
</files>
</package> |
Yesterday I added vcxproj's targetFramework support, with the help of targetFramework. We can configure different static or dynamic libraries for different toolsets. targetFramework matching order
For example, if the following 2 paths exist in a package:
If we use the v142 toolset (VCToolsVersion = 14.23.28105 vs2019), then If we use the v141 toolset (14.12.25827 vs2017), then in nuspecin nuspec, using targetFramework, we can configure different static libraries for different toolsets of C++ projects. <dependencies>
<group targetFramework="native14.0">
<dependency id="Detours.Static.v140" version="4.0.1" />
</group>
<group targetFramework="native14.10">
<dependency id="Detours.Static.v14.10" version="4.0.1" />
</group>
<group targetFramework="native14.20">
<<dependency id="Detours.Static.v14.20" version="4.0.1" />
</group>
<group targetFramework="native14.21.27702">
<<dependency id="Detours.Static.v14.21.27702" version="4.0.1" />
</group>
</dependencies> in vcxprojwe can also do like this: <ItemGroup>
<PackageReference Include="Detours.Static.v14.13.26128" Condition=" '$(TargetFramework)' == 'native14.13.26128' ">
<Version>4.0.1</Version>
</PackageReference>
</ItemGroup> |
I modified the contentFiles support. In CreateItem, I added dotnet/NuGet.BuildTasks@812a5d9#diff-5b809cf81a6b552123b02a4b102867c9 The PrecompiledHeader is unique to C++ projects, and this option reduces the generality of the asset. Because we don't know if the project has PrecompiledHeader enabled. And we don't know the name of the precompiled header file. For other projects adding PrecompiledHeader, nothing will happen. |
Hi, I'm not an expert just a user but am wondering if this will allow a vcxproj style project to PackageReference a C# package that is build AnyCPU? |
VC++ does not support AnyCPU. |
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 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. |
@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 |
Maintainer edit:
Please refer to https://developercommunity.visualstudio.com/t/use-packagereference-in-vcxproj/351636
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++.
Thanks
mingkuang
My RP(add C++ PackageReference support)
NuGet.Client
NuGet/NuGet.Client#3145
NuGet.BuildTasks
dotnet/NuGet.BuildTasks#67
The text was updated successfully, but these errors were encountered: