[Windows] Merge several toolset provisioners into single Configure-Toolset script (#1111)

* Add Configure-Toolset for windows

* Set error action preference to stop

* Move toolcache.json to config folder

* Fix in verbose

* Rename toolsets folder

* Move default version functions from install-toolset to configure-toolset

* Rework Configure-Toolset

* Fix typo and remove empty line

* Fix issues

* Fix parameters in helpers

* Fix helper syntax

* Rename defaultVariable
This commit is contained in:
Maksim Petrov
2020-06-30 07:48:55 +03:00
committed by GitHub
parent a89f839675
commit 8d0d6f85cc
13 changed files with 160 additions and 166 deletions

View File

@@ -137,7 +137,7 @@ function Stop-SvcWithErrHandling
.PARAMETER StopOnError
Switch for stopping the script and exit from PowerShell if one service is absent
#>
param
Param
(
[Parameter(Mandatory, ValueFromPipeLine = $true)]
[string] $ServiceName,
@@ -187,7 +187,7 @@ function Set-SvcWithErrHandling
Hashtable for service arguments
#>
param
Param
(
[Parameter(Mandatory, ValueFromPipeLine = $true)]
[string] $ServiceName,
@@ -217,7 +217,7 @@ function Set-SvcWithErrHandling
function Start-DownloadWithRetry
{
param
Param
(
[Parameter(Mandatory)]
[string] $Url,
@@ -348,17 +348,74 @@ function Get-VSExtensionVersion
return $packageVersion
}
function Get-ToolcachePackages {
function Get-ToolcachePackages
{
$toolcachePath = Join-Path $env:ROOT_FOLDER "toolcache.json"
Get-Content -Raw $toolcachePath | ConvertFrom-Json
}
function Get-ToolsetContent {
function Get-ToolsetContent
{
$toolsetJson = Get-Content -Path $env:TOOLSET_JSON_PATH -Raw
ConvertFrom-Json -InputObject $toolsetJson
}
function Get-ToolsByName {
function Get-ToolsetToolFullPath
{
<#
.DESCRIPTION
Function that return full path to specified toolset tool.
.PARAMETER Name
The name of required tool.
.PARAMETER Version
The version of required tool.
.PARAMETER Arch
The architecture of required tool.
#>
Param
(
[Parameter(Mandatory=$true)]
[string] $Name,
[Parameter(Mandatory=$true)]
[string] $Version,
[string] $Arch = "x64"
)
$ToolPath = Join-Path $env:AGENT_TOOLSDIRECTORY $Name
# Add wildcard if missing
if ($Version.Split(".").Length -lt 3) {
$Version += ".*"
}
# Check if version folder exists
$expectedVersionPath = Join-Path $ToolPath $Version
if (-not (Test-Path $expectedVersionPath)) {
Write-Host "Expected ${Name} ${Version} folder is not found!"
exit 1
}
# Take latest installed version in case if toolset version contains wildcards
$foundVersion = Get-Item $expectedVersionPath `
| Sort-Object -Property {[version]$_.name} -Descending `
| Select-Object -First 1
# Check for required architecture folder
$foundVersionArchPath = Join-Path $foundVersion $Arch
if (-not (Test-Path $foundVersionArchPath)) {
Write-Host "Expected ${Name}(${Arch}) $($foundVersion.name) architecture folder is not found!"
exit 1
}
return $foundVersionArchPath
}
function Get-ToolsByName
{
Param
(
[Parameter(Mandatory = $True)]
@@ -391,7 +448,7 @@ function Test-IsWin16
}
function Extract-7Zip {
param
Param
(
[Parameter(Mandatory=$true)]
[string]$Path,