Unable to execute NET core unit test in VS after uninstalling older sdk

It is not uncommon to have installed many versions of.NET core framework, especially after many Visual Studio updates. Each installation consumes disk space so I’ve decided to cleanup everything leaving only major version of the framework installed in the system. Everything worked fine, except Visual Studio Test Explorer that, upon test run request, generates this error in Tests output window

[21/11/2019 6:08:03.911] ========== Discovery aborted: 0 tests found (0:00:05,5002292) ==========[21/11/2019 6:08:03.934] ———- Run started ———-Testhost process exited with error: It was not possible to find any compatible framework versionThe framework ‘Microsoft.NETCore.App’, version ‘2.2.0’ was not found.

It seems that after uninstalling old.NET core SDK Visual Studio Test runner is not anymore capable of executing tests based on.NET core 2.2

This happens to every.NET core 2.2 test project, if I update framework to netcore3.0 everything went good. After a brief check everything seems ok, but then I realized that Visual Studio is a x86 process, so it is probably using x86 version of the.NET Core SDK. Since I’ve uninstalled every version except x64 major version of every SDK (2.0, 2.1, 2.2, 3.0) I’ve actually removed all x86 version (Except 3.0) and this could be the reason.

To verify this supposition, I went to the folder C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App where I can check every version I’ve actually installed for my system. Gotcha, only version 3.0 was present. The final proof was downloading and installing latest x86 version for.NET core 2.2, to verify if it will fix the issue, and, gotcha, VS was able to run Unit tests based on.NET core 2.2 again.

Visual Studio test runner seems to use x86 version of.NET  core SDK, so if you uninstall it (leaving only x64 version) you are not able anymore to run tests based on that.NET core version with Test Explorer.


Figure 1: My c:\program files\x86\dotnet\shared\Microsoft.Netcore.App folder that shows the installation of 2.2.5 x86 version of the sdk.

Gian Maria