'Error "It was not possible to find any installed .NET Core SDKs" when running any `dotnet` command

When running a simple dotnet --version on a fresh computer with the Windows Hosting Bundle 3.1 installed, you may get this error message:

It was not possible to find any installed .NET Core SDKs Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from: https://aka.ms/dotnet-download

what is causing this issue ?

PS: I created this question because all other questions dealing with this error message are within the scope of docker or other specific programs and not .NET generally.



Solution 1:[1]

This may happen if you have installed the ASP.NET Core Runtime (<=> Windows Hosting Bundle) but not the .NET Core Runtime itself. The tricky part is that the former still install the dotnet command but not the libraries that make it work.

So, contrarily to what may be assumed according to this, the Windows Hosting Bundle does not install the .NET SDK (at least for v3.1) which has to be installed explicitly too in order to make the dotnet command work.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1