Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The specified runtime in the document (Net70) differs from the current process runtime #4255

Closed
madnik7 opened this issue Dec 2, 2022 · 9 comments

Comments

@madnik7
Copy link

madnik7 commented Dec 2, 2022

The specified runtime in the document (Net70) differs from the current process runtime (WinX64). Change the runtime with the '/runtime:Net70' parameter or run the file with the correct command line binary.

I set the document runtime to Net70 and add /runtime:Net70 but I got the error. It works if I set both to Net60
nswag run "./Api/Api.nswag" /runtime:Net70

image

NSwag command line tool for .NET 4.6.1+ WinX64, toolchain v13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v11.0.0.0))

@davidkeaveny
Copy link

I have a similar issue when running the NSwag.ConsoleCore CLI:

nswag.exe run open-api.nswag
NSwag command line tool for .NET Core Net70, toolchain v13.18.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))
Visit http://NSwag.org for more information.
NSwag bin directory: C:\Users\david.keaveny\.dotnet\tools\.store\nswag.consolecore\13.18.0\nswag.consolecore\13.18.0\tools\net7.0\any

Executing file 'D:\Bit\MyApi\open-api.nswag' with variables ''...
System.InvalidOperationException: The specified runtime in the document (Net60) differs from the current process runtime (Net70). Change the runtime with the '/runtime:Net60' parameter or run the file with the correct command line binary.
   at NSwag.Commands.Document.ExecuteDocumentCommand.ExecuteDocumentAsync(IConsoleHost host, String filePath) in /_/src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 68
   at NSwag.Commands.Document.ExecuteDocumentCommand.RunAsync(CommandLineProcessor processor, IConsoleHost host) in /_/src/NSwag.Commands/Commands/Document/ExecuteDocumentCommand.cs:line 48
   at NConsole.CommandLineProcessor.ProcessSingleAsync(String[] args, Object input)
   at NConsole.CommandLineProcessor.ProcessAsync(String[] args, Object input)
   at NSwag.Commands.NSwagCommandProcessor.ProcessAsync(String[] args) in /_/src/NSwag.Commands/NSwagCommandProcessor.cs:line 61

In this case, my application is compiled against .NET 6.0 (since it's an LTS release) rather than the newer-but-won't-be-supported-as-long .NET 7.0.

My open-api.nswag file starts off as:

{
  "runtime": "Net60",
  "defaultVariables": null,
  "documentGenerator": {
    "aspNetCoreToOpenApi": {
      "project": "MyApi.csproj",
      "msBuildProjectExtensionsPath": null,
      "configuration": "Release",
      "runtime": "Net60",

so as far as I can tell I'm setting runtime correctly. If I try calling nswag.exe with /runtime:Net60 I get exactly the same error.

@mgreuelrwe
Copy link

mgreuelrwe commented Dec 6, 2022

I have the same issue as @madnik7 It just seems to be the CLI installed with nswagStudio, via the npm tool it works just fine.

Maybe 70 is just missing in the cmd

@RicoSuter
Copy link
Owner

I have the same issue as @madnik7 It just seems to be the CLI installed with nswagStudio, via the npm tool it works just fine.

Maybe 70 is just missing in the cmd

Yeah that could be...

RicoSuter added a commit that referenced this issue Dec 7, 2022
@RicoSuter
Copy link
Owner

Can you maybe patch the nswag.cmd in your install location to check whether this fixes it or more is needed?

@mgreuelrwe
Copy link

mgreuelrwe commented Dec 7, 2022

Can you maybe patch the nswag.cmd in your install location to check whether this fixes it or more is needed?

That does the trick!

@RicoSuter
Copy link
Owner

Oukey.. ill release a new version of nswag with the patch today...

@mgreuelrwe
Copy link

Perfect, thanks for the quick fix!

@RicoSuter
Copy link
Owner

v13.18.1

@qwertie
Copy link

qwertie commented Apr 24, 2023

I had this error in my csproj file and "fixed" it by replacing $(NSwagExe) with $(NSwagDir_Net70)dotnet-nswag:

  <!-- Before -->
  <Target Name="NSwag" AfterTargets="Build">
    <Exec Command="$(NSwagExe) run nswag.json /runtime:Net70 /variables:Configuration=$(Configuration)" />
  </Target>

  <!-- After -->
  <Target Name="NSwag" AfterTargets="Build">
    <Exec Command="$(NSwagDir_Net70)dotnet-nswag run nswag.json /runtime:Net70 /variables:Configuration=$(Configuration)" />
  </Target>

(it's not really fixed, as issue #4404 appeared right afterward.)

shuruev added a commit to servicetitan/NSwag that referenced this issue Nov 16, 2023
* Update README.md

* Add nswag.cmd (RicoSuter#4255)

* v13.18.1

* v13.18.2

* Remove description from OpenApiResponse when serializing for Swagger v2 (RicoSuter#4314)

* Remove description from OpenApiResponse when serializing for Swagger v2 to prevent error "Structural error at paths.somepath.get.responses.304 should NOT have additional properties additionalProperty: description" [PR].

* Remove description from OpenApiResponse when serializing for Swagger v2 to prevent error "Structural error at paths.somepath.get.responses.304 should NOT have additional properties additionalProperty: description" [PR].

* Add check for IsBindingAllowed so that BindNever attribute works correctly

* Add CS0612 to the File.Header.liquid (RicoSuter#4409)

OpenApi which contains deprecated schemas correctly generates `[Obsolete]` attribute. If the API document does not propagate `deprecate` all the way to path/method resulting c# code produce warning CS0612: '...' is obsolete

* Update Client.Class.liquid (RicoSuter#4402)

Fix Newtonsoft.Json being used instead of System.Text.Json

* Descriptive exception for duplicate XML doc line (RicoSuter#2863) (RicoSuter#4388)

Duplicate response code in XML documentation response xml tag causes
somewhat hard to debug exception, which is now made more descriptive.

Did not yet figure out how to make an unit test for this one or if some
other other exception type would be more suitable than
InvalidOperationException.

Bug: Duplicate return code declaration causes nasty exception
id: RicoSuter#2863

Co-authored-by: Antti Viita <[email protected]>

* Revert PR RicoSuter#4314

* v13.18.3

* Improve NRT support for API parameters

* Required path parameters are not nullable (when NRT is off)

* v13.18.4

* Add enforceNotNull parameter and use for required path parameters

* v13.18.5

* Add File.Footer.liquid (RicoSuter#4411)

* Swagger UI v4.18.3, closes RicoSuter#4311 and RicoSuter#4387 (v13.18.5)

* add axios abort signal (RicoSuter#4282)

* add axios abort signal

* unit test

* Add support for MSBuild transitive dependency flow RicoSuter#4026 (RicoSuter#4338)

* Use GNU tar for cache and install .NET in single step (RicoSuter#4251)

* Unwrap ValueTask<T> return types (RicoSuter#4374)

* Unwrap ValueTask<T> return types, same as Task<T>, unwrap (Value)Task<ActionResult<T>> and unify unwrapping for consistency RicoSuter#4373

* lahma suggestion for performance

* cleanup

* NJsonSchema v10.9.0

* Fix build

* Revert "Fix build"

This reverts commit 21bf926.

* Fix build

* Fix dep

* Add .NET 5 SDK

* Improve build

* v13.19.0

* fix default value docs of SerializeTypeInformation, closes RicoSuter#4480

* Add SwaggerRoutesFactory to SwaggerUi3Settings

* Disable warning CS8604 "Possible null reference argument for parameter" in generated code (RicoSuter#4422)

* Disable warning CS8604 "Possible null reference argument for parameter" in code generation file header template

* Restore warning in file footer

* Update Client.Class.liquid (RicoSuter#4471)

* Update Client.Class.liquid

fix RicoSuter#4466

* Update Client.Class.liquid

---------

Co-authored-by: Rico Suter <[email protected]>

* install .net 3.1 sdk

* v13.20.0

* Set ChocolateyPush source

* Post-merge adjustments

* Updated more Newtonsoft.Json versions, for consistency

---------

Co-authored-by: Rico Suter <[email protected]>
Co-authored-by: Patrick Hofman <[email protected]>
Co-authored-by: Jan Trejbal <[email protected]>
Co-authored-by: Jean-Luc <[email protected]>
Co-authored-by: Antti Viita <[email protected]>
Co-authored-by: Antti Viita <[email protected]>
Co-authored-by: Rico Suter <[email protected]>
Co-authored-by: Lydon Chandra <[email protected]>
Co-authored-by: Daniel Sack <[email protected]>
Co-authored-by: Marko Lahma <[email protected]>
Co-authored-by: Alasdair <[email protected]>
Co-authored-by: Noah Stolk <[email protected]>
Co-authored-by: Alireza Mahdavi <[email protected]>
lahma pushed a commit to lahma/NSwag that referenced this issue Jan 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants