1

I have a few MSTest projects which need to target both netcoreapp1.1 as well as something newer such as netcoreapp3.0

I've tried most of the things suggested in:

https://www.meziantou.net/mstest-v2-testing-against-multiple-frameworks.htm

How to properly unit test a .NET project with multiple target frameworks, given implementation differences among targets?

https://developercommunity.visualstudio.com/content/problem/215235/test-container-not-found-when-trying-to-run-tests.html

However my results are always:

  • dotnet test runs only the netcoreapp3.0 targets. None of the netcorapp1.1 or netcoreapp2.0 are picked up
  • VS2019 runs zero of the test targets, crashing with error:
StreamJsonRpc.RemoteInvocationException: The following TestContainer was not found 'C:\Projects\fact\collection\src\Fact.Extensions.Collection.Tests\bin\Debug\netcoreapp1.1\Fact.Extensions.Collection.Tests.dll'
   at StreamJsonRpc.JsonRpc.<InvokeCoreAsync>d__96`1.MoveNext()
Malachi
  • 2,260
  • 3
  • 27
  • 40

1 Answers1

0

While writing this question, I deduced that the newest Microsoft.NET.Test.Sdk (16.4.0 at time of this writing) may not be compatible with previous frameworks. I tested this theory by both:

  • Conditionally specifying 15.3.0 for netcoreapp1.1 ItemGroup+PackageReference
  • Rolling back to 16.3.0 for one of the netcoreapp2.0 targets

Upon doing this:

  • dotnet test finds almost everything, but still not the 16.3.0 + netcoreapp2.0 target. This appears to be rectified by further backing off to 16.2.0, as Microsoft.TestPlafrom.TestHost 16.3.0 has a netcoreapp2.1 requirement
  • VS2019 still has complaints, but is able to find both the 15.3.0 and 16.3.0 Microsoft.NET.Test.Sdk referred projects

This is congruent with Bruno Garcia's findings in the developercommunity link. I don't consider rolling back a solution so much as a workaround. I feel better about this workaround by using Condition to filter by TargetFramework.

What would be quite helpful is more warning from Visual Studio that indeed version dependency issues are causing issues. dotnet test does give some feedback in that area if you look closely.

Malachi
  • 2,260
  • 3
  • 27
  • 40