tfsbuildazure-devopsxunitxunit.net

An exception occurred while invoking executor 'executor://xunit/VsTestRunner2/uap': Could not load file or assembly 'System.IO.FileSystem


I'm facing to an issue when I'm running my unit tests on a VSTS build. When I'm launching all my tests on Visual Studio locally, everything works fine. No error at all. Perfect. But when I'm launching my tests via a tests task on a VSTS build, I have this error:

An exception occurred while invoking executor 'executor://xunit/VsTestRunner2/uap': Could not load file or assembly 'System.IO.FileSystem, Version=4.0.1.0, Culture=neutral, PublicKeyToken=***********' or one of its dependencies. The system cannot find the file specified.

My test project is set like this:

On the build server I have:

I'm running out of clues... I'm surely missing something... Thanks for your help

PS:

EDIT

I have Nuget packages "FluentAssertions" v5.4.1 and "System.ValueTuple" v4.5.0. I already tried to downgrade one of them and both. It failed. But I saw that "FluentAssertions" has a dependency to "System.ValueTuple"

EDIT 2

As @PatrickLu-MSFT said, passing the vs test task version to 1 solved the issue. But when I'm looking closely, the Test platform versions available are 2015 and 2013:

Test platform version for VS test task version 1

When I'm choosing VS test task version 2, I have those choices:

Test platform version for VS test task version 2

I would like to stay on vs test task version 2 (in case of future updates, I don't want to be stuck...). What I saw is when I'm on Test platform version set to "Latest" or "Visual Studio 2017", it does not work. When I'm choosing "Visual Studio 2015", it working... So what I point is:

So:

EDIT 3

After connected remotely to the server of my build agent and run tests from VS2017, I compare the output of Visual Studio 2017 of the host server to the output of my local Visual Studio 2017:

My local Visual Studio 2017 output

Remote Visual Studio 2017 output

Are there some issues with "xUnit.net VSTest Adapter v2.4.0 (32-bit Universal Windows)" on the host?


Solution

  • I hit this same problem and solved it by changing the "Path to custom test adapters" to point specifically to the correct test adapter by setting it to "Source\packages\xunit.runner.visualstudio.2.4.0\build_common". (You should modify the path to account for where the packages folder is in your repository.)

    This apparently happens because by default VSTS tries to be helpful and scans the entire working directory structure for test adapters and loads all of them, but the xUnit Visual Studio test adapter Nuget package installs test adaptors for .Net Core and UWP as well, so VSTS happily loads them and they blow up.