From c6ac97093665e0582dfc6bbefebe52fd9ceb29d8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 19:34:56 +0000 Subject: [PATCH 1/4] Initial plan From 8e56827e355858a21c8b3934aaf7ac3b5e3db62e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 4 May 2026 19:37:32 +0000 Subject: [PATCH 2/4] Add breaking change article: VSTest removes Newtonsoft.Json dependency in .NET 11 Agent-Logs-Url: https://github.com/dotnet/docs/sessions/339e02d8-bbe0-4dec-99bf-af7f8430dd0b Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com> --- docs/core/compatibility/11.md | 1 + .../sdk/11/vstest-removes-newtonsoft-json.md | 89 +++++++++++++++++++ docs/core/compatibility/toc.yml | 2 + 3 files changed, 92 insertions(+) create mode 100644 docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md diff --git a/docs/core/compatibility/11.md b/docs/core/compatibility/11.md index 089c8e7daf3f4..397c0198239f3 100644 --- a/docs/core/compatibility/11.md +++ b/docs/core/compatibility/11.md @@ -82,3 +82,4 @@ See [Breaking changes in EF Core 11](/ef/core/what-is-new/ef-core-11.0/breaking- | Title | Type of change | |-------------------------------------------------------------------|-------------------| | [mono launch target not set for .NET Framework apps](sdk/11/mono-launch-target-removed.md) | Behavioral change | +| [VSTest removes dependency on Newtonsoft.Json](sdk/11/vstest-removes-newtonsoft-json.md) | Binary/source incompatible | diff --git a/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md b/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md new file mode 100644 index 0000000000000..f60b97230d50e --- /dev/null +++ b/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md @@ -0,0 +1,89 @@ +--- +title: "Breaking change: VSTest removes dependency on Newtonsoft.Json" +description: "Learn about the breaking change in .NET 11 where the VSTest platform and Microsoft.NET.Test.SDK no longer depend on Newtonsoft.Json." +ms.date: 05/04/2026 +ai-usage: ai-assisted +--- + +# VSTest removes dependency on Newtonsoft.Json + +The VSTest platform and `Microsoft.NET.Test.SDK` NuGet package no longer depend on `Newtonsoft.Json`. On .NET, `System.Text.Json` is used instead. On .NET Framework, JSONite is used. + +## Version introduced + +.NET 11 Preview 4 + +## Previous behavior + +Previously, `Microsoft.NET.Test.SDK` brought a transitive dependency on `Newtonsoft.Json` into test projects. `Newtonsoft.Json` was available for compilation and at runtime without an explicit package reference. Projects that used `Newtonsoft.Json` types without declaring a direct dependency on the package compiled and ran successfully. + +Additionally, VSTest's internal communication utilities exposed `Newtonsoft.Json` types (such as `Newtonsoft.Json.Linq.JToken`) in its public API. + +## New behavior + +Starting in .NET 11, `Newtonsoft.Json` is no longer a transitive dependency of `Microsoft.NET.Test.SDK`. Projects that used `Newtonsoft.Json` types without a direct package reference fail to compile. Projects that excluded `Newtonsoft.Json` runtime assets and relied on the copy shipped with VSTest now fail at runtime with: + +``` +FileNotFoundException: Could not load 'Newtonsoft.Json' +``` + +Test extensions (such as data collectors or test adapters) that depended on `Newtonsoft.Json` being provided by VSTest also fail with: + +``` +Data collector 'SampleDataCollector' threw an exception during type loading, construction, or initialization: +System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, +Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. +``` + +The `Newtonsoft.Json`-based types in `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities` have been removed from the public API. + +## Type of breaking change + +This change can affect [source compatibility](../../categories.md#source-compatibility) and [binary compatibility](../../categories.md#binary-compatibility). + +## Reason for change + +To align the VSTest platform's dependencies with the .NET SDK and the broader .NET ecosystem, `Newtonsoft.Json` was removed as a dependency. To minimize unintended side effects on the code under test, the number of assemblies that VSTest adds to the test output folder is reduced. Test projects can bring exactly the dependencies they need at the versions they require. + +## Recommended action + +In all cases, the fix is to add an explicit `Newtonsoft.Json` package reference to any project that uses it: + +```xml + +``` + +### Test projects that fail to compile + +If your test project uses `Newtonsoft.Json` types (for example, `JsonConvert`, `JToken`, or `JObject`) without a direct package reference, add a `PackageReference` to `Newtonsoft.Json` in your test project file. + +### Tests that fail with FileNotFoundException at runtime + +If your project has a `PackageReference` for `Newtonsoft.Json` with `runtime` and previously relied on the copy shipped with VSTest, remove the `ExcludeAssets` restriction or add a separate direct reference: + +```xml + + + runtime + + + + +``` + +### Test extensions that fail with FileNotFoundException + +If you maintain or use a test extension (data collector or test adapter) that depended on `Newtonsoft.Json` being provided by VSTest, add `Newtonsoft.Json` as a direct dependency to the extension's project. + +## Affected APIs + +The following `Newtonsoft.Json`-based APIs were removed from `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities`: + +- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Message.Payload` property (type `Newtonsoft.Json.Linq.JToken?`) +- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.DefaultTestPlatformContractResolver` +- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestCaseConverter` +- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestObjectConverter` +- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestPlatformContractResolver1` +- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestResultConverter` +- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestRunStatisticsConverter` +- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.VersionedMessage` diff --git a/docs/core/compatibility/toc.yml b/docs/core/compatibility/toc.yml index ed732eb84f966..1e693fadf413a 100644 --- a/docs/core/compatibility/toc.yml +++ b/docs/core/compatibility/toc.yml @@ -58,6 +58,8 @@ items: items: - name: mono launch target not set for .NET Framework apps href: sdk/11/mono-launch-target-removed.md + - name: VSTest removes dependency on Newtonsoft.Json + href: sdk/11/vstest-removes-newtonsoft-json.md - name: .NET 10 items: - name: Overview From d380315b47b3eb7340a854c2a0e2181a1cc86a54 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 4 May 2026 13:22:29 -0700 Subject: [PATCH 3/4] Update docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md --- .../core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md b/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md index f60b97230d50e..3af8e0525fc4f 100644 --- a/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md +++ b/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md @@ -50,7 +50,7 @@ To align the VSTest platform's dependencies with the .NET SDK and the broader .N In all cases, the fix is to add an explicit `Newtonsoft.Json` package reference to any project that uses it: ```xml - + ``` ### Test projects that fail to compile From cb26002dc4c801b3126beda8a78563720908b9a7 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Mon, 4 May 2026 13:35:02 -0700 Subject: [PATCH 4/4] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md b/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md index 3af8e0525fc4f..8d07e00581751 100644 --- a/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md +++ b/docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md @@ -83,7 +83,7 @@ The following `Newtonsoft.Json`-based APIs were removed from `Microsoft.VisualSt - `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.DefaultTestPlatformContractResolver` - `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestCaseConverter` - `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestObjectConverter` -- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestPlatformContractResolver1` +- `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestPlatformContractResolver` - `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestResultConverter` - `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestRunStatisticsConverter` - `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.VersionedMessage`