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 c07a81f commit a495c8f
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/android/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
// Add the Android SDK tooling and emulator to the path.
"remoteEnv": {
"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}",
"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}",
"DOTNET_MULTILEVEL_LOOKUP": "0"
},

Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
// Add the locally installed dotnet to the path to ensure that it is activated
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
"remoteEnv": {
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerEnv:PATH}",
"PATH": "${containerWorkspaceFolder}/.dotnet/x64:${containerEnv:PATH}",
"DOTNET_MULTILEVEL_LOOKUP": "0"
},

Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/libraries/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
// Add the locally installed dotnet to the path to ensure that it is activated
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
"remoteEnv": {
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerEnv:PATH}",
"PATH": "${containerWorkspaceFolder}/.dotnet/x64:${containerEnv:PATH}",
"DOTNET_MULTILEVEL_LOOKUP": "0"
},

Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/wasm-multiThreaded/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
// Add the global tools dir to the PATH so that globally installed tools will work
"remoteEnv": {
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
"PATH": "${containerWorkspaceFolder}/.dotnet/x64:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
"DOTNET_MULTILEVEL_LOOKUP": "0",
},

Expand Down
2 changes: 1 addition & 1 deletion .devcontainer/wasm/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
// This allows developers to just use 'dotnet build' on the command-line, and the local dotnet version will be used.
// Add the global tools dir to the PATH so that globally installed tools will work
"remoteEnv": {
"PATH": "${containerWorkspaceFolder}/.dotnet:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
"PATH": "${containerWorkspaceFolder}/.dotnet/x64:${containerWorkspaceFolder}/.dotnet-tools-global:${containerEnv:PATH}",
"DOTNET_MULTILEVEL_LOOKUP": "0",
},

Expand Down
4 changes: 2 additions & 2 deletions dotnet.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set Platform=
:: Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
set DOTNET_MULTILEVEL_LOOKUP=0

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

call "%dotnetPath%\dotnet.exe" %*
4 changes: 2 additions & 2 deletions dotnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
# Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
export DOTNET_MULTILEVEL_LOOKUP=0

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

source $scriptroot/eng/common/tools.sh

Expand Down
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
2 changes: 1 addition & 1 deletion eng/pipelines/libraries/fuzzing/deploy-to-onefuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ variables:
- name: fuzzerProject
value: $(Build.SourcesDirectory)/src/libraries/Fuzzing/DotnetFuzzing
- name: dotnetPath
value: $(Build.SourcesDirectory)/.dotnet/dotnet
value: $(Build.SourcesDirectory)/dotnet.cmd

extends:
template: /eng/pipelines/common/templates/pipeline-with-resources.yml
Expand Down
10 changes: 5 additions & 5 deletions src/tests/readytorun/crossboundarylayout/buildcrossgen2image.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,36 @@ goto Loop

if "%COMPOSITENAME%"=="" goto done

set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\.dotnet\dotnet %CORE_ROOT%\crossgen2\crossgen2.dll -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\*.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%Composite.dll --composite %COMPILEARG%
set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\dotnet.cmd %CORE_ROOT%\crossgen2\crossgen2.dll -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\*.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%Composite.dll --composite %COMPILEARG%
echo %BUILDCMD% > %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%Composite.dll.log
call %BUILDCMD% >> %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%Composite.dll.log 2>&1
if NOT EXIST %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%Composite.dll del %TESTINITIALBINPATH%\%TESTTARGET_DIR%\a.dll
goto done

:CG2Single
del %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll
set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\.dotnet\dotnet %CORE_ROOT%\crossgen2\crossgen2.dll -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\*.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll %TESTINITIALBINPATH%\%COMPOSITENAME%.dll
set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\dotnet.cmd %CORE_ROOT%\crossgen2\crossgen2.dll -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\*.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll %TESTINITIALBINPATH%\%COMPOSITENAME%.dll
echo %BUILDCMD% > %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll.log
call %BUILDCMD% >> %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll.log 2>&1
goto done

:CG2NoMethods
del %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll
set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\.dotnet\dotnet %CORE_ROOT%\crossgen2\crossgen2.dll --compile-no-methods -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\*.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll %TESTINITIALBINPATH%\%COMPOSITENAME%.dll
set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\dotnet.cmd %CORE_ROOT%\crossgen2\crossgen2.dll --compile-no-methods -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\*.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll %TESTINITIALBINPATH%\%COMPOSITENAME%.dll
echo %BUILDCMD% > %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll.log
call %BUILDCMD% >> %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll.log 2>&1
goto done

:CG2SingleInputBubble
del %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll
set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\.dotnet\dotnet %CORE_ROOT%\crossgen2\crossgen2.dll -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\*.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll --inputbubble %TESTINITIALBINPATH%\%COMPOSITENAME%.dll
set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\dotnet.cmd %CORE_ROOT%\crossgen2\crossgen2.dll -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\*.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll --inputbubble %TESTINITIALBINPATH%\%COMPOSITENAME%.dll
echo %BUILDCMD% > %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll.log
call %BUILDCMD% >> %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll.log 2>&1
goto done

:CG2SingleBubbleADOnly
del %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll
set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\.dotnet\dotnet %CORE_ROOT%\crossgen2\crossgen2.dll -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\d.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll --inputbubble %TESTINITIALBINPATH%\%COMPOSITENAME%.dll
set BUILDCMD=%TESTBATCHROOT%\..\..\..\..\..\..\dotnet.cmd %CORE_ROOT%\crossgen2\crossgen2.dll -r %CORE_ROOT%\* -r %TESTINITIALBINPATH%\d.dll -o %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll --inputbubble %TESTINITIALBINPATH%\%COMPOSITENAME%.dll
echo %BUILDCMD% > %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll.log
call %BUILDCMD% >> %TESTINITIALBINPATH%\%TESTTARGET_DIR%\%COMPOSITENAME%.dll.log 2>&1
goto done
Expand Down

0 comments on commit a495c8f

Please sign in to comment.