VSTest Drops Newtonsoft.Json: What You Need to Know
<p>Starting with .NET 11 Preview 4 and Visual Studio 18.8, VSTest—the engine behind <code>dotnet test</code> and Test Explorer—will no longer ship with Newtonsoft.Json as a dependency. Instead, it will use System.Text.Json on .NET and JSONite on .NET Framework. This change is a proactive security measure, as older Newtonsoft.Json versions (below 13.0.0) are flagged as vulnerable, and carrying an unneeded dependency increases future risk. Most test projects will see no impact, but a small number may encounter build or runtime errors that are easy to fix. Below, we answer common questions about what's changing, who is affected, and how to resolve issues.</p>
<h2 id="q1">Why is VSTest removing its Newtonsoft.Json dependency?</h2>
<p>VSTest has included Newtonsoft.Json as part of the .NET SDK and Visual Studio for many years. However, all versions of Newtonsoft.Json prior to 13.0.0 are now marked as vulnerable on NuGet.org. Keeping this dependency—especially when VSTest no longer requires it—exposes the test platform to potential security advisories in a component that is not needed. Removing Newtonsoft.Json is part of a broader effort across the .NET SDK to eliminate unnecessary dependencies and improve security. By switching to System.Text.Json (on .NET) and JSONite (on .NET Framework), VSTest maintains full functionality while reducing its attack surface.</p><figure style="margin:20px 0"><img src="https://devblogs.microsoft.com/dotnet/wp-content/uploads/sites/10/2026/04/vs-test-is-removing-its-newtonsoft-json-dependency.webp" alt="VSTest Drops Newtonsoft.Json: What You Need to Know" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px">Source: devblogs.microsoft.com</figcaption></figure>
<h2 id="q2">What is changing and what remains the same?</h2>
<p>The most notable change is the replacement of Newtonsoft.Json with System.Text.Json on .NET and JSONite on .NET Framework. However, the VSTest wire format is <strong>not</strong> changing—messages are serialized identically regardless of which JSON library is used. Older test hosts remain fully compatible with the updated platform, and vice versa. Serialization performance is at least as good, and often better, due to the efficiency of the new libraries. In short, the underlying mechanics stay the same; only the implementation details of JSON handling are swapped out.</p>
<h2 id="q3">Which test projects are NOT affected?</h2>
<p>Most test projects will experience no disruption. Specifically, you are <strong>not</strong> affected if:</p>
<ul>
<li>Your project does not use any Newtonsoft.Json types (like <code>JObject</code>, <code>JsonConvert</code>).</li>
<li>Your project already references Newtonsoft.Json as a normal <code>PackageReference</code> (i.e., you manage the dependency yourself).</li>
<li>You are using xUnit or NUnit on .NET, or if your project runs with AppDomains—these configurations already required an explicit Newtonsoft.Json reference for other reasons.</li>
</ul>
<p>If you fall into one of these categories, no action is needed. The change is transparent and will not break your test runs.</p>
<h2 id="q4">How do I fix a build error about a missing Newtonsoft.Json reference?</h2>
<p>If your test project uses Newtonsoft.Json types (for example, <code>JObject</code> or <code>JsonConvert</code>) but does <em>not</em> include a direct package reference, it previously compiled successfully only because Newtonsoft.Json was leaked through VSTest. After the update, the compiler will no longer find the assembly, resulting in a build error like <em>“The type or namespace name ‘Newtonsoft’ could not be found.”</em> The fix is straightforward: add an explicit <code>PackageReference</code> for Newtonsoft.Json to your test project. Use the latest stable version, such as 13.0.3. For example:</p>
<pre><code><PackageReference Include="Newtonsoft.Json" Version="13.0.3" /></code></pre>
<p>This ensures your project declares its own dependency and resolves correctly.</p><figure style="margin:20px 0"><img src="https://uhf.microsoft.com/images/microsoft/RE1Mu3b.png" alt="VSTest Drops Newtonsoft.Json: What You Need to Know" style="width:100%;height:auto;border-radius:8px" loading="lazy"><figcaption style="font-size:12px;color:#666;margin-top:5px">Source: devblogs.microsoft.com</figcaption></figure>
<h2 id="q5">What if I get a FileNotFoundException at runtime for Newtonsoft.Json?</h2>
<p>Some projects reference Newtonsoft.Json but exclude the runtime asset using <code><ExcludeAssets>runtime</ExcludeAssets></code>. These projects relied on VSTest's copy being present at test time. After the update, the runtime asset is no longer provided by VSTest, so you'll see an error like:</p>
<pre><code>System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, ...'</code></pre>
<p>To fix this, either remove the <code><ExcludeAssets>runtime</ExcludeAssets></code> element from your package reference, or install Newtonsoft.Json without excluding runtime assets. For example:</p>
<pre><code><PackageReference Include="Newtonsoft.Json" Version="13.0.3" /></code></pre>
<p>This ensures the assembly is available at runtime.</p>
<h2 id="q6">What about test adapters or data collectors that fail to load?</h2>
<p>Test adapters and data collectors that used Newtonsoft.Json without declaring it as a dependency will fail at load time with an error such as <em>“Data collector 'SampleDataCollector' threw an exception during type loading, construction, or initialization: System.IO.FileNotFoundException: Could not load file or assembly 'Newtonsoft.Json'…”</em> This happens because the extension assumed Newtonsoft.Json would be present, but VSTest no longer provides it. To resolve, the extension author must add a direct dependency on Newtonsoft.Json (version 13.0.3 or later) in their project. If you are using a third-party extension, check for an updated version that includes this fix. As a temporary workaround, you can add an explicit reference to Newtonsoft.Json in your test project itself, though this is not a long-term solution.</p>
<h2 id="q7">Is the wire format or serialization performance affected?</h2>
<p>No. The VSTest wire format remains unchanged. Messages are serialized identically whether Newtonsoft.Json, System.Text.Json, or JSONite is used. This means all existing test runners, adapters, and reporting tools will continue to work without modification. In terms of performance, you can expect it to be at least as good as before—often better, because System.Text.Json and JSONite are designed for high throughput and low allocation. So you get the same reliability with improved efficiency.</p>
Tags: