From 018d52547b566c396f241e188becafee1d1ed513 Mon Sep 17 00:00:00 2001 From: MaksimZhukov Date: Thu, 2 Apr 2020 15:03:35 +0300 Subject: [PATCH 1/9] Add Toolset provision for Windows --- images/win/Windows2016-Azure.json | 24 +++++ images/win/Windows2019-Azure.json | 24 +++++ .../scripts/ImageHelpers/ImageHelpers.psm1 | 1 + .../scripts/ImageHelpers/InstallHelpers.ps1 | 5 + .../scripts/Installers/Download-ToolCache.ps1 | 16 --- .../scripts/Installers/Install-Toolset.ps1 | 70 ++++++++++++ .../scripts/Installers/Validate-Toolset.ps1 | 101 ++++++++++++++++++ images/win/toolcache-2016.json | 6 -- images/win/toolcache-2019.json | 6 -- images/win/toolset-2016.json | 32 ++++++ images/win/toolset-2019.json | 32 ++++++ 11 files changed, 289 insertions(+), 28 deletions(-) create mode 100644 images/win/scripts/Installers/Install-Toolset.ps1 create mode 100644 images/win/scripts/Installers/Validate-Toolset.ps1 create mode 100644 images/win/toolset-2016.json create mode 100644 images/win/toolset-2019.json diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index f7753eb9aad0..bd14a948a597 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -18,6 +18,7 @@ "run_scan_antivirus": "false", "root_folder": "C:", + "toolset_json_path": "{{env `TEMP`}}\\toolset.json", "image_folder": "C:\\image", "commit_file": "C:\\image\\commit.txt", "imagedata_file": "C:\\imagedata.json", @@ -316,6 +317,11 @@ "source": "{{template_dir}}/toolcache-2016.json", "destination": "{{user `root_folder`}}/toolcache.json" }, + { + "type": "file", + "source": "{{template_dir}}/toolset-2016.json", + "destination": "{{user `toolset_json_path`}}" + }, { "type": "powershell", "environment_vars":[ @@ -326,6 +332,15 @@ "{{ template_dir }}/scripts/Installers/Download-ToolCache.ps1" ] }, + { + "type": "powershell", + "environment_vars":[ + "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" + ], + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -636,6 +651,15 @@ "{{ template_dir }}/scripts/Installers/Validate-ToolCache.ps1" ] }, + { + "type": "powershell", + "environment_vars":[ + "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" + ], + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-Toolset.ps1" + ] + }, { "type": "powershell", "scripts":[ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 424c7b8531d7..f477a75c6373 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -18,6 +18,7 @@ "run_scan_antivirus": "false", "root_folder": "C:", + "toolset_json_path": "{{env `TEMP`}}\\toolset.json", "image_folder": "C:\\image", "commit_file": "C:\\image\\commit.txt", "imagedata_file": "C:\\imagedata.json", @@ -291,6 +292,11 @@ "source": "{{template_dir}}/toolcache-2019.json", "destination": "{{user `root_folder`}}/toolcache.json" }, + { + "type": "file", + "source": "{{template_dir}}/toolset-2019.json", + "destination": "{{user `toolset_json_path`}}" + }, { "type": "powershell", "environment_vars":[ @@ -301,6 +307,15 @@ "{{ template_dir }}/scripts/Installers/Download-ToolCache.ps1" ] }, + { + "type": "powershell", + "environment_vars":[ + "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" + ], + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1" + ] + }, { "type": "powershell", "scripts":[ @@ -629,6 +644,15 @@ "{{ template_dir }}/scripts/Installers/Validate-ToolCache.ps1" ] }, + { + "type": "powershell", + "environment_vars":[ + "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" + ], + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-Toolset.ps1" + ] + }, { "type": "powershell", "scripts":[ diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index c40b10989bc2..f2efeed3b1df 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -15,6 +15,7 @@ Export-ModuleMember -Function @( 'Install-MSI' 'Install-EXE' 'Get-ToolcachePackages' + 'Get-ToolsetContent' 'Get-ToolsByName' 'Add-ContentToMarkdown' 'Add-SoftwareDetailsToMarkdown' diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index 03c4b98f8f36..2fdabe74bf95 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -294,6 +294,11 @@ function Get-ToolcachePackages { Get-Content -Raw $toolcachePath | ConvertFrom-Json } +function Get-ToolsetContent { + $toolsetJson = Get-Content -Path $env:TOOLSET_JSON_PATH -Raw + ConvertFrom-Json -InputObject $toolsetJson +} + function Get-ToolsByName { param ( [Parameter(Mandatory = $True)] diff --git a/images/win/scripts/Installers/Download-ToolCache.ps1 b/images/win/scripts/Installers/Download-ToolCache.ps1 index cc42e97ece22..d79d1793f0e2 100644 --- a/images/win/scripts/Installers/Download-ToolCache.ps1 +++ b/images/win/scripts/Installers/Download-ToolCache.ps1 @@ -44,21 +44,6 @@ Function NPMFeed-AuthSetup { $npmrcContent | Out-File -FilePath "$($env:TEMP)/.npmrc" -Encoding utf8 } -Function Set-DefaultPythonVersion { - param( - [Parameter(Mandatory=$true)] - [System.Version] $Version, - [System.String] $Arch = "x64" - ) - - $pythonPath = $Env:AGENT_TOOLSDIRECTORY + "/Python/${Version}*/${Arch}" - $pythonDir = Get-Item -Path $pythonPath - - Write-Host "Use Python ${Version} as a system Python" - Add-MachinePathItem -PathItem $pythonDir.FullName - Add-MachinePathItem -PathItem "$($pythonDir.FullName)\Scripts" -} - Function Set-DefaultRubyVersion { param( [Parameter(Mandatory=$true)] @@ -104,5 +89,4 @@ $ToolVersions.PSObject.Properties | ForEach-Object { } } -Set-DefaultPythonVersion -Version "3.7" Set-DefaultRubyVersion -Version "2.5" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Toolset.ps1 b/images/win/scripts/Installers/Install-Toolset.ps1 new file mode 100644 index 000000000000..a70adf41222b --- /dev/null +++ b/images/win/scripts/Installers/Install-Toolset.ps1 @@ -0,0 +1,70 @@ +################################################################################ +## File: Install-Toolset.ps1 +## Team: CI-Build +## Desc: Install toolset +################################################################################ + +Function Install-Asset { + param( + [Parameter(Mandatory=$true)] + [object] $ReleaseAsset + ) + + $releaseAssetName = [System.IO.Path]::GetFileNameWithoutExtension($ReleaseAsset.filename) + $assetFolderPath = Join-Path $env:TEMP $releaseAssetName + $assetArchivePath = Start-DownloadWithRetry -Url $ReleaseAsset.download_url -Name $ReleaseAsset.filename + + Write-Host "Expand $($ReleaseAsset.filename) archive to the $assetFolderPath folder..." + 7z.exe x $assetArchivePath -o"$assetFolderPath" -y + + Write-Host "Invoke installation script..." + Push-Location -Path $assetFolderPath + Invoke-Expression .\setup.ps1 + 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 + $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" +} + +$ErrorActionPreference = "Stop" + +Import-Module -Name ImageHelpers -Force + +# Get toolcache content from toolset +$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache + +foreach ($tool in $tools) { + # Get versions manifest for current tool + $assets = Invoke-RestMethod $tool.url + + # Get github release asset for each version + foreach ($toolVersion in $tool.versions) { + $asset = $assets | Where-Object version -like $toolVersion ` + | Select-Object -ExpandProperty files ` + | Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $tool.arch) } ` + | Select-Object -First 1 + + Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..." + if ($asset -ne $null) { + Install-Asset -ReleaseAsset $asset + } else { + Write-Host "Asset was not found in versions manifest" + exit 1 + } + } +} + +# Install default python version +Set-DefaultPythonVersion -Toolset $tools \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-Toolset.ps1 b/images/win/scripts/Installers/Validate-Toolset.ps1 new file mode 100644 index 000000000000..ad2f1a904c96 --- /dev/null +++ b/images/win/scripts/Installers/Validate-Toolset.ps1 @@ -0,0 +1,101 @@ +################################################################################ +## File: Validate-Toolset.ps1 +## Team: CI-Build +## Desc: Validate Toolset +################################################################################ + +function Run-ExecutableTests { + param ( + [Parameter(Mandatory)] [string[]] $Executables, + [Parameter(Mandatory)] [string] $ToolPath + ) + + foreach ($executable in $Executables) { + $executablePath = Join-Path $ToolPath $executable + + Write-Host "Check $executable..." + if (Test-Path $executablePath) { + Write-Host "$executable is successfully installed: $(& $executablePath --version)" + } else { + Write-Host "$executablePath is not installed!" + exit 1 + } + } +} + +function Validate-SystemDefaultTool { + param ( + [Parameter(Mandatory)] [string] $ToolName, + [Parameter(Mandatory)] [string] $ExpectedVersion + ) + + $binName = $ToolName.ToLower() + + # Check if tool on path + if (Get-Command -Name $binName) { + $versionOnPath = $(& $binName --version 2>&1) | Select-String -Pattern ".*(\d+\.\d+\.\d+)" + $versionBinPath = Split-Path -Path (Get-Command -Name $binName).Path + + # Check if version is correct + if ($versionOnPath.matches.Groups[1].Value -notlike $ExpectedVersion) { + Write-Error "$ToolName $ExpectedVersion is not in the PATH" + exit 1 + } + + Write-Host "$ToolName $versionOnPath on path" + } else { + Write-Host "$ToolName is not on path" + exit 1 + } + + # Add default version description to markdown + $description = "
__System default version:__ $versionOnPath
" + $description += "_Environment:_
" + $description += "* Location: $versionBinPath
" + $description += "* PATH: contains the location of $versionOnPath
" + + return $description +} + +$ErrorActionPreference = "Stop" + +Import-Module -Name ImageHelpers -Force + +# Define executables for cached tools +$toolsExecutables = @{ Python = @("python.exe", "Scripts\pip.exe") } + +# Get toolcache content from toolset +$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache + +foreach($tool in $tools) { + $markdownDescription = "" + + $toolPath = Join-Path $env:AGENT_TOOLSDIRECTORY $tool.name + # Get executables for current tool + $toolExecs = $toolsExecutables[$tool.name] + + foreach ($version in $tool.versions) { + # Check if version folder exists + $foundVersionPath = Join-Path $toolPath $version | Join-Path -ChildPath $tool.arch | Get-Item + if ($foundVersionPath -eq $null) { + Write-Host "Expected $($tool.name) $version ($($tool.arch)) folder is not installed!" + exit 1 + } + + $foundVersion = $($foundVersionPath.parent.fullname.Split("\")[-1]) + + Write-Host "Run validation test for $($tool.name)($($tool.arch)) $foundVersion executables..." + Run-ExecutableTests -Executables $toolExecs -ToolPath $foundVersionPath + + # Add to tool version to markdown + $markdownDescription += "_Version:_ $foundVersion
" + } + + # Create markdown description for system default tool + if ($tool.default -ne "") { + Write-Host "Validate system default $($tool.name)($($tool.arch)) $($tool.default)..." + $markdownDescription += Validate-SystemDefaultTool -ToolName $tool.name -ExpectedVersion $tool.default + } + + Add-SoftwareDetailsToMarkdown -SoftwareName "$($tool.name) ($($tool.arch))" -DescriptionMarkdown $markdownDescription +} \ No newline at end of file diff --git a/images/win/toolcache-2016.json b/images/win/toolcache-2016.json index 8db575c23b3b..1b4f1a6c7c50 100644 --- a/images/win/toolcache-2016.json +++ b/images/win/toolcache-2016.json @@ -1,10 +1,4 @@ { - "@actions/toolcache-python-windows-x64": [ - "2.7", "3.5", "3.6", "3.7", "3.8" - ], - "@actions/toolcache-python-windows-x86": [ - "2.7", "3.5", "3.6", "3.7", "3.8" - ], "@actions/toolcache-ruby-windows-x64": [ "2.4", "2.5", "2.6", "2.7" ], diff --git a/images/win/toolcache-2019.json b/images/win/toolcache-2019.json index 4f946cfaf442..6873c14e5765 100644 --- a/images/win/toolcache-2019.json +++ b/images/win/toolcache-2019.json @@ -1,10 +1,4 @@ { - "@actions/toolcache-python-windows-x64": [ - "2.7", "3.5", "3.6", "3.7", "3.8" - ], - "@actions/toolcache-python-windows-x86": [ - "2.7", "3.5", "3.6", "3.7", "3.8" - ], "@actions/toolcache-ruby-windows-x64": [ "2.4", "2.5", "2.6", "2.7" ], diff --git a/images/win/toolset-2016.json b/images/win/toolset-2016.json new file mode 100644 index 000000000000..44f017712134 --- /dev/null +++ b/images/win/toolset-2016.json @@ -0,0 +1,32 @@ +{ + "toolcache": [ + { + "name": "Python", + "url" : "https://raw.githubusercontent.com/akv-platform/toolcache-python-generation/master/versions-manifest.json", + "arch": "x64", + "platform" : "win32", + "versions": [ + "2.7.*", + "3.5.*", + "3.6.*", + "3.7.*", + "3.8.*" + ], + "default": "3.7.*" + }, + { + "name": "Python", + "url" : "https://raw.githubusercontent.com/akv-platform/toolcache-python-generation/master/versions-manifest.json", + "arch": "x86", + "platform" : "win32", + "versions": [ + "2.7.*", + "3.5.*", + "3.6.*", + "3.7.*", + "3.8.*" + ], + "default": "" + } + ] +} \ No newline at end of file diff --git a/images/win/toolset-2019.json b/images/win/toolset-2019.json new file mode 100644 index 000000000000..44f017712134 --- /dev/null +++ b/images/win/toolset-2019.json @@ -0,0 +1,32 @@ +{ + "toolcache": [ + { + "name": "Python", + "url" : "https://raw.githubusercontent.com/akv-platform/toolcache-python-generation/master/versions-manifest.json", + "arch": "x64", + "platform" : "win32", + "versions": [ + "2.7.*", + "3.5.*", + "3.6.*", + "3.7.*", + "3.8.*" + ], + "default": "3.7.*" + }, + { + "name": "Python", + "url" : "https://raw.githubusercontent.com/akv-platform/toolcache-python-generation/master/versions-manifest.json", + "arch": "x86", + "platform" : "win32", + "versions": [ + "2.7.*", + "3.5.*", + "3.6.*", + "3.7.*", + "3.8.*" + ], + "default": "" + } + ] +} \ No newline at end of file From 35153d343fff6a2fcfdba3858959473ae3f34059 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Fri, 10 Apr 2020 00:48:49 +0300 Subject: [PATCH 2/9] Fix version sort in Install-Toolset --- images/win/scripts/Installers/Install-Toolset.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/images/win/scripts/Installers/Install-Toolset.ps1 b/images/win/scripts/Installers/Install-Toolset.ps1 index a70adf41222b..23e36218c5ef 100644 --- a/images/win/scripts/Installers/Install-Toolset.ps1 +++ b/images/win/scripts/Installers/Install-Toolset.ps1 @@ -52,6 +52,7 @@ foreach ($tool in $tools) { # Get github release asset for each version foreach ($toolVersion in $tool.versions) { $asset = $assets | Where-Object version -like $toolVersion ` + | Sort-Object -Property {[version]$_.version} -Descending ` | Select-Object -ExpandProperty files ` | Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $tool.arch) } ` | Select-Object -First 1 From 16f25e4a1001c96fd8ce3198a6dfd6b1a2d8ee27 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Fri, 10 Apr 2020 18:51:39 +0300 Subject: [PATCH 3/9] Fix for Validate-Toolset for windows --- .../scripts/Installers/Validate-Toolset.ps1 | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/images/win/scripts/Installers/Validate-Toolset.ps1 b/images/win/scripts/Installers/Validate-Toolset.ps1 index ad2f1a904c96..5138c47c9f2a 100644 --- a/images/win/scripts/Installers/Validate-Toolset.ps1 +++ b/images/win/scripts/Installers/Validate-Toolset.ps1 @@ -76,16 +76,26 @@ foreach($tool in $tools) { foreach ($version in $tool.versions) { # Check if version folder exists - $foundVersionPath = Join-Path $toolPath $version | Join-Path -ChildPath $tool.arch | Get-Item - if ($foundVersionPath -eq $null) { - Write-Host "Expected $($tool.name) $version ($($tool.arch)) folder is not installed!" + $foundVersionPath = Join-Path $toolPath $version + if (-not (Test-Path $foundVersionPath)) { + Write-Host "Expected $($tool.name) $version folder is not found!" exit 1 } - $foundVersion = $($foundVersionPath.parent.fullname.Split("\")[-1]) + # Take latest installed version in case if toolset version contains wildcards + $foundVersion = Get-Item $foundVersionPath + | Sort-Object -Property {[version]$_.name} -Descending + | Select-Object -First 1 + + # Check for required architecture folder + $foundVersionArchPath = Join-Path $foundVersionPath $tool.arch + if (-not (Test-Path $foundVersionArchPath)) { + Write-Host "Expected $($tool.name)($($tool.arch)) $foundVersion folder is not found!" + exit 1 + } Write-Host "Run validation test for $($tool.name)($($tool.arch)) $foundVersion executables..." - Run-ExecutableTests -Executables $toolExecs -ToolPath $foundVersionPath + Run-ExecutableTests -Executables $toolExecs -ToolPath $foundVersionArchPath # Add to tool version to markdown $markdownDescription += "_Version:_ $foundVersion
" From 9599a3623876e01a6a3a7b801cc15ecdc05a718b Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Fri, 10 Apr 2020 19:06:14 +0300 Subject: [PATCH 4/9] Fix for Validate-Toolset for windows --- images/win/scripts/Installers/Validate-Toolset.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/images/win/scripts/Installers/Validate-Toolset.ps1 b/images/win/scripts/Installers/Validate-Toolset.ps1 index 5138c47c9f2a..b812beffc1e0 100644 --- a/images/win/scripts/Installers/Validate-Toolset.ps1 +++ b/images/win/scripts/Installers/Validate-Toolset.ps1 @@ -76,29 +76,29 @@ foreach($tool in $tools) { foreach ($version in $tool.versions) { # Check if version folder exists - $foundVersionPath = Join-Path $toolPath $version - if (-not (Test-Path $foundVersionPath)) { + $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 $foundVersionPath + $foundVersionPath = Get-Item $expectedVersionPath | Sort-Object -Property {[version]$_.name} -Descending | Select-Object -First 1 # Check for required architecture folder $foundVersionArchPath = Join-Path $foundVersionPath $tool.arch if (-not (Test-Path $foundVersionArchPath)) { - Write-Host "Expected $($tool.name)($($tool.arch)) $foundVersion folder is not found!" + Write-Host "Expected $($tool.name)($($tool.arch)) $($foundVersion.name) folder is not found!" exit 1 } - Write-Host "Run validation test for $($tool.name)($($tool.arch)) $foundVersion executables..." + Write-Host "Run validation test for $($tool.name)($($tool.arch)) $($foundVersion.name) executables..." Run-ExecutableTests -Executables $toolExecs -ToolPath $foundVersionArchPath # Add to tool version to markdown - $markdownDescription += "_Version:_ $foundVersion
" + $markdownDescription += "_Version:_ $($foundVersion.name)
" } # Create markdown description for system default tool From 00323b35ff72d9a77d637cbd8b855ceac950cc83 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Fri, 10 Apr 2020 19:16:12 +0300 Subject: [PATCH 5/9] Fix for Validate-Toolset for windows --- images/win/scripts/Installers/Validate-Toolset.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/images/win/scripts/Installers/Validate-Toolset.ps1 b/images/win/scripts/Installers/Validate-Toolset.ps1 index b812beffc1e0..089a6bb72a27 100644 --- a/images/win/scripts/Installers/Validate-Toolset.ps1 +++ b/images/win/scripts/Installers/Validate-Toolset.ps1 @@ -83,14 +83,14 @@ foreach($tool in $tools) { } # Take latest installed version in case if toolset version contains wildcards - $foundVersionPath = Get-Item $expectedVersionPath + $foundVersion = Get-Item $expectedVersionPath | Sort-Object -Property {[version]$_.name} -Descending | Select-Object -First 1 # Check for required architecture folder - $foundVersionArchPath = Join-Path $foundVersionPath $tool.arch + $foundVersionArchPath = Join-Path $foundVersion $tool.arch if (-not (Test-Path $foundVersionArchPath)) { - Write-Host "Expected $($tool.name)($($tool.arch)) $($foundVersion.name) folder is not found!" + Write-Host "Expected $($tool.name)($($tool.arch)) $($foundVersion.name) architecture folder is not found!" exit 1 } From c6aa5e0acab52d695d8ea8dd5ff74bdaaae1ea7a Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Fri, 10 Apr 2020 19:37:11 +0300 Subject: [PATCH 6/9] Fix in syntax --- images/win/scripts/Installers/Validate-Toolset.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/win/scripts/Installers/Validate-Toolset.ps1 b/images/win/scripts/Installers/Validate-Toolset.ps1 index 089a6bb72a27..6bf04a58bc17 100644 --- a/images/win/scripts/Installers/Validate-Toolset.ps1 +++ b/images/win/scripts/Installers/Validate-Toolset.ps1 @@ -83,8 +83,8 @@ foreach($tool in $tools) { } # Take latest installed version in case if toolset version contains wildcards - $foundVersion = Get-Item $expectedVersionPath - | Sort-Object -Property {[version]$_.name} -Descending + $foundVersion = Get-Item $expectedVersionPath ` + | Sort-Object -Property {[version]$_.name} -Descending ` | Select-Object -First 1 # Check for required architecture folder From 57ac745874f187b9b612027c741d3e60ded8e4b2 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Fri, 10 Apr 2020 20:24:55 +0300 Subject: [PATCH 7/9] Fix for default Python version installation and validation --- .../scripts/Installers/Install-Toolset.ps1 | 13 +++++--- .../scripts/Installers/Validate-ToolCache.ps1 | 33 ------------------- .../scripts/Installers/Validate-Toolset.ps1 | 2 +- images/win/toolset-2016.json | 3 +- images/win/toolset-2019.json | 3 +- 5 files changed, 12 insertions(+), 42 deletions(-) diff --git a/images/win/scripts/Installers/Install-Toolset.ps1 b/images/win/scripts/Installers/Install-Toolset.ps1 index 23e36218c5ef..d2c91c6e82f1 100644 --- a/images/win/scripts/Installers/Install-Toolset.ps1 +++ b/images/win/scripts/Installers/Install-Toolset.ps1 @@ -31,11 +31,16 @@ Function Set-DefaultPythonVersion { $python = $Toolset | Where-Object { ($_.name -eq "Python") -and ($_.default -ne "") } ` | Select-Object default, arch -First 1 - $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" + 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!" + } } $ErrorActionPreference = "Stop" diff --git a/images/win/scripts/Installers/Validate-ToolCache.ps1 b/images/win/scripts/Installers/Validate-ToolCache.ps1 index 5ad500bf444f..526254e2b612 100644 --- a/images/win/scripts/Installers/Validate-ToolCache.ps1 +++ b/images/win/scripts/Installers/Validate-ToolCache.ps1 @@ -63,32 +63,6 @@ function RunTestsByPath { } } -function Get-SystemDefaultPython { - Write-Host "Validate system Python..." - - if (Get-Command -Name 'python') - { - Write-Host "Python $(& python -V 2>&1) on path" - } - else - { - Write-Host "Python is not on path" - exit 1 - } - - $pythonBinVersion = $(& python -V 2>&1) - if ($pythonBinVersion -notlike "Python 3.*") - { - Write-Error "Python 3 is not in the PATH" - exit 1 - } - - $pythonBinOnPath = Split-Path -Path (Get-Command -Name 'python').Path - $description = GetDefaultToolDescription -SoftwareVersion $pythonBinVersion -SoftwareLocation $pythonBinOnPath - - return $description -} - function Get-SystemDefaultRuby { Write-Host "Validate system Ruby..." @@ -196,9 +170,6 @@ function ToolcacheTest { } } - if ($SoftwareName -contains "Python") { - $markdownDescription += Get-SystemDefaultPython - } if ($SoftwareName -contains "Ruby") { $markdownDescription += Get-SystemDefaultRuby } @@ -206,10 +177,6 @@ function ToolcacheTest { Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $markdownDescription } -# Python test -$PythonTests = @("python.exe", "Scripts\pip.exe") -ToolcacheTest -SoftwareName "Python" -ExecTests $PythonTests - # PyPy test $PyPyTests = @("python.exe", "bin\pip.exe") ToolcacheTest -SoftwareName "PyPy" -ExecTests $PyPyTests diff --git a/images/win/scripts/Installers/Validate-Toolset.ps1 b/images/win/scripts/Installers/Validate-Toolset.ps1 index 6bf04a58bc17..28963b12a781 100644 --- a/images/win/scripts/Installers/Validate-Toolset.ps1 +++ b/images/win/scripts/Installers/Validate-Toolset.ps1 @@ -102,7 +102,7 @@ foreach($tool in $tools) { } # Create markdown description for system default tool - if ($tool.default -ne "") { + if (-not ([string]::IsNullOrEmpty($tool.default))) { Write-Host "Validate system default $($tool.name)($($tool.arch)) $($tool.default)..." $markdownDescription += Validate-SystemDefaultTool -ToolName $tool.name -ExpectedVersion $tool.default } diff --git a/images/win/toolset-2016.json b/images/win/toolset-2016.json index 44f017712134..06de24aafb68 100644 --- a/images/win/toolset-2016.json +++ b/images/win/toolset-2016.json @@ -25,8 +25,7 @@ "3.6.*", "3.7.*", "3.8.*" - ], - "default": "" + ] } ] } \ No newline at end of file diff --git a/images/win/toolset-2019.json b/images/win/toolset-2019.json index 44f017712134..06de24aafb68 100644 --- a/images/win/toolset-2019.json +++ b/images/win/toolset-2019.json @@ -25,8 +25,7 @@ "3.6.*", "3.7.*", "3.8.*" - ], - "default": "" + ] } ] } \ No newline at end of file From e1ef8a35ad415ce41a8540281de936b648983a2f Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Fri, 10 Apr 2020 20:37:28 +0300 Subject: [PATCH 8/9] Minor fix in verbose --- images/win/scripts/Installers/Install-Toolset.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images/win/scripts/Installers/Install-Toolset.ps1 b/images/win/scripts/Installers/Install-Toolset.ps1 index d2c91c6e82f1..25bfe58ec18b 100644 --- a/images/win/scripts/Installers/Install-Toolset.ps1 +++ b/images/win/scripts/Installers/Install-Toolset.ps1 @@ -14,8 +14,8 @@ Function Install-Asset { $assetFolderPath = Join-Path $env:TEMP $releaseAssetName $assetArchivePath = Start-DownloadWithRetry -Url $ReleaseAsset.download_url -Name $ReleaseAsset.filename - Write-Host "Expand $($ReleaseAsset.filename) archive to the $assetFolderPath folder..." - 7z.exe x $assetArchivePath -o"$assetFolderPath" -y + Write-Host "Extract $($ReleaseAsset.filename) content..." + 7z.exe x $assetArchivePath -o"$assetFolderPath" -y | Out-Null Write-Host "Invoke installation script..." Push-Location -Path $assetFolderPath From 78927b6ab662b9daf72e49c585af376fef1575e6 Mon Sep 17 00:00:00 2001 From: Maksim Petrov Date: Mon, 20 Apr 2020 18:13:24 +0300 Subject: [PATCH 9/9] Update toolset urls --- images/win/toolset-2016.json | 4 ++-- images/win/toolset-2019.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/images/win/toolset-2016.json b/images/win/toolset-2016.json index 06de24aafb68..da372c498667 100644 --- a/images/win/toolset-2016.json +++ b/images/win/toolset-2016.json @@ -2,7 +2,7 @@ "toolcache": [ { "name": "Python", - "url" : "https://raw.githubusercontent.com/akv-platform/toolcache-python-generation/master/versions-manifest.json", + "url" : "https://raw.githubusercontent.com/actions/python-versions/master/versions-manifest.json", "arch": "x64", "platform" : "win32", "versions": [ @@ -16,7 +16,7 @@ }, { "name": "Python", - "url" : "https://raw.githubusercontent.com/akv-platform/toolcache-python-generation/master/versions-manifest.json", + "url" : "https://raw.githubusercontent.com/actions/python-versions/master/versions-manifest.json", "arch": "x86", "platform" : "win32", "versions": [ diff --git a/images/win/toolset-2019.json b/images/win/toolset-2019.json index 06de24aafb68..da372c498667 100644 --- a/images/win/toolset-2019.json +++ b/images/win/toolset-2019.json @@ -2,7 +2,7 @@ "toolcache": [ { "name": "Python", - "url" : "https://raw.githubusercontent.com/akv-platform/toolcache-python-generation/master/versions-manifest.json", + "url" : "https://raw.githubusercontent.com/actions/python-versions/master/versions-manifest.json", "arch": "x64", "platform" : "win32", "versions": [ @@ -16,7 +16,7 @@ }, { "name": "Python", - "url" : "https://raw.githubusercontent.com/akv-platform/toolcache-python-generation/master/versions-manifest.json", + "url" : "https://raw.githubusercontent.com/actions/python-versions/master/versions-manifest.json", "arch": "x86", "platform" : "win32", "versions": [