-
Notifications
You must be signed in to change notification settings - Fork 252
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
Restore fails when .NET Framework Project depends on C++ CLI project #10511
Comments
Hey @nkolev92, thank you for the reply. Even when it's not supported, PackageReference is working with native projects. At least calling nuget restore with NuGet Client 5.8.4 on native project is restoring the PackageReferences as expected. Therefore, I would appreciate if you can share some information about this change. |
Due to the nature of MSBuild, the tooling cannot block every unsupported scenario.
In the scenario described, the .NET project is not PackageReference. The error suggests that the project is PackageReference.
Can you please upload a project? Following the instructions I just get a failure when vcxproj is restore (which is expected).
Note that even if the behavior did change, this is still an unsupported scenario and we might not be able to change the new behavior. |
Hi @nkolev92 , sorry for delayed answer. |
Hey @snthomae Trying it out with NuGet.exe I wasn't able to repro it (note that NuGet.exe carries the same bits). C:\Users\Roki2\Downloads\NuGetExample [master]> C:\Programs\NuGet\nuget-5.8.0.exe restore MSBuild auto-detection: using msbuild version '16.9.0.63002' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin'.
Restoring packages for C:\Users\Roki2\Downloads\NuGetExample\CppProject\CppProject.vcxproj...
Restoring packages for C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\DotNetProject.csproj...
NU1201: Project CppProject is not compatible with net48 (.NETFramework,Version=v4.8). Project CppProject supports: native (native,Version=v0.0)
Committing restore...
Installing boost 1.71.0.0.
Generating MSBuild file C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\obj\DotNetProject.csproj.nuget.g.props.
Generating MSBuild file C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\obj\DotNetProject.csproj.nuget.g.targets.
Writing assets file to disk. Path: C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\obj\project.assets.json
Failed to restore C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\DotNetProject.csproj (in 269 ms).
Committing restore...
Generating MSBuild file C:\Users\Roki2\Downloads\NuGetExample\CppProject\obj\CppProject.vcxproj.nuget.g.props.
Generating MSBuild file C:\Users\Roki2\Downloads\NuGetExample\CppProject\obj\CppProject.vcxproj.nuget.g.targets.
Writing assets file to disk. Path: C:\Users\Roki2\Downloads\NuGetExample\CppProject\obj\project.assets.json
Restored C:\Users\Roki2\Downloads\NuGetExample\CppProject\CppProject.vcxproj (in 19.44 sec).
Errors in C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\DotNetProject.csproj
NU1201: Project CppProject is not compatible with net48 (.NETFramework,Version=v4.8). Project CppProject supports: native (native,Version=v0.0)
NuGet Config files used:
C:\Users\Roki2\Downloads\NuGetExample\NuGet.Config
C:\Users\Roki2\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config
Feeds used:
C:\Users\Roki2\Downloads\NuGetExample\.nuget
Installed:
1 package(s) to C:\Users\Roki2\Downloads\NuGetExample\CppProject\CppProject.vcxproj
C:\Users\Roki2\Downloads\NuGetExample [master +3 ~0 -0 !]> C:\Users\Roki2\Downloads\NuGetExample [master +3 ~0 -0 !]> C:\Programs\NuGet\nuget-5.7.0.exe restore MSBuild auto-detection: using msbuild version '16.9.0.63002' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin'.
Committing restore...
Assets file has not changed. Skipping assets file writing. Path: C:\Users\Roki2\Downloads\NuGetExample\CppProject\obj\project.assets.json
Restored C:\Users\Roki2\Downloads\NuGetExample\CppProject\CppProject.vcxproj (in 54 ms).
Restoring packages for C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\DotNetProject.csproj...
NU1201: Project CppProject is not compatible with net48 (.NETFramework,Version=v4.8). Project CppProject supports: native (native,Version=v0.0)
Committing restore...
Generating MSBuild file C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\obj\DotNetProject.csproj.nuget.g.props.
Assets file has not changed. Skipping assets file writing. Path: C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\obj\project.assets.json
Failed to restore C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\DotNetProject.csproj (in 274 ms).
Errors in C:\Users\Roki2\Downloads\NuGetExample\DotNetProject\DotNetProject.csproj
NU1201: Project CppProject is not compatible with net48 (.NETFramework,Version=v4.8). Project CppProject supports: native (native,Version=v0.0)
NuGet Config files used:
C:\Users\Roki2\Downloads\NuGetExample\NuGet.Config
C:\Users\Roki2\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
C:\Program Files (x86)\NuGet\Config\Xamarin.Offline.config
Feeds used:
C:\Users\Roki2\Downloads\NuGetExample\.nuget
1 of 2 projects are up-to-date for restore.
C:\Users\Roki2\Downloads\NuGetExample [master +3 ~0 -0 !]> cc @zivkan who's the handling incoming issues this week. |
Hey @nkolev92 but you were able to reproduce it - you are getting exactly same NU1201 error as mentioned: This error doesn't come up when you do a restore with nuget version < 5.8.X. |
If you look at my logs again you will see that I ran the same thing with 5.7.0 and got the same result. The indentation is messed up but search for |
@nkolev92 Please can you retry it again with following sample: Result with NuGet 5.7.0: Result with NuGet 5.8.X: |
Thanks for clarifying. I can repro the behavior. Unfortunately, this is exactly where we get in the unsupported scenario. Prior to 5.8 (and .NET Core 5.0), NuGet and the dotnet SDK were incorrectly handling the TargetFramework inference. When frameworks of the net5.0-windows were introduced in .NET 5, NuGet and the SDK needed to fix this longstanding inconsistency. You can add another hack on top of your current behavior by adding Unfortunately at this point, we can't commit to making any changes. NuGet does not have support for vcxproj projects & AssetTargetFallback is the big hammer to workaround 2 things being incompatible. |
thanks so much for this incredible trick - I spent hours to fix the pipeline and now finally with the "remove" or "condition" in the Directory.Build.Props it works |
@lorenz-haenggi-jarowa can you please share your condition or remove in the Directory.Build.Props? |
Details about Problem
After upgrading to Visual Studio 16.8 (which integrates NuGet 5.8.1), restore is failing when .NET Framework project is referencing a C++ CLI Project via ProjectReferences. Also setting a TargetFramework Version in C++ Project has no impact.
C++ Project is always treated as Target Framework 'Native' which seems not to be compatible to any .NET Framework Project.
NuGet product used (NuGet.exe | Visual Studio | MSBuild.exe | dotnet.exe):
Visual Studio Version 16.8.4.
MSBuild 16.8.3.61104
NuGet 5.8.1
Worked before? If so, with which NuGet version:
Worked before with Visual Studio 16.7.X and NuGet 5.7.0.
Repro steps and/or sample project
Verbose Logs
The text was updated successfully, but these errors were encountered: