Relocate %USERPROFILE%\.dotnet and .nuget to non-OS drive dotnet core 2.0 preview

913 views Asked by At

Question

Can the folder %USERPROFILE%\.dotnet and %USERPROFILE%\.nuget be relocated to non-OS drive (in my case D: drive).

Constraints

  1. I use a VM which is provisioned by organization I work for; with limited space in OS drive.
  2. We are asked to save data to a different drive which has sufficient enough space and could be expanded.
  3. I cannot edit system environment variables. I can only add/edit environment variables at User scope / level.

Activities performed

I have futile attempts the following suggestions already -

  1. Edit the %APPDATA%\NuGet\NuGet.config file and change the value for key - CliFallbackFolder, and globalPackagesFolder.

    <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" /> <add key="globalPackagesFolder" value="D:\nuget\packages" /> <add key="CliFallbackFolder" value="D:\dotnet\NuGetFallbackFolder" /> </packageSources> </configuration>

    a. The value for CliFallbackFolder gets reset to %USERPROFILE%\.dotnet next time I run dotnet restore

  2. I have defined NUGET_PACKAGES environment variable @ user scope and have set its value to non-OS drive. **affects only the .nuget folder location **

  3. I SO'ed this question and have already seen (with problem still persisting) -

    a. https://github.com/dotnet/cli/issues/4003 (Question on the .dotnet folder is not responded)

    b. Is it possible to change the location of packages for NuGet? (focuses on the .nuget folder and not on the .dotnet\CliNuGetFallbackFolderFallbackFolder)

  4. Raised an issue in github. I realized that I have committed a mistake by raising an issue in preview 3 of the code branch. I also realized this is more a question than a issue, thus posting the question here. (https://github.com/dotnet/cli/issues/7256)

dotnet --info output

.NET Command Line Tools (2.0.0-preview2-006497)

Product Information: Version: 2.0.0-preview2-006497 Commit SHA-1 hash: 06a2093335

Runtime Environment: OS Name: Windows OS Version: 6.1.7601 OS Platform: Windows RID: win7-x64 Base Path: C:\Program Files\dotnet\sdk\2.0.0-preview2-006497\

Microsoft .NET Core Shared Framework Host Version : 2.0.0-preview2-25407-01 Build : 40c565230930ead58a50719c0ec799df77bddee9

dotnet nuget --version

NuGet Command Line 4.3.0.3

1

There are 1 answers

0
Siva Senthil On BEST ANSWER

For the first part of the question -

Can the folder %USERPROFILE%\.dotnet be relocated to non-OS drive (in my case D: drive).

Answer is

As of dotnet core 2.0.0-preview2-006497, it is not possible. The folder in question is part of SDK and is expected to be located in %USERPROFILE% directory.

github response on the issue

I still feel for the constraints listed above, it is essential that at least in future versions it should be enabled.

The question which is still open is

Can the folder %USERPROFILE%\.nuget be relocated to non-OS drive (in my case D: drive).

Please do share suggestions and do mind the steps already taken as an attempt to achieve the goal in the first post.