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

Change the default dotnet installation location from .dotnet/ to .dotnet/$hostRid/ #14751

Open
am11 opened this issue May 4, 2024 · 4 comments · May be fixed by #14913
Open

Change the default dotnet installation location from .dotnet/ to .dotnet/$hostRid/ #14751

am11 opened this issue May 4, 2024 · 4 comments · May be fixed by #14913

Comments

@am11
Copy link
Member

am11 commented May 4, 2024

The downstream repos have dotnet.sh script, which calls scripts in arcade to install dotnet in :(top)/.dotnet/ directory's root if it wasn't present and continues using the one that was installed. If the installed .dotnet/dotnet belonged to a different platform, it fails with (a cryptic) run-time error.

I often find myself mounting the repo directory (with local changes) in docker container to test the build against different platform e.g.
docker run --rm -v(pwd):/runtime -w /runtime --platform linux/amd64 ubuntu sh -c 'eng/install-native-dependencies.sh && ./build.sh clr+libs (or using cross prereq image)
on Apple Silicon or Windows host machines. This requires deleting .dotnet/ directory each time if the repo was built on host machine first (or vice-versa). In comparison, the artifacts/ directory keeps the platform dependent bits separate in $rid/ sub-directories and we don't need to delete it when switching the executing platform.

It would make things consistent if arcade installs dotnet in $rid sub-directory as well, to avoid installing when switching between the host and the container. i.e. :(top)/.dotnet/win-arm64/dotnet.exe instead of :(top)/.dotnet/dotnet.exe to match the followed under artifacts/ directory.

Important

There is a difference between the $rid used under artifacts/ (which is always the "target RID") and proposed .dotnet/$rid (which is expected to be the "(effective) host RID"). For instance, if the host where docker is running has RID osx-arm64, the effective host in docker container where the build is running has linux-x64 cross-targeting freebsd-arm64; then the dotnet is expected to be installed in .dotnet/linux-x64.

cc @ViktorHofer, @jkoritzinsky, @akoeplinger

@akoeplinger
Copy link
Member

I've run into this myself so I'd generally agree with the change, however there are probably some workflows/scripts that rely on <repo root>/.dotnet/dotnet so I'm not sure it's enough of a pain point to force this change on everyone.

We could add an env var to override the location into InitializeDotNetCli in eng/common/tools.sh (and their Windows equivalents?) as a first step.

@am11
Copy link
Member Author

am11 commented Jun 19, 2024

Environment variable would essentially be a workaround and honestly it won't be much of an improvement over the current workaround: mv .dotnet .dotnet_osx-arm64 before running the container build.

If we go ahead with it, it won't be the first time we will have to update a few lines during the arcade update in downstream repos. It's relatively straightforward: .dotnet/dotnet to .dotnet/$rid/dotnet or simply to ./dotnet.sh/cmd which we can do already independent of this change.

@akoeplinger
Copy link
Member

Right I mostly meant to use the env var so we can try to opt-in repos step by step to see if something breaks and then make it the default later on.

@am11
Copy link
Member Author

am11 commented Jun 21, 2024

Ah, makes sense. I'll try to implement it.

@am11 am11 linked a pull request Jul 2, 2024 that will close this issue
@missymessa missymessa added this to the Tracking for other teams milestone Aug 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants