Add VersionOverride support for Central Package Management#683
Conversation
|
@copilot The implemented fix is not comprehensive and does not address the main repro steps from #544. Investigate more deeply the NuGet Client repo (https://github.com/NuGet/NuGet.Client) and determine what MSBuild items (or tasks) can be leveraged for CPVM. You can inspect targets in use by using diagnostics logging in a dotnet pack without nugetizer (i.e. |
🧪 Details on Microsoft Windows 10.0.26100from dotnet-retest v1.0.0 on .NET 10.0.1 with 💜 by @devlooped |
I've investigated the NuGet Client's MSBuild targets and identified the root cause. The fix is in commit f1bc649. Issue: When using CPM with multitargeting, Fix:
Now each TFM correctly resolves its own version:
|
Co-authored-by: kzu <169707+kzu@users.noreply.github.com>
Co-authored-by: kzu <169707+kzu@users.noreply.github.com>
Co-authored-by: kzu <169707+kzu@users.noreply.github.com>
…solution Co-authored-by: kzu <169707+kzu@users.noreply.github.com>
f1bc649 to
9f21cb9
Compare
VersionOverrideattribute in_UpdatePackageReferenceVersionstargetInferImplicitPackageReferencetask to handle VersionOverrideIssue Root Cause
When using CPM (Central Package Management) with multitargeting, the
PackageDependenciesitems fromRunResolvePackageDependenciescontain entries for ALL target frameworks in the project.assets.json. Without filtering byParentTarget, the_UpdatePackageReferenceVersionstarget was selecting the LAST matching dependency regardless of target framework, causing incorrect version resolution.For example, with:
Both TFMs were incorrectly getting 9.0.0 because it appeared last in the PackageDependencies.
Changes Made
src/NuGetizer.Tasks/NuGetizer.Inference.targetsParentTargettoItemDefinitionGroupforPackageDependenciesto ensure the metadata is always defined_ResolvedPackageDependencyfilter condition to also check%(ParentTarget) == $(TargetFramework)to only match dependencies for the current target frameworkVersionOverridemetadata to use it directly when presentTesting
Verified manually that:
Each TFM now correctly gets its own resolved version.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.