Cmd precedence: How to use correct dotnet.exe when installed in 2 locations?

1.2k views Asked by At

a while ago I installed the dotnet core 2.1.2 SDK manually, by unzipping it into my %AppData% folder, and adding its location to the PATH environment variable. This worked well, I could invoke the dotnet commands via cmd, and VS Code picked up the correct location.

Recently, I installed Visual Studio 2017, which installed the net core 1.1 SDK to %ProgramFiles%\dotnet. Even though this particular path isn't registered in the PATH variable, it seems the dotnet.exe from this folder is now used by default.

Or in other words, when I open cmd.exe and type "where dotnet", I see two locations:

  1. %ProgramFiles%\dotnet\dotnet.exe (the 1.1 SDK installed by Vs2017)
  2. %AppData%....\dotnet\dotnet.exe - I.e. the 2.1.2 SDK i unzipped manually

When i run "dotnet --version", I see 1.1.0 - so the default dotnet command seems to be associated with the old 1.1 version from the %ProgramFiles% folder.

How can I change the precedence there - e.g. how can I have the dotnet command be associated with my custom folder instead?

I should note I am running on a non-admin windows account. I cannot change anything in the %ProgramFiles% folder myself (so cannot copy over the newer SDK to that folder, or delete/change the old one).

Thanks

1

There are 1 answers

1
Walter White On

Try to change the %PATH% environment variable so it includes only one of the .NET folders.