Build/Test Issues

Could not load file or assembly 'xunit.runner.utility.netstandard15

Started by mmisztal on 3,217 views

I'm working on a netcore2.2 based solution. When NCrunch is enabled, all test projects fail to build with an exception:


An error occurred while analysing this project after it was built: System.IO.FileNotFoundException: Could not load file or assembly 'xunit.runner.utility.netstandard15, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c'. The system cannot find the file specified.
File name: 'xunit.runner.utility.netstandard15, Version=2.2.0.3545, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c'
   at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.<>c__DisplayClass2_0.<FindFrameworkTestsInAssembly>b__1()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.Module.XUnit2.Integration.XUnit2DiscoveryEnvironment.FindFrameworkTestsInAssembly(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
   at nCrunch.TestExecution.TestFinder.<>c__DisplayClass2_2.<FindTestsForFrameworks>b__2()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.TestExecution.TestFinder.<>c__DisplayClass2_0.<FindTestsForFrameworks>b__0()
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.TestExecution.TestFinder.FindTestsForFrameworks(ReflectedAssembly assembly, FilePath assemblyFilePath, IList`1 referencedAssemblyFilePaths, DescribedTestFrameworkDiscoverer[] describedDiscoverers, ComponentUniqueName testComponentUniqueName, PlatformType platformType, DynamicProxy[] dynamicProxies)
   at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)


Below is a sample .csproj from one of the test projects


<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>    
    <LangVersion>7.3</LangVersion>
    <TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.reporters" Version="2.4.1" />
    <PackageReference Include="xunit" Version="2.4.1" />    
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\..\..\core\core-pkg\src\Core.Testing\Core.Testing.csproj" />
    <ProjectReference Include="..\..\..\core-http-pkg\src\Core.Http\Core.Http.csproj" />
    <ProjectReference Include="..\..\src\Core.Http.Consul\Core.Http.Consul.csproj" />
  </ItemGroup>

  <ItemGroup>
    <None Update="IntegrationTests\service-discovery-consul-settings01.json">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>


Are there any issues when working against .net core 2.2? Why is NCrunch expecting a .NET Standard 1.5?
Hi, thanks for sharing this issue.

Could you check the following?

- If you have any binding redirections in place, could you try removing them to see if this changes anything

- Could you try removing the reference to xunit.runner.visualstudio to see if this changes anything

- Could you try creating a small sample project that references only the latest version of Xunit and contains only one test, to see if this works? This will help establish if the problem is on your machine or in the solution itself.
Hi Remco,

As far as I can tell I'm not 'conciously' using any binding redirects, nor is automatic generation enabled in the .csproj files.

I've created a new solution with a single XUnitProject, my instance of VS2019 defaulted to a preview version of .net core 3.0:


<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.0.0-preview-20181205-02" />
    <PackageReference Include="xunit" Version="2.4.0" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
  </ItemGroup>

</Project>


This has worked, and NCrunch has successfully initialized, built and run the test assembly.

I've changed the project to target .net core 2.2 and use the same versions of XUnit as my originally failing project(s):


<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.2</TargetFramework>

    <IsPackable>false</IsPackable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.1" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
  </ItemGroup>
</Project>


NCrunch has succesfully reloaded, rebuilt and re-run the test assembly.
I'm not sure what's wrong here.
Inside any sample project, could you try introducing a package reference to the xunit.runner.utility Nuget package, then build the project? This will cause Nuget to ensure the package is downloaded and installed on your machine. NCrunch should normally restore this package automatically and it should warn you if it wasn't able to do so.

If the above doesn't work, could you try introducing a package reference to the xunit.runner.utility package from inside the test project encountering the problem?

If neither of the above work, I might need to ask for a sample project from you that can reproduce this problem so that I can investigate it further. You're welcome to submit any code samples through the NCrunch contact form.

Edited

Hi Remco,

I've uploaded a sample solution to a private GitHub repo and added you as a collaborator: https://github.com/mmisztal1980/ncrunch-netstandard15-repro/invitations
Just checked - still fails.
Thanks for sending through the sample solution. This really helped with analysing the issue. It appears to be a reference clash involving xunit.runner.utility (which is also used by NCrunch to interact with xunit).

Would you like to try the build below to see if this solves the problem for you?

NCrunch_Console_3.29.0.2.msi
NCrunch_Console_3.29.0.2.zip
NCrunch_GridNodeServer_3.29.0.2.msi
NCrunch_GridNodeServer_3.29.0.2.zip
NCrunch_LicenseServer_3.29.0.2.zip
NCrunch_VS2008_3.29.0.2.msi
NCrunch_VS2010_3.29.0.2.msi
NCrunch_VS2010_3.29.0.2.zip
NCrunch_VS2012_3.29.0.2.msi
NCrunch_VS2012_3.29.0.2.zip
NCrunch_VS2013_3.29.0.2.msi
NCrunch_VS2013_3.29.0.2.zip
NCrunch_VS2015_3.29.0.2.msi
NCrunch_VS2015_3.29.0.2.msi.7z
NCrunch_VS2015_3.29.0.2.zip
NCrunch_VS2017_3.29.0.2.msi
NCrunch_VS2017_3.29.0.2.msi.7z
NCrunch_VS2017_3.29.0.2.zip
NCrunch_VS2019_3.29.0.2.msi
NCrunch_VS2019_3.29.0.2.msi.7z
NCrunch_VS2019_3.29.0.2.zip

Edited

The new build works fine. All assemblies are being loaded and tests are being executed as expected. Thank you Sir.

Post a reply

Log in to reply.