dotnet / core

.NET news, announcements, release notes, and more!
https://dot.net
MIT License
20.97k stars 4.91k forks source link

How to install .NET on another drive than c: ? #4819

Closed jwinkler-sp closed 4 years ago

jwinkler-sp commented 4 years ago

Problem encountered on https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install Operating System: windows

Provide details about the problem you're experiencing. Include your operating system version, exact error message, code sample, and anything else that is relevant.

Hello to all, to learn coding in C# I want to install the .NET sdk on my PC (Windows 10 Enterprise, 64 Bit, version 1909, 16 GB Ram). But because drive C: is low on space I want to install the SDK on drive F: - how can I do this ? Thanks for your answer. Regards Jo

just-s-i-d commented 4 years ago

While installing it asks where to install .net Or you can go to control panel and change default drive for installing programs

mairaw commented 4 years ago

@KathleenDollard it doesn't seem you can specify the SDK install location. Does the SDK uses the default app save location? If so, can @jwinkler-sp just change the default save location for apps under Storage settings on Windows 10?

KathleenDollard commented 4 years ago

@joeloff

Do we have a straightforward way to install on another drive? Can you make any suggestions here?

Is this in our backlog?

joeloff commented 4 years ago

If there are no previous installs of .NET CORE, you can execute the SDK installer from the command line and do something like the example below.

dotnet-sdk-3.1.301-win-x64.exe DOTNETHOME_X64="F:\dotnet\x64" DOTNETHOME_X86="F:\dotnet\x86"
mairaw commented 4 years ago

@adegeo I don't think we cover this in the docs

joeloff commented 4 years ago

Also, the support for this came in around 3.x development. I'd have to check whether we did this in 3.0 or only 3.1.

One problem with this approach is that when you install older SDKs, e.g. 2.1, they will default to the Program Files location which usually resides on C:.

The main reason for adding this support was so that VS could move .NET Core off the primary volume, but I suspect this wasn't fully implemented.

mairaw commented 4 years ago

So, by default, does it use the default app save location?

For example, in Windows 10, you can change drives: image

joeloff commented 4 years ago

The MSIs default to ProgramFilesFolder or ProgramFiles64Folder These properties are set by the Windows Installer Service.

AFAIK, their values come from the registry values under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion

The settings page you mentioned impacts the user locations, e.g. My Documents, etc. SDKs are machine wide installs

mairaw commented 4 years ago

Ok thanks! Since @adegeo already created a work item to document this behavior, I'll close this issue.

Spiralis commented 3 years ago

I don't think this is working any longer, is that correct? I just tried dotnet-sdk-5.0.400-win-x64.exe DOTNETHOME_X64="D:\dotnet\x64" DOTNETHOME_X86="D:\dotnet\x86" and it still installed to C:\Program Files\dotnet

joeloff commented 3 years ago

The log files will tell if those properties were reset. If you have any previous install, e.g. 2.1 where this wasn't supported, it will set the default location and everything else will start using that. It only really works well when you start with a clean machine and start with 3.1 and later versions.

NotAsea commented 2 years ago

there is no way to change install location starting dotnet 5, unless you risky mesh with registry as describe above, but it will likely break your machine. Screw you microsoft

joeloff commented 2 years ago

The custom locations has additional constraints that came about with the introduction of x64 emulation on arm64 where both could be installed on the same machine, SxS. Those constraints were back ported to 5.0 and 3.1

adegeo commented 2 years ago

@joeloff Can you explain those constraints? Is it in the wiki?

joeloff commented 2 years ago

I'll need to check if it's in the wiki. arm64 supported emulation for x64. Windows did not partition things like the registry or Program Files, so arm64 and x64 share the same default location. The primary change that was made is that x64 will install to ProgramFiles\dotnet\x64 (on arm64), allowing the arm64 installation to use ProgramFiles\dotnet.

ahsanu123 commented 1 year ago

for anyone landing on this page. based from documentation, you can install dotnet with custom directory with dotnet install script.

[IMPORTANT] Starting in November 2021, you can't change the installation path of .NET with the Windows Installer package. To install .NET to a different path, use the dotnet-install scripts.

by using script argument, you can change installation folder

dotnet-install.ps1 [-Architecture <ARCHITECTURE>] [-AzureFeed]
    [-Channel <CHANNEL>] [-DryRun] [-FeedCredential]
    [-InstallDir <DIRECTORY>] [-JSonFile <JSONFILE>]
    [-NoCdn] [-NoPath] [-ProxyAddress] [-ProxyBypassList <LIST_OF_URLS>]
    [-ProxyUseDefaultCredentials] [-Quality <QUALITY>] [-Runtime <RUNTIME>]
    [-SkipNonVersionedFiles] [-UncachedFeed] [-Verbose]
    [-Version <VERSION>]

Get-Help ./dotnet-install.ps1

thanks, hopefully its help someone.

phamnamkhanhs commented 1 year ago

I meet errors Failed to resolve the exact version number. At C:\Users\Admin\Downloads\dotnet-install.ps1:1263 char:5