diff --git a/images/linux/scripts/installers/Configure-Toolset.ps1 b/images/linux/scripts/installers/Configure-Toolset.ps1 new file mode 100644 index 00000000..4a145a5d --- /dev/null +++ b/images/linux/scripts/installers/Configure-Toolset.ps1 @@ -0,0 +1,95 @@ +################################################################################ +## File: Configure-Toolset.ps1 +## Team: CI-Build +## Desc: Configure toolset +################################################################################ + +function Get-ToolsetToolFullPath +{ + param + ( + [Parameter(Mandatory)] [string] $ToolName, + [Parameter(Mandatory)] [string] $ToolVersion, + [Parameter(Mandatory)] [string] $ToolArchitecture + ) + + $toolPath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $toolName + $toolPathVersion = Join-Path -Path $toolPath -ChildPath $toolVersion + $foundVersion = Get-Item $toolPathVersion | Sort-Object -Property {[version]$_.name} -Descending | Select-Object -First 1 + $installationDir = Join-Path -Path $foundVersion -ChildPath $toolArchitecture + return $installationDir +} + +function Add-EnvironmentVariable +{ + param + ( + [Parameter(Mandatory)] [string] $Name, + [Parameter(Mandatory)] [string] $Value, + [string] $FilePath = "/etc/environment" + ) + + $envVar = "{0}={1}" -f $name, $value + Tee-Object -InputObject $envVar -FilePath $filePath -Append +} + +$ErrorActionPreference = "Stop" + +Write-Host "Configure toolset tools environment..." +$toolsEnvironment = @{ + boost = @{ + variableTemplate = "BOOST_ROOT_{0}_{1}_{2}" + } + go = @{ + command = "ln -s {0}/bin/* /usr/bin/" + defaultVariable = "GOROOT" + variableTemplate = "GOROOT_{0}_{1}_X64" + } +} + +$toolset = Get-Content -Path "$env:INSTALLER_SCRIPT_FOLDER/toolset.json" -Raw | ConvertFrom-Json + +foreach ($tool in $toolset.toolcache) +{ + $toolName = $tool.name + $toolArch = $tool.arch + $toolEnvironment = $toolsEnvironment[$toolName] + + if (-not $toolEnvironment) + { + continue + } + + foreach ($toolVersion in $tool.versions) + { + Write-Host "Set $toolName $toolVersion environment variable..." + $toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolVersion -ToolArchitecture $toolArch + $envName = $toolEnvironment.variableTemplate -f $toolVersion.split(".") + + # Add environment variable name=value + Add-EnvironmentVariable -Name $envName -Value $toolPath + } + + # Invoke command and add env variable for the default tool version + $toolDefVersion = $tool.default + if (-not $toolDefVersion) + { + continue + } + + $envDefName = $toolEnvironment.defaultVariable + $toolPath = Get-ToolsetToolFullPath -ToolName $toolName -ToolVersion $toolDefVersion -ToolArchitecture $toolArch + + if ($envDefName) + { + Write-Host "Set default $envDefName for $toolName $toolDefVersion environment variable..." + Add-EnvironmentVariable -Name $envDefName -Value $toolPath + } + + if ($toolEnvironment.command) + { + $command = $toolEnvironment.command -f $toolPath + Write-Host "Invoke $command command for default $toolName $toolDefVersion..." + Invoke-Expression -Command $command + } +} diff --git a/images/linux/scripts/installers/Install-Toolset.ps1 b/images/linux/scripts/installers/Install-Toolset.ps1 index ce5bfb0d..e95645e5 100644 --- a/images/linux/scripts/installers/Install-Toolset.ps1 +++ b/images/linux/scripts/installers/Install-Toolset.ps1 @@ -30,7 +30,7 @@ $ErrorActionPreference = "Stop" $toolsetJson = Get-Content -Path "$env:INSTALLER_SCRIPT_FOLDER/toolset.json" -Raw $toolsToInstall = @("Python", "Node", "Boost", "Go") -$tools = ConvertFrom-Json -InputObject $toolsetJson | Select-Object -ExpandProperty toolcache | Where {$ToolsToInstall -contains $_.Name} +$tools = ConvertFrom-Json -InputObject $toolsetJson | Select-Object -ExpandProperty toolcache | Where-Object {$ToolsToInstall -contains $_.Name} foreach ($tool in $tools) { # Get versions manifest for current tool @@ -44,10 +44,9 @@ foreach ($tool in $tools) { | Select-Object -First 1 Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..." - if ($asset -ne $null) { + if ($null -ne $asset) { Install-Asset -ReleaseAsset $asset - } - else { + } else { Write-Host "Asset was not found in versions manifest" exit 1 } diff --git a/images/linux/scripts/installers/boost.sh b/images/linux/scripts/installers/boost.sh deleted file mode 100644 index 8f05054d..00000000 --- a/images/linux/scripts/installers/boost.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -################################################################################ -## File: boost.sh -## Desc: Installs Boost C++ Libraries -################################################################################ - -TOOLSET_PATH="$INSTALLER_SCRIPT_FOLDER/toolset.json" -BOOST_LIB="$AGENT_TOOLSDIRECTORY/boost" -BOOST_VERSIONS=$(cat $TOOLSET_PATH | jq -r '.toolcache[] | select(.name | contains("boost")) | .versions[]') -BOOST_ARCH=$(cat $TOOLSET_PATH | jq -r '.toolcache[] | select(.name | contains("boost")) | .arch') - -# Install Boost -for BOOST_VERSION in ${BOOST_VERSIONS} -do - BOOST_SYMLINK_VER=$(echo "${BOOST_VERSION//[.]/_}") - BOOST_ROOT_VERSION="BOOST_ROOT_$BOOST_SYMLINK_VER" - - echo "$BOOST_ROOT_VERSION=$BOOST_LIB/$BOOST_VERSION/$BOOST_ARCH" | tee -a /etc/environment -done diff --git a/images/linux/scripts/installers/docker-moby.sh b/images/linux/scripts/installers/docker-moby.sh index c1d62be3..1037b220 100644 --- a/images/linux/scripts/installers/docker-moby.sh +++ b/images/linux/scripts/installers/docker-moby.sh @@ -27,6 +27,10 @@ else echo "Docker ($docker_package) is already installed" fi +# Enable docker.service +systemctl is-active --quiet docker.service || systemctl start docker.service +systemctl is-enabled --quiet docker.service || systemctl enable docker.service + # Run tests to determine that the software installed as expected echo "Testing to make sure that script performed as expected, and basic scenarios work" echo "Checking the docker-moby and moby-buildx" diff --git a/images/linux/scripts/installers/go.sh b/images/linux/scripts/installers/go.sh deleted file mode 100644 index d6f4a9c2..00000000 --- a/images/linux/scripts/installers/go.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -################################################################################ -## File: go.sh -## Desc: Installs go, configures GOROOT, and adds go to the path -################################################################################ - -# Fail out if any setups fail -set -e - -toolsetJson="$INSTALLER_SCRIPT_FOLDER/toolset.json" -toolsetVersions=(`ls $AGENT_TOOLSDIRECTORY/go`) -defaultVersion=$(jq -r '.toolcache[] | select(.name | contains("go")) | .default' $toolsetJson) - -for toolsetVersion in ${toolsetVersions[@]} -do - major="$(cut -d'.' -f1 <<< "$toolsetVersion")" - minor="$(cut -d'.' -f2 <<< "$toolsetVersion")" - goFolder="$AGENT_TOOLSDIRECTORY/go/$toolsetVersion/x64" - - echo "GOROOT_${major}_${minor}_X64=$goFolder" | tee -a /etc/environment - - if [[ "$toolsetVersion" =~ $defaultVersion ]]; then - ln -s $goFolder/bin/* /usr/bin/ - echo "GOROOT=$goFolder" | tee -a /etc/environment - fi -done \ No newline at end of file diff --git a/images/linux/toolcache-1604.json b/images/linux/toolsets/toolcache-1604.json similarity index 100% rename from images/linux/toolcache-1604.json rename to images/linux/toolsets/toolcache-1604.json diff --git a/images/linux/toolcache-1804.json b/images/linux/toolsets/toolcache-1804.json similarity index 100% rename from images/linux/toolcache-1804.json rename to images/linux/toolsets/toolcache-1804.json diff --git a/images/linux/toolcache-2004.json b/images/linux/toolsets/toolcache-2004.json similarity index 100% rename from images/linux/toolcache-2004.json rename to images/linux/toolsets/toolcache-2004.json diff --git a/images/linux/toolset-1604.json b/images/linux/toolsets/toolset-1604.json similarity index 100% rename from images/linux/toolset-1604.json rename to images/linux/toolsets/toolset-1604.json diff --git a/images/linux/toolset-1804.json b/images/linux/toolsets/toolset-1804.json similarity index 100% rename from images/linux/toolset-1804.json rename to images/linux/toolsets/toolset-1804.json diff --git a/images/linux/toolset-2004.json b/images/linux/toolsets/toolset-2004.json similarity index 100% rename from images/linux/toolset-2004.json rename to images/linux/toolsets/toolset-2004.json diff --git a/images/linux/ubuntu1604.json b/images/linux/ubuntu1604.json index bb58b775..66184753 100644 --- a/images/linux/ubuntu1604.json +++ b/images/linux/ubuntu1604.json @@ -247,12 +247,12 @@ }, { "type": "file", - "source": "{{template_dir}}/toolcache-1604.json", + "source": "{{template_dir}}/toolsets/toolcache-1604.json", "destination": "{{user `installer_script_folder`}}/toolcache.json" }, { "type": "file", - "source": "{{template_dir}}/toolset-1604.json", + "source": "{{template_dir}}/toolsets/toolset-1604.json", "destination": "{{user `installer_script_folder`}}/toolset.json" }, { @@ -278,6 +278,7 @@ "type": "shell", "scripts":[ "{{template_dir}}/scripts/installers/Install-Toolset.ps1", + "{{template_dir}}/scripts/installers/Configure-Toolset.ps1", "{{template_dir}}/scripts/installers/Validate-Toolset.ps1" ], "environment_vars": [ @@ -287,28 +288,6 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/go.sh" - ], - "environment_vars": [ - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts":[ - "{{template_dir}}/scripts/installers/boost.sh" - ], - "environment_vars": [ - "METADATA_FILE={{user `metadata_file`}}", - "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, { "type": "shell", "scripts":[ diff --git a/images/linux/ubuntu1804.json b/images/linux/ubuntu1804.json index 5cbabc00..41cc8c52 100644 --- a/images/linux/ubuntu1804.json +++ b/images/linux/ubuntu1804.json @@ -251,12 +251,12 @@ }, { "type": "file", - "source": "{{template_dir}}/toolcache-1804.json", + "source": "{{template_dir}}/toolsets/toolcache-1804.json", "destination": "{{user `installer_script_folder`}}/toolcache.json" }, { "type": "file", - "source": "{{template_dir}}/toolset-1804.json", + "source": "{{template_dir}}/toolsets/toolset-1804.json", "destination": "{{user `installer_script_folder`}}/toolset.json" }, { @@ -282,6 +282,7 @@ "type": "shell", "scripts":[ "{{template_dir}}/scripts/installers/Install-Toolset.ps1", + "{{template_dir}}/scripts/installers/Configure-Toolset.ps1", "{{template_dir}}/scripts/installers/Validate-Toolset.ps1" ], "environment_vars": [ @@ -291,28 +292,6 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/go.sh" - ], - "environment_vars": [ - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, - { - "type": "shell", - "scripts":[ - "{{template_dir}}/scripts/installers/boost.sh" - ], - "environment_vars": [ - "METADATA_FILE={{user `metadata_file`}}", - "HELPER_SCRIPTS={{user `helper_script_folder`}}", - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, { "type": "shell", "scripts":[ diff --git a/images/linux/ubuntu2004.json b/images/linux/ubuntu2004.json index f4131a45..611fdc6b 100644 --- a/images/linux/ubuntu2004.json +++ b/images/linux/ubuntu2004.json @@ -252,12 +252,12 @@ }, { "type": "file", - "source": "{{template_dir}}/toolcache-2004.json", + "source": "{{template_dir}}/toolsets/toolcache-2004.json", "destination": "{{user `installer_script_folder`}}/toolcache.json" }, { "type": "file", - "source": "{{template_dir}}/toolset-2004.json", + "source": "{{template_dir}}/toolsets/toolset-2004.json", "destination": "{{user `installer_script_folder`}}/toolset.json" }, { @@ -283,6 +283,7 @@ "type": "shell", "scripts":[ "{{template_dir}}/scripts/installers/Install-Toolset.ps1", + "{{template_dir}}/scripts/installers/Configure-Toolset.ps1", "{{template_dir}}/scripts/installers/Validate-Toolset.ps1" ], "environment_vars": [ @@ -292,16 +293,6 @@ ], "execute_command": "sudo sh -c '{{ .Vars }} pwsh -f {{ .Path }}'" }, - { - "type": "shell", - "scripts": [ - "{{template_dir}}/scripts/installers/go.sh" - ], - "environment_vars": [ - "INSTALLER_SCRIPT_FOLDER={{user `installer_script_folder`}}" - ], - "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'" - }, { "type": "shell", "scripts":[ diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 5baec7c1..c65be16e 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -337,12 +337,12 @@ }, { "type": "file", - "source": "{{template_dir}}/toolcache-2016.json", + "source": "{{template_dir}}/toolsets/toolcache-2016.json", "destination": "{{user `root_folder`}}/toolcache.json" }, { "type": "file", - "source": "{{template_dir}}/toolset-2016.json", + "source": "{{template_dir}}/toolsets/toolset-2016.json", "destination": "{{user `toolset_json_path`}}" }, { @@ -370,16 +370,8 @@ "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" ], "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1" - ] - }, - { - "type": "powershell", - "environment_vars":[ - "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" - ], - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Go.ps1" + "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1", + "{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1" ] }, { @@ -606,16 +598,6 @@ "{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1" ] }, - { - "type": "powershell", - "environment_vars": [ - "ROOT_FOLDER={{user `root_folder`}}", - "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" - ], - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Boost.ps1" - ] - }, { "type": "powershell", "scripts":[ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 8f512506..8b17eae4 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -304,12 +304,12 @@ }, { "type": "file", - "source": "{{template_dir}}/toolcache-2019.json", + "source": "{{template_dir}}/toolsets/toolcache-2019.json", "destination": "{{user `root_folder`}}/toolcache.json" }, { "type": "file", - "source": "{{template_dir}}/toolset-2019.json", + "source": "{{template_dir}}/toolsets/toolset-2019.json", "destination": "{{user `toolset_json_path`}}" }, { @@ -337,16 +337,8 @@ "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" ], "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1" - ] - }, - { - "type": "powershell", - "environment_vars":[ - "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" - ], - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Go.ps1" + "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1", + "{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1" ] }, { @@ -567,16 +559,6 @@ "{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1" ] }, - { - "type": "powershell", - "environment_vars": [ - "ROOT_FOLDER={{user `root_folder`}}", - "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" - ], - "scripts":[ - "{{ template_dir }}/scripts/Installers/Install-Boost.ps1" - ] - }, { "type": "powershell", "scripts":[ diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index c4485493..95a7d6c7 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -16,6 +16,7 @@ Export-ModuleMember -Function @( 'Install-VisualStudio' 'Get-ToolcachePackages' 'Get-ToolsetContent' + 'Get-ToolsetToolFullPath' 'Get-ToolsByName' 'Stop-SvcWithErrHandling' 'Set-SvcWithErrHandling' diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index b4e28705..af82e378 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -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, diff --git a/images/win/scripts/Installers/Configure-Toolset.ps1 b/images/win/scripts/Installers/Configure-Toolset.ps1 new file mode 100644 index 00000000..07594eb1 --- /dev/null +++ b/images/win/scripts/Installers/Configure-Toolset.ps1 @@ -0,0 +1,84 @@ +################################################################################ +## File: Configure-Toolset.ps1 +## Team: CI-Build +## Desc: Configure Toolset +################################################################################ + +Function Set-DefaultVariables +{ + param + ( + [Parameter(Mandatory=$true)] + [object] $EnvVars, + [Parameter(Mandatory=$true)] + [string] $ToolVersionPath + ) + + $templates = $EnvVars.pathTemplates + foreach ($template in $templates) + { + $toolSystemPath = $template -f $ToolVersionPath + Add-MachinePathItem -PathItem $toolSystemPath | Out-Null + } + + if (-not ([string]::IsNullOrEmpty($EnvVars.defaultVariable))) + { + setx $toolEnvVars.defaultVariable $ToolVersionPath /M | Out-Null + } +} + +$ErrorActionPreference = "Stop" + +Import-Module -Name ImageHelpers -Force -DisableNameChecking + +# Define executables for cached tools +$toolsEnvironmentVariables = @{ + Python = @{ + pathTemplates = @( + "{0}", + "{0}\Scripts" + ) + } + Boost = @{ + variableTemplate = "BOOST_ROOT_{0}_{1}_{2}" + } + go = @{ + pathTemplates = @( + "{0}\bin" + ) + defaultVariable = "GOROOT" + variableTemplate = "GOROOT_{0}_{1}_X64" + } +} + +$toolsToConfigure = @("Python", "Boost", "Go") +$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache ` + | Where-Object { $toolsToConfigure -contains $_.name } + +Write-Host "Configure toolset tools environment..." +foreach ($tool in $tools) +{ + $toolEnvVars = $toolsEnvironmentVariables[$tool.name] + + if (-not ([string]::IsNullOrEmpty($toolEnvVars.variableTemplate))) + { + foreach ($version in $tool.versions) + { + Write-Host "Set $($tool.name) $version environment variable..." + + $foundVersionArchPath = Get-ToolsetToolFullPath -Name $tool.name -Version $version -Arch $tool.arch + $envName = $toolEnvVars.variableTemplate -f $version.Split(".") + + setx $envName $foundVersionArchPath /M | Out-Null + } + } + + if (-not ([string]::IsNullOrEmpty($tool.default))) + { + Write-Host "Use $($tool.name) $($tool.default) as a system $($tool.name)..." + + $toolVersionPath = Get-ToolsetToolFullPath -Name $tool.name -Version $tool.default -Arch $tool.arch + + Set-DefaultVariables -ToolVersionPath $toolVersionPath -EnvVars $toolEnvVars + } +} \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Boost.ps1 b/images/win/scripts/Installers/Install-Boost.ps1 deleted file mode 100644 index a11013fe..00000000 --- a/images/win/scripts/Installers/Install-Boost.ps1 +++ /dev/null @@ -1,19 +0,0 @@ -################################################################################ -## File: Set-BoostRoot.ps1 -## Team: CI-Build -## Desc: Install boost using tool cache -################################################################################ - -Import-Module -Name ImageHelpers - -$SoftwareName = "Boost" -$BoostDirectory = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath $SoftwareName -$BoostVersions = (Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object { $_.Name -eq "Boost"}).Versions - -foreach($BoostVersion in $BoostVersions) -{ - $BoostInstallationDir = Join-Path -Path $BoostDirectory -ChildPath "$BoostVersion\X86_64" - - $EnvBoostPath = "BOOST_ROOT_{0}" -f ($BoostVersion.Replace('.', '_')) - setx $EnvBoostPath $BoostInstallationDir /M | Out-Null -} diff --git a/images/win/scripts/Installers/Install-Go.ps1 b/images/win/scripts/Installers/Install-Go.ps1 deleted file mode 100644 index 53a8278e..00000000 --- a/images/win/scripts/Installers/Install-Go.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -################################################################################ -## File: Install-Go.ps1 -## Desc: Install Go -################################################################################ - -Import-Module -Name ImageHelpers -Force -DisableNameChecking - -# Get Go content from toolset -$goTool = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object Name -eq "go" - -$toolPath = Join-Path $env:AGENT_TOOLSDIRECTORY $goTool.name -foreach($goVersion in $goTool.versions) -{ - if ($goVersion.Split(".").Length -lt 3) { - $goVersion += ".*" - } - $expectedVersionPath = Join-Path $toolPath $goVersion - $foundVersion = Get-Item $expectedVersionPath ` - | Sort-Object -Property {[version]$_.name} -Descending ` - | Select-Object -First 1 - # Check for required architecture folder - $foundVersionArchPath = Join-Path $foundVersion $goTool.arch - $envName = "GOROOT_{0}_{1}_X64" -f $goVersion.split(".") - setx $envName "$foundVersionArchPath" /M -} \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Toolset.ps1 b/images/win/scripts/Installers/Install-Toolset.ps1 index ffdcc15b..cc0a0aa7 100644 --- a/images/win/scripts/Installers/Install-Toolset.ps1 +++ b/images/win/scripts/Installers/Install-Toolset.ps1 @@ -29,47 +29,6 @@ Function Install-Asset { Pop-Location } -Function Set-DefaultPythonVersion { - param( - [Parameter(Mandatory=$true)] - [object[]] $Toolset - ) - - $python = $Toolset | Where-Object { ($_.name -eq "Python") -and ($_.default -ne "") } ` - | Select-Object default, arch -First 1 - - if ($python.default -ne $null) { - $pythonPath = Join-Path $Env:AGENT_TOOLSDIRECTORY "/Python/$($python.default)/$($python.arch)" -Resolve - - Write-Host "Use Python $($python.default) as a system Python" - Add-MachinePathItem -PathItem $pythonPath - Add-MachinePathItem -PathItem "$pythonPath\Scripts" - } else { - Write-Host "Default Python version not found in toolset file!" - } -} - -Function Set-DefaultGoVersion { - param( - [Parameter(Mandatory=$true)] - [object[]] $Toolset - ) - - $goToolset = $Toolset | Where-Object { ($_.name -eq "go") -and ($_.default -ne "") } ` - | Select-Object default, arch -First 1 - - if ($goToolset.default -ne $null) { - $goPath = Join-Path $Env:AGENT_TOOLSDIRECTORY "/go/$($goToolset.default)/$($goToolset.arch)" -Resolve - - Write-Host "Use Go $($goToolset.default) as a system Go" - Add-MachinePathItem -PathItem "$goPath\bin" | Out-Null - # Set the GOROOT environment variable. - setx GOROOT "$goPath" /M | Out-Null - } else { - Write-Host "Default Go version not found in toolset file!" - } -} - $ErrorActionPreference = "Stop" Import-Module -Name ImageHelpers -Force @@ -92,15 +51,11 @@ foreach ($tool in $tools) { | Select-Object -First 1 Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..." - if ($asset -ne $null) { + if ($null -ne $asset) { Install-Asset -ReleaseAsset $asset } else { Write-Host "Asset was not found in versions manifest" exit 1 } } -} - -# Install default python version -Set-DefaultPythonVersion -Toolset $tools -Set-DefaultGoVersion -Toolset $tools \ No newline at end of file +} \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-Toolset.ps1 b/images/win/scripts/Installers/Validate-Toolset.ps1 index 9217e009..93dcc9bd 100644 --- a/images/win/scripts/Installers/Validate-Toolset.ps1 +++ b/images/win/scripts/Installers/Validate-Toolset.ps1 @@ -75,34 +75,11 @@ $toolsExecutables = @{ $tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache foreach($tool in $tools) { - $toolPath = Join-Path $env:AGENT_TOOLSDIRECTORY $tool.name # Get executables for current tool $toolExecs = $toolsExecutables[$tool.name] foreach ($version in $tool.versions) { - # 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 $($tool.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 $tool.arch - if (-not (Test-Path $foundVersionArchPath)) { - Write-Host "Expected $($tool.name)($($tool.arch)) $($foundVersion.name) architecture folder is not found!" - exit 1 - } + $foundVersionArchPath = Get-ToolsetToolFullPath -Name $tool.name -Version $version -Arch $tool.arch if ($toolExecs) { Write-Host "Run validation test for $($tool.name)($($tool.arch)) $($foundVersion.name) executables..." diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 1d380743..a87bde94 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -156,7 +156,6 @@ $markdown += New-MDHeader ".NET Core Runtime" -Level 3 Get-DotnetRuntimes | Foreach-Object { $path = $_.Path $versions = $_.Versions - $markdown += "``Type: Developer Pack``" $markdown += "``Location: $path``" $markdown += New-MDNewLine $markdown += New-MDList -Lines $versions -Style Unordered @@ -164,6 +163,8 @@ Get-DotnetRuntimes | Foreach-Object { $markdown += New-MDHeader ".NET Framework" -Level 3 $frameworks = Get-DotnetFrameworkTools +$markdown += "``Type: Developer Pack``" +$markdown += New-MDNewLine $markdown += "``Location $($frameworks.Path)``" $markdown += New-MDNewLine $markdown += New-MDList -Lines $frameworks.Versions -Style Unordered diff --git a/images/win/toolcache-2016.json b/images/win/toolsets/toolcache-2016.json similarity index 100% rename from images/win/toolcache-2016.json rename to images/win/toolsets/toolcache-2016.json diff --git a/images/win/toolcache-2019.json b/images/win/toolsets/toolcache-2019.json similarity index 100% rename from images/win/toolcache-2019.json rename to images/win/toolsets/toolcache-2019.json diff --git a/images/win/toolset-2016.json b/images/win/toolsets/toolset-2016.json similarity index 100% rename from images/win/toolset-2016.json rename to images/win/toolsets/toolset-2016.json diff --git a/images/win/toolset-2019.json b/images/win/toolsets/toolset-2019.json similarity index 100% rename from images/win/toolset-2019.json rename to images/win/toolsets/toolset-2019.json