Reputation: 669
I had a .Net Core console app built and deployed.
The project's Platform target is x86.
Target framework is .Net Core 2.2(x86).
Although .Net Core 2.2 (x86) SDK is installed, I get following error after executing the command dotnet myapp.dll in Developer Command Prompt VS2017.
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '2.2.0' was not found.
- The following versions are installed:
2.0.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
2.1.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
The .Net Core 2.2(x86) SDK was installed under path "C:\Program Files (x86)\dotnet\shared", and System Environment Variables contains "C:\Program Files (x86)\dotnet\".
Any suggestion? Thanks!
~~~Update1
Following are part of .csproj info, sorry can't show whole thing.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<Platforms>AnyCPU;x86;x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<PlatformTarget>x86</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
Upvotes: 27
Views: 90540
Reputation: 1067
After searching through Microsoft's documentations, I noticed that I was missing an additional required Nugget package.
The documentation stated:
Before you can use the tools on a specific project, you'll need to add the Microsoft.EntityFrameworkCore.Design package to it.
This is what I did by adding the package
$ dotnet add package Microsoft.EntityFrameworkCore.Design
Upvotes: 42
Reputation: 3591
I was using testenvironments.json
for running the unit tests, but when picking my Ubuntu distribution from the list
no tests are discovered. The Output window (Tests output) shows the following:
Log level is set to Informational (Default).
Connected to test environment '< Local Windows Environment >'
Test data store opened in 0,323 sec.
Connected to test environment '< Local Windows Environment >'
========== Starting test discovery ==========
========== Test discovery skipped: All test containers are up to date ==========
WSL2 environment 'Ubuntu' is starting.
Connected to test environment 'Ubuntu'
WSL2 environment 'Ubuntu' is running.
========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) '/mnt/c/Users/user/source/repos/Project/Project.UnitTests/bin/Debug/net6.0/Project.UnitTests.dll' exited with error: You must install or update .NET to run this application.
App: /mnt/c/Users/user/source/repos/Project/Project.UnitTests/bin/Debug/net6.0/testhost.dll
Architecture: x64
Framework: 'Microsoft.AspNetCore.App', version '6.0.0' (x64)
.NET location: /usr/local/.dotnet_install/
No frameworks were found.
Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed
To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=6.0.0&arch=x64&rid=ubuntu.22.04-x64
. Please check the diagnostic logs for more information.
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
========== Test discovery aborted: 0 Tests found in 704,8 ms ==========
After restarting Visual Studio, it suggested me to install the missing runtime inside WSL:
Upvotes: 0
Reputation: 2168
"Testhost process exited with error: It was not possible to find any compatible framework version"
I needed to enalbe the Remote Testing install option in the Test Options:
Upvotes: 0
Reputation: 1085
If you have this issue in 2022. @Khai Nguyen answer worked for me.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp6.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>
I changed the <TargetFramework>netcoreapp5.0</TargetFramework>
to
<TargetFramework>netcoreapp6.0</TargetFramework>
Since, 6.0 was already installed.
Upvotes: 0
Reputation: 61
This error also happened to me, and the answer I found was very easy, => in my solution I had two projects and a class library, the data folder was in the API project, in the case of Migration, I set the default project to the API and I got the same error, but the answer: I just set the API project as the startup project and tried again. The issue was gone.
Have fun. Shahab Attarnejad
Upvotes: 2
Reputation: 21
When I got this error just now, it turned out that I need to run an update on Visual Studio.
Close your project window, open the Visual Studio Installer, and run the update.
Upvotes: 0
Reputation: 351
For me, I just verified that all the projects in the solution is of same Target framework version. Once that was done, the issue was fixed.
You could view the Target framework version by right clicking a project (*.csproj) and go to properties.
Upvotes: 0
Reputation: 336
Some months ago a Visual Studio update broke my capability of running tests. One of the issues was exactly this error. I have the x64 version of the SDK installed but VS tests runner was attempting to use the x86 version. The fix is just changing a setting inside the Test Explorer: Processor Architecture for AnyCPU Projects -> x64
.
Upvotes: 19
Reputation: 669
It seem to be a known issue for .Net Core installation, github.com/dotnet/core-setup/issues/4350
I have to uninstall all .Net Core packages, both x64 and x86, then reinstalled .Net Core x86 package. And that solved the problem.
Upvotes: 5
Reputation: 945
Can you change .csproj to add RunCommand
like below:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<Prefer32Bit>false</Prefer32Bit>
<PlatformTarget>x86</PlatformTarget>
<Optimize>false</Optimize>
<RunCommand Condition="'$(PlatformTarget)' == 'x86'">$(MSBuildProgramFiles32)\dotnet\dotnet</RunCommand>
<RunCommand Condition="'$(PlatformTarget)' == 'x64'">$(ProgramW6432)\dotnet\dotnet</RunCommand>
</PropertyGroup>
</Project>
Maybe you need to add 2 line of RunCommand
and update the correct path of dotnet on your laptop.
This issue happens when you are on windows 64bit and run x86 application.
Upvotes: 1