1

I have a project that was created in VisualStudio and after migrated to Visual Studio Code. Now I have the following problem, when executing Debug Test or Run Test in VSCode:

enter image description here

I got the following error:

Test run will use DLL(s) built for framework .NETCoreApp,Version=v2.1 and platform X86. Following DLL(s) do not match framework/platform settings.
CoreTests.dll is built for Framework 2.0 and Platform AnyCPU.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.

Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Unable to find /home/ronaldo.lanhellas/Workspace/safepark/backend-netcore/CoreTests/bin/Debug/netstandard2.0/testhost.dll. Please publish your test project and retry.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostPath(String runtimeConfigDevPath, String depsFilePath, String sourceDirectory)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
Debugging complete.

But executing under dotnet test command, everything works fine:

enter image description here

This is my CoreTests.csproj file:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="NSubstitute" Version="4.2.1" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
      <PrivateAssets>all</PrivateAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Core\Core.csproj" />
  </ItemGroup>

</Project>
Ronaldo Lanhellas
  • 2,975
  • 5
  • 46
  • 92

1 Answers1

0

Test Project and your project should be on the same platform, X86 or X64.

CoreTests.dll is built for Framework 2.0 and Platform AnyCPU.

Change it from AnyCPU to specific platform.

MKasprzyk
  • 503
  • 5
  • 17