From a2d76d2a0e52f14897950ac014385ac71a5c9290 Mon Sep 17 00:00:00 2001 From: Maxim Lobanov Date: Mon, 23 Aug 2021 11:13:14 +0300 Subject: [PATCH] Add Windows Server 2022 image templates (#3929) * add windows2022 image template Co-authored-by: Aleksandr Chebotov Co-authored-by: Mikhail Timofeev <48208649+miketimofeev@users.noreply.github.com> Co-authored-by: Aleksandr Chebotov <47745270+al-cheb@users.noreply.github.com> Co-authored-by: MaksimZhukov <46996400+MaksimZhukov@users.noreply.github.com> --- .../azure-pipelines/windows2022.yml | 20 ++ .../scripts/ImageHelpers/ImageHelpers.psm1 | 1 + .../scripts/ImageHelpers/InstallHelpers.ps1 | 5 + .../scripts/Installers/Configure-Shell.ps1 | 4 +- .../scripts/Installers/Install-DotnetSDK.ps1 | 58 ++-- .../scripts/Installers/Update-ImageData.ps1 | 6 +- .../SoftwareReport/SoftwareReport.Common.psm1 | 23 +- .../SoftwareReport.Generator.ps1 | 59 ++-- images/win/scripts/Tests/BizTalk.Tests.ps1 | 2 +- images/win/scripts/Tests/CLI.Tools.Tests.ps1 | 2 +- .../win/scripts/Tests/ChocoPackages.Tests.ps1 | 6 +- images/win/scripts/Tests/MSYS2.Tests.ps1 | 9 +- images/win/scripts/Tests/Miniconda.Tests.ps1 | 2 +- .../scripts/Tests/PowerShellModules.Tests.ps1 | 4 +- images/win/scripts/Tests/Tools.Tests.ps1 | 17 +- images/win/scripts/Tests/WDK.Tests.ps1 | 2 +- images/win/scripts/Tests/Wix.Tests.ps1 | 2 +- images/win/toolsets/toolset-2022.json | 247 +++++++++++++++ images/win/windows2022.json | 285 ++++++++++++++++++ 19 files changed, 679 insertions(+), 75 deletions(-) create mode 100644 images.CI/linux-and-win/azure-pipelines/windows2022.yml create mode 100644 images/win/toolsets/toolset-2022.json create mode 100644 images/win/windows2022.json diff --git a/images.CI/linux-and-win/azure-pipelines/windows2022.yml b/images.CI/linux-and-win/azure-pipelines/windows2022.yml new file mode 100644 index 000000000..30dcfa366 --- /dev/null +++ b/images.CI/linux-and-win/azure-pipelines/windows2022.yml @@ -0,0 +1,20 @@ +schedules: +- cron: "0 0 * * *" + displayName: Daily + branches: + include: + - main + always: true + +trigger: none +pr: + autoCancel: true + branches: + include: + - main + +jobs: +- template: image-generation.yml + parameters: + image_type: windows2022 + image_readme_name: Windows2022-Readme.md \ No newline at end of file diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 index 9e5f9424b..5eed22990 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 +++ b/images/win/scripts/ImageHelpers/ImageHelpers.psm1 @@ -25,6 +25,7 @@ Export-ModuleMember -Function @( 'Install-VsixExtension' 'Get-VSExtensionVersion' 'Get-WinVersion' + 'Test-IsWin22' 'Test-IsWin19' 'Test-IsWin16' 'Choco-Install' diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 index 14a164832..30f08c97d 100644 --- a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 +++ b/images/win/scripts/ImageHelpers/InstallHelpers.ps1 @@ -380,6 +380,11 @@ function Get-WinVersion (Get-CimInstance -ClassName Win32_OperatingSystem).Caption } +function Test-IsWin22 +{ + (Get-WinVersion) -match "2022" +} + function Test-IsWin19 { (Get-WinVersion) -match "2019" diff --git a/images/win/scripts/Installers/Configure-Shell.ps1 b/images/win/scripts/Installers/Configure-Shell.ps1 index f3487fe9e..f72b7a3c2 100644 --- a/images/win/scripts/Installers/Configure-Shell.ps1 +++ b/images/win/scripts/Installers/Configure-Shell.ps1 @@ -15,8 +15,8 @@ C:\msys64\usr\bin\bash.exe -leo pipefail %* # gitbash <--> C:\Program Files\Git\bin\bash.exe New-Item -ItemType SymbolicLink -Path "$shellPath\gitbash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" | Out-Null -# WSL is available on Windows Server 2019 -if (Test-IsWin19) +# WSL is available on Windows Server 2019 and Windows Server 2022 +if (-not (Test-IsWin16)) { # wslbash <--> C:\Windows\System32\bash.exe New-Item -ItemType SymbolicLink -Path "$shellPath\wslbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null diff --git a/images/win/scripts/Installers/Install-DotnetSDK.ps1 b/images/win/scripts/Installers/Install-DotnetSDK.ps1 index 1c41de28c..0add58f50 100644 --- a/images/win/scripts/Installers/Install-DotnetSDK.ps1 +++ b/images/win/scripts/Installers/Install-DotnetSDK.ps1 @@ -12,6 +12,32 @@ Set-SystemVariable -SystemVariable DOTNET_MULTILEVEL_LOOKUP -Value "0" [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" +function Get-SDKVersionsToInstall ( + $DotnetVersion +) { + $releaseJson = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${DotnetVersion}/releases.json" + $releasesJsonPath = Start-DownloadWithRetry -Url $releaseJson -Name "releases-${DotnetVersion}.json" + $currentReleases = Get-Content -Path $releasesJsonPath | ConvertFrom-Json + # filtering out the preview/rc releases + $currentReleases = $currentReleases.'releases' | Where-Object { !$_.'release-version'.Contains('-') } + + $sdks = @() + ForEach ($release in $currentReleases) + { + $sdks += $release.'sdk' + $sdks += $release.'sdks' + } + + $sortedSdkVersions = $sdks.version | Sort-Object { [Version] $_ } -Unique + + if (Test-IsWin22) + { + return $sortedSdkVersions | Group-Object { $_.Substring(0, $_.LastIndexOf('.') + 2) } | Foreach-Object { $_.Group[-1] } + } + + return $sortedSdkVersions +} + function Invoke-Warmup ( $SdkVersion ) { @@ -78,35 +104,11 @@ function InstallAllValidSdks() ForEach ($dotnetVersion in $dotnetVersions) { - $releaseJson = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${dotnetVersion}/releases.json" - $releasesJsonPath = Start-DownloadWithRetry -Url $releaseJson -Name "releases-${dotnetVersion}.json" - $currentReleases = Get-Content -Path $releasesJsonPath | ConvertFrom-Json - # filtering out the preview/rc releases - $currentReleases = $currentReleases.'releases' | Where-Object { !$_.'release-version'.Contains('-') } | Sort-Object { [Version] $_.'release-version' } - - ForEach ($release in $currentReleases) + $sdkVersionsToInstall = Get-SDKVersionsToInstall -DotnetVersion $dotnetVersion + + ForEach ($sdkVersion in $sdkVersionsToInstall) { - if ($release.'sdks'.Count -gt 0) - { - Write-Host 'Found sdks property in release: ' + $release.'release-version' + 'with sdks count: ' + $release.'sdks'.Count - - # Remove duplicate entries & preview/rc version from download list - # Sort the sdks on version - $sdks = @($release.'sdk'); - - $sdks += $release.'sdks' | Where-Object { !$_.'version'.Contains('-') -and !$_.'version'.Equals($release.'sdk'.'version') } - $sdks = $sdks | Sort-Object { [Version] $_.'version' } - - ForEach ($sdk in $sdks) - { - InstallSDKVersion -sdkVersion $sdk.'version' -Warmup $warmup - } - } - elseif (!$release.'sdk'.'version'.Contains('-')) - { - $sdkVersion = $release.'sdk'.'version' - InstallSDKVersion -SdkVersion $sdkVersion -Warmup $warmup - } + InstallSDKVersion -SdkVersion $sdkVersion -Warmup $warmup } } } diff --git a/images/win/scripts/Installers/Update-ImageData.ps1 b/images/win/scripts/Installers/Update-ImageData.ps1 index cc4f4b86d..754ce77a1 100644 --- a/images/win/scripts/Installers/Update-ImageData.ps1 +++ b/images/win/scripts/Installers/Update-ImageData.ps1 @@ -7,7 +7,11 @@ $imageVersion = $env:IMAGE_VERSION $imageDataFile = $env:IMAGEDATA_FILE $githubUrl="https://github.com/actions/virtual-environments/blob" -if (Test-IsWin19) { +if (Test-IsWin22) { + $imageLabel = "windows-2022" + $softwareUrl = "${githubUrl}/win22/${imageVersion}/images/win/Windows2022-Readme.md" + $releaseUrl="https://github.com/actions/virtual-environments/releases/tag/win22%2F${imageVersion}" +} elseif (Test-IsWin19) { $imageLabel = "windows-2019" $softwareUrl = "${githubUrl}/win19/${imageVersion}/images/win/Windows2019-Readme.md" $releaseUrl="https://github.com/actions/virtual-environments/releases/tag/win19%2F${imageVersion}" diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 1ff73ab0f..51e8e7708 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -9,7 +9,7 @@ function Get-OSVersion { } function Get-BashVersion { - $version = bash -c 'echo ${BASH_VERSION}' + $version = bash --% -c 'echo ${BASH_VERSION}' return "Bash $version" } @@ -276,6 +276,10 @@ function Get-CachedDockerImages { function Get-CachedDockerImagesTableData { $allImages = docker images --digests --format "*{{.Repository}}:{{.Tag}}|{{.Digest}} |{{.CreatedAt}}" + if (-not $allImages) { + return $null + } + $allImages.Split("*") | Where-Object { $_ } | ForEach-Object { $parts = $_.Split("|") [PSCustomObject] @{ @@ -321,16 +325,21 @@ function Get-PipxVersion { } function Build-PackageManagementEnvironmentTable { - return @( - @{ - "Name" = "CONDA" - "Value" = $env:CONDA - }, + $envVariables = @( @{ "Name" = "VCPKG_INSTALLATION_ROOT" "Value" = $env:VCPKG_INSTALLATION_ROOT } - ) | ForEach-Object { + ) + if ((Test-IsWin16) -or (Test-IsWin19)) { + $envVariables += @( + @{ + "Name" = "CONDA" + "Value" = $env:CONDA + } + ) + } + return $envVariables | ForEach-Object { [PSCustomObject] @{ "Name" = $_.Name "Value" = $_.Value diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index 67cd528fc..c664ef980 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -31,25 +31,27 @@ if (Test-IsWin19) $markdown += New-MDHeader "Installed Software" -Level 2 $markdown += New-MDHeader "Language and Runtime" -Level 3 -$markdown += New-MDList -Style Unordered -Lines (@( +$languageTools = @( (Get-BashVersion), (Get-GoVersion), (Get-JuliaVersion), (Get-NodeVersion), - (Get-PerlVersion), (Get-PHPVersion), (Get-PythonVersion), (Get-RubyVersion), (Get-KotlinVersion) - ) | Sort-Object ) +if ((Test-IsWin16) -or (Test-IsWin19)) { + $languageTools += @( + (Get-PerlVersion) + ) +} +$markdown += New-MDList -Style Unordered -Lines ($languageTools | Sort-Object) -$markdown += New-MDHeader "Package Management" -Level 3 -$markdown += New-MDList -Style Unordered -Lines (@( +$packageManagementList = @( (Get-ChocoVersion), (Get-ComposerVersion), (Get-HelmVersion), - (Get-CondaVersion), (Get-NPMVersion), (Get-NugetVersion), (Get-PipxVersion), @@ -57,23 +59,36 @@ $markdown += New-MDList -Style Unordered -Lines (@( (Get-RubyGemsVersion), (Get-VcpkgVersion), (Get-YarnVersion) - ) | Sort-Object ) + +if ((Test-IsWin16) -or (Test-IsWin19)) { + $packageManagementList += @( + (Get-CondaVersion) + ) +} + +$markdown += New-MDHeader "Package Management" -Level 3 +$markdown += New-MDList -Style Unordered -Lines ($packageManagementList | Sort-Object) + $markdown += New-MDHeader "Environment variables" -Level 4 $markdown += Build-PackageManagementEnvironmentTable | New-MDTable $markdown += New-MDNewLine $markdown += New-MDHeader "Project Management" -Level 3 -$markdown += New-MDList -Style Unordered -Lines (@( +$projectManagementTools = @( (Get-AntVersion), (Get-GradleVersion), - (Get-MavenVersion), - (Get-SbtVersion) - ) | Sort-Object + (Get-MavenVersion) ) +if ((Test-IsWin16) -or (Test-IsWin19)) { + $projectManagementTools += @( + (Get-SbtVersion) + ) +} +$markdown += New-MDList -Style Unordered -Lines ($projectManagementTools | Sort-Object) $markdown += New-MDHeader "Tools" -Level 3 -$markdown += New-MDList -Style Unordered -Lines (@( +$toolsList = @( (Get-7zipVersion), (Get-Aria2Version), (Get-AzCopyVersion), @@ -89,7 +104,6 @@ $markdown += New-MDList -Style Unordered -Lines (@( (Get-GitVersion), (Get-GitLFSVersion), (Get-GVFSVersion), - (Get-GoogleCloudSDKVersion), (Get-InnoSetupVersion), (Get-JQVersion), (Get-KindVersion), @@ -97,7 +111,6 @@ $markdown += New-MDList -Style Unordered -Lines (@( (Get-MercurialVersion), (Get-MinGWVersion), (Get-NewmanVersion), - (Get-NSISVersion), (Get-OpenSSLVersion), (Get-PackerVersion), (Get-PulumiVersion), @@ -109,22 +122,32 @@ $markdown += New-MDList -Style Unordered -Lines (@( (Get-WinAppDriver), (Get-ZstdVersion), (Get-YAMLLintVersion) - ) | Sort-Object ) +if ((Test-IsWin16) -or (Test-IsWin19)) { + $toolsList += @( + (Get-NSISVersion), + (Get-GoogleCloudSDKVersion) + ) +} +$markdown += New-MDList -Style Unordered -Lines ($toolsList | Sort-Object) $markdown += New-MDHeader "CLI Tools" -Level 3 -$markdown += New-MDList -Style Unordered -Lines (@( +$cliTools = @( (Get-AlibabaCLIVersion), (Get-AWSCLIVersion), (Get-AWSSAMVersion), (Get-AWSSessionManagerVersion), (Get-AzureCLIVersion), (Get-AzureDevopsExtVersion), - (Get-CloudFoundryVersion), (Get-GHVersion), (Get-HubVersion) - ) | Sort-Object ) +if ((Test-IsWin16) -or (Test-IsWin19)) { + $cliTools += @( + (Get-CloudFoundryVersion) + ) +} +$markdown += New-MDList -Style Unordered -Lines ($cliTools | Sort-Object) $markdown += New-MDHeader "Rust Tools" -Level 3 $markdown += New-MDList -Style Unordered -Lines (@( diff --git a/images/win/scripts/Tests/BizTalk.Tests.ps1 b/images/win/scripts/Tests/BizTalk.Tests.ps1 index efe792162..0a3860c70 100644 --- a/images/win/scripts/Tests/BizTalk.Tests.ps1 +++ b/images/win/scripts/Tests/BizTalk.Tests.ps1 @@ -3,7 +3,7 @@ ## Desc: Test BizTalk project build component installed. ################################################################################ -Describe "BizTalk Build Component Setup" -Skip:(Test-IsWin16) { +Describe "BizTalk Build Component Setup" -Skip:(-not (Test-IsWin19)) { It "BizTalk Registry Check" { Test-Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\BizTalk Server\3.0" | Should -BeTrue } diff --git a/images/win/scripts/Tests/CLI.Tools.Tests.ps1 b/images/win/scripts/Tests/CLI.Tools.Tests.ps1 index d230fcfcd..c508c4d72 100644 --- a/images/win/scripts/Tests/CLI.Tools.Tests.ps1 +++ b/images/win/scripts/Tests/CLI.Tools.Tests.ps1 @@ -39,7 +39,7 @@ Describe "GitHub CLI" { } } -Describe "CloudFoundry CLI" { +Describe "CloudFoundry CLI" -Skip:(Test-IsWin22) { It "cf is located in C:\cf-cli" { "C:\cf-cli\cf.exe" | Should -Exist } diff --git a/images/win/scripts/Tests/ChocoPackages.Tests.ps1 b/images/win/scripts/Tests/ChocoPackages.Tests.ps1 index 1fb602acd..cb95e0954 100644 --- a/images/win/scripts/Tests/ChocoPackages.Tests.ps1 +++ b/images/win/scripts/Tests/ChocoPackages.Tests.ps1 @@ -22,13 +22,13 @@ Describe "Bicep" { } } -Describe "GitVersion" { +Describe "GitVersion" -Skip:(Test-IsWin22) { It "gitversion is installed" { "gitversion /version" | Should -ReturnZeroExitCode } } -Describe "InnoSetup" { +Describe "InnoSetup" -Skip:(Test-IsWin22) { It "InnoSetup" { (Get-Command -Name iscc).CommandType | Should -BeExactly "Application" } @@ -58,7 +58,7 @@ Describe "Packer" { } } -Describe "Perl" { +Describe "Perl" -Skip:(Test-IsWin22) { It "Perl" { "perl --version" | Should -ReturnZeroExitCode } diff --git a/images/win/scripts/Tests/MSYS2.Tests.ps1 b/images/win/scripts/Tests/MSYS2.Tests.ps1 index 9316730b1..85e1fc512 100644 --- a/images/win/scripts/Tests/MSYS2.Tests.ps1 +++ b/images/win/scripts/Tests/MSYS2.Tests.ps1 @@ -14,10 +14,15 @@ Describe "MSYS2 packages" { $TestCases = @( @{ ToolName = "bash.exe" } - @{ ToolName = "tar.exe" } - @{ ToolName = "make.exe" } ) + if ((Test-IsWin16) -or (Test-IsWin19)) { + $TestCases += @( + @{ ToolName = "tar.exe" } + @{ ToolName = "make.exe" } + ) + } + It " is installed in " -TestCases $TestCases { (Get-Command "$ToolName").Source | Should -BeLike "$msys2Dir*" } diff --git a/images/win/scripts/Tests/Miniconda.Tests.ps1 b/images/win/scripts/Tests/Miniconda.Tests.ps1 index b19f2db51..c3538d70e 100644 --- a/images/win/scripts/Tests/Miniconda.Tests.ps1 +++ b/images/win/scripts/Tests/Miniconda.Tests.ps1 @@ -1,4 +1,4 @@ -Describe "Miniconda" { +Describe "Miniconda" -Skip:(Test-IsWin22) { It "Miniconda Environment variables is set. " { ${env:CONDA} | Should -Not -BeNullOrEmpty } diff --git a/images/win/scripts/Tests/PowerShellModules.Tests.ps1 b/images/win/scripts/Tests/PowerShellModules.Tests.ps1 index ebda62bb9..48254d48b 100644 --- a/images/win/scripts/Tests/PowerShellModules.Tests.ps1 +++ b/images/win/scripts/Tests/PowerShellModules.Tests.ps1 @@ -59,8 +59,8 @@ Describe "AzureModules" { if ($module.default) { $moduleInfo = @{ moduleName = $moduleName; moduleDefault = $module.default } It " set as default" -TestCases $moduleInfo { - $moduleVersion = (Get-Module -ListAvailable -Name $moduleName).Version.ToString() - $moduleVersion | Should -Match $moduleDefault + $moduleVersions = Get-Module -ListAvailable -Name $moduleName | ForEach-Object { $_.Version.ToString() } + $moduleVersions | Should -Contain $moduleDefault } } } diff --git a/images/win/scripts/Tests/Tools.Tests.ps1 b/images/win/scripts/Tests/Tools.Tests.ps1 index 03756723e..6755193ad 100644 --- a/images/win/scripts/Tests/Tools.Tests.ps1 +++ b/images/win/scripts/Tests/Tools.Tests.ps1 @@ -42,13 +42,16 @@ Describe "DACFx" { It "DACFx" { (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*).DisplayName -Contains "Microsoft SQL Server Data-Tier Application Framework (x64)" | Should -BeTrue $sqlPackagePath = 'C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe' - $sqlLocalDBPath = 'C:\Program Files\Microsoft SQL Server\130\Tools\Binn\SqlLocalDB.exe' "${sqlPackagePath}" | Should -Exist + } + + It "SqlLocalDB" -Skip:(Test-IsWin22) { + $sqlLocalDBPath = 'C:\Program Files\Microsoft SQL Server\130\Tools\Binn\SqlLocalDB.exe' "${sqlLocalDBPath}" | Should -Exist } } -Describe "DotnetTLS" { +Describe "DotnetTLS" -Skip:(Test-IsWin22) { It "Tls 1.2 is enabled" { [Net.ServicePointManager]::SecurityProtocol -band "Tls12" | Should -Be Tls12 } @@ -88,7 +91,7 @@ Describe "Mingw64" { } } -Describe "GoogleCloudSDK" { +Describe "GoogleCloudSDK" -Skip:(Test-IsWin22) { It "" -TestCases @( @{ ToolName = "bq" } @{ ToolName = "gcloud" } @@ -105,7 +108,7 @@ Describe "NET48" { } } -Describe "NSIS" { +Describe "NSIS" -Skip:(Test-IsWin22) { It "NSIS" { "makensis /VERSION" | Should -ReturnZeroExitCode } @@ -121,13 +124,13 @@ Describe "PowerShell Core" { } } -Describe "Sbt" { +Describe "Sbt" -Skip:(Test-IsWin22) { It "sbt" { "sbt --version" | Should -ReturnZeroExitCode } } -Describe "ServiceFabricSDK" { +Describe "ServiceFabricSDK" -Skip:(Test-IsWin22) { It "PowerShell Module" { Get-Module -Name ServiceFabric -ListAvailable | Should -Not -BeNullOrEmpty } @@ -153,7 +156,7 @@ Describe "Vcpkg" { } } -Describe "WebPlatformInstaller" { +Describe "WebPlatformInstaller" -Skip:(Test-IsWin22) { It "WebPlatformInstaller" { "WebPICMD" | Should -ReturnZeroExitCode } diff --git a/images/win/scripts/Tests/WDK.Tests.ps1 b/images/win/scripts/Tests/WDK.Tests.ps1 index c67586e79..6c5dc3295 100644 --- a/images/win/scripts/Tests/WDK.Tests.ps1 +++ b/images/win/scripts/Tests/WDK.Tests.ps1 @@ -1,4 +1,4 @@ -Describe "WDK" { +Describe "WDK" -Skip:(Test-IsWin22) { It "WDK exists" { $WDKVersion = (Get-CimInstance -ClassName Win32_Product -Filter "Name = 'Windows Driver Kit'").Version $WDKVersion| Should -Not -BeNullOrEmpty diff --git a/images/win/scripts/Tests/Wix.Tests.ps1 b/images/win/scripts/Tests/Wix.Tests.ps1 index 2a12261e2..ed9bed384 100644 --- a/images/win/scripts/Tests/Wix.Tests.ps1 +++ b/images/win/scripts/Tests/Wix.Tests.ps1 @@ -1,4 +1,4 @@ -Describe "Wix" { +Describe "Wix" -Skip:(Test-IsWin22) { BeforeAll { $regKey = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*" $installedApplications = Get-ItemProperty -Path $regKey diff --git a/images/win/toolsets/toolset-2022.json b/images/win/toolsets/toolset-2022.json new file mode 100644 index 000000000..32803e3e6 --- /dev/null +++ b/images/win/toolsets/toolset-2022.json @@ -0,0 +1,247 @@ +{ + "toolcache": [ + { + "name": "Ruby", + "arch": "x64", + "platform" : "win32", + "versions": [ + "2.7", + "3.0" + ], + "default": "3.0" + }, + { + "name": "Python", + "url" : "https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json", + "arch": "x64", + "platform" : "win32", + "versions": [ + "3.7.*", + "3.8.*", + "3.9.*" + ], + "default": "3.9.*" + }, + { + "name": "PyPy", + "arch": "x86", + "platform" : "win64", + "versions": [ + "2.7", + "3.7" + ] + }, + { + "name": "node", + "url" : "https://raw.githubusercontent.com/actions/node-versions/main/versions-manifest.json", + "arch": "x64", + "platform" : "win32", + "versions": [ + "10.*", + "12.*", + "14.*" + ] + }, + { + "name": "go", + "url" : "https://raw.githubusercontent.com/actions/go-versions/main/versions-manifest.json", + "arch": "x64", + "platform" : "win32", + "versions": [ + "1.15.*", + "1.16.*" + ], + "default": "1.16.*" + } + ], + "powershellModules": [ + { "name": "DockerMsftProvider" }, + { "name": "MarkdownPS" }, + { "name": "Pester" }, + { "name": "PowerShellGet" }, + { "name": "PSScriptAnalyzer" }, + { "name": "PSWindowsUpdate" }, + { "name": "SqlServer" }, + { "name": "VSSetup" } + ], + "azureModules": [ + { + "name": "azurerm", + "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", + "versions": [ + "2.1.0", + "6.13.1" + ], + "zip_versions": [ + "3.8.0", + "4.2.1", + "5.1.1", + "6.7.0" + ], + "default": "2.1.0" + }, + { + "name": "azure", + "blob_url": "https://vstsagenttools.blob.core.windows.net/tools/azurepowershellmodules/", + "versions": [ + "2.1.0", + "5.3.0" + ], + "zip_versions": [ + "3.8.0", + "4.2.1", + "5.1.1" + ], + "default": "2.1.0" + }, + { + "name": "az", + "url" : "https://raw.githubusercontent.com/Azure/az-ps-module-versions/main/versions-manifest.json", + "versions": [ + "6.1.0" + ], + "zip_versions": [] + } + ], + "java": { + "default": "8", + "versions": [ + "8", "11" + ] + }, + "android": { + "platform_min_version": "27", + "build_tools_min_version": "27.0.0", + "extra_list": [ + "android;m2repository", + "google;m2repository", + "google;google_play_services" + ], + "addon_list": [], + "additional_tools": [ + "cmake;3.18.1", + "patcher;v4" + ], + "ndk": { + "lts": "21", + "latest": "22" + } + }, + "MsysPackages": { + "msys2": [], + "mingw": [] + }, + "windowsFeatures": [ + { "name": "Containers" }, + { "name": "Microsoft-Windows-Subsystem-Linux", "optionalFeature": true }, + { "name": "VirtualMachinePlatform", "optionalFeature": true }, + { "name": "NET-Framework-45-Features", "includeAllSubFeatures": true }, + { "name": "Client-ProjFS", "optionalFeature": true }, + { "name": "NET-Framework-Features", "includeAllSubFeatures": true } + ], + "visualStudio": { + "version" : "2022", + "subversion" : "17", + "edition" : "Enterprise", + "channel": "pre", + "workloads": [ + "Component.Linux.CMake", + "Component.UnityEngine.x64", + "Component.Unreal.Android", + "Microsoft.Component.VC.Runtime.UCRTSDK", + "Microsoft.Net.Component.4.7.2.TargetingPack", + "Microsoft.VisualStudio.Component.AspNet45", + "Microsoft.VisualStudio.Component.Azure.ServiceFabric.Tools", + "Microsoft.VisualStudio.Component.Debugger.JustInTime", + "Microsoft.VisualStudio.Component.EntityFramework", + "Microsoft.VisualStudio.Component.LinqToSql", + "Microsoft.VisualStudio.Component.SQL.SSDT", + "Microsoft.VisualStudio.Component.Sharepoint.Tools", + "Microsoft.VisualStudio.Component.PortableLibrary", + "Microsoft.VisualStudio.Component.TeamOffice", + "Microsoft.VisualStudio.Component.TestTools.CodedUITest", + "Microsoft.VisualStudio.Component.TestTools.WebLoadTest", + "Microsoft.VisualStudio.Component.VC.CLI.Support", + "Microsoft.VisualStudio.Component.VC.CMake.Project", + "Microsoft.VisualStudio.Component.VC.DiagnosticTools", + "Microsoft.VisualStudio.Component.VC.Llvm.ClangToolset", + "Microsoft.VisualStudio.Component.VC.Runtimes.x86.x64.Spectre", + "Microsoft.VisualStudio.Component.VC.TestAdapterForBoostTest", + "Microsoft.VisualStudio.Component.VC.TestAdapterForGoogleTest", + "Microsoft.VisualStudio.Component.VC.v141.x86.x64", + "Microsoft.VisualStudio.Component.VC.v141.x86.x64.Spectre", + "Microsoft.VisualStudio.Component.VC.v141.MFC", + "Microsoft.VisualStudio.Component.VC.v141.MFC.Spectre", + "Microsoft.VisualStudio.Component.Windows10SDK.19041", + "Microsoft.VisualStudio.Component.Workflow", + "Microsoft.VisualStudio.ComponentGroup.Azure.CloudServices", + "Microsoft.VisualStudio.ComponentGroup.Azure.ResourceManager.Tools", + "Microsoft.VisualStudio.ComponentGroup.Web.CloudTools", + "Microsoft.VisualStudio.Workload.Azure", + "Microsoft.VisualStudio.Workload.Data", + "Microsoft.VisualStudio.Workload.ManagedDesktop", + "Microsoft.VisualStudio.Workload.ManagedGame", + "Microsoft.VisualStudio.Workload.NativeCrossPlat", + "Microsoft.VisualStudio.Workload.NativeDesktop", + "Microsoft.VisualStudio.Workload.NativeGame", + "Microsoft.VisualStudio.Workload.NativeMobile", + "Microsoft.VisualStudio.Workload.NetCrossPlat", + "Microsoft.VisualStudio.Workload.NetWeb", + "Microsoft.VisualStudio.Workload.Node", + "Microsoft.VisualStudio.Workload.Office", + "Microsoft.VisualStudio.Workload.Python", + "Microsoft.VisualStudio.Workload.Universal", + "Microsoft.VisualStudio.Workload.VisualStudioExtension", + "Component.MDD.Linux" + ], + "vsix": [] + }, + "docker": { + "images": [] + }, + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint --version" + } + ], + "npm": { + "global_packages": [ + { "name": "yarn", "test": "yarn --version" }, + { "name": "newman", "test": "newman --version" }, + { "name": "lerna", "test": "lerna --version" } + ] + }, + "dotnet": { + "versions": [ + "3.1", + "5.0" + ], + "warmup": false + }, + "choco": { + "common_packages": [ + { "name": "7zip.install" }, + { "name": "aria2" }, + { "name": "azcopy10" }, + { "name": "Bicep" }, + { "name": "jq" }, + { "name": "NuGet.CommandLine" }, + { "name": "openssl.light" }, + { "name": "packer" }, + { "name": "pulumi" }, + { "name": "tortoisesvn" }, + { "name": "swig" }, + { "name": "vswhere" }, + { "name": "kotlinc" }, + { + "name": "julia", + "args": [ "--ia", "/DIR=C:\\Julia" ] + }, + { + "name": "cmake.install", + "args": [ "--installargs", "ADD_CMAKE_TO_PATH=\"System\"" ] + } + ] + } +} diff --git a/images/win/windows2022.json b/images/win/windows2022.json new file mode 100644 index 000000000..a0ad7b76b --- /dev/null +++ b/images/win/windows2022.json @@ -0,0 +1,285 @@ +{ + "variables": { + "client_id": "{{env `ARM_CLIENT_ID`}}", + "client_secret": "{{env `ARM_CLIENT_SECRET`}}", + "subscription_id": "{{env `ARM_SUBSCRIPTION_ID`}}", + "tenant_id": "{{env `ARM_TENANT_ID`}}", + "object_id": "{{env `ARM_OBJECT_ID`}}", + "resource_group": "{{env `ARM_RESOURCE_GROUP`}}", + "storage_account": "{{env `ARM_STORAGE_ACCOUNT`}}", + "build_resource_group_name": "{{env `BUILD_RESOURCE_GROUP_NAME`}}", + "temp_resource_group_name": "{{env `TEMP_RESOURCE_GROUP_NAME`}}", + "location": "{{env `ARM_RESOURCE_LOCATION`}}", + "virtual_network_name": "{{env `VNET_NAME`}}", + "virtual_network_resource_group_name": "{{env `VNET_RESOURCE_GROUP`}}", + "virtual_network_subnet_name": "{{env `VNET_SUBNET`}}", + "private_virtual_network_with_public_ip": "{{env `PRIVATE_VIRTUAL_NETWORK_WITH_PUBLIC_IP`}}", + "allowed_inbound_ip_addresses": "{{env `AGENT_IP`}}", + "vm_size": "Standard_D8s_v4", + "image_folder": "C:\\image", + "imagedata_file": "C:\\imagedata.json", + "helper_script_folder": "C:\\Program Files\\WindowsPowerShell\\Modules\\", + "agent_tools_directory": "C:\\hostedtoolcache\\windows", + "install_user": "installer", + "install_password": null, + "capture_name_prefix": "packer", + "image_version": "dev", + "image_os": "win22" + }, + "sensitive-variables": [ + "install_password", + "client_secret" + ], + "builders": [ + { + "name": "vhd", + "type": "azure-arm", + "client_id": "{{user `client_id`}}", + "client_secret": "{{user `client_secret`}}", + "subscription_id": "{{user `subscription_id`}}", + "object_id": "{{user `object_id`}}", + "tenant_id": "{{user `tenant_id`}}", + "os_disk_size_gb": "256", + "location": "{{user `location`}}", + "vm_size": "{{user `vm_size`}}", + "resource_group_name": "{{user `resource_group`}}", + "storage_account": "{{user `storage_account`}}", + "build_resource_group_name": "{{user `build_resource_group_name`}}", + "temp_resource_group_name": "{{user `temp_resource_group_name`}}", + "capture_container_name": "images", + "capture_name_prefix": "{{user `capture_name_prefix`}}", + "virtual_network_name": "{{user `virtual_network_name`}}", + "virtual_network_resource_group_name": "{{user `virtual_network_resource_group_name`}}", + "virtual_network_subnet_name": "{{user `virtual_network_subnet_name`}}", + "private_virtual_network_with_public_ip": "{{user `private_virtual_network_with_public_ip`}}", + "allowed_inbound_ip_addresses": "{{user `allowed_inbound_ip_addresses`}}", + "os_type": "Windows", + "image_publisher": "MicrosoftWindowsServer", + "image_offer": "WindowsServer", + "image_sku": "2022-Datacenter", + "communicator": "winrm", + "winrm_use_ssl": "true", + "winrm_insecure": "true", + "winrm_username": "packer" + } + ], + "provisioners": [ + { + "type": "powershell", + "inline": [ + "New-Item -Path {{user `image_folder`}} -ItemType Directory -Force" + ] + }, + { + "type": "file", + "source": "{{ template_dir }}/scripts/ImageHelpers", + "destination": "{{user `helper_script_folder`}}" + }, + { + "type": "file", + "source": "{{ template_dir }}/scripts/SoftwareReport", + "destination": "{{user `image_folder`}}" + }, + { + "type": "file", + "source": "{{ template_dir }}/post-generation", + "destination": "C:/" + }, + { + "type": "file", + "source": "{{ template_dir }}/scripts/Tests", + "destination": "{{user `image_folder`}}" + }, + { + "type": "file", + "source": "{{template_dir}}/toolsets/toolset-2022.json", + "destination": "{{user `image_folder`}}\\toolset.json" + }, + { + "type": "windows-shell", + "inline": [ + "net user {{user `install_user`}} {{user `install_password`}} /add /passwordchg:no /passwordreq:yes /active:yes /Y", + "net localgroup Administrators {{user `install_user`}} /add", + "winrm set winrm/config/service/auth @{Basic=\"true\"}", + "winrm get winrm/config/service/auth" + ] + }, + { + "type": "powershell", + "inline": [ + "if (-not ((net localgroup Administrators) -contains '{{user `install_user`}}')) { exit 1 }" + ] + }, + { + "type": "powershell", + "environment_vars": [ + "IMAGE_VERSION={{user `image_version`}}", + "IMAGE_OS={{user `image_os`}}", + "AGENT_TOOLSDIRECTORY={{user `agent_tools_directory`}}", + "IMAGEDATA_FILE={{user `imagedata_file`}}" + ], + "scripts": [ + "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1", + "{{ template_dir }}/scripts/Installers/Install-PowerShellModules.ps1", + "{{ template_dir }}/scripts/Installers/Install-WindowsFeatures.ps1", + "{{ template_dir }}/scripts/Installers/Install-Choco.ps1", + "{{ template_dir }}/scripts/Installers/Initialize-VM.ps1", + "{{ template_dir }}/scripts/Installers/Update-ImageData.ps1", + "{{ template_dir }}/scripts/Installers/Update-DotnetTLS.ps1" + ], + "execution_policy": "unrestricted" + }, + { + "type": "windows-restart", + "restart_timeout": "10m" + }, + { + "type": "powershell", + "scripts": [ + "{{ template_dir }}/scripts/Installers/Install-VCRedist.ps1", + "{{ template_dir }}/scripts/Installers/Install-Docker.ps1", + "{{ template_dir }}/scripts/Installers/Install-PowershellCore.ps1" + ] + }, + { + "type": "windows-restart", + "restart_timeout": "10m" + }, + { + "type": "powershell", + "valid_exit_codes": [ + 0, + 3010 + ], + "scripts": [ + "{{ template_dir }}/scripts/Installers/Install-VS.ps1", + "{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1" + ], + "elevated_user": "{{user `install_user`}}", + "elevated_password": "{{user `install_password`}}" + }, + { + "type": "powershell", + "scripts": [ + "{{ template_dir }}/scripts/Installers/Install-Vsix.ps1", + "{{ template_dir }}/scripts/Installers/Install-AzureCli.ps1", + "{{ template_dir }}/scripts/Installers/Install-AzureDevOpsCli.ps1", + "{{ template_dir }}/scripts/Installers/Install-NodeLts.ps1", + "{{ template_dir }}/scripts/Installers/Install-CommonUtils.ps1", + "{{ template_dir }}/scripts/Installers/Install-JavaTools.ps1" + ] + }, + { + "type": "windows-restart", + "restart_timeout": "10m" + }, + { + "type": "windows-shell", + "inline": [ + "wmic product where \"name like '%%microsoft azure powershell%%'\" call uninstall /nointeractive" + ] + }, + { + "type": "powershell", + "scripts": [ + "{{ template_dir }}/scripts/Installers/Install-Ruby.ps1", + "{{ template_dir }}/scripts/Installers/Install-PyPy.ps1", + "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1", + "{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1", + "{{ template_dir }}/scripts/Installers/Install-AndroidSDK.ps1", + "{{ template_dir }}/scripts/Installers/Install-AzureModules.ps1", + "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", + "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1", + "{{ template_dir }}/scripts/Installers/Install-Git.ps1", + "{{ template_dir }}/scripts/Installers/Install-GitHub-CLI.ps1", + "{{ template_dir }}/scripts/Installers/Install-PHP.ps1", + "{{ template_dir }}/scripts/Installers/Install-Rust.ps1", + "{{ template_dir }}/scripts/Installers/Install-Chrome.ps1", + "{{ template_dir }}/scripts/Installers/Install-Edge.ps1", + "{{ template_dir }}/scripts/Installers/Install-Firefox.ps1", + "{{ template_dir }}/scripts/Installers/Install-Selenium.ps1", + "{{ template_dir }}/scripts/Installers/Install-IEWebDriver.ps1", + "{{ template_dir }}/scripts/Installers/Install-Apache.ps1", + "{{ template_dir }}/scripts/Installers/Install-Nginx.ps1", + "{{ template_dir }}/scripts/Installers/Install-Msys2.ps1", + "{{ template_dir }}/scripts/Installers/Install-WinAppDriver.ps1", + "{{ template_dir }}/scripts/Installers/Install-R.ps1", + "{{ template_dir }}/scripts/Installers/Install-AWS.ps1", + "{{ template_dir }}/scripts/Installers/Install-DACFx.ps1", + "{{ template_dir }}/scripts/Installers/Install-MysqlCli.ps1", + "{{ template_dir }}/scripts/Installers/Install-SQLPowerShellTools.ps1", + "{{ template_dir }}/scripts/Installers/Install-DotnetSDK.ps1", + "{{ template_dir }}/scripts/Installers/Install-Mingw64.ps1", + "{{ template_dir }}/scripts/Installers/Install-Haskell.ps1", + "{{ template_dir }}/scripts/Installers/Install-Stack.ps1", + "{{ template_dir }}/scripts/Installers/Install-AzureCosmosDbEmulator.ps1", + "{{ template_dir }}/scripts/Installers/Install-Mercurial.ps1", + "{{ template_dir }}/scripts/Installers/Install-Zstd.ps1", + "{{ template_dir }}/scripts/Installers/Install-Vcpkg.ps1", + "{{ template_dir }}/scripts/Installers/Install-PostgreSQL.ps1", + "{{ template_dir }}/scripts/Installers/Install-Bazel.ps1", + "{{ template_dir }}/scripts/Installers/Install-AliyunCli.ps1", + "{{ template_dir }}/scripts/Installers/Install-RootCA.ps1", + "{{ template_dir }}/scripts/Installers/Install-MongoDB.ps1", + "{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1", + "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.ps1", + "{{ template_dir }}/scripts/Installers/Run-NGen.ps1" + ] + }, + { + "type": "powershell", + "scripts": [ + "{{ 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/Enable-DeveloperMode.ps1" + ], + "elevated_user": "{{user `install_user`}}", + "elevated_password": "{{user `install_password`}}" + }, + { + "type": "windows-restart", + "restart_timeout": "30m" + }, + { + "type": "powershell", + "scripts": [ + "{{ template_dir }}/scripts/Tests/RunAll-Tests.ps1" + ] + }, + { + "type": "powershell", + "inline": [ + "pwsh -File '{{user `image_folder`}}\\SoftwareReport\\SoftwareReport.Generator.ps1'" + ], + "environment_vars": [ + "IMAGE_VERSION={{user `image_version`}}" + ] + }, + { + "type": "file", + "source": "C:\\InstalledSoftware.md", + "destination": "{{ template_dir }}/Windows2022-Readme.md", + "direction": "download" + }, + { + "type": "powershell", + "scripts": [ + "{{ template_dir }}/scripts/Installers/Finalize-VM.ps1" + ] + }, + { + "type": "windows-restart", + "restart_timeout": "10m" + }, + { + "type": "powershell", + "inline": [ + "if( Test-Path $Env:SystemRoot\\System32\\Sysprep\\unattend.xml ){ rm $Env:SystemRoot\\System32\\Sysprep\\unattend.xml -Force}", + "& $env:SystemRoot\\System32\\Sysprep\\Sysprep.exe /oobe /generalize /quiet /quit", + "while($true) { $imageState = Get-ItemProperty HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Setup\\State | Select ImageState; if($imageState.ImageState -ne 'IMAGE_STATE_GENERALIZE_RESEAL_TO_OOBE') { Write-Output $imageState.ImageState; Start-Sleep -s 10 } else { break } }" + ] + } + ] +}