c# – Visual Studio silently reverts mstest package versions


With

Microsoft Visual Studio Community 2022, Version 17.14.12
VisualStudio.17.Release/17.14.12+36408.4
Microsoft .NET Framework
Version 4.8.09032

and this simple mstest project content:

<Project Sdk="MSTest.Sdk/3.6.4">
  <PropertyGroup>
    <TestingPlatformShowTestsFailure>true</TestingPlatformShowTestsFailure>
    <TestingExtensionsProfile>AllMicrosoft</TestingExtensionsProfile>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Update="MSTest.Analyzers" Version="3.10.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <PackageReference Update="MSTest.TestAdapter" Version="3.10.3" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Update="MSTest.TestFramework" Version="3.10.3" />
  </ItemGroup>
</Project>

I have a dual environmental/build problem. It looks like NuGet package manager has successfully upgraded my references to MSTest to 3.10.3 as above as well as the following output:

Successfully uninstalled 'Microsoft.ApplicationInsights 2.22.0' from Tests
Successfully uninstalled 'Microsoft.Testing.Extensions.Telemetry 1.4.3' from Tests
Successfully uninstalled 'Microsoft.Testing.Extensions.TrxReport.Abstractions 1.4.3' from Tests
Successfully uninstalled 'Microsoft.Testing.Extensions.VSTestBridge 1.4.3' from Tests
Successfully uninstalled 'Microsoft.Testing.Platform 1.4.3' from Tests
Successfully uninstalled 'Microsoft.Testing.Platform.MSBuild 1.4.3' from Tests
Successfully uninstalled 'Microsoft.TestPlatform.ObjectModel 17.11.1' from Tests
Successfully uninstalled 'MSTest.Analyzers 3.6.4' from Tests
Successfully uninstalled 'MSTest.TestAdapter 3.6.4' from Tests
Successfully uninstalled 'MSTest.TestFramework 3.6.4' from Tests
Successfully installed 'Microsoft.ApplicationInsights 2.23.0' to Tests
Successfully installed 'Microsoft.Testing.Extensions.Telemetry 1.8.3' to Tests
Successfully installed 'Microsoft.Testing.Extensions.TrxReport.Abstractions 1.8.3' to Tests
Successfully installed 'Microsoft.Testing.Extensions.VSTestBridge 1.8.3' to Tests
Successfully installed 'Microsoft.Testing.Platform 1.8.3' to Tests
Successfully installed 'Microsoft.Testing.Platform.MSBuild 1.8.3' to Tests
Successfully installed 'Microsoft.TestPlatform.AdapterUtilities 17.13.0' to Tests
Successfully installed 'Microsoft.TestPlatform.ObjectModel 17.13.0' to Tests
Successfully installed 'MSTest.Analyzers 3.10.3' to Tests
Successfully installed 'MSTest.TestAdapter 3.10.3' to Tests
Successfully installed 'MSTest.TestFramework 3.10.3' to Tests

…but in the dependencies / packages UI, it only temporarily shows that and then reverts to the following once I run the tests:

Packages

I need to solve that problem because it’s my best guess as to the cause of the following behaviour. In test classes, this:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;

// ...
Assert.IsLessThan(upperBound: 1e-2, value: error);

fails with

Error CS0117: ‘Assert’ does not contain a definition for ‘IsLessThan’

despite the fact that (1) Visual Studio temporarily was able to find that method via IntelliSense, and (2) that method is clearly documented here:

Assert.IsLessThan(T, T, String) Method

I have no idea what’s going on. As a wild guess informed by MSTest refuses to run 64-bit? , I’ve tried switching from x64 to Any CPU but the behaviour has not changed.

Leave a Reply

Your email address will not be published. Required fields are marked *