3 Entry point script for installing native tools
6 Reads
$RepoRoot\global
.json file to determine native assets to install
7 and executes installers for those tools
10 Base file directory or Url from which to acquire tool archives
12 .PARAMETER InstallDirectory
13 Directory to install native toolset
. This is a command-line override for the default
14 Install directory precedence order
:
15 - InstallDirectory command-line override
16 - NETCOREENG_INSTALL_DIRECTORY environment variable
17 - (default
) %USERPROFILE
%/.netcoreeng
/native
20 Switch specifying to not install anything
, but cleanup native asset folders
23 Clean and then install tools
25 .PARAMETER DownloadRetries
26 Total number of retry attempts
28 .PARAMETER RetryWaitTimeInSeconds
29 Wait time between retry attempts
in seconds
31 .PARAMETER GlobalJsonFile
32 File path to global
.json file
36 [CmdletBinding
(PositionalBinding
=$false)]
38 [string
] $BaseUri = "https://netcorenativeassets.blob.core.windows.net/resource-packages/external",
39 [string
] $InstallDirectory,
40 [switch] $Clean = $False,
41 [switch] $Force = $False,
42 [int
] $DownloadRetries = 5,
43 [int
] $RetryWaitTimeInSeconds = 30,
44 [string
] $GlobalJsonFile
47 if (!$GlobalJsonFile) {
48 $GlobalJsonFile = Join-Path (Get-Item $PSScriptRoot).Parent
.Parent
.FullName
"global.json"
51 Set-StrictMode
-version
2.0
52 $ErrorActionPreference="Stop"
54 Import-Module
-Name
(Join-Path $PSScriptRoot "native\CommonLibrary.psm1")
57 # Define verbose switch if undefined
58 $Verbose = $VerbosePreference -Eq
"Continue"
60 $EngCommonBaseDir = Join-Path $PSScriptRoot "native\"
61 $NativeBaseDir = $InstallDirectory
62 if (!$NativeBaseDir) {
63 $NativeBaseDir = CommonLibrary\Get-NativeInstallDirectory
65 $Env:CommonLibrary_NativeInstallDir
= $NativeBaseDir
66 $InstallBin = Join-Path $NativeBaseDir "bin"
67 $InstallerPath = Join-Path $EngCommonBaseDir "install-tool.ps1"
70 Write-Host "Processing $GlobalJsonFile"
71 If
(-Not
(Test-Path $GlobalJsonFile)) {
72 Write-Host "Unable to find '$GlobalJsonFile'"
75 $NativeTools = Get-Content($GlobalJsonFile) -Raw
|
77 Select-Object -Expand
"native-tools" -ErrorAction SilentlyContinue
79 $NativeTools.PSObject
.Properties
| ForEach-Object {
81 $ToolVersion = $_.Value
82 $LocalInstallerArguments = @
{ ToolName
= "$ToolName" }
83 $LocalInstallerArguments += @
{ InstallPath
= "$InstallBin" }
84 $LocalInstallerArguments += @
{ BaseUri
= "$BaseUri" }
85 $LocalInstallerArguments += @
{ CommonLibraryDirectory
= "$EngCommonBaseDir" }
86 $LocalInstallerArguments += @
{ Version
= "$ToolVersion" }
89 $LocalInstallerArguments += @
{ Verbose
= $True }
91 if (Get-Variable 'Force' -ErrorAction
'SilentlyContinue') {
93 $LocalInstallerArguments += @
{ Force
= $True }
97 $LocalInstallerArguments += @
{ Clean
= $True }
100 Write-Verbose "Installing $ToolName version $ToolVersion"
101 Write-Verbose "Executing '$InstallerPath $($LocalInstallerArguments.Keys.ForEach({"-$_ '$($LocalInstallerArguments.$_)'"}) -join
' ')'"
102 & $InstallerPath @LocalInstallerArguments
103 if ($LASTEXITCODE -Ne "0") {
104 $errMsg = "$ToolName installation failed"
105 if ((Get-Variable 'DoNotAbortNativeToolsInstallationOnFailure
' -ErrorAction 'SilentlyContinue
') -and $DoNotAbortNativeToolsInstallationOnFailure) {
106 $showNativeToolsWarning = $true
107 if ((Get-Variable 'DoNotDisplayNativeToolsInstallationWarnings
' -ErrorAction 'SilentlyContinue
') -and $DoNotDisplayNativeToolsInstallationWarnings) {
108 $showNativeToolsWarning = $false
110 if ($showNativeToolsWarning) {
111 Write-Warning $errMsg
113 $toolInstallationFailure = $true
121 if ((Get-Variable 'toolInstallationFailure
' -ErrorAction 'SilentlyContinue
') -and $toolInstallationFailure) {
126 Write-Host "No native tools defined in global.json"
133 if (Test-Path $InstallBin) {
134 Write-Host "Native tools are available from" (Convert-Path -Path $InstallBin)
135 Write-Host "##vso[task.prependpath]$(Convert-Path -Path $InstallBin)"
139 Write-Error "Native tools install directory does not exist, installation failed"
146 Write-Host $_.Exception