Files
runner-images-sangeeth/images/win/scripts/Installers/Install-Go.ps1
Dmitry Shibanov b41fda16c1 Switch provisioners to install Go from GitHub releases on Windows (#1026)
* add go to json toolset

* add install and validate go

* fiixing go tests

* fix validation for go

* check zero build version

* add 1.9 version

* setup variables for go

* fix comments

* remove script invokation

* remove lines

* fixing install go

* remove comments

* remove fake url

Co-authored-by: Dmitry Shibanov <v-dmshib@microsoft.com>
2020-06-19 13:47:55 +03:00

25 lines
1.0 KiB
PowerShell

################################################################################
## 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
}