TargetFrameworks doesn't seem to be handled properly

Aberta
#674 1 comentário 1 reação 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
22/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
csharp
Domínio
build-system, tooling

Direção de pesquisa

Reproduce with the two-target MyDualFrameworkTest.csproj from the report, which lists net6.0 and net8.0 in TargetFrameworks, and run dotnet outdated with --upgrade:Auto. Find where the tool chooses one package version for all target frameworks, then decide how a per-framework upgrade should respect each framework's support. Done when the net6.0 build no longer pulls in Microsoft.NET.Test.Sdk 17.14.1 or xunit.runner.visualstudio 3.1.0, and the test suite still passes on both frameworks.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

My workstation is an Oracle Linux Server 8.10.

$ dotnet --list-sdks
6.0.136 [/usr/lib64/dotnet/sdk]
8.0.115 [/usr/lib64/dotnet/sdk]

$ dotnet --list-runtimes
Microsoft.AspNetCore.App 6.0.36 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 8.0.15 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.36 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 8.0.15 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

$ dotnet outdated --version
A .NET Core global tool to list outdated Nuget packages.
4.6.8+c299fe8ae17f9d5fcfbb2170e2e2d6fce978ea5e

I have a simple project MyDualFrameworkTest.csproj for a single UnitTest defined like this:

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

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

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
    <PackageReference Include="xunit" Version="2.9.3" />
    <PackageReference Include="xunit.runner.visualstudio" Version="3.0.2">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

</Project>

Microsoft.NET.Test.Sdk Version 17.13.0 is the last one that supports net6.0. Same story for xunit.runner.visualstudio. Running the UTs on this project works fine:

$ dotnet test
  Determining projects to restore...
  All projects are up-to-date for restore.
  MyDualFrameworkTest -> /home/mmacrina/Playground/MyDualFrameworkTest/bin/Debug/net6.0/MyDualFrameworkTest.dll
  MyDualFrameworkTest -> /home/mmacrina/Playground/MyDualFrameworkTest/bin/Debug/net8.0/MyDualFrameworkTest.dll
Test run for /home/mmacrina/Playground/MyDualFrameworkTest/bin/Debug/net6.0/MyDualFrameworkTest.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.8.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 28 ms - MyDualFrameworkTest.dll (net6.0)
Test run for /home/mmacrina/Playground/MyDualFrameworkTest/bin/Debug/net8.0/MyDualFrameworkTest.dll (.NETCoreApp,Version=v8.0)
Microsoft (R) Test Execution Command Line Tool Version 17.8.0 (x64)
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.

Passed!  - Failed:     0, Passed:     1, Skipped:     0, Total:     1, Duration: 20 ms - MyDualFrameworkTest.dll (net8.0)

If I attempt to use dotnet outdated on this project, the UTs break. See below:

$ dotnet outdated MyDualFrameworkTest.csproj --upgrade:Auto --pre-release Never --version-lock Major
Discovering projects...
Analyzing project(s)...
Analyzing dependencies...
» MyDualFrameworkTest
  [net8.0]
  Microsoft.NET.Test.Sdk     17.13.0 -> 17.14.1
  xunit.runner.visualstudio  3.0.2   -> 3.1.0  
  [net6.0]
  xunit.runner.visualstudio  3.0.2 -> 3.1.0

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.NET.Test.Sdk...
Project MyDualFrameworkTest [net8.0] upgraded successfully

Upgrading package xunit.runner.visualstudio...
Project MyDualFrameworkTest [net8.0] upgraded successfully
Project MyDualFrameworkTest [net6.0] upgraded successfully

dotnet test
  Determining projects to restore...
/home/mmacrina/Playground/MyDualFrameworkTest/MyDualFrameworkTest.csproj : warning NU1701: Package 'xunit.runner.visualstudio 3.1.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project.
  All projects are up-to-date for restore.
/home/mmacrina/.nuget/packages/microsoft.net.test.sdk/17.14.1/build/netcoreapp2.0/Microsoft.NET.Test.Sdk.targets(4,5): error : Microsoft.NET.Test.Sdk doesn't support net6.0 and has not been tested with it. Consider upgrading your TargetFramework to net8.0 or later. You may also set <SuppressTfmSupportBuildErrors>true</SuppressTfmSupportBuildErrors> in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk. [/home/mmacrina/Playground/MyDualFrameworkTest/MyDualFrameworkTest.csproj::TargetFramework=net6.0]
/home/mmacrina/Playground/MyDualFrameworkTest/MyDualFrameworkTest.csproj : warning NU1701: Package 'xunit.runner.visualstudio 3.1.0' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8, .NETFramework,Version=v4.8.1' instead of the project target framework 'net6.0'. This package may not be fully compatible with your project. [TargetFramework=net8.0]
  MyDualFrameworkTest -> /home/mmacrina/Playground/MyDualFrameworkTest/bin/Debug/net8.0/MyDualFrameworkTest.dll

The error is due to dotnet outdated bringing Microsoft.NET.Test.Sdk up to 17.14.1 and xunit.runner.visualstudio up to 3.1.0 - both don't support net6.0.

Since the project specified multiple target frameworks (net6.0 and net8.0), dotnet outdated should honour that and do a 'safe' update considering the older runtime that is being targeted.

Linguagem predominante
C#
Estrelas
1.7k
Forks
172
Merge médio
1d 19h
PRs com merge (30d)
39

Preparar o ambiente

Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de dotnet-outdated/dotnet-outdated

Todas as issues de dotnet-outdated/dotnet-outdated

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.