Skip to content

Commit

Permalink
Add DisableNativeToolsetInstalls check to tools.ps1/.sh (#4133)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
sunandabalu authored Oct 21, 2019
1 parent 2f60e5b commit 7a82f9a
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 8 deletions.
2 changes: 1 addition & 1 deletion eng/common/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ try {
$nodeReuse = $false
}

if (($restore) -and ($null -eq $env:DisableNativeToolsetInstalls)) {
if ($restore) {
InitializeNativeTools
}

Expand Down
2 changes: 1 addition & 1 deletion eng/common/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ if [[ "$clean" == true ]]; then
exit 0
fi

if [[ "$restore" == true && -z ${DisableNativeToolsetInstalls:-} ]]; then
if [[ "$restore" == true ]]; then
InitializeNativeTools
fi

Expand Down
1 change: 1 addition & 0 deletions eng/common/post-build/post-build-utils.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
1 change: 1 addition & 0 deletions eng/common/sdl/extract-artifact-packages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
13 changes: 10 additions & 3 deletions eng/common/tools.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}
}
12 changes: 9 additions & 3 deletions eng/common/tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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=""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7a82f9a

Please sign in to comment.