Why does Visual Studio 2019 run tests in dotnet core 1.0 even though my projects target dotnet core 2.2?

Tur*_*rbo 7 c# vstest .net-core visual-studio-2019

I have a solution with 2 projects, one of which is a test project. Both projects target dotnet core 2.2:

<TargetFramework>netcoreapp2.2</TargetFramework>
Run Code Online (Sandbox Code Playgroud)

I am using Visual Studio 2019 (version 16.1.1). When I click "Run all" in test explorer, it outputs this warning in output window:

[5/28/2019 10:25:40 PM Informational] ------ Run test started ------
[5/28/2019 10:25:40 PM Warning] Test run will use DLL(s) built for framework .NETCoreApp,Version=v1.0 and platform X64. Following DLL(s) do not match framework/platform settings.
MyApp.UnitTests.dll is built for Framework 2.2 and Platform AnyCPU.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.

[5/28/2019 10:25:41 PM Informational] ========== Run test finished: 3 run (0:00:01.167997) ==========
Run Code Online (Sandbox Code Playgroud)

The tests do run, and finish successfully. But I am wondering about how to get rid of this warning.

I added a .runsettings file with following settings, but I still see the same warning.

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <RunConfiguration>
    <TargetFrameworkVersion>FrameworkCore10</TargetFrameworkVersion>
  </RunConfiguration>
</RunSettings>
Run Code Online (Sandbox Code Playgroud)

Changing FrameworkCore10 to FrameworkCore22 (or netcoreapp2.2) throws a huge exception. Top few lines of the exception:

[5/28/2019 10:41:30 PM Error] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.Controller.RequestConfiguration.GroupTestContainersConfigByFrameworkAndArchitecture(IEnumerable`1 testContainersConfig, IXPathNavigable runSetting)
   at Microsoft.VisualStudio.TestWindow.Controller.TestRunConfiguration.<GetAllCriteriaQueues>d__64.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.TestRunRequest.<CreateRequests>d__23.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<RunRequests>d__95.MoveNext()
   --- End of inner exception stack trace ---
Run Code Online (Sandbox Code Playgroud)

Note that the same projects work fine in Visual Studio 2017, without the need of any runsettings file whatsoever.

Tur*_*rbo 7

这不是答案,而是发布信息以帮助其他人登陆这里。

Visual Studio团队已确认该问题,正在寻求解决。最好在这里遵循它: