Nswag: nswag CLI doesn't work on MacOS High Sierra with DotNet Core 2.0

Created on 31 Jan 2018  Â·  10Comments  Â·  Source: RicoSuter/NSwag

Following exceptions are thrown if using nswag CLI:

➜ nswag
NSwag NPM CLI
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '1.1.2' was not found.

  • Check application dependencies and target a framework version installed at:
    /
  • Alternatively, install the framework version '1.1.2'.
    child_process.js:644
    throw err;
    ^

Error: Command failed: dotnet "/usr/local/lib/node_modules/nswag/bin/binaries/NetCore11/dotnet-nswag.dll"
at checkExecSyncError (child_process.js:601:13)
at Object.execSync (child_process.js:641:13)
at c.exec (/usr/local/lib/node_modules/nswag/bin/nswag.js:65:11)
at ChildProcess.exithandler (child_process.js:267:7)
at emitTwo (events.js:126:13)
at ChildProcess.emit (events.js:214:7)
at maybeClose (internal/child_process.js:925:16)
at Socket.stream.socket.on (internal/child_process.js:346:11)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
➜ dotnet --version
2.0.0

NSwag.AssemblyLoader done question

Most helpful comment

Ok, I think I will not remove it but change the default to .NET Core 2.0 or 2.1 in the summer... (next major release)

All 10 comments

Add the parameter /runtime:NetCore20 to enforce the .NET Core 2.0 runtime...

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

Updated to the latest version via npm:

➜ nswag /runtime:NetCore20
NSwag NPM CLI
NSwag command line tool for .NET Core NetCore20, toolchain v11.14.0.0 (NJsonSchema v9.10.24.0 (Newtonsoft.Json v9.0.0.0))
Visit http://NSwag.org for more information.
NSwag bin directory: usr/local/lib/node_modules/nswag/bin/binaries/NetCore20
Commands:
  help
  aspnetcore2swagger
  version
  list-types
  list-controllers
  types2swagger
  webapi2swagger
  new
  run
  jsonschema2csclient
  jsonschema2tsclient
  swagger2csclient
  swagger2cscontroller
  swagger2tsclient
Command: version

NSwag version: 11.14.0.0
NJsonSchema version: 9.10.24.0 (Newtonsoft.Json v9.0.0.0)

Duration: 00:00:23.2289930

However the latest available runtime cannot be found:

➜ nswag
NSwag NPM CLI
It was not possible to find any compatible framework version
The specified framework 'Microsoft.NETCore.App', version '1.1.2' was not found.
  - Check application dependencies and target a framework version installed at:
      /
  - Alternatively, install the framework version '1.1.2'.
child_process.js:644
    throw err;
    ^

Error: Command failed: dotnet "/usr/local/lib/node_modules/nswag/bin/binaries/NetCore11/dotnet-nswag.dll"
    at checkExecSyncError (child_process.js:601:13)
    at Object.execSync (child_process.js:641:13)
    at c.exec (/usr/local/lib/node_modules/nswag/bin/nswag.js:65:11)
    at ChildProcess.exithandler (child_process.js:267:7)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)

Yes, if you do not specify a runtime, it uses .net core 1.1 which seems to be not installed on your system... this behavior is expected. You always have to specify the runtime...

Are there any plans to deprecate the use of .net core 1.1 and switch to 2.x?

I don't think we will deprecate 1.1 soon, just add /runtime:NetCore20 as cmd parameter and it should work... isnt this the case?

It is. Was just a thought because 1.1 is barely mentioned anymore by MS and basically legacy already.

Ok, I think I will not remove it but change the default to .NET Core 2.0 or 2.1 in the summer... (next major release)

Breaking defaults updated: https://github.com/RSuter/NSwag/issues/984

Was this page helpful?
0 / 5 - 0 ratings

Related issues

RawsomeGH picture RawsomeGH  Â·  4Comments

Peter554 picture Peter554  Â·  3Comments

Rui90 picture Rui90  Â·  4Comments

akamyshanov picture akamyshanov  Â·  4Comments

p0wertiger picture p0wertiger  Â·  3Comments