mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
add VS build tools installation, tests, reports, made minor changes to current VS install helper functions
This commit is contained in:
@@ -35,8 +35,7 @@ Export-ModuleMember -Function @(
|
|||||||
'Get-EnvironmentVariable'
|
'Get-EnvironmentVariable'
|
||||||
'Invoke-PesterTests'
|
'Invoke-PesterTests'
|
||||||
'Get-VsCatalogJsonPath'
|
'Get-VsCatalogJsonPath'
|
||||||
'Get-VisualStudioPath'
|
|
||||||
'Install-AndroidSDKPackages'
|
'Install-AndroidSDKPackages'
|
||||||
'Get-VisualStudioPackages'
|
'Get-VisualStudioInstallation'
|
||||||
'Get-VisualStudioComponents'
|
'Get-VisualStudioComponents'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -266,14 +266,8 @@ function Get-VSExtensionVersion
|
|||||||
[string] $packageName
|
[string] $packageName
|
||||||
)
|
)
|
||||||
|
|
||||||
$instanceFolders = Get-ChildItem -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
$instanceFolders = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioInstallation -VSInstallType "VS").InstanceId
|
||||||
if ($instanceFolders -is [array])
|
$stateContent = Get-Content -Path (Join-Path $instanceFolders '\state.packages.json')
|
||||||
{
|
|
||||||
Write-Host "More than one instance installed"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
$stateContent = Get-Content -Path (Join-Path $instanceFolders.FullName '\state.packages.json')
|
|
||||||
$state = $stateContent | ConvertFrom-Json
|
$state = $stateContent | ConvertFrom-Json
|
||||||
$packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version
|
$packageVersion = ($state.packages | Where-Object { $_.id -eq $packageName }).version
|
||||||
|
|
||||||
|
|||||||
@@ -61,20 +61,40 @@ Function Install-VisualStudio
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-VsCatalogJsonPath {
|
function Get-VsCatalogJsonPath {
|
||||||
$instanceFolder = Get-Item "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\*" | Select-Object -First 1
|
$instanceFolder = "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioInstallation -VSInstallType "VS").InstanceId
|
||||||
return Join-Path $instanceFolder.FullName "catalog.json"
|
return Join-Path $instanceFolder "catalog.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-VisualStudioPath {
|
function Get-VisualStudioInstallation {
|
||||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).InstallationPath
|
Param
|
||||||
}
|
(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[String] $VSInstallType
|
||||||
|
)
|
||||||
|
|
||||||
function Get-VisualStudioPackages {
|
if ($VSInstallType -eq "VS")
|
||||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).Packages
|
{
|
||||||
|
$VSSelectionType = "*Enterprise*"
|
||||||
|
}
|
||||||
|
elseif ($VSInstallType -eq "BuildTools")
|
||||||
|
{
|
||||||
|
$VSSelectionType = "*Build*"
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Write-Output "Visual Studio Installation type have to be 'VS' or 'BuildTools'"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
return Get-VSSetupInstance | Select-VSSetupInstance -Product * | Where-Object -Property DisplayName -like $VSSelectionType
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-VisualStudioComponents {
|
function Get-VisualStudioComponents {
|
||||||
Get-VisualStudioPackages | Where-Object type -in 'Component', 'Workload' |
|
Param
|
||||||
|
(
|
||||||
|
[Parameter(Mandatory)]
|
||||||
|
[String] $VSInstallType
|
||||||
|
)
|
||||||
|
(Get-VisualStudioInstallation -VSInstallType $VSInstallType).Packages | Where-Object type -in 'Component', 'Workload' |
|
||||||
Sort-Object Id, Version | Select-Object @{n = 'Package'; e = {$_.Id}}, Version |
|
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}" }
|
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}" }
|
||||||
}
|
}
|
||||||
@@ -1,38 +1,35 @@
|
|||||||
################################################################################
|
################################################################################
|
||||||
## File: Install-VS.ps1
|
## File: Install-VS.ps1
|
||||||
## Desc: Install Visual Studio
|
## Desc: Install Visual Studio and build tools
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
$toolset = Get-ToolsetContent
|
$toolset = Get-ToolsetContent
|
||||||
$requiredComponents = $toolset.visualStudio.workloads | ForEach-Object { "--add $_" }
|
$requiredComponents = $toolset.visualStudio.workloads | ForEach-Object { "--add $_" }
|
||||||
|
$buildRequiredComponents = $toolset.visualStudio.build_workloads | ForEach-Object { "--add $_" }
|
||||||
$workLoads = @(
|
$workLoads = @(
|
||||||
"--allWorkloads --includeRecommended"
|
"--allWorkloads --includeRecommended"
|
||||||
$requiredComponents
|
$requiredComponents
|
||||||
"--remove Component.CPython3.x64"
|
"--remove Component.CPython3.x64"
|
||||||
)
|
)
|
||||||
$workLoadsArgument = [String]::Join(" ", $workLoads)
|
$workLoadsArgument = [String]::Join(" ", $workLoads)
|
||||||
|
$buildWorkLoads = @(
|
||||||
|
"--includeRecommended"
|
||||||
|
$buildRequiredComponents
|
||||||
|
)
|
||||||
|
$buildWorkLoadsArgument = [String]::Join(" ", $buildWorkLoads)
|
||||||
|
|
||||||
$releaseInPath = $toolset.visualStudio.edition
|
$releaseInPath = $toolset.visualStudio.edition
|
||||||
$subVersion = $toolset.visualStudio.subversion
|
$subVersion = $toolset.visualStudio.subversion
|
||||||
$bootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_${releaseInPath}.exe"
|
$bootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_${releaseInPath}.exe"
|
||||||
|
$buildbootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_buildtools.exe"
|
||||||
|
|
||||||
# Install VS
|
# Install VS and VS Build tools
|
||||||
Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument
|
Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument
|
||||||
|
Install-VisualStudio -BootstrapperUrl $buildbootstrapperUrl -WorkLoads $buildWorkLoadsArgument
|
||||||
|
|
||||||
# Find the version of VS installed for this instance
|
$vsInstallRoot = (Get-VisualStudioInstallation -VStype "VS").InstallationPath
|
||||||
# Only supports a single instance
|
|
||||||
$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
|
||||||
$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName
|
|
||||||
|
|
||||||
if ($instanceFolders -is [array])
|
|
||||||
{
|
|
||||||
Write-Host "More than one instance installed"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
$vsInstallRoot = Get-VisualStudioPath
|
|
||||||
|
|
||||||
# Initialize Visual Studio Experimental Instance
|
# Initialize Visual Studio Experimental Instance
|
||||||
& "$vsInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit
|
& "$vsInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit
|
||||||
|
|||||||
@@ -171,7 +171,12 @@ $markdown += New-MDNewLine
|
|||||||
|
|
||||||
$markdown += New-MDHeader "Workloads, components and extensions:" -Level 4
|
$markdown += New-MDHeader "Workloads, components and extensions:" -Level 4
|
||||||
$markdown += New-MDNewLine
|
$markdown += New-MDNewLine
|
||||||
$markdown += ((Get-VisualStudioComponents) + (Get-VisualStudioExtensions)) | New-MDTable
|
$markdown += ((Get-VisualStudioComponents -VSInstallType "VS") + (Get-VisualStudioExtensions)) | New-MDTable
|
||||||
|
$markdown += New-MDNewLine
|
||||||
|
|
||||||
|
$markdown += New-MDHeader "Build Workloads and components:" -Level 4
|
||||||
|
$markdown += New-MDNewLine
|
||||||
|
$markdown += (Get-VisualStudioComponents -VSInstallType "BuildTools") | New-MDTable
|
||||||
$markdown += New-MDNewLine
|
$markdown += New-MDNewLine
|
||||||
|
|
||||||
$markdown += New-MDHeader "Microsoft Visual C++:" -Level 4
|
$markdown += New-MDHeader "Microsoft Visual C++:" -Level 4
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ function Get-VisualStudioExtensions {
|
|||||||
# Wix
|
# Wix
|
||||||
$vs = (Get-VisualStudioVersion).Name.Split()[-1]
|
$vs = (Get-VisualStudioVersion).Name.Split()[-1]
|
||||||
$wixPackageVersion = Get-WixVersion
|
$wixPackageVersion = Get-WixVersion
|
||||||
$wixExtensionVersion = (Get-VisualStudioPackages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version
|
$wixExtensionVersion = ((Get-VisualStudioInstallation -VSInstallType "VS").Packages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version
|
||||||
|
|
||||||
# WDK
|
# WDK
|
||||||
$wdkPackageVersion = Get-VSExtensionVersion -packageName 'Microsoft.Windows.DriverKit'
|
$wdkPackageVersion = Get-VSExtensionVersion -packageName 'Microsoft.Windows.DriverKit'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Describe "Visual Studio" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Devenv.exe" {
|
It "Devenv.exe" {
|
||||||
$vsInstallRoot = Get-VisualStudioPath
|
$vsInstallRoot = (Get-VisualStudioInstallation -VStype "VS").InstallationPath
|
||||||
$devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe"
|
$devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe"
|
||||||
$devenvexePath | Should -Exist
|
$devenvexePath | Should -Exist
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,19 @@ Describe "Visual Studio" {
|
|||||||
$expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty workloads
|
$expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty workloads
|
||||||
$testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} }
|
$testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} }
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
$installedComponents = Get-VisualStudioComponents | Select-Object -ExpandProperty Package
|
$installedComponents = Get-VisualStudioComponents -VSInstallType "VS" | Select-Object -ExpandProperty Package
|
||||||
|
}
|
||||||
|
|
||||||
|
It "<ComponentName>" -TestCases $testCases {
|
||||||
|
$installedComponents | Should -Contain $ComponentName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Context "Visual Studio build components" {
|
||||||
|
$expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty build_workloads
|
||||||
|
$testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} }
|
||||||
|
BeforeAll {
|
||||||
|
$installedComponents = Get-VisualStudioComponents -VSInstallType "Build" | Select-Object -ExpandProperty Package
|
||||||
}
|
}
|
||||||
|
|
||||||
It "<ComponentName>" -TestCases $testCases {
|
It "<ComponentName>" -TestCases $testCases {
|
||||||
|
|||||||
@@ -226,6 +226,9 @@
|
|||||||
"Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre",
|
"Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre",
|
||||||
"Microsoft.VisualStudio.Component.Workflow",
|
"Microsoft.VisualStudio.Component.Workflow",
|
||||||
"Microsoft.VisualStudio.Workload.Office"
|
"Microsoft.VisualStudio.Workload.Office"
|
||||||
|
],
|
||||||
|
"build_workloads": [
|
||||||
|
"Microsoft.VisualStudio.Workload.WebBuildTools"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -257,6 +257,9 @@
|
|||||||
"Microsoft.VisualStudio.Workload.VisualStudioExtension",
|
"Microsoft.VisualStudio.Workload.VisualStudioExtension",
|
||||||
"Component.MDD.Linux",
|
"Component.MDD.Linux",
|
||||||
"Component.MDD.Linux.GCC.arm"
|
"Component.MDD.Linux.GCC.arm"
|
||||||
|
],
|
||||||
|
"build_workloads": [
|
||||||
|
"Microsoft.VisualStudio.Workload.WebBuildTools"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user