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
Support Central Package Management with conditional ItemGroups per target framework #529
I have a monorepo with some libraries which multi targets .NET 6 and 8.
They use Central Package Management with different packages per target framework.
When I use dotnet outdate -vl Minor it reports correctly the available updates:
This was seemingly lost to time but seemingly still an issue, but may be a duplicate of dotnet/sdk#49614 and/or NuGet/Home#14438 for the current dotnet SDK/product. This may be a dealbreaker to the ability to multi target and use CPM, so I'm posting everywhere I can to try to get it noticed.
@msherms2 building multi targeting projects with different package versions (or even different package references) per TFM does work for me without problems.
For me it's just dotnet-outdated, which cannot distinct the references per TFM.
Or I don't understand your issue, which may be totally possible... 😎
This is still an issue with the latest version, v4.6.9.
To be clear, dotnet-outdated correctly identifies the latest update compatible with each target framework, but dotnet outdated --upgrade incorrectly sets them all to the same version, possibly even downgrading!
Both dotnet-outdated by itself or dotnet-outdated --upgrade correctly identify the appropriate version updates, but the latter applies them incorrectly:
❯ dotnet outdated --upgrade
Discovering projects...
Analyzing project(s)...
Analyzing dependencies...
» AppLibrary
[net8.0]
Microsoft.EntityFrameworkCore 8.0.0 -> 9.0.11
[net10.0]
Microsoft.EntityFrameworkCore 10.0.0 -> 10.0.1
[net9.0]
Microsoft.EntityFrameworkCore 9.0.0 -> 9.0.11
Version color legend:
<red> : Major version update or pre-release version. Possible breaking changes.
<yellow>: Minor version update. Backwards-compatible features added.
<green> : Patch version update. Backwards-compatible bug fixes.
Upgrading package Microsoft.EntityFrameworkCore...
Project AppLibrary [net8.0] upgraded successfully
Upgrading package Microsoft.EntityFrameworkCore...
An error occurred while upgrading AppLibrary
Failed to restore project after upgrading!
Upgrading package Microsoft.EntityFrameworkCore...
Project AppLibrary [net9.0] upgraded successfully
Note the interesting order for the target frameworks. This is random, and a different order can occur each time it's run.
Also note that v9.0.11 of the NuGet package is indeed compatible with net8.0, so the analysis is correct. But the result is that all packages are up/downgraded to v9.0.11:
In fact, keeping the Directory.Packages.props file open in a text editor reveals that all the targeted entries are updated multiple times. In this example, all three are changed to v9.0.11, then v10.0.1, then v9.0.11 again, reflecting the order listed in the analysis.
You can see that the standard method includes a project.Framework parameter, but the CPM method does not.
These two AddPackage methods work very differently. The former calls the built-in dotnet package add command, which respects the target framework parameter. On the other hand, the latter uses regex to modify the Directory.Packages.props file without regard to framework.
I wonder why these methods were written so differently and why they were bifurcated in the first place? According to the documentation, dotnet package add is compatible with CPM.
Actually, I just looked at the history of the CPM version, and it looks like it was done this way because the dotnet CLI did not initially support CPM. From PR #243:
This PR aims to fix #6 or at the very least provide the rudimentry support needed to fix it while the dotnet CLI does not support CPVM.
(Bolding in the original.) So it looks like a fix could be as simple as consolidating the two separate versions to only use the CLI command.
Activity
msherms2 commentedon Jul 22, 2025
This was seemingly lost to time but seemingly still an issue, but may be a duplicate of dotnet/sdk#49614 and/or NuGet/Home#14438 for the current dotnet SDK/product. This may be a dealbreaker to the ability to multi target and use CPM, so I'm posting everywhere I can to try to get it noticed.
flensrocker commentedon Jul 22, 2025
@msherms2 building multi targeting projects with different package versions (or even different package references) per TFM does work for me without problems.
For me it's just dotnet-outdated, which cannot distinct the references per TFM.
Or I don't understand your issue, which may be totally possible... 😎
mpickers commentedon Oct 15, 2025
It's also just dotnet-outdated for me as well.
I've just hit this issue when moving to CPM. An example is:
Which is valid and works for CPM: https://learn.microsoft.com/en-us/nuget/consume-packages/central-package-management#using-different-versions-for-different-target-frameworks
What happens when running dotnet-outdated is that the Version of both of those entries gets set to the same...usually to the latest but sometimes not.
dougwaldron commentedon Jan 8, 2026
This is still an issue with the latest version, v4.6.9.
To be clear,
dotnet-outdatedcorrectly identifies the latest update compatible with each target framework, butdotnet outdated --upgradeincorrectly sets them all to the same version, possibly even downgrading!I think my example will be instructive.
AppLibrary.csproj
Directory.Packages.props
Both
dotnet-outdatedby itself ordotnet-outdated --upgradecorrectly identify the appropriate version updates, but the latter applies them incorrectly:Note the interesting order for the target frameworks. This is random, and a different order can occur each time it's run.
Also note that v9.0.11 of the NuGet package is indeed compatible with net8.0, so the analysis is correct. But the result is that all packages are up/downgraded to v9.0.11:
In fact, keeping the Directory.Packages.props file open in a text editor reveals that all the targeted entries are updated multiple times. In this example, all three are changed to v9.0.11, then v10.0.1, then v9.0.11 again, reflecting the order listed in the analysis.
dougwaldron commentedon Jan 8, 2026
Inside the
UpgradePackagesmethod, differentAddPackagemethods are called depending on whether CPM is used:dotnet-outdated/src/DotNetOutdated/Program.cs
Lines 295 to 297 in 5754b2b
You can see that the standard method includes a
project.Frameworkparameter, but the CPM method does not.These two
AddPackagemethods work very differently. The former calls the built-indotnet package addcommand, which respects the target framework parameter. On the other hand, the latter uses regex to modify the Directory.Packages.props file without regard to framework.I wonder why these methods were written so differently and why they were bifurcated in the first place? According to the documentation,
dotnet package addis compatible with CPM.Actually, I just looked at the history of the CPM version, and it looks like it was done this way because the dotnet CLI did not initially support CPM. From PR #243:
(Bolding in the original.) So it looks like a fix could be as simple as consolidating the two separate versions to only use the CLI command.
Remove specialized code for Central Package Management (#697)