Runtime exception on IWebHostBuilder CreateWebHostBuilder(string[] args):
An error occurred while starting the application.
MissingMethodException: Method not found: 'Void Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware..ctor(Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Hosting.IHostingEnvironment, Microsoft.Extensions.Options.IOptions`1
Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.CreateStaticFileMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, ILoggerFactory loggerFactory, SwaggerUIOptions options)
MissingMethodException: Method not found: 'Void Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware..ctor(Microsoft.AspNetCore.Http.RequestDelegate, Microsoft.AspNetCore.Hosting.IHostingEnvironment, Microsoft.Extensions.Options.IOptions`1
Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.CreateStaticFileMiddleware(RequestDelegate next, IHostingEnvironment hostingEnv, ILoggerFactory loggerFactory, SwaggerUIOptions options)
Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware..ctor(RequestDelegate next, IHostingEnvironment hostingEnv, ILoggerFactory loggerFactory, SwaggerUIOptions options)
System.RuntimeMethodHandle.InvokeMethod(object target, object[] arguments, Signature sig, bool constructor, bool wrapExceptions)
System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
Microsoft.Extensions.Internal.ActivatorUtilities+ConstructorMatcher.CreateInstance(IServiceProvider provider)
Microsoft.Extensions.Internal.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, object[] parameters)
Microsoft.AspNetCore.Builder.UseMiddlewareExtensions+<>c__DisplayClass4_0.
Microsoft.AspNetCore.Builder.ApplicationBuilder.Build()
Microsoft.AspNetCore.Hosting.WebHost.BuildApplication()
Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, string startupMessage)
Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, string startupMessage)
Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
WebAPIApplication.Program.Main(string[] args) in Program.cs
+
CreateWebHostBuilder(args).Build().Run();
I can second this, upgrade to .NET Core 3.0 (ASP.NET Core) yesterday and I am facing the same issue.
I had the same issue with Swashbuckle.AspNetCore 4.0.0. Upgrade to 5.0.0.-rc3 solved it.
I had the same issue with Swashbuckle.AspNetCore 4.0.0. Upgrade to 5.0.0.-rc3 solved it.
It might fix the issue but it also introduces breaking changes. No solution to the issue from my point of view.
5.0.0-rc3 is still referencing Microsoft.Extensions.ApiDescription.Server (>= 0.3.0-preview7.19365.7) which is still Preview7 and not 3.0.0. Unfortunately this introduces conflicts on my side and cannot work.
In net core 3.0,I had the same issue with Swashbuckle.AspNetCore 4.0.0. Upgrade to 5.0.0.-rc3 can not solved it.
I actually found .NET Core 3.0 didn't work with rc3, but did with rc2. I recommend you try rc2.
Could someone on this thread please put together a minimal application (from scratch) that repro's the issue and post it on GitHub. I have lots of examples (and tests) of rc3 working with .NET Core 3.0 so _just_ saying it doesn't work isn't particularly helpful in terms of finding a solution. If someone posts the minimal repro application, then I'll take a look and maybe we can get somewhere. Thanks
To clarify, I received the error originally posted above. I was upgrading a web api app from ASP.NET Core 2.2 to ASP.NET Core 3.0, not sure if that is related. I do not have time to create a repro until Saturday or Sunday...
@drikusvd Referencing version 3.0.0 of Microsoft.Extensions.ApiDescription.Server manually in your csproj file should resolve the issue of conflicts. As far as I can tell (been doing this a couple of days) Swashbuckle is completely compatible with this version. (3.0.0 also gives far better build errors then preview 7, so that's nice too)
@drikusvd, @nphmuller
Confirming that directly referencing version 3.0.0 of Microsoft.Extensions.ApiDescription.Server in a project resolves this issue:
5.0.0-rc3 is still referencing Microsoft.Extensions.ApiDescription.Server (>= 0.3.0-preview7.19365.7) which is still Preview7 and not 3.0.0. Unfortunately this introduces conflicts on my side and cannot work.
@drikusvd Referencing version 3.0.0 of
Microsoft.Extensions.ApiDescription.Servermanually in your csproj file should resolve the issue of conflicts. As far as I can tell (been doing this a couple of days) Swashbuckle is completely compatible with this version. (3.0.0 also gives far better build errors then preview 7, so that's nice too)
Could someone on this thread please put together a minimal application (from scratch) that repro's the issue and post it on GitHub. I have lots of examples (and tests) of rc3 working with .NET Core 3.0 so _just_ saying it doesn't work isn't particularly helpful in terms of finding a solution. If someone posts the minimal repro application, then I'll take a look and maybe we can get somewhere. Thanks
I get this. I don't know if it's the same as the others.
Repro steps:
1) Create a new API template project in VS 2019 pro16.3.1.
2) In the pm console type: Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc3
Severity Code Description Project File Line Suppression State
Error MSB3073 The command "dotnet "C:\Users\XXXX.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\build\/../tools/dotnet-getdocument.dll" --assembly "C:\Users\XXXX\source\repos\SwashBuckleExample\SwashBuckleExample\bin\Debug\netcoreapp3.0\SwashBuckleExample.dll" --file-list "obj\SwashBuckleExample.OpenApiFiles.cache" --framework ".NETCoreApp,Version=v3.0" --output "obj" --project "SwashBuckleExample" --assets-file "C:\Users\XXXX\source\repos\SwashBuckleExample\SwashBuckleExample\obj\project.assets.json" --platform "AnyCPU" " exited with code 6. SwashBuckleExample C:\Users\XXXX.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\buildMicrosoft.Extensions.ApiDescription.Server.targets 41
I get this. I don't know if it's the same as the others.
Repro steps:
- Create a new API template project in VS 2019 pro16.3.1.
- In the pm console type: Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc3
- Run
Severity Code Description Project File Line Suppression State
Error MSB3073 The command "dotnet "C:\Users\XXXX.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\build/../tools/dotnet-getdocument.dll" --assembly "C:\Users\XXXX\source\repos\SwashBuckleExample\SwashBuckleExample\bin\Debug\netcoreapp3.0\SwashBuckleExample.dll" --file-list "obj\SwashBuckleExample.OpenApiFiles.cache" --framework ".NETCoreApp,Version=v3.0" --output "obj" --project "SwashBuckleExample" --assets-file "C:\Users\XXXX\source\repos\SwashBuckleExample\SwashBuckleExample\obj\project.assets.json" --platform "AnyCPU" " exited with code 6. SwashBuckleExample C:\Users\XXXX.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\buildMicrosoft.Extensions.ApiDescription.Server.targets 41
I had a API template that I made just to make future projects more easy to go and it was running on Core 2.2.
Today I decided to up this to Core 3.0 also I update Swash to rc3 and now I'm expecting the following error:
Severity Code Description Project File Line Suppression State Suppression State
Error MSB3073 The command "dotnet "C:\Usersandre.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\build\/../tools/dotnet-getdocument.dll" --assembly "C:\Workspace\diretor-cash\src\Diretor.Cash\Diretor.Cash.Api\bin\Debug\netcoreapp3.0\Diretor.Cash.Api.dll" --file-list "obj\Diretor.Cash.Api.OpenApiFiles.cache" --framework ".NETCoreApp,Version=v3.0" --output "obj" --project "Diretor.Cash.Api" --assets-file "C:\Workspace\diretor-cash\src\Diretor.Cash\Diretor.Cash.Api\obj\project.assets.json" --platform "AnyCPU" " exited with code 6. Diretor.Cash.Api C:\Usersandre.nuget\packages\microsoft.extensions.apidescription.server\0.3.0-preview7.19365.7\buildMicrosoft.Extensions.ApiDescription.Server.targets 41
Same here. Only works with:
<OpenApiGenerateDocuments>false</OpenApiGenerateDocuments>
Related issue: https://github.com/aspnet/AspNetCore/issues/14232
Swashbuckle.AspNetCore.SwaggerGen 5.0.0-rc4 is still referencing Microsoft.AspNetCore.Mvc.NewtonsoftJson (>= 3.0.0-preview3-19153-02) which is still Preview3 and not 3.0.0.
I upgrade Swashbuckle.AspNetCore 5.0.0-rc3 to rc4 and works!
Works for me as well upgrading to rc4. Just need to tweak The "Info" object from swagger to "OpenApiInfo"
I also had to tweek the implementation of SwaggerDefaultValues class to accomodate the new IOperationFilter. (uses OpenApi in the same manner as the Info object @cmarrades mentions)
I encountered the same error using Swashbuckle.AspNetCore 5.0.0-rc4.
The Swashbuckle packages have been used within a class library targeting netstandard2.1 which does not seems to be supported by now ?!?
Changed the library to target netcoreapp3 solved the problem, but this is only a temporary solution
For me the steps:
Create a new API template project in VS 2019 pro16.3.1.
In the pm console type: Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc3
Run
Make works, thanks.
As Swashbuckle.AspNetCore 5.x.x introduces breaking changes we would like to avoid updating from 4.x.x. Can you confirm that Swashbuckle.AspNetCore 4.x.x will not be supporting .net core >= 3.0.0 ?
4x will not be supporting NET Core 3.0
Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc4
and change services to:
c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Core API", Description = "Swagger Core API" });
Install package Microsoft.OpenApi and Swashbuckle.AspNetCore -Version 5.0.0-rc4:
Keep only your defined endpoints.
Running now in NET Core 3.1
https://docs.microsoft.com/en-us/aspnet/core/tutorials/getting-started-with-swashbuckle?view=aspnetcore-3.1&tabs=visual-studio
@danielPollackGitHub based on the thread above, can this be closed?
Closing due to inactivity
I used OpenApiInfo
Most helpful comment
Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc4
and change services to:
c.SwaggerDoc("v1", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Core API", Description = "Swagger Core API" });