question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

WebHostBuilder.ConfigureServices method not found when using nunit3testadapter 4.4.0

See original GitHub issue

Describe the bug I try to update the WireMock.Net to 1.5.17 and the nunit3testadapter to 4.4.0 in the test project and I got an exception when starting the wiremock as below

System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'. StackTrace: at WireMock.Owin.AspNetCoreSelfHost.StartAsync() at WireMock.Server.WireMockServer..ctor(WireMockServerSettings settings) at WireMock.Server.WireMockServer.Start(Nullable1 port, Boolean ssl) Error Message: OneTimeSetUp: System.MissingMethodException : Method not found: ‘Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)'. Stack Trace: Failed WhenGetArticles_GivenApiReturnTwoErrorResponses_ShouldRetry [54 ms] Error Message: OneTimeSetUp: System.MissingMethodException : Method not found: 'Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)’. Stack Trace: Failed WhenGetArticles_GivenQueryMoreThanBatchSize_ShouldReturnExpected [54 ms] Error Message: OneTimeSetUp: System.MissingMethodException : Method not found: ‘Microsoft.AspNetCore.Hosting.IWebHostBuilder Microsoft.AspNetCore.Hosting.IWebHostBuilder.ConfigureServices(System.Action`1<Microsoft.Extensions.DependencyInjection.IServiceCollection>)’. Stack Trace: …

After I downgrade the nunit3testadapter 4.4.0 back to 4.3.1 then the same test worked again. I am not sure this is issue from WireMock and Nunit3TestAdpter and thereby I raised this issue in both projects.

I heard that WebHostBuilder was depreciated https://github.com/dotnet/aspnetcore/issues/20964 before but I still can see the .NET 7 still try to support it from https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.hosting.webhostbuilder.-ctor?view=aspnetcore-7.0.

Expected behaviour: I will expect the latest of WireMock.Net should work with the latest nunit3testadapter

Test to reproduce 1 Refence WireMock.Net 1.5.17 and nunit3testadapter 4.4.0 in the same test project

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:27 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
OsirisTerjecommented, Mar 1, 2023

Hotfix version 4.4.2, nearly identical to the alpha version attached yesterday, is now released. The difference from the attached version is that the Microsoft.Extensions.DependencyModel is not include in the adapter package. It is not needed there, so it was removed. The release notes is here https://docs.nunit.org/articles/vs-test-adapter/AdapterV4-Release-Notes.html (includes some more explanations) and the package is uploaded to nuget https://www.nuget.org/packages/NUnit3TestAdapter/4.4.2. Thanks, everyone for reporting and providing repros!

3reactions
iamzhaoxucommented, Feb 27, 2023

Hi, @OsirisTerje I noticed

  1. When you add Microsoft.Extensions.Hosting 7.0.1, WireMock.Net 1.5.17 and nunit3testadapter 4.4.0 as a dependency in the project and you keep the project TargetFramework as .net6.0, if you run the test on Linux OS, the error can be reproduced. You can give it a try with your sample https://github.com/nunit/nunit3-vs-adapter.issues/tree/master/Issue1065/wiremocktests . The same scenario can run successfully on Windows OS.

  2. If you change the TargetFramework to .net7.0, both Linux and Windows will run successfully.

  3. When you downgrade the nunit3testadapter to 4.3.1 and you keep the project TargetFramework as .net6.0,, both Linux and Windows will run successfully.

image

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

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <Nullable>enable</Nullable>

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

  <ItemGroup>
    <PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.11.0" />
    <PackageReference Include="NUnit" Version="3.13.2" />
    <PackageReference Include="NUnit3TestAdapter" Version="4.4.0" />
    <PackageReference Include="coverlet.collector" Version="3.1.0" />
    <PackageReference Include="WireMock.Net" Version="1.5.17" />
  </ItemGroup>

</Project>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Adapter V4 Release Notes
The following issues, all related to the same problem, are fixed in this release: 1065 WebHostBuilder.ConfigureServices method not found when using version 4.4....
Read more >
Testing ASP.NET Core full .NET Framework with ...
NET Core full .NET Framework with TestServer gives method not found in vs 2017 ... Server = new TestServer( new WebHostBuilder() .
Read more >
ASP.NET Core 6 - how to deal with the missing Startup.cs file
NET Core 6 - how to deal with the missing Startup.cs file ... you were given a Startup.cs class with two methods in...
Read more >
App startup in ASP.NET Core
Learn how the Startup class in ASP.NET Core configures services and the app's request pipeline.
Read more >
ASP.NET Core — Autofac 7.0.0 documentation
In the ConfigureServices method of your Startup class register things into the IServiceCollection using extension methods provided by other libraries.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found