From 7a82f9a5b5aa43761a55ce0953622ef93acc711f Mon Sep 17 00:00:00 2001 From: Sunanda Balasubramanian Date: Mon, 21 Oct 2019 16:36:40 -0700 Subject: [PATCH] Add DisableNativeToolsetInstalls check to tools.ps1/.sh (#4133) * Add DisableNativeToolsetInstalls check to tools.ps1/.sh * Set the variable in post-build-utils.ps1 as well * Fix condition is tools.sh * Move conditions around * Fix indentation * Add the check to configureToolsetScript as well * Use a custom variable for Post Build Disable Native Tools * chane custom variable name for Post Build Disable Native Tools * Make the change to tools.sh as well * Camel Casing the variable name * Update variable name to follow conventions --- eng/common/build.ps1 | 2 +- eng/common/build.sh | 2 +- eng/common/post-build/post-build-utils.ps1 | 1 + eng/common/sdl/extract-artifact-packages.ps1 | 1 + eng/common/tools.ps1 | 13 ++++++++++--- eng/common/tools.sh | 12 +++++++++--- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/eng/common/build.ps1 b/eng/common/build.ps1 index a67fe8bb505..55dff332044 100644 --- a/eng/common/build.ps1 +++ b/eng/common/build.ps1 @@ -133,7 +133,7 @@ try { $nodeReuse = $false } - if (($restore) -and ($null -eq $env:DisableNativeToolsetInstalls)) { + if ($restore) { InitializeNativeTools } diff --git a/eng/common/build.sh b/eng/common/build.sh index 9c597613b29..36f9aa0462e 100755 --- a/eng/common/build.sh +++ b/eng/common/build.sh @@ -209,7 +209,7 @@ if [[ "$clean" == true ]]; then exit 0 fi -if [[ "$restore" == true && -z ${DisableNativeToolsetInstalls:-} ]]; then +if [[ "$restore" == true ]]; then InitializeNativeTools fi diff --git a/eng/common/post-build/post-build-utils.ps1 b/eng/common/post-build/post-build-utils.ps1 index 551ae113f89..aa9a025c0bb 100644 --- a/eng/common/post-build/post-build-utils.ps1 +++ b/eng/common/post-build/post-build-utils.ps1 @@ -8,6 +8,7 @@ Set-StrictMode -Version 2.0 # scripts don't necessarily execute in the same agent that run the # build.ps1/sh script this variable isn't automatically set. $ci = $true +$disableConfigureToolsetImport = "true" . $PSScriptRoot\..\tools.ps1 function Create-MaestroApiRequestHeaders([string]$ContentType = "application/json") { diff --git a/eng/common/sdl/extract-artifact-packages.ps1 b/eng/common/sdl/extract-artifact-packages.ps1 index 6e6825013bf..d857ae21972 100644 --- a/eng/common/sdl/extract-artifact-packages.ps1 +++ b/eng/common/sdl/extract-artifact-packages.ps1 @@ -10,6 +10,7 @@ Set-StrictMode -Version 2.0 # scripts don't necessarily execute in the same agent that run the # build.ps1/sh script this variable isn't automatically set. $ci = $true +$disableConfigureToolsetImport = "true" . $PSScriptRoot\..\tools.ps1 $ExtractPackage = { diff --git a/eng/common/tools.ps1 b/eng/common/tools.ps1 index fdfffbf1c04..26ccbe14dce 100644 --- a/eng/common/tools.ps1 +++ b/eng/common/tools.ps1 @@ -49,6 +49,8 @@ # An array of names of processes to stop on script exit if prepareMachine is true. $processesToStopOnExit = if (Test-Path variable:processesToStopOnExit) { $processesToStopOnExit } else { @("msbuild", "dotnet", "vbcscompiler") } +$disableConfigureToolsetImport = if (Test-Path variable:disableConfigureToolsetImport) { $disableConfigureToolsetImport } else { $null } + set-strictmode -version 2.0 $ErrorActionPreference = "Stop" [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 @@ -418,6 +420,9 @@ function GetSdkTaskProject([string]$taskName) { } function InitializeNativeTools() { + if ($env:DisableNativeToolsetInstalls) { + return + } if (Get-Member -InputObject $GlobalJson -Name "native-tools") { $nativeArgs= @{} if ($ci) { @@ -602,7 +607,9 @@ Write-PipelineSetVariable -Name 'TMP' -Value $TempDir # Import custom tools configuration, if present in the repo. # Note: Import in global scope so that the script set top-level variables without qualification. -$configureToolsetScript = Join-Path $EngRoot "configure-toolset.ps1" -if (Test-Path $configureToolsetScript) { - . $configureToolsetScript +if (!$disableConfigureToolsetImport) { + $configureToolsetScript = Join-Path $EngRoot "configure-toolset.ps1" + if (Test-Path $configureToolsetScript) { + . $configureToolsetScript + } } diff --git a/eng/common/tools.sh b/eng/common/tools.sh index 94b9aff7475..0c86c396073 100755 --- a/eng/common/tools.sh +++ b/eng/common/tools.sh @@ -4,6 +4,7 @@ # CI mode - set to true on CI server for PR validation build or official build. ci=${ci:-false} +disable_configure_toolset_import=${disable_configure_toolset_import:-null} # Set to true to use the pipelines logger which will enable Azure logging output. # https://github.com/Microsoft/azure-pipelines-tasks/blob/master/docs/authoring/commands.md @@ -252,6 +253,9 @@ function GetNuGetPackageCachePath { } function InitializeNativeTools() { + if [[ -z "${DisableNativeToolsetInstalls:-}" ]]; then + return + fi if grep -Fq "native-tools" $global_json_file then local nativeArgs="" @@ -413,9 +417,11 @@ Write-PipelineSetVariable -name "Temp" -value "$temp_dir" Write-PipelineSetVariable -name "TMP" -value "$temp_dir" # Import custom tools configuration, if present in the repo. -configure_toolset_script="$eng_root/configure-toolset.sh" -if [[ -a "$configure_toolset_script" ]]; then - . "$configure_toolset_script" +if [[ "$disable_configure_toolset_import" != null ]]; then + configure_toolset_script="$eng_root/configure-toolset.sh" + if [[ -a "$configure_toolset_script" ]]; then + . "$configure_toolset_script" + fi fi # TODO: https://github.com/dotnet/arcade/issues/1468