Skip to content

dotnet package update rejects packages with different versions per target framework (blocks Roslyn) #15123

Open

Description

@tmat

NuGet Product Used

dotnet.exe

Product Version

Reproduced with:

.NET SDK: 11.0.100-rc.1.26425.128
SDK commit: 3551975be0
MSBuild: 18.11.0-1.26425.128+3551975be
OS: Windows 10.0.26300, win-x64

Worked before?

Unknown.

Impact

It's more difficult to complete my work. This prevents using dotnet package update to maintain packages with framework-specific versions in the Roslyn repository, not just in a synthetic project.

Repro Steps & Context

Create Repro.csproj in an otherwise empty directory:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFrameworks>netstandard2.0;net10.0</TargetFrameworks>
  </PropertyGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
    <PackageReference Include="NuGet.Common" Version="6.3.4" />
  </ItemGroup>
  <ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
    <PackageReference Include="NuGet.Common" Version="6.14.3" />
  </ItemGroup>
</Project>

Run:

dotnet package update --project Repro.csproj

Actual result:

Updating outdated packages in ...\Repro.csproj.
The package NuGet.Common references different versions of the package for different target frameworks. This is not supported by this command. Edit the project file directly. (...\Repro.csproj)

The command exits with code 3. This minimal repro was run and verified with the SDK above. It does not require central package management or any Roslyn-specific build infrastructure.

Expected result: support updating packages that intentionally use different versions for different target frameworks, preserving the conditional references and respecting compatibility for each framework. The existing difference in versions should not by itself make the package ineligible for automated updates; flattening the references to one unconditional version would not be an equivalent fix.

Real-world impact: dotnet/roslyn

Running dotnet package update from the Roslyn repository root reports this error for all four of these packages in src\RoslynSdk\Microsoft.CodeAnalysis.Testing\Microsoft.CodeAnalysis.Analyzer.Testing\Microsoft.CodeAnalysis.Analyzer.Testing.csproj:

  • NuGet.Common
  • NuGet.Packaging
  • NuGet.Protocol
  • NuGet.Resolver

For example:

C:\R0>dotnet package update
Updating outdated packages in C:\R0.
The package NuGet.Common references different versions of the package for different target frameworks. This is not supported by this command. Edit the project file directly. (C:\R0\src\RoslynSdk\Microsoft.CodeAnalysis.Testing\Microsoft.CodeAnalysis.Analyzer.Testing\Microsoft.CodeAnalysis.Analyzer.Testing.csproj)

Roslyn uses central package management for this project. Its src/RoslynSdk/Directory.Packages.props deliberately selects RoslynSdkNuGetApiVersion=6.14.3 for net472 and $(NetRoslyn), and defaults to 6.3.4 for the other target framework. All four package versions use this property. The testing library targets $(NetRoslyn);netstandard2.0;net472.

Relevant public source, pinned to Roslyn commit 7ed110c0f961a5f8800139bc2df914ffb0099aca:

This blocks automatic maintenance of these existing framework-specific dependencies when using the repository-wide update command and requires manual version updates instead.

Related context

The accepted package-update design discusses ambiguity around framework-specific updates. This report provides a minimal repro and a concrete real-world use case where the framework-specific versions already exist.

#6521 concerns framework handling in dotnet add package; this report concerns the explicit rejection in dotnet package update.

Activity

  1. dotnet-policy-service commented on Oct 30, 2026

    @dotnet-policy-service
    Contributor

    Issue is missing Type label, remember to add a Type label

  2. added
    missing-required-type
    on Oct 30, 2026
  3. added and removed
    missing-required-type
    on Nov 3, 2026
  4. added
    Functionality:Update
    on Nov 3, 2026
  5. dotnet-policy-service commented on Nov 3, 2026

    @dotnet-policy-service
    Contributor

    Issue is missing Type label, remember to add a Type label

  6. added
    missing-required-type
    on Nov 3, 2026
  7. added
    Priority:2
    and removed
    missing-required-type
    on Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Functionality:UpdatePriority:2Product:dotnet.exeType:Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions