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"
|
$devEnvPath = "$vsInstallRoot\Common7\IDE\devenv.exe"
|
||||||
|
|
||||||
cmd.exe /c "`"$devEnvPath`" /updateconfiguration"
|
cmd.exe /c "`"$devEnvPath`" /updateconfiguration"
|
||||||
@@ -34,11 +34,10 @@ Export-ModuleMember -Function @(
|
|||||||
'Get-EnvironmentVariable'
|
'Get-EnvironmentVariable'
|
||||||
'Invoke-PesterTests'
|
'Invoke-PesterTests'
|
||||||
'Get-VsCatalogJsonPath'
|
'Get-VsCatalogJsonPath'
|
||||||
'Get-VisualStudioPath'
|
|
||||||
'Install-AndroidSDKPackages'
|
'Install-AndroidSDKPackages'
|
||||||
'Get-AndroidPackages'
|
'Get-AndroidPackages'
|
||||||
'Get-AndroidPackagesByName'
|
'Get-AndroidPackagesByName'
|
||||||
'Get-AndroidPackagesByVersion'
|
'Get-AndroidPackagesByVersion'
|
||||||
'Get-VisualStudioPackages'
|
'Get-VisualStudioInstance'
|
||||||
'Get-VisualStudioComponents'
|
'Get-VisualStudioComponents'
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -72,16 +72,14 @@ function Get-VsCatalogJsonPath {
|
|||||||
return Join-Path $instanceFolder.FullName "catalog.json"
|
return Join-Path $instanceFolder.FullName "catalog.json"
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-VisualStudioPath {
|
function Get-VisualStudioInstance {
|
||||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).InstallationPath
|
# 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-VisualStudioPackages {
|
|
||||||
return (Get-VSSetupInstance | Select-VSSetupInstance -Product *).Packages
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function Get-VisualStudioComponents {
|
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 |
|
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}" }
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,8 @@ $workLoadsArgument = [String]::Join(" ", $workLoads)
|
|||||||
|
|
||||||
$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"
|
$channel = $toolset.visualStudio.channel
|
||||||
|
$bootstrapperUrl = "https://aka.ms/vs/${subVersion}/${channel}/vs_${releaseInPath}.exe"
|
||||||
|
|
||||||
# Install VS
|
# Install VS
|
||||||
Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument
|
Install-VisualStudio -BootstrapperUrl $bootstrapperUrl -WorkLoads $workLoadsArgument
|
||||||
@@ -30,7 +31,7 @@ if ($instanceFolders -is [array])
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
$vsInstallRoot = Get-VisualStudioPath
|
$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath
|
||||||
|
|
||||||
# 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
|
||||||
|
|||||||
@@ -10,4 +10,4 @@ $InstallerName = "WindowsApplicationDriver.msi"
|
|||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
Install-Binary -Url $InstallerUrl -Name $InstallerName
|
Install-Binary -Url $InstallerUrl -Name $InstallerName
|
||||||
|
|
||||||
Invoke-PesterTests -TestFile "WinAppDriver"
|
Invoke-PesterTests -TestFile "WinAppDriver" -TestName "WinAppDriver"
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
function Get-VisualStudioVersion {
|
function Get-VisualStudioVersion {
|
||||||
$vsVersion = vswhere -format json | ConvertFrom-Json
|
$vsInstance = Get-VisualStudioInstance
|
||||||
[PSCustomObject]@{
|
[PSCustomObject]@{
|
||||||
Name = $vsVersion.displayName
|
Name = $vsInstance.DisplayName
|
||||||
Version = $vsVersion.installationVersion
|
Version = $vsInstance.InstallationVersion
|
||||||
Path = $vsVersion.installationPath
|
Path = $vsInstance.InstallationPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,6 +20,8 @@ function Get-WDKVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-VisualStudioExtensions {
|
function Get-VisualStudioExtensions {
|
||||||
|
$vsPackages = (Get-VisualStudioInstance).Packages
|
||||||
|
|
||||||
# Additional vsixs
|
# Additional vsixs
|
||||||
$toolset = Get-ToolsetContent
|
$toolset = Get-ToolsetContent
|
||||||
$vsixUrls = $toolset.visualStudio.vsix
|
$vsixUrls = $toolset.visualStudio.vsix
|
||||||
@@ -27,7 +29,8 @@ function Get-VisualStudioExtensions {
|
|||||||
{
|
{
|
||||||
$vsixs = $vsixUrls | ForEach-Object {
|
$vsixs = $vsixUrls | ForEach-Object {
|
||||||
$vsix = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_
|
$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
|
Package = $vsix.ExtensionName
|
||||||
Version = $vsixVersion
|
Version = $vsixVersion
|
||||||
@@ -52,7 +55,7 @@ function Get-VisualStudioExtensions {
|
|||||||
if (Test-IsWin16 -or Test-IsWin19) {
|
if (Test-IsWin16 -or Test-IsWin19) {
|
||||||
# Wix
|
# Wix
|
||||||
$wixPackageVersion = Get-WixVersion
|
$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 = @(
|
$wixPackages = @(
|
||||||
@{Package = 'WIX Toolset'; Version = $wixPackageVersion}
|
@{Package = 'WIX Toolset'; Version = $wixPackageVersion}
|
||||||
@{Package = "WIX Toolset Studio $vs Extension"; Version = $wixExtensionVersion}
|
@{Package = "WIX Toolset Studio $vs Extension"; Version = $wixExtensionVersion}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Describe "Visual Studio" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Devenv.exe" {
|
It "Devenv.exe" {
|
||||||
$vsInstallRoot = Get-VisualStudioPath
|
$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath
|
||||||
$devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe"
|
$devenvexePath = "${vsInstallRoot}\Common7\IDE\devenv.exe"
|
||||||
$devenvexePath | Should -Exist
|
$devenvexePath | Should -Exist
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ Describe "Vsix" {
|
|||||||
$toolset = Get-ToolsetContent
|
$toolset = Get-ToolsetContent
|
||||||
$requiredVsixs = $toolset.visualStudio.vsix
|
$requiredVsixs = $toolset.visualStudio.vsix
|
||||||
|
|
||||||
$allPackages = (Get-VSSetupInstance | Select-VsSetupInstance -Product *).Packages
|
$allPackages = (Get-VisualStudioInstance).Packages
|
||||||
$testCases = $requiredVsixs | ForEach-Object {
|
$testCases = $requiredVsixs | ForEach-Object {
|
||||||
$vsix = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_
|
$vsix = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_
|
||||||
@{
|
@{
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ Describe "WinAppDriver" {
|
|||||||
It "WinAppDriver directory exists" {
|
It "WinAppDriver directory exists" {
|
||||||
Test-Path -Path "${env:ProgramFiles(x86)}\Windows Application Driver" | Should -BeTrue
|
Test-Path -Path "${env:ProgramFiles(x86)}\Windows Application Driver" | Should -BeTrue
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Describe "Developer Mode" {
|
||||||
It "Developer Mode is enabled" {
|
It "Developer Mode is enabled" {
|
||||||
$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock";
|
$path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock";
|
||||||
Get-ItemProperty -Path $path | Select-Object -ExpandProperty "AllowDevelopmentWithoutDevLicense" | Should -Be 1
|
Get-ItemProperty -Path $path | Select-Object -ExpandProperty "AllowDevelopmentWithoutDevLicense" | Should -Be 1
|
||||||
|
|||||||
@@ -260,6 +260,7 @@
|
|||||||
"version" : "2017",
|
"version" : "2017",
|
||||||
"subversion" : "15",
|
"subversion" : "15",
|
||||||
"edition" : "Enterprise",
|
"edition" : "Enterprise",
|
||||||
|
"channel": "release",
|
||||||
"workloads": [
|
"workloads": [
|
||||||
"Microsoft.Net.Component.4.6.2.SDK",
|
"Microsoft.Net.Component.4.6.2.SDK",
|
||||||
"Microsoft.Net.Component.4.6.2.TargetingPack",
|
"Microsoft.Net.Component.4.6.2.TargetingPack",
|
||||||
|
|||||||
@@ -258,6 +258,7 @@
|
|||||||
"version" : "2019",
|
"version" : "2019",
|
||||||
"subversion" : "16",
|
"subversion" : "16",
|
||||||
"edition" : "Enterprise",
|
"edition" : "Enterprise",
|
||||||
|
"channel": "release",
|
||||||
"workloads": [
|
"workloads": [
|
||||||
"Component.Dotfuscator",
|
"Component.Dotfuscator",
|
||||||
"Component.Linux.CMake",
|
"Component.Linux.CMake",
|
||||||
|
|||||||
@@ -154,11 +154,10 @@
|
|||||||
3010
|
3010
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1",
|
|
||||||
"{{ template_dir }}/scripts/Installers/Install-VS.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/Install-NET48.ps1",
|
||||||
"{{ template_dir }}/scripts/Installers/Windows2016/Install-SSDT.ps1",
|
"{{ template_dir }}/scripts/Installers/Windows2016/Install-SSDT.ps1"
|
||||||
"{{ template_dir }}/scripts/Installers/Enable-DeveloperMode.ps1"
|
|
||||||
],
|
],
|
||||||
"elevated_user": "{{user `install_user`}}",
|
"elevated_user": "{{user `install_user`}}",
|
||||||
"elevated_password": "{{user `install_password`}}"
|
"elevated_password": "{{user `install_password`}}"
|
||||||
@@ -249,7 +248,8 @@
|
|||||||
"{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1",
|
"{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1",
|
||||||
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1",
|
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1",
|
||||||
"{{ template_dir }}/scripts/Installers/Configure-GDIProcessHandleQuota.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_user": "{{user `install_user`}}",
|
||||||
"elevated_password": "{{user `install_password`}}"
|
"elevated_password": "{{user `install_password`}}"
|
||||||
|
|||||||
@@ -161,10 +161,9 @@
|
|||||||
3010
|
3010
|
||||||
],
|
],
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1",
|
|
||||||
"{{ template_dir }}/scripts/Installers/Install-VS.ps1",
|
"{{ template_dir }}/scripts/Installers/Install-VS.ps1",
|
||||||
"{{ template_dir }}/scripts/Installers/Install-NET48.ps1",
|
"{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1",
|
||||||
"{{ template_dir }}/scripts/Installers/Enable-DeveloperMode.ps1"
|
"{{ template_dir }}/scripts/Installers/Install-NET48.ps1"
|
||||||
],
|
],
|
||||||
"elevated_user": "{{user `install_user`}}",
|
"elevated_user": "{{user `install_user`}}",
|
||||||
"elevated_password": "{{user `install_password`}}"
|
"elevated_password": "{{user `install_password`}}"
|
||||||
@@ -258,7 +257,8 @@
|
|||||||
"{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1",
|
"{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1",
|
||||||
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1",
|
"{{ template_dir }}/scripts/Installers/Configure-DynamicPort.ps1",
|
||||||
"{{ template_dir }}/scripts/Installers/Configure-GDIProcessHandleQuota.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_user": "{{user `install_user`}}",
|
||||||
"elevated_password": "{{user `install_password`}}"
|
"elevated_password": "{{user `install_password`}}"
|
||||||
|
|||||||
Reference in New Issue
Block a user