Skip to content

[Breaking Change in 18.8, .NET11 Preview 4] VSTest dropping Newtonsoft.Json #15677

@nohwnd

Description

@nohwnd

It took us a long while, but aligning with dotnet/sdk finally gave us the right opportunity to break public API and remove Newtonsoft.Json from VSTest. We replace it with System.Text.Json in .NET and JSONite in .NET Framework.

This was asked by community before #2488 and was previously closed as not planned.

This is a breaking change, so we're being very careful about it. Today is the first step: an alpha package on NuGet for you to try.

How it will break me?

We don't ship Newtonsoft.Json anymore. If you depend on it in your project, but don't bring it yourself, you will see:

FileNotFoundException: Could not load 'Newtonsoft.Json'

Accompanied with additional information about where the error is coming from.
This can cause:

  • compile time error, if you used serialization in your code.
  • test failures, if you used the dependency in your product but for whatever reason don't copy Newtonsoft.Json to output folder.
  • test run failure if your extensions rely on Newtonsoft.Json.

We expect most projects to not be affected, because they bring the dependency via nuget dependencies (when they need it), or they simply don't need it. This is an assumption we would like to confirm by running this prototype. As well as general sanity check that our tests were correct. And that the change won't result in silent test failures.

How can I test?

The packages are available directly on nuget.org as version 1.0.0-alpha-stj-26213-07. This is based on 18.7.0 version of VSTest that is currently in development.

There are several ways to test, based on which types of tests you are running:

dotnet test with alpha vstest.console.dll

This tests if your .NET Framework projects and other tools can work with the new vstest.console. If you updated Microsoft.NET.Test.SDK in all your projects it tests also .NET.

# Please provide
$testSolution = "MyTests.sln"

$version = "1.0.0-alpha-stj-26213-07"
$url = "https://www.nuget.org/api/v2/package/Microsoft.TestPlatform.CLI/$version"
Invoke-WebRequest $url -OutFile "Microsoft.TestPlatform.CLI.$version.zip"
Expand-Archive "Microsoft.TestPlatform.CLI.$version.zip" -DestinationPath "Microsoft.TestPlatform.CLI.$version"
$consolePath = "$PWD\Microsoft.TestPlatform.CLI.$version\contentFiles\any\net10.0\vstest.console.dll"

dotnet test $testSolution /p:VSTestConsolePath=$consolePath /p:VSTestNoLogo=false

vstest.console.exe

This tests if your .NET Framework projects and other tools can work with the new vstest.console. If you updated Microsoft.NET.Test.SDK in all your projects it tests also .NET.

# Please provide
$testDll = "MyTests.dll"

$version = "1.0.0-alpha-stj-26213-07"
$url = "https://www.nuget.org/api/v2/package/Microsoft.TestPlatform/$version"
Invoke-WebRequest $url -OutFile "Microsoft.TestPlatform.$version.zip"
Expand-Archive "Microsoft.TestPlatform.$version.zip" -DestinationPath "Microsoft.TestPlatform.$version"

& "Microsoft.TestPlatform.$version\tools\net462\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" $testDll

Update Microsoft.NET.Test.Sdk in your project

This tests if your .NET projects can work with the new testhost. This should not require you to update dotnet test / vstest.console (e.g won't force you to update to latest .NET SDK).

# Please provide
$testProject = "MyTests.csproj"

$version = "1.0.0-alpha-stj-26213-07"
dotnet add $testProject package Microsoft.NET.Test.Sdk --version $version
dotnet test $testProject

Translation Layer

If you are one of the few people implementing a client, please update your project to the latest TranslationLayer, and point it to latest vstest.console.dll or exe (or not, it should be compatible with older versions as well).

VSTest task in AzDO

VSTest task in azdo allows you to choose any version of VSTest via TestPlatform installer task. This works for both classic and yaml pipeline. If you are already using Test Platform Installer you just need to point it to the right version, and nuget feed.

If you are not using Test Platform Installer yet, make sure you point your VSTest task to the toolsInstaller.

- task: VisualStudioTestPlatformInstaller@1
  inputs:
    packageFeedSelector: nugetOrg
    versionSelector: specificVersion
    testPlatformVersion: '1.0.0-alpha-stj-26213-07'

- task: VSTest@3
  inputs:
    testAssemblyVer2: '**bin\**\*.Tests.dll'
    testPlatformVersion: toolsInstaller

How to report issues?

Please report your issues directly in the comments here, or create new issues. All feedback is welcome.

What will happen next?

The change is implemented via #15540 but not merged into VSTest main, it will live on rel/stj branch until done.

The change is in VSTest main, will be inserted into .NET11 Preview 4, and VS 18.8, and VSTest 18.8.

What we need to do is confirm our tests, and real scope of breaking changes agrees with our expectations (detailed on top). Once that is done we want to merge to .NET11 and VS as soon as possible, for a round of internal and public dogfooding directly in the respective products. Further information will be provided.

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