"Did you mean to run dotnet SDK commands? Please install dotnetsdk" in windows command prompt
In my case somehow I also had a C:\Program Files (x86)\dotnet with a runtime version there which was picked from Path instead of the SDK in C:\Program Files\dotnet
This was causing exactly the same error message + it was breaking solutions in Visual Studio (but not in Rider)
Please, make sure you've installed SDK not just runtime.
UPDATE
This is what you will see on the server without SDK installed if you run dotnet.exe --list-sdks
command
And this with SDK installed:
One needs to install SDK on a development machine to be able to build and run applications and runtime (usually on an application server or user machine) to be able to just run built applications.
I was getting the same problem when I was trying to dockerize my .Net Core 2.2
Web API solution.
I was using the below images to build the images. Please note that place where the sdk(mcr.microsoft.com/dotnet/core/sdk:2.2) is used.
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS base
WORKDIR /app
EXPOSE 5051
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS build
Apparently the order I was used is wrong, So I changed it as preceding .
FROM mcr.microsoft.com/dotnet/core/aspnet:2.2 AS base
WORKDIR /app
EXPOSE 5051
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build
WORKDIR /src
........
RUN dotnet restore "Api.csproj"
WORKDIR "/src/Api"
COPY . .
WORKDIR "/src/Api"
RUN dotnet build "Api.csproj" -c Release -o /app
FROM build AS publish
RUN dotnet publish "Api.csproj" -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENV ASPNETCORE_ENVIRONMENT DevStaging
ENV ASPNETCORE_URLS=http://+:5051
ENTRYPOINT ["dotnet", "Api.dll"]
This fixed my issue. Hope it helps.