I have xUnit tests which run fine locally but do not get run on Azure DevOps. The assembly under test is a .NET 5.0 assembly as is the test assembly.
Examining the log file from the VsTest task, I see the following
Test run detected DLL(s) which were built for different framework and platform versions. Following DLL(s) do not match current settings, which are .NETFramework,Version=v5.0 framework and X86 platform.
UnitTests.dll is built for Framework .NETCoreApp,Version=v5.0 and Platform AnyCPU.
Microsoft.TestPlatform.CommunicationUtilities.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
Microsoft.TestPlatform.CoreUtilities.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
Microsoft.TestPlatform.CrossPlatEngine.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
Microsoft.TestPlatform.PlatformAbstractions.dll is built for Framework .NETCoreApp,Version=v2.1 and Platform AnyCPU.
Microsoft.TestPlatform.Utilities.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
Microsoft.VisualStudio.TestPlatform.Common.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
Microsoft.VisualStudio.TestPlatform.ObjectModel.dll is built for Framework .NETStandard,Version=v2.0 and Platform AnyCPU.
testhost.dll is built for Framework .NETCoreApp,Version=v2.1 and Platform AnyCPU.
xunit.runner.visualstudio.dotnetcore.testadapter.dll is built for Framework .NETCoreApp,Version=v2.1 and Platform AnyCPU.
Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.
The link does not really help much (perhaps the content has changed). I have tried changing this using commandline arguments in my Build task: /Framework:net50 /Platform:x64 (AnyCPU does not seem to be a valid option.)
... and also by using a .runsettings file (linked in my build task)
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<RunConfiguration>
<TargetPlatform>x64</TargetPlatform>
<TargetFrameworkVersion>net50</TargetFrameworkVersion>
</RunConfiguration>
</RunSettings>
... and also by linking to the BuildPlatform for the pipeline.
Regardless of any of these changes, the errors in the log file (and also the current settings listed in the first sentence) remain the same.
question from:
https://stackoverflow.com/questions/65928305/xunit-tests-run-locally-but-not-on-azure-devops