mirror of
https://github.com/actions/runner-images.git
synced 2025-12-14 22:05:17 +00:00
[Windows] Improve Visual Studio installation scripts to support Preview versions (#3850)
* Support Preview versions of Visual Studio * resolve comments * Fix test * fix tests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
$vsInstallRoot = Get-VisualStudioPath
|
||||
$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath
|
||||
$devEnvPath = "$vsInstallRoot\Common7\IDE\devenv.exe"
|
||||
|
||||
cmd.exe /c "`"$devEnvPath`" /updateconfiguration"
|
||||
@@ -34,11 +34,10 @@ Export-ModuleMember -Function @(
|
||||
'Get-EnvironmentVariable'
|
||||
'Invoke-PesterTests'
|
||||
'Get-VsCatalogJsonPath'
|
||||
'Get-VisualStudioPath'
|
||||
'Install-AndroidSDKPackages'
|
||||
'Get-AndroidPackages'
|
||||
'Get-AndroidPackagesByName'
|
||||
'Get-AndroidPackagesByVersion'
|
||||
'Get-VisualStudioPackages'
|
||||
'Get-VisualStudioInstance'
|
||||
'Get-VisualStudioComponents'
|
||||
)
|
||||
|
||||
@@ -72,16 +72,14 @@ function Get-VsCatalogJsonPath {
|
||||
return Join-Path $instanceFolder.FullName "catalog.json"
|
||||
}
|
||||
|
||||
function Get-VisualStudioPath {
|
||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).InstallationPath
|
||||
}
|
||||
|
||||
function Get-VisualStudioPackages {
|
||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).Packages
|
||||
function Get-VisualStudioInstance {
|
||||
# Use -Prerelease and -All flags to make sure that Preview versions of VS are found correctly
|
||||
$vsInstance = Get-VSSetupInstance -Prerelease -All | Where-Object { $_.DisplayName -match "Visual Studio" } | Select-Object -First 1
|
||||
$vsInstance | Select-VSSetupInstance -Product *
|
||||
}
|
||||
|
||||
function Get-VisualStudioComponents {
|
||||
Get-VisualStudioPackages | Where-Object type -in 'Component', 'Workload' |
|
||||
(Get-VisualStudioInstance).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}" }
|
||||
}
|
||||
@@ -14,7 +14,8 @@ $workLoadsArgument = [String]::Join(" ", $workLoads)
|
||||
|
||||
$releaseInPath = $toolset.visualStudio.edition
|
||||
$subVersion = $toolset.visualStudio.subversion
|
||||
$bootstrapperUrl = "https://aka.ms/vs/${subVersion}/release/vs_${releaseInPath}.exe"
|
||||
$channel = $toolset.visualStudio.channel
|
||||
$bootstrapperUrl = "https://aka.ms/vs/${subVersion}/${channel}/vs_${releaseInPath}.exe"
|
||||
|
||||
# Install VS
|
||||
Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument
|
||||
@@ -30,7 +31,7 @@ if ($instanceFolders -is [array])
|
||||
exit 1
|
||||
}
|
||||
|
||||
$vsInstallRoot = Get-VisualStudioPath
|
||||
$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath
|
||||
|
||||
# Initialize Visual Studio Experimental Instance
|
||||
& "$vsInstallRoot\Common7\IDE\devenv.exe" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit
|
||||
|
||||
@@ -10,4 +10,4 @@ $InstallerName = "WindowsApplicationDriver.msi"
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName
|
||||
|
||||
Invoke-PesterTests -TestFile "WinAppDriver"
|
||||
Invoke-PesterTests -TestFile "WinAppDriver" -TestName "WinAppDriver"
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
function Get-VisualStudioVersion {
|
||||
$vsVersion = vswhere -format json | ConvertFrom-Json
|
||||
$vsInstance = Get-VisualStudioInstance
|
||||
[PSCustomObject]@{
|
||||
Name = $vsVersion.displayName
|
||||
Version = $vsVersion.installationVersion
|
||||
Path = $vsVersion.installationPath
|
||||
Name = $vsInstance.DisplayName
|
||||
Version = $vsInstance.InstallationVersion
|
||||
Path = $vsInstance.InstallationPath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ function Get-WDKVersion {
|
||||
}
|
||||
|
||||
function Get-VisualStudioExtensions {
|
||||
$vsPackages = (Get-VisualStudioInstance).Packages
|
||||
|
||||
# Additional vsixs
|
||||
$toolset = Get-ToolsetContent
|
||||
$vsixUrls = $toolset.visualStudio.vsix
|
||||
@@ -27,7 +29,8 @@ function Get-VisualStudioExtensions {
|
||||
{
|
||||
$vsixs = $vsixUrls | ForEach-Object {
|
||||
$vsix = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_
|
||||
$vsixVersion = (Get-VisualStudioPackages | Where-Object {$_.Id -match $vsix.VsixId -and $_.type -eq 'vsix'}).Version
|
||||
|
||||
$vsixVersion = ($vsPackages | Where-Object {$_.Id -match $vsix.VsixId -and $_.type -eq 'vsix'}).Version
|
||||
@{
|
||||
Package = $vsix.ExtensionName
|
||||
Version = $vsixVersion
|
||||
@@ -52,7 +55,7 @@ function Get-VisualStudioExtensions {
|
||||
if (Test-IsWin16 -or Test-IsWin19) {
|
||||
# Wix
|
||||
$wixPackageVersion = Get-WixVersion
|
||||
$wixExtensionVersion = (Get-VisualStudioPackages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version
|
||||
$wixExtensionVersion = ($vsPackages | Where-Object {$_.Id -match 'WixToolset.VisualStudioExtension.Dev' -and $_.type -eq 'vsix'}).Version
|
||||
$wixPackages = @(
|
||||
@{Package = 'WIX Toolset'; Version = $wixPackageVersion}
|
||||
@{Package = "WIX Toolset Studio $vs Extension"; Version = $wixExtensionVersion}
|
||||
|
||||
@@ -5,7 +5,7 @@ Describe "Visual Studio" {
|
||||
}
|
||||
|
||||
It "Devenv.exe" {
|
||||
$vsInstallRoot = Get-VisualStudioPath
|
||||
$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath
|
||||
$devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe"
|
||||
$devenvexePath | Should -Exist
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ Describe "Vsix" {
|
||||
$toolset = Get-ToolsetContent
|
||||
$requiredVsixs = $toolset.visualStudio.vsix
|
||||
|
||||
$allPackages = (Get-VSSetupInstance | Select-VsSetupInstance -Product *).Packages
|
||||
$allPackages = (Get-VisualStudioInstance).Packages
|
||||
$testCases = $requiredVsixs | ForEach-Object {
|
||||
$vsix = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_
|
||||
@{
|
||||
|
||||
@@ -2,7 +2,9 @@ Describe "WinAppDriver" {
|
||||
It "WinAppDriver directory exists" {
|
||||
Test-Path -Path "${env:ProgramFiles(x86)}\Windows Application Driver" | Should -BeTrue
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Developer Mode" {
|
||||
It "Developer Mode is enabled" {
|
||||
$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock";
|
||||
Get-ItemProperty -Path $path | Select-Object -ExpandProperty "AllowDevelopmentWithoutDevLicense" | Should -Be 1
|
||||
|
||||
@@ -260,6 +260,7 @@
|
||||
"version" : "2017",
|
||||
"subversion" : "15",
|
||||
"edition" : "Enterprise",
|
||||
"channel": "release",
|
||||
"workloads": [
|
||||
"Microsoft.Net.Component.4.6.2.SDK",
|
||||
"Microsoft.Net.Component.4.6.2.TargetingPack",
|
||||
|
||||
@@ -258,6 +258,7 @@
|
||||
"version" : "2019",
|
||||
"subversion" : "16",
|
||||
"edition" : "Enterprise",
|
||||
"channel": "release",
|
||||
"workloads": [
|
||||
"Component.Dotfuscator",
|
||||
"Component.Linux.CMake",
|
||||
|
||||
@@ -154,11 +154,10 @@
|
||||
3010
|
||||
],
|
||||
"scripts": [
|
||||
"{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-VS.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-NET48.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Windows2016/Install-SSDT.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Enable-DeveloperMode.ps1"
|
||||
"{{ template_dir }}/scripts/Installers/Windows2016/Install-SSDT.ps1"
|
||||
],
|
||||
"elevated_user": "{{user `install_user`}}",
|
||||
"elevated_password": "{{user `install_password`}}"
|
||||
@@ -249,7 +248,8 @@
|
||||
"{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Configure-GDIProcessHandleQuota.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Configure-Shell.ps1"
|
||||
"{{ template_dir }}/scripts/Installers/Configure-Shell.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Enable-DeveloperMode.ps1"
|
||||
],
|
||||
"elevated_user": "{{user `install_user`}}",
|
||||
"elevated_password": "{{user `install_password`}}"
|
||||
|
||||
@@ -161,10 +161,9 @@
|
||||
3010
|
||||
],
|
||||
"scripts": [
|
||||
"{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-VS.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-NET48.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Enable-DeveloperMode.ps1"
|
||||
"{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Install-NET48.ps1"
|
||||
],
|
||||
"elevated_user": "{{user `install_user`}}",
|
||||
"elevated_password": "{{user `install_password`}}"
|
||||
@@ -258,7 +257,8 @@
|
||||
"{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Configure-GDIProcessHandleQuota.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Configure-Shell.ps1"
|
||||
"{{ template_dir }}/scripts/Installers/Configure-Shell.ps1",
|
||||
"{{ template_dir }}/scripts/Installers/Enable-DeveloperMode.ps1"
|
||||
],
|
||||
"elevated_user": "{{user `install_user`}}",
|
||||
"elevated_password": "{{user `install_password`}}"
|
||||
|
||||
Reference in New Issue
Block a user