dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.73k stars 1.07k forks source link

Outdated packages are wrongly displayed for given target framework #30503

Open msmolka opened 1 year ago

msmolka commented 1 year ago

Describe the bug

using: dotnet list package --outdated --framework net6.0 shows packages versions that supported only by net7.0 target framework and not net6.0

To Reproduce

project with reference: <PackageReference Include="Ardalis.SmartEnum" Version="2.1.0" />

outdate will show:

[net6.0]:
Top-level Package Requested Resolved Latest
> Ardalis.SmartEnum 2.1.0 2.1.0 7.0.0 

7.0.0 is not compatible with net6

Further technical details

.NET SDK:
 Version:   7.0.102
 Commit:    4bbdd14480

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19044
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\7.0.102\

Host:
  Version:      7.0.2
  Architecture: x64
  Commit:       d037e070eb
tebeco commented 1 year ago

Can confirm it's quite annoying another example is Microsoft.AspNetCore.Mvc.Newtonsoft https://www.nuget.org/packages/Microsoft.AspNetCore.Mvc.NewtonsoftJson#dependencies-body-tab image

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFrameworks>net6.0;net7.0</TargetFrameworks>
  </PropertyGroup>

  <ItemGroup>
    <PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.5" Condition=" '$(TargetFramework)' == 'net7.0' " />
    <PackageVersion Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="6.0.16" Condition=" '$(TargetFramework)' == 'net6.0' " />
  </ItemGroup>
</Project>
dotnet list package --outdate
   [net6.0]:
   Top-level Package                              Requested   Resolved   Latest
   > Microsoft.AspNetCore.Mvc.NewtonsoftJson                  6.0.16     7.0.5

   [net7.0]: No package updates available for this framework.
minj commented 1 year ago

System.ServiceModel.* v=6.0.0 are mistakenly listed for net48