Skip to content

Upgrading packages injected by a custom project SDK fails #794

Closed

Description

@thomhurst

Problem

Some MSBuild project SDKs add PackageReference items to the project without marking them as auto-referenced. dotnet-outdated reports these packages as direct dependencies. When you run -u, it tries to upgrade them with dotnet add package, which fails. The version comes from the SDK, not from the project file.

One example is Cake.Sdk, which injects Cake.Generator.

Repro

project-sdk.csproj:

<Project Sdk="Cake.Sdk/6.0.0">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
  </PropertyGroup>
</Project>

Program.cs:

Information("Project with a versioned custom SDK");

Run dotnet outdated -u:

» Cake.Sdk
  [net10.0]
  Cake.Generator  6.0.0 -> 6.3.0

Upgrading package Cake.Generator...
An error occurred while upgrading Cake.Sdk

The exit code is 3.

The restore graph (obj/*.dgspec.json) lists the package without autoReferenced, so --include-auto-references does not change anything:

"dependencies": {
  "Cake.Generator": {
    "target": "Package",
    "version": "[6.0.0, )",
    "versionOverride": "[6.0.0, )"
  }
}

A second, smaller problem shows in the output above: the project is labelled Cake.Sdk instead of project-sdk.

Expected

Packages that come from an SDK should not be offered as separate upgrades. The fix is to upgrade the SDK itself. #793 adds support for that in project files, and #755 already does it for #:sdk in file-based apps. For file-based apps, the directives already replace the dependencies from the restore graph, so the injected packages are hidden there.

SDKs that mark their implicit packages as auto-referenced, such as Aspire.AppHost.Sdk, are not affected.

Possible approaches

  • Only report direct dependencies that come from a PackageReference, PackageVersion or GlobalPackageReference in the project file or its imported props files, or from a declared SDK.
  • Check whether the PackageReference was defined inside the SDK's own props or targets files, for example through MSBuild evaluation, and treat it as implicit.

Activity

  1. added a commit that references this issue on Sep 30, 2026
    327ce52
  2. added a commit that references this issue on Nov 8, 2026
    f1c0888
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions