Skip to content

Commit ce400da

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

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

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

0 commit comments

Comments
 (0)