-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Expand file tree
/
Copy pathConfigure-Toolset.ps1
More file actions
66 lines (54 loc) · 2.25 KB
/
Configure-Toolset.ps1
File metadata and controls
66 lines (54 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
################################################################################
## File: Configure-Toolset.ps1
## Team: CI-Build
## Desc: Configure Toolset
################################################################################
if ( Test-IsArm64 ) {
$envVarTemplate = "GOROOT_{0}_{1}_AARCH64"
} else {
$envVarTemplate = "GOROOT_{0}_{1}_X64"
}
$toolEnvConfigs = @{
Python = @{
pathTemplates = @(
"{0}"
"{0}\Scripts"
)
}
go = @{
pathTemplates = @(
"{0}\bin"
)
envVarTemplate = $envVarTemplate
}
}
$tools = Get-ToolsetContent `
| Select-Object -ExpandProperty toolcache `
| Where-Object { $toolEnvConfigs.Keys -contains $_.name }
Write-Host "Configure toolset tools environment..."
foreach ($tool in $tools) {
$toolEnvConfig = $toolEnvConfigs[$tool.name]
if (-not ([string]::IsNullOrEmpty($toolEnvConfig.envVarTemplate))) {
foreach ($version in $tool.versions) {
Write-Host "Set $($tool.name) $version environment variable..."
$foundVersionArchPath = Get-TCToolVersionPath -Name $tool.name -Version $version -Arch $tool.arch
$envName = $toolEnvConfig.envVarTemplate -f $version.Split(".")
Write-Host "Set $envName to $foundVersionArchPath"
[Environment]::SetEnvironmentVariable($envName, $foundVersionArchPath, "Machine")
}
}
if (-not ([string]::IsNullOrEmpty($tool.default))) {
Write-Host "Use $($tool.name) $($tool.default) as a system $($tool.name)..."
$toolVersionPath = Get-TCToolVersionPath -Name $tool.name -Version $tool.default -Arch $tool.arch
foreach ($template in $toolEnvConfig.pathTemplates) {
$toolSystemPath = $template -f $toolVersionPath
Write-Host "Add $toolSystemPath to system PATH..."
Add-MachinePathItem -PathItem $toolSystemPath | Out-Null
}
if (-not ([string]::IsNullOrEmpty($tool.defaultVariable))) {
Write-Host "Set $($tool.name) $($tool.default) $($tool.defaultVariable) environment variable..."
[Environment]::SetEnvironmentVariable($tool.defaultVariable, $toolVersionPath, "Machine")
}
}
}
Invoke-PesterTests -TestFile "Toolset"