You must install or update .NET to run this application
Asked Answered
K

9

22

I have a WebAPI project and I do a post-build process that calls "swagger.exe", which is a tool provided by NuGet Package. To install globally it, I used the following command:

dotnet tool install -g --version 5.3.1 Swashbuckle.AspNetCore.Cli

The problem is: My CI process was working fine yesterday. Today it doesn't work anymore. I narrowed down the problem to the swagger executable... Just by calling it, without any parameters, it returns the following message:

Terminal screenshot

You must install or update .NET to run this application.

App: C:\Users\DRibeiro\.dotnet\tools\swagger.exe
Architecture: x64
Framework: 'Microsoft.NETCore.App', version '3.1.27' (x64)
.NET location: C:\Program Files\dotnet\

The following frameworks were found:
  3.1.21 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  3.1.26 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  5.0.12 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  5.0.17 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  6.0.6 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  6.0.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

Notice that I have the Runtime 3.1.26 installed on my Windows.

Notice, also, that the Swashbuckle.AspNetCore.Cli version 5.3.1 was released in 2020! More than 2 years ago! NuGet Screenshot

So, the question is: Why this Package from 2020 requires a .NET Runtime released 2 weeks ago? Why can't it use one of the other Runtimes that I already have (and was working fine yesterday) ?

I know that I could just install the newer version and the problem would be solved... Just want to keep my CI's running smoothly without having to fix it every time a new Runtime version is released.

Knudson answered 27/7, 2022 at 0:50 Comment(5)
You have many versions. There simply could be some conflict. Normally best to remove older versions and keep the latest you are using.Leading
I agree with the suggestion given by the community member. We could see that you have multiple versions of .NET installed on your machine. When multiple versions are available then your app might try to use the latest version of it but it could be possible that your app is compatible with any specific version of .NET and generate the said error. I would suggest you only keep the .NET version that is compatible with your app and you could remove other versions that are not in use. It might help to avoid the said error.Beefburger
Ok, it doesn't answer the questions thought... Why it was working before, and why an older program is now requiring the latest version of the framework.Knudson
It could be possible that the .Net Framework your app is using has some issues or it got corrupted. Further, something in your app is checking for the new .Net versions and showing you the errors when new .Net is available.Beefburger
Not my app... It's "Swagger CLI", available on NuGet. I took the time to check it's source code and it doesn't has this error message. It doesn't check for .NET versions. This verification is on the Runtime itself somehow. But looking at the source code of this CLI tool actually gave me an idea to workaround this issue for this specific case.Knudson
K
-1

It turns out that our Automatic Software Distribution system was not doing it's job correctly and sent to our CI machines the incorrect files for the .NET Runtimes. Probably some human error of the network admin.

I disconnected this particular CI machine from the system and reinstalled the Runtime, and everything worked fine.

Knudson answered 14/10, 2022 at 16:11 Comment(0)
C
13

Answer for modern .NET

Add --roll-forward LatestMajor to arguments of dotnet or set DOTNET_ROLL_FORWARD=LatestMajor environment variable.

--roll-forward

Cusped answered 14/7, 2023 at 14:9 Comment(0)
K
3

You have to update the version of ef-tool in config file manually , follow these steps:

1 : Open the config file : yourProject/.config

2 : Edit version number of dotent ef or add it if it doesnt exist :

 "tools": {
    "dotnet-ef": {
      "version": "7.0.5",
      "commands": [
        "dotnet-ef"
      ]
    }

3: Run command : dotnet tool restore

Katheykathi answered 21/5, 2023 at 5:48 Comment(0)
K
2

Removing the bin-, obj- and .vs-folder fixed it for me.

Kraken answered 19/3, 2023 at 16:5 Comment(0)
H
1

I resolved this by just installing the latest .NET 6 SDK.

Hall answered 16/6, 2023 at 14:23 Comment(1)
but no one knows HOW to do that!Isoprene
E
0

Ensure the selected .NET runtime in the swagger tool matches the version of .NET installed.

Incidentally, I was getting this exact error in NSwagStudio, where the relevant .NET framework setting is found in the Runtime drop-down at the top-left corner of the main page. The busy interface makes the setting easy to miss if you're not looking for it, and the tool inexplicably defaults the runtime to .NET Core 2.1.

Epifocal answered 26/9, 2023 at 1:5 Comment(0)
I
0

I have install again .net 8 framework with latest version or same. after that my project getting run.

Indetermination answered 31/7 at 10:4 Comment(0)
M
0

I think your SDK version and Runtime version are different

Marrowfat answered 8/8 at 9:44 Comment(0)
K
-1

It turns out that our Automatic Software Distribution system was not doing it's job correctly and sent to our CI machines the incorrect files for the .NET Runtimes. Probably some human error of the network admin.

I disconnected this particular CI machine from the system and reinstalled the Runtime, and everything worked fine.

Knudson answered 14/10, 2022 at 16:11 Comment(0)
B
-2

Step 1 - Check the dotnet version.

Step 2 - If it is a higher version compared to the instructed version (3.1.27), then uninstall the dotnet and again install the required version.

Step 3 - Follow the same procedure when the current version is higher.

Bigwig answered 22/6, 2023 at 6:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.