When executing my XUnit tests on the build server, it failed with the following message:
System.IO.FileNotFoundException : Could not load file or assembly 'Microsoft.VisualStudio.CodeCoverage.Shim, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
Inside my csproj file following packages were referenced:
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
The ‘xunit.runner.visualstudio’ implicitly has a dependency on the Microsoft.NET.Test.Sdk(at minimum version 15.0) what could explain why he tried to load the assembly mentioned above.
To get rid of this error, I had to explicitly include a reference to the ‘Microsoft.NET.Test.Sdk’:
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />