Skip to content

Parameter --maximum-version ignores exact version references #670

Closed

Description

@chefarbeiter

I have a sample project with a reference to version 2.0.0 of the xunit.v3 package:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="xunit.v3" Version="2.0.0" />
  </ItemGroup>
</Project>

When I run dotnet-outdated (v4.6.8), it correctly shows the available new version 2.0.2 of the package:

PS > dotnet outdated
Discovering projects...
Analyzing project(s)...
Analyzing dependencies...
» OutdatedProofOf
  [net9.0]
  xunit.v3  2.0.0 -> 2.0.2

Now I change the reference to an exact version match:

  <ItemGroup>
    <PackageReference Include="xunit.v3" Version="[2.0.0]" />
  </ItemGroup>

When I run dotnet-outdated again, it says, as expected, that no new version is available:

PS > dotnet outdated
Discovering projects...
Analyzing project(s)...
Analyzing dependencies...
No outdated dependencies were detected

However, if I use the --maximum-version parameter, the exact version match is ignored and version 2.0.2 is displayed again:

PS > dotnet outdated --maximum-version "99.99"
Discovering projects...
Analyzing project(s)...
Analyzing dependencies...
» OutdatedProofOf
  [net9.0]
  xunit.v3  2.0.0 -> 2.0.2

And with the -u parameter, the package is actually updated:

PS > dotnet outdated --maximum-version "99.99" -u
Discovering projects...
Analyzing project(s)...
Analyzing dependencies...
» OutdatedProofOf
  [net9.0]
  xunit.v3  2.0.0 -> 2.0.2

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 xunit.v3...
Project OutdatedProofOf [net9.0] upgraded successfully
  <ItemGroup>
    <PackageReference Include="xunit.v3" Version="2.0.2" />
  </ItemGroup>

Activity

  1. chefarbeiter commented on May 26, 2025

    @chefarbeiter
    ContributorAuthor

    I think the error is hidden in this condition:

    if (maximumVersion is not null &&
    (versionRange.MaxVersion is null || maximumVersion > versionRange.MaxVersion))
    {

    Here the MaxVersion determined by NuGet, which corresponds to this version in the case of an exact version reference, is replaced by the value of the --maximum-version parameter if this is greater. But it should be the other way around: The parameter may only be used if the maximum version of NuGet is greater than the parameter value passed.

    Samples

    (Assuming that the latest available version is 10.0.1 and the highest version in the 8.0 branch is 8.0.16.)

    csproj --maximum-version Expected Result
    6.0.4 / 10.0.1
    6.0.4 8.0 8.0.16
    [6.0.4] / 6.0.4
    [6.0.4] 8.0 6.0.4
    10.0.1 5.0 10.0.1 (no update)
  2. added a commit that references this issue on Nov 8, 2026
    d46eef1
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