I am getting this error when running vstest.console.exe against a .NET Framework 4.8.1 test project in Azure DevOps Server using the Visual Studio test platform installer task:
An exception occurred while invoking executor 'executor://mstestadapter/v4': Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Stack trace:
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery.AssemblyEnumerator.GetTypes(Assembly assembly) in /_/src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumerator.cs:line 109
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery.AssemblyEnumerator.EnumerateAssembly(String assemblyFileName) in /_/src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumerator.cs:line 73
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery.AssemblyEnumerator.EnumerateAssembly(String assemblyFileName)
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery.AssemblyEnumeratorWrapper.GetTestsInIsolation(String fullFilePath, IRunSettings runSettings) in /_/src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumeratorWrapper.cs:line 114
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Discovery.AssemblyEnumeratorWrapper.GetTests(String assemblyFileName, IRunSettings runSettings, ITestSourceHandler testSourceHandler, List`1& warnings) in /_/src/Adapter/MSTestAdapter.PlatformServices/Discovery/AssemblyEnumeratorWrapper.cs:line 50
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.UnitTestDiscoverer.DiscoverTestsInSource(String source, IMessageLogger logger, ITestCaseDiscoverySink discoverySink, IDiscoveryContext discoveryContext) in /_/src/Adapter/MSTestAdapter.PlatformServices/Discovery/UnitTestDiscoverer.cs:line 56
at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.<RunTestsAsync>d__11.MoveNext() in /_/src/Adapter/MSTestAdapter.PlatformServices/Execution/TestExecutionManager.cs:line 161
When running locally I get a slightly different error message:
An exception occurred while invoking executor 'executor://mstestadapter/v4': Discovery failed for source 'c:\Code\bin\Debug\net481\Tests.dll' with 100 errors:
MSTestAdapter failed to discover tests in class 'Tests.Test' of assembly 'D:\Code\bin\Debug\net481\Tests.dll' because Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
The test project has a transitive dependency on System.Threading.Tasks.Extensions 4.6.3 and a binding redirect is added to the configuration file when I build:
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions"
publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.4.0" newVersion="4.2.4.0" />
</dependentAssembly>
I am currently using these packages and Visual Studio 18.5.0:
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="4.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="4.1.0" />
Upgrading to the latest versions of the above NuGet packages doesn't seem to help.
If I manually replace the System.Threading.Tasks.Extensions.dll assembly in C:\Program Files\Microsoft Visual Studio\18\Enterprise\Common7\IDE\PublicAssemblies with the version from the 4.5.4 package it seems to work.
How to handle this?
I am getting this error when running vstest.console.exe against a .NET Framework 4.8.1 test project in Azure DevOps Server using the Visual Studio test platform installer task:
When running locally I get a slightly different error message:
The test project has a transitive dependency on System.Threading.Tasks.Extensions 4.6.3 and a binding redirect is added to the configuration file when I build:
I am currently using these packages and Visual Studio 18.5.0:
Upgrading to the latest versions of the above NuGet packages doesn't seem to help.
If I manually replace the
System.Threading.Tasks.Extensions.dllassembly in C:\Program Files\Microsoft Visual Studio\18\Enterprise\Common7\IDE\PublicAssemblies with the version from the 4.5.4 package it seems to work.How to handle this?