Skip to content

Commit 613df43

Browse files
committed
Add option to install dotnet at .dotnet/$rid
1 parent 48f3eaf commit 613df43

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

eng/common/tools.ps1

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,21 @@ 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+
# netfx / desktop
195+
$osArchitecture = (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture
196+
switch -Wildcard ($osArchitecture) {
197+
"*ARM 64-bit*" { $rid = "win-arm64"; break }
198+
"*ARM*" { $rid = "win-arm"; break }
199+
"*32-bit*" { $rid = "win-x86"; break }
200+
"*64-bit*" { $rid = "win-x64"; break }
201+
}
202+
}
203+
204+
$dotnetRoot = Join-Path $dotnetRoot $rid
205+
}
191206

192207
if (-not (Test-Path(Join-Path $dotnetRoot "sdk\$dotnetSdkVersion"))) {
193208
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

0 commit comments

Comments
 (0)