Skip to content

Commit

Permalink
Add option to install dotnet at .dotnet/$rid
Browse files Browse the repository at this point in the history
  • Loading branch information
am11 committed Jul 2, 2024
1 parent 48f3eaf commit de12fab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
17 changes: 17 additions & 0 deletions eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,23 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
$dotnetRoot = $env:DOTNET_INSTALL_DIR
} else {
$dotnetRoot = Join-Path $RepoRoot '.dotnet'
if ($env:DOTNET_USE_ARCH_IN_INSTALL_PATH -eq "1") {
$osArchitecture = [System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture
if ($osArchitecture) {
$rid = "win-$osArchitecture".ToLowerInvariant()
else {
# netfx / desktop
$osArchitecture = (Get-CimInstance -ClassName Win32_OperatingSystem).OSArchitecture
switch -Wildcard ($osArchitecture) {
"*ARM 64-bit*" { $rid = "win-arm64"; break }
"*ARM*" { $rid = "win-arm"; break }
"*32-bit*" { $rid = "win-x86"; break }
"*64-bit*" { $rid = "win-x64"; break }
}
}

$dotnetRoot = Join-Path $dotnetRoot $rid
}

if (-not (Test-Path(Join-Path $dotnetRoot "sdk\$dotnetSdkVersion"))) {
if ($install) {
Expand Down
5 changes: 5 additions & 0 deletions eng/common/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ function InitializeDotNetCli {
dotnet_root="$DOTNET_INSTALL_DIR"
else
dotnet_root="${repo_root}.dotnet"
if [[ "${DOTNET_USE_ARCH_IN_INSTALL_PATH:-}" == "1" ]]; then
. "$_script_dir/native/init-os-and-arch.sh"
if (ldd --version 2>&1 || true) | grep -q musl; then os="${os}-musl"; fi
dotnet_root="${dotnet_root}/${os}-${arch}"
fi

export DOTNET_INSTALL_DIR="$dotnet_root"

Expand Down

0 comments on commit de12fab

Please sign in to comment.