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 $LocalInstallerCommand = $InstallerPath
83 $LocalInstallerCommand += " -ToolName $ToolName"
84 $LocalInstallerCommand += " -InstallPath $InstallBin"
85 $LocalInstallerCommand += " -BaseUri $BaseUri"
86 $LocalInstallerCommand += " -CommonLibraryDirectory $EngCommonBaseDir"
87 $LocalInstallerCommand += " -Version $ToolVersion"
90 $LocalInstallerCommand += " -Verbose"
92 if (Get-Variable 'Force' -ErrorAction
'SilentlyContinue') {
94 $LocalInstallerCommand += " -Force"
98 $LocalInstallerCommand += " -Clean"
101 Write-Verbose "Installing $ToolName version $ToolVersion"
102 Write-Verbose "Executing '$LocalInstallerCommand'"
103 Invoke-Expression "$LocalInstallerCommand"
104 if ($LASTEXITCODE -Ne
"0") {
105 $errMsg = "$ToolName installation failed"
106 if ((Get-Variable 'DoNotAbortNativeToolsInstallationOnFailure' -ErrorAction
'SilentlyContinue') -and
$DoNotAbortNativeToolsInstallationOnFailure) {
107 Write-Warning $errMsg
108 $toolInstallationFailure = $true
116 if ((Get-Variable 'toolInstallationFailure' -ErrorAction
'SilentlyContinue') -and
$toolInstallationFailure) {
121 Write-Host "No native tools defined in global.json"
128 if (Test-Path $InstallBin) {
129 Write-Host "Native tools are available from" (Convert-Path -Path
$InstallBin)
130 Write-Host "##vso[task.prependpath]$(Convert-Path -Path $InstallBin)"
133 Write-Error "Native tools install directory does not exist, installation failed"
140 Write-Host $_.Exception