Repository navigation
Handle missing TargetFramework in nomination (#7192) - #7196
Merged
Merged
Conversation
Nigusu-Allehu
approved these changes
Mar 6, 2026
zivkan
approved these changes
Mar 6, 2026
This was referenced Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
Fixes: NuGet/Home#14788
Description
Dev version of #7192.
When we changed the main parts of restore to use TargetAlias as the pivot instead of the NuGetFramework it basically meant that TargetAlias needs to either be empty or have a value.
In many places in restore we default to empty if there's no value (non SDK projects)
https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Commands/RestoreCommand/Utility/MSBuildRestoreUtility.cs#L445
https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Build.Tasks.Console/MSBuildStaticGraphRestore.cs#L734
In legacy PR, we don't set it.
In CPSPackageReference projects however, we set it, expecting that it's only invoked in SDK based scenarios but unfortunately that's not the case.
Enter C++/CLI PackageReference hacks!
The confirmed scenario in question seems to be C++/CLI PackageReference (.NET Framework projects).
C++/CLI (.NET Core) supports PackageReference projects: https://devblogs.microsoft.com/cppblog/announcing-nuget-packagereference-support-for-c-cli-msbuild-projects-targeting-net-core/ . The way that works is the C++/CPS/project-system teams worked so that the nomination code from the managed lang system is being utilized to provide this restore data to NuGet. In the end for NuGet, while we did add some special compatibility rules, these restores appear the same as a normal SDK based project.
Note that native C++ PackageReference is not supported, https://developercommunity.visualstudio.com/t/Add-PackageReference-support-for-native-/10165376 . Similarly to many scenarios, it can work on the commandline, but project reference protocol and VS scenarios just won't work. Customers haven't really cared about that limitation.
They have been using all kinds of workarounds: Use PackageReference in vcxproj - Developer Community NuGet/Home#8874 .
They basically set things like Capability, and all kinds of stuff to try to work around the implementation limiting when restore works.
These things are all unsupported. We have been clear about that, since not all scenarios are handled in C++ PackageReference today.
NuGet generates assets file, nuget.g.props, nuget.g.targets and none of those are guaranteed to be loaded or refreshed in these scenarios. So restore happens, but whether the build or intellisense actually works the way they wanted is not guaranteed.
That being said, this did get broken and the fix is rather straightforward, so we'll fix it, but we won't service stable, but insiders only.
There is a workaround and that is setting the TargetFramework value.
sample nomination data for a C++/CLI project, https://github.com/jwfx/NuGetRestoreRepro/blob/master/Directory.Build.props.
BEGIN Nominate Restore for E:\Code\Temp\NuGetRestoreRepro\NuGetRestoreRepro\NuGetRestoreRepro.vcxproj MSBuildProjectExtensionsPath: E:\Code\Temp\NuGetRestoreRepro\NuGetRestoreRepro\obj\ OriginalTargetFrameworks: Target Frameworks (1) native,Version=v0.0 Framework References Package Downloads Project References Package References Newtonsoft.Json -- (Aliases: | ExcludeAssets: | GeneratePathProperty: | IncludeAssets: | IsImplicitlyDefined: | Name: | NoWarn: | PrivateAssets: | Version:13.0.4 | VersionOverride: | Visible:) NuGet Audit Suppressions Prune Package References Package Versions -- 0 (count only) Target Framework Properties -- (RestoreLockedMode: | RestorePackagesWithLockFile: | NuGetAudit:true | RestoreEnablePackagePruning:false | RestoreAdditionalProjectFallbackFolders: | TargetPlatformIdentifier:Windows | RestorePackagesPath: | MSBuildProjectDirectory:E:\Code\Temp\NuGetRestoreRepro\NuGetRestoreRepro | RestoreAdditionalProjectSources: | CentralPackageFloatingVersionsEnabled: | PackageId: | RuntimeIdentifier: | NoWarn:;NU1701;NU1702 | RestoreAdditionalProjectFallbackFoldersExcludes: | TargetFrameworkIdentifier:.NETFramework | VersionSuffix: | DotnetCliToolTargetFramework: | CLRSupport:true | VersionPrefix: | TargetPlatformVersion:10.0.26100.0 | Version:1.0.0.0 | NuGetAuditMode:direct | CentralPackageVersionOverrideEnabled: | NETCoreSdkVersion: | RestoreFallbackFolders: | MSBuildProjectFile:NuGetRestoreRepro.vcxproj | NuGetAuditLevel:low | TargetFrameworkMoniker:.NETFramework,Version=v4.8 | WarningsNotAsErrors: | TargetPlatformMoniker:Windows,Version=10.0.26100.0 | TargetPlatformMinVersion:7.0 | EmitAssetsLogMessages: | RestorePackagePruningDefault:false | TargetFramework:native | UsingMicrosoftNETSdk: | PackageTargetFallback: | ProjectAssetsFile:E:\Code\Temp\NuGetRestoreRepro\NuGetRestoreRepro\obj\project.assets.json | RestoreUseLegacyDependencyResolver: | WindowsTargetPlatformMinVersion:7.0 | ManagePackageVersionsCentrally: | TreatWarningsAsErrors: | TargetFrameworkProfile: | RestoreSources: | TargetFrameworks: | NuGetTargetMoniker:native,Version=v0.0 | RuntimeIdentifierGraphPath: | MSBuildProjectExtensionsPath:E:\Code\Temp\NuGetRestoreRepro\NuGetRestoreRepro\obj\ | TargetFrameworkVersion:v4.8 | NuGetLockFilePath: | RuntimeIdentifiers:win;win-x86;win-x64;win-arm64 | PackageVersion: | SdkAnalysisLevel: | CentralPackageTransitivePinningEnabled: | WarningsAsErrors: | AssetTargetFallback:net48) Tool ReferencesPR Checklist