From 218b887d87f268b3b06a6a5d6b83ea79c349248b Mon Sep 17 00:00:00 2001 From: Nick Guerrera Date: Tue, 17 Oct 2017 08:10:22 -0700 Subject: [PATCH] Download stage0 when DOTNET_TOOL_DIR is not set --- .../update-dependencies/update-dependencies.ps1 | 12 +++++++++++- .../update-dependencies/update-dependencies.sh | 13 ++++++++++++- run-build.ps1 | 17 ++++++++++++++++- run-build.sh | 13 ++++++++++++- 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/build_projects/update-dependencies/update-dependencies.ps1 b/build_projects/update-dependencies/update-dependencies.ps1 index e6422b1b2..4c70b197b 100644 --- a/build_projects/update-dependencies/update-dependencies.ps1 +++ b/build_projects/update-dependencies/update-dependencies.ps1 @@ -35,7 +35,17 @@ if (!$env:DOTNET_INSTALL_DIR) } # Install a stage 0 -cp -r $env:DOTNET_TOOL_DIR $env:DOTNET_INSTALL_DIR + Write-Output "Installing .NET Core CLI Stage 0" + +if (!$env:DOTNET_TOOL_DIR) +{ + & "$RepoRoot\scripts\obtain\dotnet-install.ps1" -Channel "master" -Architecture $Architecture + if($LASTEXITCODE -ne 0) { throw "Failed to install stage0" } +} +else +{ + cp -r $env:DOTNET_TOOL_DIR $env:DOTNET_INSTALL_DIR +} # Put the stage0 on the path $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH" diff --git a/build_projects/update-dependencies/update-dependencies.sh b/build_projects/update-dependencies/update-dependencies.sh index 8a0d7f940..fadffe928 100755 --- a/build_projects/update-dependencies/update-dependencies.sh +++ b/build_projects/update-dependencies/update-dependencies.sh @@ -33,8 +33,19 @@ fi if [ ! -d "$DOTNET_INSTALL_DIR" ]; then mkdir -p $DOTNET_INSTALL_DIR fi +# Install a stage 0 +echo "Installing .NET Core CLI Stage 0" -cp -r $DOTNET_TOOL_DIR/* $DOTNET_INSTALL_DIR/ +if [ -z "$DOTNET_TOOL_DIR" ]; then + $REPO_ROOT/scripts/obtain/dotnet-install.sh -Channel master -Architecture x64 + + if [ $? -ne 0 ]; then + echo "Failed to install stage 0" + exit 1 + fi +else + cp -r $DOTNET_TOOL_DIR/* $DOTNET_INSTALL_DIR/ +fi # Put the stage 0 on the path export PATH=$DOTNET_INSTALL_DIR:$PATH diff --git a/run-build.ps1 b/run-build.ps1 index ea5df284b..b0b04dbff 100644 --- a/run-build.ps1 +++ b/run-build.ps1 @@ -66,7 +66,22 @@ $env:VSTEST_BUILD_TRACE=1 $env:VSTEST_TRACE_BUILD=1 # install a stage0 -cp -r $env:DOTNET_TOOL_DIR $env:DOTNET_INSTALL_DIR +if (!$env:DOTNET_TOOL_DIR) +{ + $dotnetInstallPath = Join-Path $RepoRoot "scripts\obtain\dotnet-install.ps1" + + Write-Output "$dotnetInstallPath -Channel ""release/2.0.0"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture""" + Invoke-Expression "$dotnetInstallPath -Channel ""release/2.0.0"" -InstallDir $env:DOTNET_INSTALL_DIR -Architecture ""$Architecture""" + if ($LastExitCode -ne 0) + { + Write-Output "The .NET CLI installation failed with exit code $LastExitCode" + exit $LastExitCode + } +} +else +{ + cp -r $env:DOTNET_TOOL_DIR $env:DOTNET_INSTALL_DIR +} # Put the stage0 on the path $env:PATH = "$env:DOTNET_INSTALL_DIR;$env:PATH" diff --git a/run-build.sh b/run-build.sh index 4d1959cf0..f4e7a90ed 100755 --- a/run-build.sh +++ b/run-build.sh @@ -150,7 +150,18 @@ export VSTEST_TRACE_BUILD=1 export DOTNET_MULTILEVEL_LOOKUP=0 # Install a stage 0 -cp -r $DOTNET_TOOL_DIR/* $DOTNET_INSTALL_DIR/ +if [ -z "$DOTNET_TOOL_DIR" ]; then + (set -x ; "$REPOROOT/scripts/obtain/dotnet-install.sh" --channel "release/2.0.0" --install-dir "$DOTNET_INSTALL_DIR" --architecture "$ARCHITECTURE" $LINUX_PORTABLE_INSTALL_ARGS) + + EXIT_CODE=$? + if [ $EXIT_CODE != 0 ]; then + echo "run-build: Error: installing stage0 with exit code $EXIT_CODE." >&2 + exit $EXIT_CODE + fi +else + cp -r $DOTNET_TOOL_DIR/* $DOTNET_INSTALL_DIR/ +fi + # Put stage 0 on the PATH (for this shell only) PATH="$DOTNET_INSTALL_DIR:$PATH"