-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Breaking change doc: VSTest/Microsoft.NET.Test.SDK removes Newtonsoft.Json dependency (.NET 11) #53545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+92
−0
Merged
Breaking change doc: VSTest/Microsoft.NET.Test.SDK removes Newtonsoft.Json dependency (.NET 11) #53545
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c6ac970
Initial plan
Copilot 8e56827
Add breaking change article: VSTest removes Newtonsoft.Json dependenc…
Copilot d380315
Update docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md
gewarren cb26002
Potential fix for pull request finding
gewarren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
docs/core/compatibility/sdk/11/vstest-removes-newtonsoft-json.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| <PackageReference Include="Newtonsoft.Json" Version="..." /> | ||
| ``` | ||
|
|
||
| ### 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 `<ExcludeAssets>runtime</ExcludeAssets>` and previously relied on the copy shipped with VSTest, remove the `ExcludeAssets` restriction or add a separate direct reference: | ||
|
|
||
| ```xml | ||
| <!-- Before: excluded runtime assets, relying on VSTest to provide the DLL --> | ||
| <PackageReference Include="Newtonsoft.Json" Version="13.0.3"> | ||
| <ExcludeAssets>runtime</ExcludeAssets> | ||
| </PackageReference> | ||
|
|
||
| <!-- After: include runtime assets --> | ||
| <PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> | ||
| ``` | ||
|
|
||
| ### 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.TestPlatformContractResolver<T>` | ||
| - `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestResultConverter` | ||
| - `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.Serialization.TestRunStatisticsConverter` | ||
| - `Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.VersionedMessage` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.