Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions' for .NET 6
See original GitHub issueStarting from 1.3.1 version, WireMockServer.Start() starts to throw below exception when tests are run with NUnit.ConsoleRunner 3.15.2
System.IO.FileNotFoundException : Could not load file or assembly ‘Microsoft.Extensions.DependencyInjection.Abstractions, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60’. The system cannot find the file specified. at WireMock.Server.WireMockServer…ctor(WireMockServerSettings settings) at WireMock.Server.WireMockServer.Start(Nullable`1 port, Boolean ssl)
Test to reproduce
1- Create a unit test project
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" PrivateAssets="All" />
<PackageReference Include="NUnit3TestAdapter" Version="4.1.0" PrivateAssets="All" />
<PackageReference Include="NunitXml.TestLogger" Version="2.1.62" PrivateAssets="All" />
<PackageReference Include="WireMock.Net" Version="1.3.0" />
</ItemGroup>
</Project>
With Test class
[TestFixture]
public class Test
{
private WireMockServer server;
[SetUp]
public void Setup()
{
server = WireMockServer.Start();
}
[Test]
public void SomeTest()
{
Assert.Pass();
}
[TearDown]
public void TearDown()
{
server.Stop();
}
}
And global.json
{
"sdk": {
"version": "6.0.400",
"rollForward": "major"
}
}
dotnet build- Run tests using NUnit.ConsoleRunner
"C:\Users\br123\.nuget\packages\nunit.consolerunner\3.15.2\tools\nunit3-console.exe" bin\AnyCPUDebug\net6.0\WireMockSample.dll<!-- path to compiled project --!>
Expected behavior
Test Run Summary Overall result: Passed Test Count: 1, Passed: 1, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
Actual
Test Run Summary Overall result: Failed Test Count: 1, Passed: 0, Failed: 1, Warnings: 0, Inconclusive: 0, Skipped: 0
Additional info
I am not sure if this should be reported on this repository or in nunit-console, but since this a regression following WireMock.Net upgrade I choose to repot it here.
If you need further info, I’ll be glad to share it with you.
Issue Analytics
- State:
- Created 9 months ago
- Comments:7

Top Related StackOverflow Question
OK, I thought this was also a dotnet tool. I’ll try this and check if it throws the same exception.
@StefH that’s good to hear. Thank you for reporting back 🙌