mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-14 22:09:26 +00:00
removed VS buildtools installation
This commit is contained in:
@@ -35,7 +35,8 @@ Export-ModuleMember -Function @(
|
||||
'Get-EnvironmentVariable'
|
||||
'Invoke-PesterTests'
|
||||
'Get-VsCatalogJsonPath'
|
||||
'Get-VisualStudioPath'
|
||||
'Install-AndroidSDKPackages'
|
||||
'Get-VisualStudioProduct'
|
||||
'Get-VisualStudioPackages'
|
||||
'Get-VisualStudioComponents'
|
||||
)
|
||||
|
||||
@@ -258,6 +258,34 @@ function Install-VsixExtension
|
||||
}
|
||||
}
|
||||
|
||||
function Get-VSExtensionVersion
|
||||
{
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $packageName
|
||||
)
|
||||
|
||||
$instanceFolders = Get-ChildItem -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
||||
if ($instanceFolders -is [array])
|
||||
{
|
||||
Write-Host "More than one instance installed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$stateContent = Get-Content -Path (Join-Path $instanceFolders.FullName '\state.packages.json')
|
||||
$state = $stateContent | 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
|
||||
}
|
||||
|
||||
function Get-ToolcachePackages
|
||||
{
|
||||
$toolcachePath = Join-Path $env:ROOT_FOLDER "toolcache.json"
|
||||
|
||||
@@ -60,60 +60,21 @@ Function Install-VisualStudio
|
||||
}
|
||||
}
|
||||
|
||||
function Get-VisualStudioInstancePath {
|
||||
return "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\" + (Get-VisualStudioProduct -ProductType "VisualStudio").InstanceId
|
||||
}
|
||||
|
||||
function Get-VsCatalogJsonPath {
|
||||
return Join-Path (Get-VisualStudioInstancePath) "catalog.json"
|
||||
$instanceFolder = Get-Item "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances\*" | Select-Object -First 1
|
||||
return Join-Path $instanceFolder.FullName "catalog.json"
|
||||
}
|
||||
|
||||
function Get-VisualStudioProduct {
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateSet('VisualStudio','BuildTools')]
|
||||
[String] $ProductType
|
||||
)
|
||||
function Get-VisualStudioPath {
|
||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).InstallationPath
|
||||
}
|
||||
|
||||
if ($ProductType -eq "VisualStudio")
|
||||
{
|
||||
$VSSelectionType = "*Enterprise*"
|
||||
}
|
||||
elseif ($ProductType -eq "BuildTools")
|
||||
{
|
||||
$VSSelectionType = "*Build*"
|
||||
}
|
||||
return Get-VSSetupInstance | Where-Object -Property DisplayName -like $VSSelectionType
|
||||
function Get-VisualStudioPackages {
|
||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).Packages
|
||||
}
|
||||
|
||||
function Get-VisualStudioComponents {
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[String] $ProductType
|
||||
)
|
||||
(Get-VisualStudioProduct -ProductType $ProductType).Packages | Where-Object type -in 'Component', 'Workload' |
|
||||
Get-VisualStudioPackages | 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
|
||||
}
|
||||
|
||||
@@ -1,35 +1,38 @@
|
||||
################################################################################
|
||||
## File: Install-VS.ps1
|
||||
## Desc: Install Visual Studio and build tools
|
||||
## Desc: Install Visual Studio
|
||||
################################################################################
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$toolset = Get-ToolsetContent
|
||||
$requiredComponents = $toolset.visualStudio.workloads | ForEach-Object { "--add $_" }
|
||||
$buildToolsRequiredComponents = $toolset.visualStudio.buildtools_workloads | ForEach-Object { "--add $_" }
|
||||
$workLoads = @(
|
||||
"--allWorkloads --includeRecommended"
|
||||
$requiredComponents
|
||||
"--remove Component.CPython3.x64"
|
||||
)
|
||||
$workLoadsArgument = [String]::Join(" ", $workLoads)
|
||||
$buildToolsWorkloads= @(
|
||||
"--includeRecommended"
|
||||
$buildToolsRequiredComponents
|
||||
)
|
||||
$buildWorkLoadsArgument = [String]::Join(" ", $buildToolsWorkloads)
|
||||
|
||||
$releaseInPath = $toolset.visualStudio.edition
|
||||
$subVersion = $toolset.visualStudio.subversion
|
||||
$bootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_${releaseInPath}.exe"
|
||||
$buildbootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_buildtools.exe"
|
||||
|
||||
# Install VS and VS Build tools
|
||||
# Install VS
|
||||
Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument
|
||||
Install-VisualStudio -BootstrapperUrl $buildbootstrapperUrl -WorkLoads $buildWorkLoadsArgument
|
||||
|
||||
$vsInstallRoot = (Get-VisualStudioProduct -ProductType "VisualStudio").InstallationPath
|
||||
# Find the version of VS installed for this instance
|
||||
# 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
|
||||
& "$vsInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit
|
||||
|
||||
@@ -171,12 +171,7 @@ $markdown += New-MDNewLine
|
||||
|
||||
$markdown += New-MDHeader "Workloads, components and extensions:" -Level 4
|
||||
$markdown += New-MDNewLine
|
||||
$markdown += ((Get-VisualStudioComponents -ProductType "VisualStudio") + (Get-VisualStudioExtensions)) | New-MDTable
|
||||
$markdown += New-MDNewLine
|
||||
|
||||
$markdown += New-MDHeader "Build Tools Workloads:" -Level 4
|
||||
$markdown += New-MDNewLine
|
||||
$markdown += (Get-VisualStudioComponents -ProductType "BuildTools") | New-MDTable
|
||||
$markdown += ((Get-VisualStudioComponents) + (Get-VisualStudioExtensions)) | New-MDTable
|
||||
$markdown += New-MDNewLine
|
||||
|
||||
$markdown += New-MDHeader "Microsoft Visual C++:" -Level 4
|
||||
|
||||
@@ -23,18 +23,18 @@ function Get-VisualStudioExtensions {
|
||||
# Wix
|
||||
$vs = (Get-VisualStudioVersion).Name.Split()[-1]
|
||||
$wixPackageVersion = Get-WixVersion
|
||||
$wixExtensionVersion = ((Get-VisualStudioProduct -ProductType "VisualStudio").Packages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version
|
||||
$wixExtensionVersion = (Get-VisualStudioPackages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version
|
||||
|
||||
# WDK
|
||||
$wdkPackageVersion = Get-VSExtensionVersion -PackageName 'Microsoft.Windows.DriverKit'
|
||||
$wdkPackageVersion = Get-VSExtensionVersion -packageName 'Microsoft.Windows.DriverKit'
|
||||
$wdkExtensionVersion = Get-WDKVersion
|
||||
|
||||
# SSDT
|
||||
$analysisPackageVersion = Get-VSExtensionVersion -PackageName '04a86fc2-dbd5-4222-848e-911638e487fe'
|
||||
$reportingPackageVersion = Get-VSExtensionVersion -PackageName '717ad572-c4b7-435c-c166-c2969777f718'
|
||||
$analysisPackageVersion = Get-VSExtensionVersion -packageName '04a86fc2-dbd5-4222-848e-911638e487fe'
|
||||
$reportingPackageVersion = Get-VSExtensionVersion -packageName '717ad572-c4b7-435c-c166-c2969777f718'
|
||||
|
||||
$integrationPackageName = ($vs -match "2019") ? '851E7A09-7B2B-4F06-A15D-BABFCB26B970' : 'D1B09713-C12E-43CC-9EF4-6562298285AB'
|
||||
$integrationPackageVersion = Get-VSExtensionVersion -PackageName $integrationPackageName
|
||||
$integrationPackageVersion = Get-VSExtensionVersion -packageName $integrationPackageName
|
||||
|
||||
$extensions = @(
|
||||
@{Package = 'SSDT Microsoft Analysis Services Projects'; Version = $analysisPackageVersion}
|
||||
|
||||
@@ -9,12 +9,12 @@ Describe "SSDTExtensions" {
|
||||
)
|
||||
|
||||
It "Extensions id=<id>" -TestCases $testExtenions {
|
||||
$version = Get-VSExtensionVersion -PackageName "${id}"
|
||||
$version = Get-VSExtensionVersion -packageName "${id}"
|
||||
$version | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
} else {
|
||||
It "Extension SSDT" {
|
||||
$version = Get-VSExtensionVersion -PackageName "SSDT"
|
||||
$version = Get-VSExtensionVersion -packageName "SSDT"
|
||||
$version | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,27 +5,17 @@ Describe "Visual Studio" {
|
||||
}
|
||||
|
||||
It "Devenv.exe" {
|
||||
$vsInstallRoot = (Get-VisualStudioProduct -ProductType "VisualStudio").InstallationPath
|
||||
$vsInstallRoot = Get-VisualStudioPath
|
||||
$devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe"
|
||||
$devenvexePath | Should -Exist
|
||||
}
|
||||
}
|
||||
|
||||
Context "Visual Studio components" {
|
||||
$testCases = (Get-ToolsetContent).visualStudio.workloads | ForEach-Object { @{ComponentName = $_} }
|
||||
$expectedComponents = Get-ToolsetContent | Select-Object -ExpandProperty visualStudio | Select-Object -ExpandProperty workloads
|
||||
$testCases = $expectedComponents | ForEach-Object { @{ComponentName = $_} }
|
||||
BeforeAll {
|
||||
$installedComponents = Get-VisualStudioComponents -ProductType "VisualStudio" | Select-Object -ExpandProperty Package
|
||||
}
|
||||
|
||||
It "<ComponentName>" -TestCases $testCases {
|
||||
$installedComponents | Should -Contain $ComponentName
|
||||
}
|
||||
}
|
||||
|
||||
Context "Visual Studio Build Tools components" {
|
||||
$testCases = (Get-ToolsetContent).visualStudio.buildtools_workloads | ForEach-Object { @{ComponentName = $_} }
|
||||
BeforeAll {
|
||||
$installedComponents = Get-VisualStudioComponents -ProductType "BuildTools" | Select-Object -ExpandProperty Package
|
||||
$installedComponents = Get-VisualStudioComponents | Select-Object -ExpandProperty Package
|
||||
}
|
||||
|
||||
It "<ComponentName>" -TestCases $testCases {
|
||||
|
||||
@@ -5,7 +5,7 @@ Describe "WDK" {
|
||||
}
|
||||
|
||||
It "WDK version from system" {
|
||||
$version = Get-VSExtensionVersion -PackageName "Microsoft.Windows.DriverKit"
|
||||
$version = Get-VSExtensionVersion -packageName "Microsoft.Windows.DriverKit"
|
||||
$version | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,11 +12,11 @@ Describe "Wix" {
|
||||
It "Wix Toolset version from system" {
|
||||
if (Test-IsWin19)
|
||||
{
|
||||
$exVersion = Get-VSExtensionVersion -PackageName "WixToolset.VisualStudioExtension.Dev16"
|
||||
$exVersion = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev16"
|
||||
}
|
||||
else
|
||||
{
|
||||
$exVersion = Get-VSExtensionVersion -PackageName "WixToolset.VisualStudioExtension.Dev15"
|
||||
$exVersion = Get-VSExtensionVersion -packageName "WixToolset.VisualStudioExtension.Dev15"
|
||||
}
|
||||
$exVersion | Should -Not -BeNullOrEmpty
|
||||
}
|
||||
|
||||
@@ -227,9 +227,6 @@
|
||||
"Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre",
|
||||
"Microsoft.VisualStudio.Component.Workflow",
|
||||
"Microsoft.VisualStudio.Workload.Office"
|
||||
],
|
||||
"buildtools_workloads": [
|
||||
"Microsoft.VisualStudio.Workload.WebBuildTools"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,9 +259,6 @@
|
||||
"Microsoft.VisualStudio.Workload.VisualStudioExtension",
|
||||
"Component.MDD.Linux",
|
||||
"Component.MDD.Linux.GCC.arm"
|
||||
],
|
||||
"buildtools_workloads": [
|
||||
"Microsoft.VisualStudio.Workload.WebBuildTools"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user