Swashbuckle.aspnetcore: Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.OpenApi,

Created on 7 Oct 2019  路  3Comments  路  Source: domaindrivendev/Swashbuckle.AspNetCore

When running against a .netcore 2.2 project I get the following exception:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.OpenApi, Version=1.1.1.0, Culture=neutral, PublicKeyToken=3f5743946376f042'. The system cannot find the file specified.
at Swashbuckle.AspNetCore.Cli.Program.<>c.

b__0_3(IDictionary2 namedArgs) at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable1 args) in C:projectsahoysrcSwashbuckle.AspNetCore.CliCommandRunner.cs:line 68
at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable`1 args) in C:projectsahoysrcSwashbuckle.AspNetCore.CliCommandRunner.cs:line 68
at Swashbuckle.AspNetCore.Cli.Program.Main(String[] args) in C:projectsahoysrcSwashbuckle.AspNetCore.CliProgram.cs:line 99

All 3 comments

For me doing the following resolve the issue.

  1. Upgrading the Swashbuckle.AspNetCore
    <PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc3" />
  2. My csproj file looks like
    <ItemGroup> <PackageReference Include="Microsoft.AspNetCore.App" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc3" /> </ItemGroup>
    Then install the cli tool using
    dotnet tool install -g swashbuckle.aspnetcore.cli --version 5.0.0-rc3

And finally use the swagger-codegen-cli-3.0.9.jar file. It can be directly downloaded from
https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/

@domaindrivendev
Is there another workaround? I currently have netcore 2.1 with swagger v4 and do not want to upgrade to v5. As for me, swagger global tool should have all the dependencies inside and do not rely on app itself.

Closing in favor of #1699, which captures all of the outstanding compatibility issues. That issue is being addressed as a top priority.

Also ...

As for me, swagger global tool should have all the dependencies inside and do not rely on app itself

The tool needs to host and run the application, including all of it's dependencies, and therefore has to rely on the app.

Was this page helpful?
0 / 5 - 0 ratings