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>
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) ==========
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>
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 ---
Note that the same projects work fine in Visual Studio 2017, without the need of any runsettings file whatsoever.
This is not an answer, but posting to help others landing here.
Visual Studio team has acknowledged the issue and is looking into fixing this. It's best to follow it here:
I had the problem after upgrading from a netframework project to netcore.
Using VS Enterprise 16.3.8, cleaning the solution as well as deleting all temporary folders such as bin
and obj
helped me to get the tests running in the desired netcore version.
Edit:
As a sidenote VS has sometimes problems, when changing the target framework. After changing it deleting the bin
/ obj
could sometimes be your last escape.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With