NSwag: macOS nswag webapi2swagger errors with System.IO.FileNotFoundException

Hi there, I’m on a mac with dotnet 2.1.4 installed. I publish my app with dotnet publish --self-contained -r osx-x64 -c Release -o ./release ./MyApi (I’ve also tried specifying the linux-x64 runtime). Then I run nswag webapi2swagger /assembly:MyApi.dll /output:TestSwag.json /runtime:NetCore20 (I’ve also tried specifying the referencePaths to <user>/.nuget/packages) But it always errors with

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.AspNetCore.Mvc.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the path specified.

I can see that dll is in the folder from which I run nswag so I don’t know what’s going on or how to direct it to find the file. Thanks so much for the help in advance, really grateful to have found this project, just need to get past this last thing.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

Hey @RSuter , Thanks so much! 11.14.0 seems to have resolved this issue. The spec is now generated properly on mac. Thanks again for awesome work and the quick turn-around, really appreciate it.

v11.14.0:

We improved the assembly loader (mainly for .NET Core) so that it runs in a more isolated space and the loaded DLLs should better match the requested versions. Please test this with your projects to ensure that we didnt introduce regressions.

Important if you have DLL loading problems:

  • Check that the DLL in question is available in the output directory (where the selected assembly is located) or in ReferencePaths
  • Check that you selected the correct runtime: Either in NSwagStudio UI, as /runtime parameter in the NPM CLI or execute the correct exe binary

For more information regarding assembly loading: https://github.com/RSuter/NSwag/wiki/Assembly-loading

Main commit: https://github.com/RSuter/NSwag/commit/04576e4d1b714ac5bd9b5df11d72469a23f7c0ff#diff-14dafe6661bab407ae5c0d7095ccd1f4