Problem
When running a Unit Test project inside JetBrains Rider's test runner, the following error occurs:
Could not load file or assembly 'xxxx, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
This error doesn't occur when running the tests via dotnet test on the console.
Potential Cause
The issue arises due to a mismatch between Rider's "Default platform architecture" setting, e.g. the project's configured PlatformTarget in the .csproj file is set to x64:
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
Rider's internal test runner (based on JetBrains.ReSharper.TestRunner) spawns a process using its default platform architecture setting. If this setting is not explicitly configured to align with the project's PlatformTarget, Rider's test host cannot load the compiled assembly, resulting in the FileNotFoundException.
In contrast, dotnet test automatically resolves the platform architecture based on the project settings, which is why it works correctly.
Resolution
To resolve the issue:
- Open Rider's settings and navigate to Settings → Build, Execution, Deployment → Unit Testing.
- Update the Default platform architecture to match the project's configuration (
x64in this case).
Comments
0 comments
Please sign in to leave a comment.