Could not load file or assembly 'Microsoft.Extensions.DependencyInjection.Abstractions' for .NET 6 #475

Closed
opened 2025-12-29 08:28:48 +01:00 by adam · 7 comments
Owner

Originally created by @bouchraRekhadda on GitHub (Dec 19, 2022).

Originally assigned to: @StefH on GitHub.

Starting 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"
  }
}
  1. dotnet build
  2. 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.

Originally created by @bouchraRekhadda on GitHub (Dec 19, 2022). Originally assigned to: @StefH on GitHub. Starting from [`1.3.1`](https://github.com/WireMock-Net/WireMock.Net/blob/3d17913f3533af5693048ccd71b87c075ebbc457/CHANGELOG.md#131-30-september-2020) version, `WireMockServer.Start()` starts to throw below exception when tests are run with [`NUnit.ConsoleRunner`](https://www.nuget.org/packages/NUnit.ConsoleRunner/3.15.2) **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 ``` XML <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 ```C# [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` ``` JSON { "sdk": { "version": "6.0.400", "rollForward": "major" } } ``` 2. `dotnet build` 3. 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](https://github.com/nunit/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.
adam added the invalidquestion labels 2025-12-29 08:28:48 +01:00
adam closed this issue 2025-12-29 08:28:48 +01:00
Author
Owner

@StefH commented on GitHub (Dec 19, 2022):

@bouchraRekhadda
How to install NUnit.ConsoleRunner in a easy way ?

@StefH commented on GitHub (Dec 19, 2022): @bouchraRekhadda How to install `NUnit.ConsoleRunner` in a easy way ?
Author
Owner

@bouchraRekhadda commented on GitHub (Dec 20, 2022):

@StefH , I don't know any other simpler way than adding it as a dependency to a project and restore it

@bouchraRekhadda commented on GitHub (Dec 20, 2022): @StefH , I don't know any other simpler way than adding it as a dependency to a project and restore it
Author
Owner

@StefH commented on GitHub (Dec 20, 2022):

OK, I thought this was also a dotnet tool.
I'll try this and check if it throws the same exception.

@StefH commented on GitHub (Dec 20, 2022): OK, I thought this was also a dotnet tool. I'll try this and check if it throws the same exception.
Author
Owner
@StefH commented on GitHub (Mar 10, 2023): https://github.com/nunit/nunit3-vs-adapter.issues/blob/master/Issue1065/wiremocktests/UnitTest1.cs
Author
Owner

@StefH commented on GitHub (Mar 10, 2023):

https://github.com/nunit/nunit3-vs-adapter/issues/1065

@StefH commented on GitHub (Mar 10, 2023): https://github.com/nunit/nunit3-vs-adapter/issues/1065
Author
Owner

@StefH commented on GitHub (Mar 10, 2023):

@bouchraRekhadda
According to nunit, this is solved in 4.4.2

@StefH commented on GitHub (Mar 10, 2023): @bouchraRekhadda According to nunit, this is solved in 4.4.2
Author
Owner

@bouchraRekhadda commented on GitHub (Mar 10, 2023):

@StefH that's good to hear. Thank you for reporting back 🙌

@bouchraRekhadda commented on GitHub (Mar 10, 2023): @StefH that's good to hear. Thank you for reporting back 🙌
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net#475