mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
Add VS build tools installation for Windows (#1533)
* add VS build tools installation, tests, reports, made minor changes to current VS install helper functions * Vstype typo * removed unused variable * validate set for new functions * some variable names clarifications * test parameter error * style and syntax improvments * syntax notation Co-authored-by: Leonid Lapshin <originalnoe-nazvanie@yandex.ru>
This commit is contained in:
@@ -60,21 +60,60 @@ Function Install-VisualStudio
|
||||
}
|
||||
}
|
||||
|
||||
function Get-VisualStudioInstancePath {
|
||||
return "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioProduct -ProductType "VisualStudio").InstanceId
|
||||
}
|
||||
|
||||
function Get-VsCatalogJsonPath {
|
||||
$instanceFolder = Get-Item "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\*" | Select-Object -First 1
|
||||
return Join-Path $instanceFolder.FullName "catalog.json"
|
||||
return Join-Path (Get-VisualStudioInstancePath) "catalog.json"
|
||||
}
|
||||
|
||||
function Get-VisualStudioPath {
|
||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).InstallationPath
|
||||
}
|
||||
function Get-VisualStudioProduct {
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateSet('VisualStudio','BuildTools')]
|
||||
[String] $ProductType
|
||||
)
|
||||
|
||||
function Get-VisualStudioPackages {
|
||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).Packages
|
||||
if ($ProductType -eq "VisualStudio")
|
||||
{
|
||||
$VSSelectionType = "*Enterprise*"
|
||||
}
|
||||
elseif ($ProductType -eq "BuildTools")
|
||||
{
|
||||
$VSSelectionType = "*Build*"
|
||||
}
|
||||
return Get-VSSetupInstance | Where-Object -Property DisplayName -like $VSSelectionType
|
||||
}
|
||||
|
||||
function Get-VisualStudioComponents {
|
||||
Get-VisualStudioPackages | Where-Object type -in 'Component', 'Workload' |
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[String] $ProductType
|
||||
)
|
||||
(Get-VisualStudioProduct -ProductType $ProductType).Packages | Where-Object type -in 'Component', 'Workload' |
|
||||
Sort-Object Id, Version | Select-Object @{n = 'Package'; e = {$_.Id}}, Version |
|
||||
Where-Object { $_.Package -notmatch "[0-9a-fA-F]{8}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{4}\-[0-9a-fA-F]{12}" }
|
||||
}
|
||||
}
|
||||
|
||||
function Get-VSExtensionVersion
|
||||
{
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $PackageName
|
||||
)
|
||||
|
||||
$state = Get-Content -Path (Join-Path (Get-VisualStudioInstancePath) '\state.packages.json') | ConvertFrom-Json
|
||||
$packageVersion = ($state.packages | Where-Object { $_.id -eq $PackageName }).version
|
||||
|
||||
if (-not $packageVersion)
|
||||
{
|
||||
Write-Host "installed package $PackageName for Visual Studio 2019 was not found"
|
||||
exit 1
|
||||
}
|
||||
|
||||
return $packageVersion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user