Skip to content

Commit a495c8f

Browse files
committed
Add option to install dotnet at .dotnet/$rid
1 parent c07a81f commit a495c8f

File tree

11 files changed

+37
-15
lines changed

11 files changed

+37
-15
lines changed

.devcontainer/android/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
5555
// Add the Android SDK tooling and emulator to the path.
5656
"remoteEnv": {
57-
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerEnv:ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools/bin:${containerEnv:ANDROID_SDK_ROOT}/emulator:${containerEnv:ANDROID_SDK_ROOT}/platform-tools:${containerEnv:PATH}",
57+
"PATH": "${containerWorkspaceFolder}/.dotnet/x64:${containerEnv:ANDROID_SDK_ROOT}/cmdline-tools/cmdline-tools/bin:${containerEnv:ANDROID_SDK_ROOT}/emulator:${containerEnv:ANDROID_SDK_ROOT}/platform-tools:${containerEnv:PATH}",
5858
"DOTNET_MULTILEVEL_LOOKUP": "0"
5959
},
6060

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
// Add the locally installed dotnet to the path to ensure that it is activated
4040
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
4141
"remoteEnv": {
42-
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerEnv:PATH}",
42+
"PATH": "${containerWorkspaceFolder}/.dotnet/x64:${containerEnv:PATH}",
4343
"DOTNET_MULTILEVEL_LOOKUP": "0"
4444
},
4545

.devcontainer/libraries/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
// Add the locally installed dotnet to the path to ensure that it is activated
4646
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
4747
"remoteEnv": {
48-
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerEnv:PATH}",
48+
"PATH": "${containerWorkspaceFolder}/.dotnet/x64:${containerEnv:PATH}",
4949
"DOTNET_MULTILEVEL_LOOKUP": "0"
5050
},
5151

.devcontainer/wasm-multiThreaded/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
4848
// Add the global tools dir to the PATH so that globally installed tools will work
4949
"remoteEnv": {
50-
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
50+
"PATH": "${containerWorkspaceFolder}/.dotnet/x64:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
5151
"DOTNET_MULTILEVEL_LOOKUP": "0",
5252
},
5353

.devcontainer/wasm/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
4848
// Add the global tools dir to the PATH so that globally installed tools will work
4949
"remoteEnv": {
50-
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
50+
"PATH": "${containerWorkspaceFolder}/.dotnet/x64:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
5151
"DOTNET_MULTILEVEL_LOOKUP": "0",
5252
},
5353

dotnet.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ set Platform=
1616
:: Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
1717
set DOTNET_MULTILEVEL_LOOKUP=0
1818

19-
:: Disable first run since we want to control all package sources
20-
set DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
19+
:: Install at .dotent/${RID}
20+
set DOTNET_USE_ARCH_IN_INSTALL_PATH=1
2121

2222
call "%dotnetPath%\dotnet.exe" %*

dotnet.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
1515
# Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
1616
export DOTNET_MULTILEVEL_LOOKUP=0
1717

18-
# Disable first run since we want to control all package sources
19-
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
18+
# Install at .dotent/${RID}
19+
export DOTNET_USE_ARCH_IN_INSTALL_PATH=1
2020

2121
source $scriptroot/eng/common/tools.sh
2222

eng/common/tools.ps1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,23 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
188188
$dotnetRoot = $env:DOTNET_INSTALL_DIR
189189
} else {
190190
$dotnetRoot = Join-Path $RepoRoot '.dotnet'
191+
if ($env:DOTNET_USE_ARCH_IN_INSTALL_PATH -eq "1") {
192+
$osArchitecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
193+
if ($osArchitecture) {
194+
$rid = "win-$osArchitecture".ToLowerInvariant()
195+
} else {
196+
# netfx / desktop
197+
$osArchitecture = (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture
198+
switch -Wildcard ($osArchitecture) {
199+
"*ARM 64-bit*" { $rid = "win-arm64"; break }
200+
"*ARM*" { $rid = "win-arm"; break }
201+
"*32-bit*" { $rid = "win-x86"; break }
202+
"*64-bit*" { $rid = "win-x64"; break }
203+
}
204+
}
205+
206+
$dotnetRoot = Join-Path $dotnetRoot $rid
207+
}
191208

192209
if (-not (Test-Path(Join-Path $dotnetRoot "sdk\$dotnetSdkVersion"))) {
193210
if ($install) {

eng/common/tools.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ function InitializeDotNetCli {
145145
dotnet_root="$DOTNET_INSTALL_DIR"
146146
else
147147
dotnet_root="${repo_root}.dotnet"
148+
if [[ "${DOTNET_USE_ARCH_IN_INSTALL_PATH:-}" == "1" ]]; then
149+
. "$_script_dir/native/init-os-and-arch.sh"
150+
if (ldd --version 2>&1 || true) | grep -q musl; then os="${os}-musl"; fi
151+
dotnet_root="${dotnet_root}/${os}-${arch}"
152+
fi
148153

149154
export DOTNET_INSTALL_DIR="$dotnet_root"
150155

eng/pipelines/libraries/fuzzing/deploy-to-onefuzz.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ variables:
1212
- name: fuzzerProject
1313
value: $(Build.SourcesDirectory)/src/libraries/Fuzzing/DotnetFuzzing
1414
- name: dotnetPath
15-
value: $(Build.SourcesDirectory)/.dotnet/dotnet
15+
value: $(Build.SourcesDirectory)/dotnet.cmd
1616

1717
extends:
1818
template: /eng/pipelines/common/templates/pipeline-with-resources.yml

0 commit comments

Comments
 (0)