Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request, able to config the location of ~/.dotnet and ~/.templateengine #8678

Closed
ariellourenco opened this issue Aug 31, 2017 · 27 comments
Closed
Assignees
Labels
Area-dotnet new the item is related to dotnet new command triaged the item was triaged and placed to the backlog
Milestone

Comments

@ariellourenco
Copy link

Hi @livarcocc ,

May you can help me with this simple question. Is there anyway to re-locate the dotnet user profile folder (.dotnet)?

@wli3
Copy link

wli3 commented Sep 13, 2017

Hi @ariellourenco

The location is fixed relative to user profile

This may not be 100% what you want, you can change the environment variable USERPROFILE on windows, HOME on Linux. Which will create a .dotnet under that folder. Note, changing that variable will also affect other program rely on it

@wli3
Copy link

wli3 commented Sep 13, 2017

Please feel free to reopen if you need more detail

@wli3 wli3 closed this as completed Sep 13, 2017
@ariellourenco
Copy link
Author

ariellourenco commented Sep 13, 2017

Hi @wli3 ,

Thanks for your response. However, my understanding is this is an opportunity for improvement. We have a similar issue related to ~/.templateengine folder and people from template engine team are working on make it configurable. Please, see the link below and let me know your considerations.

dotnet/templating#806

@omajid
Copy link
Member

omajid commented Sep 13, 2017

As a linux power user, I would love it if both ~/.dotnet and ~/.templateengine moved their data elsewhere. For cache, moving it to an appropriate cache location would be great.

@wli3 wli3 changed the title dotnet user profile folder Able to config the location of ~/.dotnet and ~/.templateengine Sep 13, 2017
@wli3 wli3 reopened this Sep 13, 2017
@wli3 wli3 changed the title Able to config the location of ~/.dotnet and ~/.templateengine Request, able to config the location of ~/.dotnet and ~/.templateengine Sep 13, 2017
@wli3
Copy link

wli3 commented Sep 13, 2017

@KathleenDollard

@MicahZoltu
Copy link

MicahZoltu commented Jan 31, 2018

Migrating this over from #1543. Of note, I believe it is important to change the default storage paths, not just make them configurable (though both are valuable in their own right). At the moment, dotnet/cli does not respect OS conventions.

I just installed .NET Core SDK onto a Windows 10 Pro (Fall Creators Update) machine. As a side effect, it appears to have created a folder in %USERPROFILE% named .dotnet. On Windows, applications should not be writing configuration data to %USERPROFILE% and instead should be writing it to %APPDATA%\<vendor>\<product>. In this case that would be %APPDATA%\Microsoft\dotnet.

Not only does the . prefix on folders cause problems in Windows (explorer will not allow you to name a folder starting with a .), but it also pollutes what is supposed to be a user-facing folder with configuration data that is not user facing. In general, the only things that should be put into %USERPROFILE% are things the user has explicitly put there via a save dialog. Any files automatically created by an application should go into %APPDATA%\<vendor>\<product>.

As a side note, is there a way I can override this setting while waiting for this issue to be resolved? The files in this folder appear to not be intended for human consumption, and I really try to keep my %USERPROFILE% directory uncluttered with garbage from various things I have installed on my computer.

@yanoryuichi
Copy link

In Windows, configuration files should not be stored in %USERPORFILE%. They should be in %APPDATA%. Please respect Windows standards. Moreover, you should consider XDG user directories in Linux.
https://wiki.archlinux.org/index.php/XDG_user_directories

@KathleenDollard
Copy link

@livarcocc Is this still in our backlog?

@livarcocc
Copy link
Contributor

Yes.

@ryanseipp
Copy link

Has there been any progress towards this issue, or an expectation of what milestone this will be addressed in?

@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@msftgits msftgits added this to the Backlog milestone Jan 31, 2020
@rkm
Copy link

rkm commented Apr 29, 2020

Has there been any progress towards this, or would you be open to someone submitting a PR?

@wli3
Copy link

wli3 commented Apr 29, 2020

Also will setting dotnet_cli_home satisfy the requirement?

@rkm
Copy link

rkm commented Apr 29, 2020

Just tried setting DOTNET_CLI_HOME, removing my current ~/.dotnet directory, and re-building one of my projects. The result was that the ~/.dotnet directory was partially repopulated:

$ dotnet --help
.NET Core SDK (3.1.103)
$ export DOTNET_CLI_HOME=~/tmp
$ rm -r ~/.dotnet
$ dotnet build ...
$ ls ~/.dotnet
corefx  optimizationdata
$ ls -a ~/tmp
.  ..  .dotnet  .nuget

Edit: Splitting the user config from any cached data would be useful e.g. as specified here

@wli3
Copy link

wli3 commented Apr 30, 2020

I see. This is not ideal. Different component of .NET core stack have different code paths to decide the persistent storage. It is not an easy fix. I don't think this is something community can easily contribute since it requires coordination between runtime, templates engine, CLI and nuget.

It would also require a large amount of testing to ensure there is no regression.

So far there is no roadmap for this issue.

@dlagg
Copy link

dlagg commented Jul 5, 2020

I see. This is not ideal. Different component of .NET core stack have different code paths to decide the persistent storage. It is not an easy fix. I don't think this is something community can easily contribute since it requires coordination between runtime, templates engine, CLI and nuget.

It would also require a large amount of testing to ensure there is no regression.

So far there is no roadmap for this issue.

Nuget it's configurable:

export NUGET_PACKAGES="$XDG_CACHE_HOME"/NuGetPackages

@Abrynos
Copy link

Abrynos commented Mar 10, 2021

Any progress on this one?

@SaphireLattice
Copy link

There's also .templateengine from https://github.com/dotnet/templating/blob/47e96dd1af9b63888da37b632f299b7c9e86879a/src/Microsoft.TemplateEngine.Edge/DefaultPathInfo.cs - not sure if slapping an actual directory existence check (so that it can work with legacy $HOME/.templateengine when present) would be good though? Kinda introduces a bit of a side effect, but dunno, it already checks up the env variable

And of course tests for that, too.

Now for .dotnet itself... well, there's a lot.

Various scripts, of course a ton of tests, and there's a .target file referencing $([System.IO.Path]::Combine($(_DefaultUserProfileRuntimeStorePath), '.dotnet', 'store')) so that would need to be handled too, if we want to avoid any breaking changes and have no intervention required when upgrading...

...and that's before we touch on any user tools, on interaction between SDK versions and their tooling. So yeah, this thing is very hardcoded basically, across different tools and non-C# files (definitions, scripts).

@bartekpacia
Copy link

So annoying!

@roadkell
Copy link

roadkell commented Feb 8, 2023

The more the devs postpone it, the larger their technical debt will be (as this will have to be implemented, sooner or later).

@baronfel
Copy link
Member

@dotnet/templating-engine-maintainers we did some work recently on the directory of the template engine cache, didn't we? Is this still an issue for the template engine?

@vlada-shubina vlada-shubina added the Area-dotnet new the item is related to dotnet new command label Apr 14, 2023
@vlada-shubina
Copy link
Member

Dotnet new now respects DOTNET_CLI_HOME environment variable to define the location of settings. It is also possible to override location of settings with --debug:custom-hive option with path for the settings.

Tagged item to provide more details on triage.

@YuliiaKovalova YuliiaKovalova self-assigned this Apr 24, 2023
@YuliiaKovalova YuliiaKovalova added the triaged the item was triaged and placed to the backlog label Apr 24, 2023
@YuliiaKovalova
Copy link
Member

YuliiaKovalova commented May 2, 2023

The fix for DOTNET_CLI_HOME was introduced in the scope of:
dotnet/templating#1650
After introducing this environment variable, the location on .templateengine will be changed.

Or you can use --debug:custom-hive option for defining a custom location for settings.

@Neme12
Copy link

Neme12 commented Feb 29, 2024

This may not be 100% what you want, you can change the environment variable USERPROFILE on windows

I don't think changing that is supported at all. I won't even dare try changing that or I'll probably completely screw up my Windows installation.

@Neme12
Copy link

Neme12 commented Feb 29, 2024

I'd like to change my DOTNET_CLI_HOME but I don't know what the default of that folder is, so I can know which folder I should move into that new location when I change it. And I can't seem to be able to find anything about that environment variable when googling, apart from GitHub issues. It doesn't seem to be documented anywhere. It's not even mentioned here: https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables

Is DOTNET_CLI_HOME equivalent to the default %userprofile%.dotnet? Meaning when I change the environment variable to a custom directory, I should move my current content of .dotnet there? Or does DOTNET_CLI_HOME represent a subdirectory within that? Or a parent directory, so that .dotnet will be created as a subfolder?

@Neme12
Copy link

Neme12 commented Feb 29, 2024

Edit: Splitting the user config from any cached data would be useful e.g. as specified here

I agree. It's not great that cache files (that can be repopulated at any time) and config files are both in the same directory tree. Cache files should be stored either in %LOCALAPPDATA% (user\AppData\Local) or in %TEMP% by default, whereas config files should be stored in %APPDATA% (user\AppData\Roaming) by default.

@Neme12
Copy link

Neme12 commented Feb 29, 2024

In Windows, configuration files should not be stored in %USERPORFILE%. They should be in %APPDATA%. Please respect Windows standards. Moreover, you should consider XDG user directories in Linux. https://wiki.archlinux.org/index.php/XDG_user_directories

This is still not fixed as the default location afaict.

@bartekpacia
Copy link

Forgive a slight off-topic, but what did you set DOTNET_CLI_HOME to? $XDG_DATA_HOME, $XDG_CACHE_HOME, or $XDG_STATE_HOME? I'm just curious and a bit confused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-dotnet new the item is related to dotnet new command triaged the item was triaged and placed to the backlog
Projects
None yet
Development

No branches or pull requests