0

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

Bogey
  • 4,926
  • 4
  • 32
  • 57
  • have you got a `global.json` anywhere in the hierarchy of directories? (see [https://dotnetcore.gaprogman.com/2017/05/18/net-core-2-0-preview-1-released/#global-json](The Global global.json) for more info) – Jamie Taylor Feb 12 '18 at 11:31
  • Not so far. I could add one, but by looks that would only allow to specify/force a certain SDK version, but not allow to specify the path to the SDK (or dotnet.exe) in the first place - I.e. if I was trying to force SDK version 2.1.2, it'd still look in the %ProgramFiles%\dotnet directory (where the 2.1.2 SDK is not installed)? – Bogey Feb 12 '18 at 11:42
  • Once installed correctly (i.e via the installers available at [dot.net/core](dot.net/core), different versions of the SDK will run side-by-side and (unless a global.json is found) the latest installed version of the SDK will be used. I would be tempted to say that you should install the SDK via the installer, rather than manually unzipping it – Jamie Taylor Feb 12 '18 at 12:00
  • Absolutely - but unfortunately, I cannot do that due to the non-admin account here – Bogey Feb 12 '18 at 12:05
  • 2
    If `WHERE` reports these two (2) locations, it is hard to believe that they are both not in the `PATH`. Please copy and paste the text output of the `PATH` command in the cmd shell into the question. – lit Feb 12 '18 at 12:58
  • ugh - you're right, seems the %ProgramFiles%-one is contained in the System (not User) PATH variable. Seems like that, too, is not editable without admin rights though ... hmm – Bogey Feb 12 '18 at 13:08
  • @JamieTaylor The side-by-side implementation requires that all shared framework and sdks are installed in one location. Multiple `dotnet.exe`s are not supported by `global.json`. – omajid Feb 12 '18 at 14:49

1 Answers1

2

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

Walter White
  • 126
  • 1
  • 9
  • 1
    Not possible unfortunately - the %ProgramFiles% one is on the system PATH variable, which I cannot change as a non-admin user on this machine – Bogey Feb 16 '18 at 13:23