The command "dotnet..." error while integrating OpenAPI / Swagger

3.4k Views Asked by At

I use Swagger Open API and while integrating I encountered the following error after building project:

The command "dotnet "C:\Users\user.nuget\packages\nswag.msbuild\13.3.0\build../tools/NetCore31/dotnet-nswag.dll" run /variables:Configuration=Debug" exited with code -1. DemoProject with .NET DemoProject\src\WebUI.csproj

I tried to change .NET Core version from 3.1 to 3 in *.csproj file, etc. but none of them solved the problem. I also have a look at many pages expaciallh GitHub and workarounds have not fixed the problem as well. Any idea?

Update: Here is the details of the error (I have not find a proper fix on the web):

"System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.MissingMethodException: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection FluentValidation.ServiceCollectionExtensions.AddValidatorsFromAssembly(Microsoft.Extensions.DependencyInjection.IServiceCollection, System.Reflection.Assembly, Microsoft.Extensions.DependencyInjection.ServiceLifetime)'. at Demo.Application.DependencyInjection.AddApplication(IServiceCollection services) at Demo.WebUI.Startup.ConfigureServices(IServiceCollection services) in Code with .NET Demo\src\WebUI\Startup.cs:line 34 at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions) at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.InvokeCore(Object instance, IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass9_0.g__Startup|0(IServiceCollection serviceCollection) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.Invoke(Object instance, IServiceCollection services) at Microsoft.AspNetCore.Hosting.ConfigureServicesBuilder.<>c__DisplayClass8_0.b__0(IServiceCollection services) at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.UseStartup(Type startupType, HostBuilderContext context, IServiceCollection services) at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass12_0.b__0(HostBuilderContext context, IServiceCollection services) at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider() at Microsoft.Extensions.Hosting.HostBuilder.Build() at NSwag.Commands.Generation.AspNetCore.AspNetCoreToOpenApiGeneratorCommandEntryPoint.GetServiceProvider(String applicationName) in C:\projects\nswag\src\NSwag.Commands\Commands\Generation\AspNetCore\AspNetCoreToOpenApiGeneratorCommandEntryPoint.cs:line 80"

0

There are 0 best solutions below