Skip to content

dotnet-outdated fails on new mstest template switch to Sdk MSTest.Sdk #589

Open

Description

@devlead

With latest SDK Microsoft has introduced an new SDK for MSTest so there's no explicit package references in in csproj

dotnet-outdated correctly identifies packages that needs to be updated

» testmstest
  [net9.0]
  Microsoft.NET.Test.Sdk                     17.10.0 -> 17.11.1
  Microsoft.Testing.Extensions.CodeCoverage  17.11.3 -> 17.12.4
  Microsoft.Testing.Extensions.TrxReport     1.3.2   -> 1.4.0
  MSTest.Analyzers                           3.5.1   -> 3.6.0
  MSTest.TestAdapter                         3.5.1   -> 3.6.0
  MSTest.TestFramework                       3.5.1   -> 3.6.0

But when executing dotnet outdated -u all updates fails

Upgrading package Microsoft.NET.Test.Sdk...
An error occurred while upgrading testmstest


Upgrading package Microsoft.Testing.Extensions.CodeCoverage...
An error occurred while upgrading testmstest


Upgrading package Microsoft.Testing.Extensions.TrxReport...
An error occurred while upgrading testmstest


Upgrading package MSTest.Analyzers...
An error occurred while upgrading testmstest


Upgrading package MSTest.TestAdapter...
An error occurred while upgrading testmstest


Upgrading package MSTest.TestFramework...
An error occurred while upgrading testmstest

The csproj now looks like this:

<Project Sdk="MSTest.Sdk/3.5.1">

  <PropertyGroup>
    <TargetFramework>net9.0</TargetFramework>
    <LangVersion>latest</LangVersion>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <!--
      Displays error on console in addition to the log file. Note that this feature comes with a performance impact.
      For more information, visit https://learn.microsoft.com/dotnet/core/testing/unit-testing-platform-integration-dotnet-test#show-failure-per-test
      -->
    <TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
  </PropertyGroup>

</Project>

Updating SDK manually resolved most problems

- <Project Sdk="MSTest.Sdk/3.5.1">
+ <Project Sdk="MSTest.Sdk/3.6.0">

Results in one package still out of date

» testmstest
  [net9.0]
  Microsoft.NET.Test.Sdk  17.11.0 -> 17.11.1

update still fails

Upgrading package Microsoft.NET.Test.Sdk...
An error occurred while upgrading testmstest

Executing .NET Add manually results in this error which might be a lead.

dotnet add package Microsoft.NET.Test.Sdk --version 17.11.1

Build succeeded in 0,6s
info : X.509 certificate chain validation will use the default trust store selected by .NET for code signing.
info : X.509 certificate chain validation will use the default trust store selected by .NET for timestamping.
info : Adding PackageReference for package 'Microsoft.NET.Test.Sdk' into project 'C:\temp\testmstest\testmstest.csproj'.
info : Restoring packages for C:\temp\testmstest\testmstest.csproj...
info :   CACHE https://api.nuget.org/v3/vulnerabilities/index.json
info :   CACHE https://api.nuget.org/v3-vulnerabilities/2024.09.24.23.37.09/vulnerability.base.json
info :   CACHE https://api.nuget.org/v3-vulnerabilities/2024.09.24.23.37.09/2024.09.25.17.37.11/vulnerability.update.json
info : Package 'Microsoft.NET.Test.Sdk' is compatible with all the specified frameworks in project 'C:\temp\testmstest\testmstest.csproj'.
error: Value cannot be null. (Parameter 'version')

Switching to Central Package Management (CPM) makes the update silently fail regardless if the package version exists or not in Directory.Packages.props

dotnet outdated
» testmstest
  [net9.0]
  Microsoft.NET.Test.Sdk  17.11.0 -> 17.11.1

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.

You can upgrade packages to the latest version by passing the -u or -u:prompt option.
Elapsed: 00:00:02.3225000

Activity

  1. devlead commented on Sep 26, 2024

    @devlead
    ContributorAuthor

    Interestingly I noticed when CPM enabled it adds an empty ItemGroup to the csproj

    <ItemGroup />

    If I do an dotnet outdated -u -t
    It'll add the transitive dependencies to csproj

      <ItemGroup>
        <PackageReference Include="Microsoft.CodeCoverage" />
        <PackageReference Include="Microsoft.Extensions.DependencyModel" />
        <PackageReference Include="Microsoft.TestPlatform.TestHost" />
      </ItemGroup>

    and versions to Directory.Packages.props

      <ItemGroup>
        <PackageVersion Include="Microsoft.CodeCoverage" Version="17.11.1" />
        <PackageVersion Include="Microsoft.Extensions.DependencyModel" Version="8.0.1" />
        <PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.11.0" />
        <PackageVersion Include="Microsoft.TestPlatform.TestHost" Version="17.11.1" />
      </ItemGroup>

    not just not the version Microsoft.NET.Test.Sdk it'll remain and still be detected and silently fail

    dotnet outdated -u -t
    » testmstest
      [net9.0]
      Microsoft.NET.Test.Sdk  17.11.0 -> 17.11.1
    
    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 testmstest [net9.0] upgraded successfully
    
    Elapsed: 00:00:04.4347979
  2. devlead commented on Sep 26, 2024

    @devlead
    ContributorAuthor

    Hmm it's dotnet add package Microsoft.NET.Test.Sdk --version 17.11.1 will silently fail too if CPM is enabled, I've raised issue NuGet/Home#13809 about that.

  3. added a commit that references this issue on Sep 26, 2024
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