diff --git a/.github/workflows/windows2019.yml b/.github/workflows/windows2019.yml index 72ba4733..0604f357 100644 --- a/.github/workflows/windows2019.yml +++ b/.github/workflows/windows2019.yml @@ -5,7 +5,7 @@ on: pull_request_target: types: labeled paths: - - 'images/win/**' + - 'images/windows/**' defaults: run: diff --git a/.github/workflows/windows2022.yml b/.github/workflows/windows2022.yml index 0454811e..ae3a069b 100644 --- a/.github/workflows/windows2022.yml +++ b/.github/workflows/windows2022.yml @@ -5,7 +5,7 @@ on: pull_request_target: types: labeled paths: - - 'images/win/**' + - 'images/windows/**' defaults: run: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1a874be8..8c72b54d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -34,18 +34,18 @@ Here are a few things you can do that will increase the likelihood of your pull - For every new tool add validation scripts and update software report script to make sure that it is included to documentation - If the tool is available in other platforms (macOS, Windows, Linux), make sure you include it in as many as possible. -- If installing a few versions of the tool, consider putting the list of versions in the corresponding `toolset.json` file. It will help other customers to configure their builds flexibly. See [toolset-windows-2019.json](images/win/toolsets/toolset-2019.json) as example. +- If installing a few versions of the tool, consider putting the list of versions in the corresponding `toolset.json` file. It will help other customers to configure their builds flexibly. See [toolset-windows-2019.json](images/windows/toolsets/toolset-2019.json) as example. - Use consistent naming across all files - Validation scripts should be simple and shouldn't change image content ### Windows -- Add a script that will install the tool and put the script in the `scripts/Installers` folder. -There are a bunch of helper functions that could simplify your code: `Choco-Install`, `Install-Binary`, `Install-VsixExtension`, `Start-DownloadWithRetry`, `Test-IsWin19`, `Test-IsWin22` (find the full list of helpers in [ImageHelpers.psm1](images/win/scripts/ImageHelpers/ImageHelpers.psm1)). -- Add a script that will validate the tool installation and put the script in the `scripts/Tests` folder. +- Add a script that will install the tool and put the script in the `scripts/build` folder. +There are a bunch of helper functions that could simplify your code: `Choco-Install`, `Install-Binary`, `Install-VsixExtension`, `Start-DownloadWithRetry`, `Test-IsWin19`, `Test-IsWin22` (find the full list of helpers in [ImageHelpers.psm1](images/windows/scripts/helpers/ImageHelpers.psm1)). +- Add a script that will validate the tool installation and put the script in the `scripts/tests` folder. We use [Pester v5](https://github.com/pester/pester) for validation scripts. If the tests for the tool are complex enough, create a separate `*.Tests.ps1`. Otherwise, use `Tools.Tests.ps1` for simple tests. Add `Invoke-PesterTests -TestFile [-TestName ]` at the end of the installation script to make sure that your tests will be run. -- Add changes to the software report generator `images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1`. The software report generator is used to generate an image's README file, e.g. [Windows2019-Readme.md](images/win/Windows2019-Readme.md) and uses [MarkdownPS](https://github.com/Sarafian/MarkdownPS). +- Add changes to the software report generator `images/windows/scripts/docs-gen/SoftwareReport.Generator.ps1`. The software report generator is used to generate an image's README file, e.g. [Windows2019-Readme.md](images/windows/Windows2019-Readme.md) and uses [MarkdownPS](https://github.com/Sarafian/MarkdownPS). ### Ubuntu diff --git a/README.md b/README.md index 2605cddc..cb4625b2 100644 --- a/README.md +++ b/README.md @@ -36,12 +36,11 @@ To build a VM machine from this repo's source, see the [instructions](docs/creat [ubuntu-22.04]: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md [ubuntu-20.04]: https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2004-Readme.md -[windows-2022]: https://github.com/actions/runner-images/blob/main/images/win/Windows2022-Readme.md -[windows-2019]: https://github.com/actions/runner-images/blob/main/images/win/Windows2019-Readme.md +[windows-2022]: https://github.com/actions/runner-images/blob/main/images/windows/Windows2022-Readme.md +[windows-2019]: https://github.com/actions/runner-images/blob/main/images/windows/Windows2019-Readme.md [macOS-11]: https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md [macOS-12]: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md [macOS-13]: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md -[macOS-10.15]: https://github.com/actions/runner-images/blob/main/images/macos/macos-10.15-Readme.md [self-hosted runners]: https://help.github.com/en/actions/hosting-your-own-runners ## Announcements diff --git a/docs/create-image-and-azure-resources.md b/docs/create-image-and-azure-resources.md index a1f14ee7..57993feb 100644 --- a/docs/create-image-and-azure-resources.md +++ b/docs/create-image-and-azure-resources.md @@ -216,7 +216,7 @@ Where: - `InstallPassword` - password for the user used to install software (Windows only) - `Location` - location where resources will be created (e.g. "East US") - `ImageName` and `ImageResourceGroupName` - name of the resource group where managed image will be stored -- `TemplatePath` - path to the Packer template file (e.g. "images/win/windows2022.json") +- `TemplatePath` - path to the Packer template file (e.g. "images/windows/templates/windows-2022.json") ### Required variables @@ -269,9 +269,9 @@ Generated tool versions and details can be found in related projects: > :warning: These scripts are intended to run on a VM deployed in Azure -The user, created during the image generation, does not exist in the result image hence some configuration files related to the user's home directory need to be changed as well as the file permissions for some directories. Scripts for that are located in the `post-generation` folder in the repository: +The user, created during the image generation, does not exist in the result image hence some configuration files related to the user's home directory need to be changed as well as the file permissions for some directories. Scripts for that are located in the `post-gen` folder in the repository: -- Windows: +- Windows: - Linux: **Note:** The default user for Linux should have `sudo privileges`. diff --git a/helpers/GenerateResourcesAndImage.ps1 b/helpers/GenerateResourcesAndImage.ps1 index 5dd3b9ca..36528ad1 100644 --- a/helpers/GenerateResourcesAndImage.ps1 +++ b/helpers/GenerateResourcesAndImage.ps1 @@ -18,10 +18,10 @@ Function Get-PackerTemplatePath { switch ($ImageType) { ([ImageType]::Windows2019) { - $relativeTemplatePath = Join-Path "win" "windows2019.json" + $relativeTemplatePath = Join-Path "windows" "templates" "windows-2019.json" } ([ImageType]::Windows2022) { - $relativeTemplatePath = Join-Path "win" "windows2022.json" + $relativeTemplatePath = Join-Path "windows" "templates" "windows-2022.json" } ([ImageType]::Ubuntu2004) { $relativeTemplatePath = Join-Path "linux" "ubuntu2004.json" diff --git a/images.CI/linux-and-win/azure-pipelines/image-generation.yml b/images.CI/linux-and-win/azure-pipelines/image-generation.yml index 20954bdb..778ebb3c 100644 --- a/images.CI/linux-and-win/azure-pipelines/image-generation.yml +++ b/images.CI/linux-and-win/azure-pipelines/image-generation.yml @@ -12,6 +12,9 @@ parameters: - name: image_type type: string + - name: image_template_name + type: string + - name: image_readme_name type: string @@ -62,11 +65,17 @@ jobs: targetType: 'inline' script: | $ImageType = "${{ parameters.image_type }}" - $TemplateDirectoryName = if ($ImageType.StartsWith("ubuntu")) { "linux" } else { "win" } + $TemplateDirectoryName = if ($ImageType.StartsWith("ubuntu")) { "linux" } else { "windows/templates" } $TemplateDirectoryPath = Join-Path "images" $TemplateDirectoryName | Resolve-Path - $TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.pkr.hcl" - if ( -not (Test-Path $TemplatePath) ) { - $TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.json" + + $TemplateFileName = "${{ parameters.image_template_name }}" + if ($TemplateFileName) { + $TemplatePath = Join-Path $TemplateDirectoryPath $TemplateFileName + } else { + $TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.pkr.hcl" + if ( -not (Test-Path $TemplatePath) ) { + $TemplatePath = Join-Path $TemplateDirectoryPath "$ImageType.json" + } } Write-Host "##vso[task.setvariable variable=TemplateDirectoryPath;]$TemplateDirectoryPath" Write-Host "##vso[task.setvariable variable=TemplatePath;]$TemplatePath" @@ -104,8 +113,12 @@ jobs: inputs: targetType: 'inline' script: | - $readmePath = Join-Path "$(TemplateDirectoryPath)" "${{ parameters.image_readme_name }}" - $softwareReportPath = Join-Path "$(TemplateDirectoryPath)" "software-report.json" + $ImageType = "${{ parameters.image_type }}" + $rootDirectoryName = if ($ImageType.StartsWith("ubuntu")) { "linux" } else { "windows" } + $rootDirectoryPath = Join-Path "images" $rootDirectoryName | Resolve-Path + + $readmePath = Join-Path $rootDirectoryPath "${{ parameters.image_readme_name }}" + $softwareReportPath = Join-Path $rootDirectoryPath "software-report.json" Copy-Item -Path $readmePath -Destination "$(Build.ArtifactStagingDirectory)/" if (Test-Path $softwareReportPath) { diff --git a/images.CI/linux-and-win/azure-pipelines/windows2019.yml b/images.CI/linux-and-win/azure-pipelines/windows2019.yml index ccad8f88..d81c173e 100644 --- a/images.CI/linux-and-win/azure-pipelines/windows2019.yml +++ b/images.CI/linux-and-win/azure-pipelines/windows2019.yml @@ -17,4 +17,5 @@ jobs: - template: image-generation.yml parameters: image_type: windows2019 - image_readme_name: Windows2019-Readme.md \ No newline at end of file + image_readme_name: Windows2019-Readme.md + image_template_name: windows-2019.json diff --git a/images.CI/linux-and-win/azure-pipelines/windows2022.yml b/images.CI/linux-and-win/azure-pipelines/windows2022.yml index 30dcfa36..07e52356 100644 --- a/images.CI/linux-and-win/azure-pipelines/windows2022.yml +++ b/images.CI/linux-and-win/azure-pipelines/windows2022.yml @@ -17,4 +17,5 @@ jobs: - template: image-generation.yml parameters: image_type: windows2022 - image_readme_name: Windows2022-Readme.md \ No newline at end of file + image_readme_name: Windows2022-Readme.md + image_template_name: windows-2022.json diff --git a/images/win/scripts/README.md b/images/win/scripts/README.md deleted file mode 100644 index 7204e5ff..00000000 --- a/images/win/scripts/README.md +++ /dev/null @@ -1 +0,0 @@ -Common scripts for all Windows images regardless of Visual Studio or OS version diff --git a/images/win/Windows2019-Readme.md b/images/windows/Windows2019-Readme.md similarity index 100% rename from images/win/Windows2019-Readme.md rename to images/windows/Windows2019-Readme.md diff --git a/images/win/Windows2022-Readme.md b/images/windows/Windows2022-Readme.md similarity index 100% rename from images/win/Windows2022-Readme.md rename to images/windows/Windows2022-Readme.md diff --git a/images/win/post-generation/GenerateIISExpressCertificate.ps1 b/images/windows/assets/post-gen/GenerateIISExpressCertificate.ps1 similarity index 100% rename from images/win/post-generation/GenerateIISExpressCertificate.ps1 rename to images/windows/assets/post-gen/GenerateIISExpressCertificate.ps1 diff --git a/images/win/post-generation/InternetExplorerConfiguration.ps1 b/images/windows/assets/post-gen/InternetExplorerConfiguration.ps1 similarity index 100% rename from images/win/post-generation/InternetExplorerConfiguration.ps1 rename to images/windows/assets/post-gen/InternetExplorerConfiguration.ps1 diff --git a/images/win/post-generation/Msys2FirstLaunch.ps1 b/images/windows/assets/post-gen/Msys2FirstLaunch.ps1 similarity index 100% rename from images/win/post-generation/Msys2FirstLaunch.ps1 rename to images/windows/assets/post-gen/Msys2FirstLaunch.ps1 diff --git a/images/win/post-generation/VSConfiguration.ps1 b/images/windows/assets/post-gen/VSConfiguration.ps1 similarity index 97% rename from images/win/post-generation/VSConfiguration.ps1 rename to images/windows/assets/post-gen/VSConfiguration.ps1 index c21c8b2e..99108897 100644 --- a/images/win/post-generation/VSConfiguration.ps1 +++ b/images/windows/assets/post-gen/VSConfiguration.ps1 @@ -1,14 +1,14 @@ -$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath -$devEnvPath = "$vsInstallRoot\Common7\IDE\devenv.exe" - -# Initialize Visual Studio Experimental Instance -# The Out-Null cmdlet is required to ensure PowerShell waits until the '/ResetSettings' command fully completes. -& "$devEnvPath" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit | Out-Null - -cmd.exe /c "`"$devEnvPath`" /updateconfiguration" - -# -# https://github.com/actions/runner-images/issues/5301 -# -$warmup_vdproj = $(Join-Path $PSScriptRoot 'warmup.vdproj') -& "$devEnvPath" $warmup_vdproj /build Release | Out-Null +$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath +$devEnvPath = "$vsInstallRoot\Common7\IDE\devenv.exe" + +# Initialize Visual Studio Experimental Instance +# The Out-Null cmdlet is required to ensure PowerShell waits until the '/ResetSettings' command fully completes. +& "$devEnvPath" /RootSuffix Exp /ResetSettings General.vssettings /Command File.Exit | Out-Null + +cmd.exe /c "`"$devEnvPath`" /updateconfiguration" + +# +# https://github.com/actions/runner-images/issues/5301 +# +$warmup_vdproj = $(Join-Path $PSScriptRoot 'warmup.vdproj') +& "$devEnvPath" $warmup_vdproj /build Release | Out-Null diff --git a/images/win/post-generation/warmup.vdproj b/images/windows/assets/post-gen/warmup.vdproj similarity index 100% rename from images/win/post-generation/warmup.vdproj rename to images/windows/assets/post-gen/warmup.vdproj diff --git a/images/win/scripts/Installers/Configure-Antivirus.ps1 b/images/windows/scripts/build/Configure-Antivirus.ps1 similarity index 100% rename from images/win/scripts/Installers/Configure-Antivirus.ps1 rename to images/windows/scripts/build/Configure-Antivirus.ps1 diff --git a/images/win/scripts/Installers/Configure-DynamicPort.ps1 b/images/windows/scripts/build/Configure-DynamicPort.ps1 similarity index 98% rename from images/win/scripts/Installers/Configure-DynamicPort.ps1 rename to images/windows/scripts/build/Configure-DynamicPort.ps1 index 88e8ae20..39acdda4 100644 --- a/images/win/scripts/Installers/Configure-DynamicPort.ps1 +++ b/images/windows/scripts/build/Configure-DynamicPort.ps1 @@ -1,14 +1,14 @@ -# https://support.microsoft.com/en-us/help/929851/the-default-dynamic-port-range-for-tcp-ip-has-changed-in-windows-vista -# The new default start port is 49152, and the new default end port is 65535. -# Default port configuration was changed during image generation by Visual Studio Enterprise Installer to: -# Protocol tcp Dynamic Port Range -# --------------------------------- -# Start Port : 1024 -# Number of Ports : 64511 -Write-Host "Set the dynamic port range to start at port 49152 and to end at the 65536 (16384 ports)" -$null = netsh int ipv4 set dynamicport tcp start=49152 num=16384 -$null = netsh int ipv4 set dynamicport udp start=49152 num=16384 -$null = netsh int ipv6 set dynamicport tcp start=49152 num=16384 -$null = netsh int ipv6 set dynamicport udp start=49152 num=16384 - +# https://support.microsoft.com/en-us/help/929851/the-default-dynamic-port-range-for-tcp-ip-has-changed-in-windows-vista +# The new default start port is 49152, and the new default end port is 65535. +# Default port configuration was changed during image generation by Visual Studio Enterprise Installer to: +# Protocol tcp Dynamic Port Range +# --------------------------------- +# Start Port : 1024 +# Number of Ports : 64511 +Write-Host "Set the dynamic port range to start at port 49152 and to end at the 65536 (16384 ports)" +$null = netsh int ipv4 set dynamicport tcp start=49152 num=16384 +$null = netsh int ipv4 set dynamicport udp start=49152 num=16384 +$null = netsh int ipv6 set dynamicport tcp start=49152 num=16384 +$null = netsh int ipv6 set dynamicport udp start=49152 num=16384 + Invoke-PesterTests -TestFile "WindowsFeatures" -TestName "DynamicPorts" \ No newline at end of file diff --git a/images/win/scripts/Installers/Configure-GDIProcessHandleQuota.ps1 b/images/windows/scripts/build/Configure-GDIProcessHandleQuota.ps1 similarity index 100% rename from images/win/scripts/Installers/Configure-GDIProcessHandleQuota.ps1 rename to images/windows/scripts/build/Configure-GDIProcessHandleQuota.ps1 diff --git a/images/win/scripts/Installers/Configure-PowerShell.ps1 b/images/windows/scripts/build/Configure-PowerShell.ps1 similarity index 100% rename from images/win/scripts/Installers/Configure-PowerShell.ps1 rename to images/windows/scripts/build/Configure-PowerShell.ps1 diff --git a/images/win/scripts/Installers/Configure-Shell.ps1 b/images/windows/scripts/build/Configure-Shell.ps1 similarity index 100% rename from images/win/scripts/Installers/Configure-Shell.ps1 rename to images/windows/scripts/build/Configure-Shell.ps1 diff --git a/images/win/scripts/Installers/Configure-Toolset.ps1 b/images/windows/scripts/build/Configure-Toolset.ps1 similarity index 100% rename from images/win/scripts/Installers/Configure-Toolset.ps1 rename to images/windows/scripts/build/Configure-Toolset.ps1 diff --git a/images/win/scripts/Installers/Disable-JITDebugger.ps1 b/images/windows/scripts/build/Disable-JITDebugger.ps1 similarity index 98% rename from images/win/scripts/Installers/Disable-JITDebugger.ps1 rename to images/windows/scripts/build/Disable-JITDebugger.ps1 index 1ae5d21b..b500a294 100644 --- a/images/win/scripts/Installers/Disable-JITDebugger.ps1 +++ b/images/windows/scripts/build/Disable-JITDebugger.ps1 @@ -1,16 +1,16 @@ -Write-Host "Disable Just-In-Time Debugger" - -# Turn off Application Error Debugger -New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug" -Name Debugger -Value "-" -Type String -Force -New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug" -Name Debugger -Value "-" -Type String -Force - -# Turn off the Debug dialog -New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\.NETFramework" -Name DbgManagedDebugger -Value "-" -Type String -Force -New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\.NETFramework" -Name DbgManagedDebugger -Value "-" -Type String -Force - -# Disable the WER UI -New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name DontShowUI -Value 1 -Type DWORD -Force -# Send all reports to the user's queue -New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name ForceQueue -Value 1 -Type DWORD -Force -# Default consent choice 1 - Always ask (default) +Write-Host "Disable Just-In-Time Debugger" + +# Turn off Application Error Debugger +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug" -Name Debugger -Value "-" -Type String -Force +New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug" -Name Debugger -Value "-" -Type String -Force + +# Turn off the Debug dialog +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\.NETFramework" -Name DbgManagedDebugger -Value "-" -Type String -Force +New-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\.NETFramework" -Name DbgManagedDebugger -Value "-" -Type String -Force + +# Disable the WER UI +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name DontShowUI -Value 1 -Type DWORD -Force +# Send all reports to the user's queue +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name ForceQueue -Value 1 -Type DWORD -Force +# Default consent choice 1 - Always ask (default) New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\Consent" -Name DefaultConsent -Value 1 -Type DWORD -Force \ No newline at end of file diff --git a/images/win/scripts/Installers/Enable-DeveloperMode.ps1 b/images/windows/scripts/build/Enable-DeveloperMode.ps1 similarity index 100% rename from images/win/scripts/Installers/Enable-DeveloperMode.ps1 rename to images/windows/scripts/build/Enable-DeveloperMode.ps1 diff --git a/images/win/scripts/Installers/Finalize-VM.ps1 b/images/windows/scripts/build/Finalize-VM.ps1 similarity index 100% rename from images/win/scripts/Installers/Finalize-VM.ps1 rename to images/windows/scripts/build/Finalize-VM.ps1 diff --git a/images/win/scripts/Installers/Initialize-VM.ps1 b/images/windows/scripts/build/Initialize-VM.ps1 similarity index 100% rename from images/win/scripts/Installers/Initialize-VM.ps1 rename to images/windows/scripts/build/Initialize-VM.ps1 diff --git a/images/win/scripts/Installers/Install-AWS.ps1 b/images/windows/scripts/build/Install-AWS.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-AWS.ps1 rename to images/windows/scripts/build/Install-AWS.ps1 diff --git a/images/win/scripts/Installers/Install-ActionArchiveCache.ps1 b/images/windows/scripts/build/Install-ActionArchiveCache.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-ActionArchiveCache.ps1 rename to images/windows/scripts/build/Install-ActionArchiveCache.ps1 diff --git a/images/win/scripts/Installers/Install-AliyunCli.ps1 b/images/windows/scripts/build/Install-AliyunCli.ps1 similarity index 98% rename from images/win/scripts/Installers/Install-AliyunCli.ps1 rename to images/windows/scripts/build/Install-AliyunCli.ps1 index 9aef5955..97f7c371 100644 --- a/images/win/scripts/Installers/Install-AliyunCli.ps1 +++ b/images/windows/scripts/build/Install-AliyunCli.ps1 @@ -1,29 +1,29 @@ -################################################################################ -## File: Install-AliyunCli.ps1 -## Desc: Install Alibaba Cloud CLI -## Supply chain security: Alibaba Cloud CLI - checksum validation -################################################################################ - -Write-Host "Download Latest aliyun-cli archive" -$repoUrl = "https://api.github.com/repos/aliyun/aliyun-cli/releases/latest" -$installerFileName = "aliyun-cli-windows" -$assets = (Invoke-RestMethod -Uri $repoUrl).assets -$downloadUrl = ($assets.browser_download_url -ilike "*aliyun-cli-windows-*-amd64.zip*") | Select-Object -First 1 -$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name "$installerFileName.zip" - -#region Supply chain security - Alibaba Cloud CLI -$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash -$hashUrl = ($assets.browser_download_url -ilike "*SHASUMS256.txt*") | Select-Object -First 1 -$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*$installerFileName*" }).Split(' ')[0] -Use-ChecksumComparison $fileHash $externalHash -#endregion - -Write-Host "Expand aliyun-cli archive" -$aliyunPath = "C:\aliyun-cli" -New-Item -Path $aliyunPath -ItemType Directory -Force -Extract-7Zip -Path $packagePath -DestinationPath $aliyunPath - -# Add aliyun-cli to path -Add-MachinePathItem $aliyunPath - -Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Aliyun CLI" +################################################################################ +## File: Install-AliyunCli.ps1 +## Desc: Install Alibaba Cloud CLI +## Supply chain security: Alibaba Cloud CLI - checksum validation +################################################################################ + +Write-Host "Download Latest aliyun-cli archive" +$repoUrl = "https://api.github.com/repos/aliyun/aliyun-cli/releases/latest" +$installerFileName = "aliyun-cli-windows" +$assets = (Invoke-RestMethod -Uri $repoUrl).assets +$downloadUrl = ($assets.browser_download_url -ilike "*aliyun-cli-windows-*-amd64.zip*") | Select-Object -First 1 +$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name "$installerFileName.zip" + +#region Supply chain security - Alibaba Cloud CLI +$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash +$hashUrl = ($assets.browser_download_url -ilike "*SHASUMS256.txt*") | Select-Object -First 1 +$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*$installerFileName*" }).Split(' ')[0] +Use-ChecksumComparison $fileHash $externalHash +#endregion + +Write-Host "Expand aliyun-cli archive" +$aliyunPath = "C:\aliyun-cli" +New-Item -Path $aliyunPath -ItemType Directory -Force +Extract-7Zip -Path $packagePath -DestinationPath $aliyunPath + +# Add aliyun-cli to path +Add-MachinePathItem $aliyunPath + +Invoke-PesterTests -TestFile "CLI.Tools" -TestName "Aliyun CLI" diff --git a/images/win/scripts/Installers/Install-AndroidSDK.ps1 b/images/windows/scripts/build/Install-AndroidSDK.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-AndroidSDK.ps1 rename to images/windows/scripts/build/Install-AndroidSDK.ps1 diff --git a/images/win/scripts/Installers/Install-Apache.ps1 b/images/windows/scripts/build/Install-Apache.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Apache.ps1 rename to images/windows/scripts/build/Install-Apache.ps1 diff --git a/images/win/scripts/Installers/Install-AzureCli.ps1 b/images/windows/scripts/build/Install-AzureCli.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-AzureCli.ps1 rename to images/windows/scripts/build/Install-AzureCli.ps1 diff --git a/images/win/scripts/Installers/Install-AzureCosmosDbEmulator.ps1 b/images/windows/scripts/build/Install-AzureCosmosDbEmulator.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-AzureCosmosDbEmulator.ps1 rename to images/windows/scripts/build/Install-AzureCosmosDbEmulator.ps1 diff --git a/images/win/scripts/Installers/Install-AzureDevOpsCli.ps1 b/images/windows/scripts/build/Install-AzureDevOpsCli.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-AzureDevOpsCli.ps1 rename to images/windows/scripts/build/Install-AzureDevOpsCli.ps1 diff --git a/images/win/scripts/Installers/Install-AzureModules.ps1 b/images/windows/scripts/build/Install-AzureModules.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-AzureModules.ps1 rename to images/windows/scripts/build/Install-AzureModules.ps1 diff --git a/images/win/scripts/Installers/Install-Bazel.ps1 b/images/windows/scripts/build/Install-Bazel.ps1 similarity index 97% rename from images/win/scripts/Installers/Install-Bazel.ps1 rename to images/windows/scripts/build/Install-Bazel.ps1 index 7d5479fd..61dd94ee 100644 --- a/images/win/scripts/Installers/Install-Bazel.ps1 +++ b/images/windows/scripts/build/Install-Bazel.ps1 @@ -1,10 +1,10 @@ -################################################################################ -## File: Install-Bazel.ps1 -## Desc: Install Bazel and Bazelisk (A user-friendly launcher for Bazel) -################################################################################ - -Choco-Install -PackageName bazel - -npm install -g @bazel/bazelisk - +################################################################################ +## File: Install-Bazel.ps1 +## Desc: Install Bazel and Bazelisk (A user-friendly launcher for Bazel) +################################################################################ + +Choco-Install -PackageName bazel + +npm install -g @bazel/bazelisk + Invoke-PesterTests -TestFile "Tools" -TestName "Bazel" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-BizTalkBuildComponent.ps1 b/images/windows/scripts/build/Install-BizTalkBuildComponent.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-BizTalkBuildComponent.ps1 rename to images/windows/scripts/build/Install-BizTalkBuildComponent.ps1 diff --git a/images/win/scripts/Installers/Install-Choco.ps1 b/images/windows/scripts/build/Install-Choco.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Choco.ps1 rename to images/windows/scripts/build/Install-Choco.ps1 diff --git a/images/win/scripts/Installers/Install-Chrome.ps1 b/images/windows/scripts/build/Install-Chrome.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Chrome.ps1 rename to images/windows/scripts/build/Install-Chrome.ps1 diff --git a/images/win/scripts/Installers/Install-CloudFoundryCli.ps1 b/images/windows/scripts/build/Install-CloudFoundryCli.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-CloudFoundryCli.ps1 rename to images/windows/scripts/build/Install-CloudFoundryCli.ps1 diff --git a/images/win/scripts/Installers/Install-CodeQLBundle.ps1 b/images/windows/scripts/build/Install-CodeQLBundle.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-CodeQLBundle.ps1 rename to images/windows/scripts/build/Install-CodeQLBundle.ps1 diff --git a/images/win/scripts/Installers/Install-CommonUtils.ps1 b/images/windows/scripts/build/Install-CommonUtils.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-CommonUtils.ps1 rename to images/windows/scripts/build/Install-CommonUtils.ps1 diff --git a/images/win/scripts/Installers/Install-DACFx.ps1 b/images/windows/scripts/build/Install-DACFx.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-DACFx.ps1 rename to images/windows/scripts/build/Install-DACFx.ps1 diff --git a/images/win/scripts/Installers/Install-Docker-Compose.ps1 b/images/windows/scripts/build/Install-Docker-Compose.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Docker-Compose.ps1 rename to images/windows/scripts/build/Install-Docker-Compose.ps1 diff --git a/images/win/scripts/Installers/Install-Docker-WinCred.ps1 b/images/windows/scripts/build/Install-Docker-WinCred.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Docker-WinCred.ps1 rename to images/windows/scripts/build/Install-Docker-WinCred.ps1 diff --git a/images/win/scripts/Installers/Install-Docker.ps1 b/images/windows/scripts/build/Install-Docker.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Docker.ps1 rename to images/windows/scripts/build/Install-Docker.ps1 diff --git a/images/win/scripts/Installers/Install-DotnetSDK.ps1 b/images/windows/scripts/build/Install-DotnetSDK.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-DotnetSDK.ps1 rename to images/windows/scripts/build/Install-DotnetSDK.ps1 diff --git a/images/win/scripts/Installers/Install-Edge.ps1 b/images/windows/scripts/build/Install-Edge.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Edge.ps1 rename to images/windows/scripts/build/Install-Edge.ps1 diff --git a/images/win/scripts/Installers/Install-Firefox.ps1 b/images/windows/scripts/build/Install-Firefox.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Firefox.ps1 rename to images/windows/scripts/build/Install-Firefox.ps1 diff --git a/images/win/scripts/Installers/Install-Git.ps1 b/images/windows/scripts/build/Install-Git.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Git.ps1 rename to images/windows/scripts/build/Install-Git.ps1 diff --git a/images/win/scripts/Installers/Install-GitHub-CLI.ps1 b/images/windows/scripts/build/Install-GitHub-CLI.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-GitHub-CLI.ps1 rename to images/windows/scripts/build/Install-GitHub-CLI.ps1 diff --git a/images/win/scripts/Installers/Install-GoogleCloudCLI.ps1 b/images/windows/scripts/build/Install-GoogleCloudCLI.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-GoogleCloudCLI.ps1 rename to images/windows/scripts/build/Install-GoogleCloudCLI.ps1 diff --git a/images/win/scripts/Installers/Install-Haskell.ps1 b/images/windows/scripts/build/Install-Haskell.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Haskell.ps1 rename to images/windows/scripts/build/Install-Haskell.ps1 diff --git a/images/win/scripts/Installers/Install-IEWebDriver.ps1 b/images/windows/scripts/build/Install-IEWebDriver.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-IEWebDriver.ps1 rename to images/windows/scripts/build/Install-IEWebDriver.ps1 diff --git a/images/win/scripts/Installers/Install-JavaTools.ps1 b/images/windows/scripts/build/Install-JavaTools.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-JavaTools.ps1 rename to images/windows/scripts/build/Install-JavaTools.ps1 diff --git a/images/win/scripts/Installers/Install-Kotlin.ps1 b/images/windows/scripts/build/Install-Kotlin.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Kotlin.ps1 rename to images/windows/scripts/build/Install-Kotlin.ps1 diff --git a/images/win/scripts/Installers/Install-KubernetesTools.ps1 b/images/windows/scripts/build/Install-KubernetesTools.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-KubernetesTools.ps1 rename to images/windows/scripts/build/Install-KubernetesTools.ps1 diff --git a/images/win/scripts/Installers/Install-LLVM.ps1 b/images/windows/scripts/build/Install-LLVM.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-LLVM.ps1 rename to images/windows/scripts/build/Install-LLVM.ps1 diff --git a/images/win/scripts/Installers/Install-Mercurial.ps1 b/images/windows/scripts/build/Install-Mercurial.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Mercurial.ps1 rename to images/windows/scripts/build/Install-Mercurial.ps1 diff --git a/images/win/scripts/Installers/Install-Mingw64.ps1 b/images/windows/scripts/build/Install-Mingw64.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Mingw64.ps1 rename to images/windows/scripts/build/Install-Mingw64.ps1 diff --git a/images/win/scripts/Installers/Install-Miniconda.ps1 b/images/windows/scripts/build/Install-Miniconda.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Miniconda.ps1 rename to images/windows/scripts/build/Install-Miniconda.ps1 diff --git a/images/win/scripts/Installers/Install-MongoDB.ps1 b/images/windows/scripts/build/Install-MongoDB.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-MongoDB.ps1 rename to images/windows/scripts/build/Install-MongoDB.ps1 diff --git a/images/win/scripts/Installers/Install-Msys2.ps1 b/images/windows/scripts/build/Install-Msys2.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Msys2.ps1 rename to images/windows/scripts/build/Install-Msys2.ps1 diff --git a/images/win/scripts/Installers/Install-MysqlCli.ps1 b/images/windows/scripts/build/Install-MysqlCli.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-MysqlCli.ps1 rename to images/windows/scripts/build/Install-MysqlCli.ps1 diff --git a/images/win/scripts/Installers/Install-NET48-devpack.ps1 b/images/windows/scripts/build/Install-NET48-devpack.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-NET48-devpack.ps1 rename to images/windows/scripts/build/Install-NET48-devpack.ps1 diff --git a/images/win/scripts/Installers/Install-NET48.ps1 b/images/windows/scripts/build/Install-NET48.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-NET48.ps1 rename to images/windows/scripts/build/Install-NET48.ps1 diff --git a/images/win/scripts/Installers/Install-NSIS.ps1 b/images/windows/scripts/build/Install-NSIS.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-NSIS.ps1 rename to images/windows/scripts/build/Install-NSIS.ps1 diff --git a/images/win/scripts/Installers/Install-Nginx.ps1 b/images/windows/scripts/build/Install-Nginx.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Nginx.ps1 rename to images/windows/scripts/build/Install-Nginx.ps1 diff --git a/images/win/scripts/Installers/Install-NodeLts.ps1 b/images/windows/scripts/build/Install-NodeLts.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-NodeLts.ps1 rename to images/windows/scripts/build/Install-NodeLts.ps1 diff --git a/images/win/scripts/Installers/Install-OpenSSL.ps1 b/images/windows/scripts/build/Install-OpenSSL.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-OpenSSL.ps1 rename to images/windows/scripts/build/Install-OpenSSL.ps1 diff --git a/images/win/scripts/Installers/Install-PHP.ps1 b/images/windows/scripts/build/Install-PHP.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-PHP.ps1 rename to images/windows/scripts/build/Install-PHP.ps1 diff --git a/images/win/scripts/Installers/Install-Pipx.ps1 b/images/windows/scripts/build/Install-Pipx.ps1 similarity index 97% rename from images/win/scripts/Installers/Install-Pipx.ps1 rename to images/windows/scripts/build/Install-Pipx.ps1 index a78cf456..b3e85f4f 100644 --- a/images/win/scripts/Installers/Install-Pipx.ps1 +++ b/images/windows/scripts/build/Install-Pipx.ps1 @@ -1,14 +1,14 @@ -# Set custom directorys for pipx -$env:PIPX_BIN_DIR = "${env:ProgramFiles(x86)}\pipx_bin" -$env:PIPX_HOME = "${env:ProgramFiles(x86)}\pipx" - -# Install pipx -pip install pipx - -# Set environment variables -Add-MachinePathItem "${env:PIPX_BIN_DIR}" -Set-SystemVariable -SystemVariable PIPX_BIN_DIR -Value $env:PIPX_BIN_DIR -Set-SystemVariable -SystemVariable PIPX_HOME -Value $env:PIPX_HOME - -# Test pipx +# Set custom directorys for pipx +$env:PIPX_BIN_DIR = "${env:ProgramFiles(x86)}\pipx_bin" +$env:PIPX_HOME = "${env:ProgramFiles(x86)}\pipx" + +# Install pipx +pip install pipx + +# Set environment variables +Add-MachinePathItem "${env:PIPX_BIN_DIR}" +Set-SystemVariable -SystemVariable PIPX_BIN_DIR -Value $env:PIPX_BIN_DIR +Set-SystemVariable -SystemVariable PIPX_HOME -Value $env:PIPX_HOME + +# Test pipx Invoke-PesterTests -TestFile "Tools" -TestName "Pipx" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-PipxPackages.ps1 b/images/windows/scripts/build/Install-PipxPackages.ps1 similarity index 97% rename from images/win/scripts/Installers/Install-PipxPackages.ps1 rename to images/windows/scripts/build/Install-PipxPackages.ps1 index e83f5add..c4a48ec9 100644 --- a/images/win/scripts/Installers/Install-PipxPackages.ps1 +++ b/images/windows/scripts/build/Install-PipxPackages.ps1 @@ -1,12 +1,12 @@ -$pipxToolset = (Get-ToolsetContent).pipx -foreach($tool in $pipxToolset) { - if ($tool.python) { - $pythonPath = (Get-Item -Path "${env:AGENT_TOOLSDIRECTORY}\Python\${tool.python}.*\x64\python-${tool.python}*").FullName - Write-Host "Install ${tool.package} into python ${tool.python}" - pipx install $tool.package --python $pythonPath - } else { - Write-Host "Install ${tool.package} into default python" - pipx install $tool.package - } -} +$pipxToolset = (Get-ToolsetContent).pipx +foreach($tool in $pipxToolset) { + if ($tool.python) { + $pythonPath = (Get-Item -Path "${env:AGENT_TOOLSDIRECTORY}\Python\${tool.python}.*\x64\python-${tool.python}*").FullName + Write-Host "Install ${tool.package} into python ${tool.python}" + pipx install $tool.package --python $pythonPath + } else { + Write-Host "Install ${tool.package} into default python" + pipx install $tool.package + } +} Invoke-PesterTests -TestFile "PipxPackages" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-PostgreSQL.ps1 b/images/windows/scripts/build/Install-PostgreSQL.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-PostgreSQL.ps1 rename to images/windows/scripts/build/Install-PostgreSQL.ps1 diff --git a/images/win/scripts/Installers/Install-PowerShellModules.ps1 b/images/windows/scripts/build/Install-PowerShellModules.ps1 similarity index 96% rename from images/win/scripts/Installers/Install-PowerShellModules.ps1 rename to images/windows/scripts/build/Install-PowerShellModules.ps1 index b3ab7a35..ec8b45e1 100644 --- a/images/win/scripts/Installers/Install-PowerShellModules.ps1 +++ b/images/windows/scripts/build/Install-PowerShellModules.ps1 @@ -1,26 +1,26 @@ -# Set TLS1.2 -[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" - -# Install PowerShell modules -$modules = (Get-ToolsetContent).powershellModules - -foreach($module in $modules) -{ - $moduleName = $module.name - Write-Host "Installing ${moduleName} module" - - if ($module.versions) - { - foreach ($version in $module.versions) - { - Write-Host " - $version" - Install-Module -Name $moduleName -RequiredVersion $version -Scope AllUsers -SkipPublisherCheck -Force - } - continue - } - - Install-Module -Name $moduleName -Scope AllUsers -SkipPublisherCheck -Force -} - -Import-Module Pester -Invoke-PesterTests -TestFile "PowerShellModules" -TestName "PowerShellModules" +# Set TLS1.2 +[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12" + +# Install PowerShell modules +$modules = (Get-ToolsetContent).powershellModules + +foreach($module in $modules) +{ + $moduleName = $module.name + Write-Host "Installing ${moduleName} module" + + if ($module.versions) + { + foreach ($version in $module.versions) + { + Write-Host " - $version" + Install-Module -Name $moduleName -RequiredVersion $version -Scope AllUsers -SkipPublisherCheck -Force + } + continue + } + + Install-Module -Name $moduleName -Scope AllUsers -SkipPublisherCheck -Force +} + +Import-Module Pester +Invoke-PesterTests -TestFile "PowerShellModules" -TestName "PowerShellModules" diff --git a/images/win/scripts/Installers/Install-PowershellCore.ps1 b/images/windows/scripts/build/Install-PowershellCore.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-PowershellCore.ps1 rename to images/windows/scripts/build/Install-PowershellCore.ps1 diff --git a/images/win/scripts/Installers/Install-PyPy.ps1 b/images/windows/scripts/build/Install-PyPy.ps1 similarity index 97% rename from images/win/scripts/Installers/Install-PyPy.ps1 rename to images/windows/scripts/build/Install-PyPy.ps1 index 4808b3b6..69e3c32c 100644 --- a/images/win/scripts/Installers/Install-PyPy.ps1 +++ b/images/windows/scripts/build/Install-PyPy.ps1 @@ -1,124 +1,124 @@ -################################################################################ -## File: Install-PyPy.ps1 -## Team: CI-Build -## Desc: Install PyPy -## Supply chain security: checksum validation -################################################################################ -function Install-PyPy -{ - param( - [String]$PackagePath, - [String]$Architecture - ) - - # Create PyPy toolcache folder - $pypyToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "PyPy" - if (-not (Test-Path $pypyToolcachePath)) { - Write-Host "Create PyPy toolcache folder" - New-Item -ItemType Directory -Path $pypyToolcachePath | Out-Null - } - - # Expand archive with binaries - $packageName = [IO.Path]::GetFileNameWithoutExtension((Split-Path -Path $packagePath -Leaf)) - $tempFolder = Join-Path -Path $pypyToolcachePath -ChildPath $packageName - Extract-7Zip -Path $packagePath -DestinationPath $pypyToolcachePath - - # Get Python version from binaries - $pypyApp = Get-ChildItem -Path "$tempFolder\pypy*.exe" | Where-Object Name -match "pypy(\d+)?.exe" | Select-Object -First 1 - $pythonVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))" - - $pypyFullVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))" - Write-Host "Put '$pypyFullVersion' to PYPY_VERSION file" - New-Item -Path "$tempFolder\PYPY_VERSION" -Value $pypyFullVersion | Out-Null - - if ($pythonVersion) - { - Write-Host "Installing PyPy $pythonVersion" - $pypyVersionPath = Join-Path -Path $pypyToolcachePath -ChildPath $pythonVersion - $pypyArchPath = Join-Path -Path $pypyVersionPath -ChildPath $architecture - - Write-Host "Create PyPy '${pythonVersion}' folder in '${pypyVersionPath}'" - New-Item -ItemType Directory -Path $pypyVersionPath -Force | Out-Null - - Write-Host "Move PyPy '${pythonVersion}' files to '${pypyArchPath}'" - Invoke-SBWithRetry -Command { - Move-Item -Path $tempFolder -Destination $pypyArchPath -ErrorAction Stop | Out-Null - } - - Write-Host "Install PyPy '${pythonVersion}' in '${pypyArchPath}'" - if (Test-Path "$pypyArchPath\python.exe") { - cmd.exe /c "cd /d $pypyArchPath && python.exe -m ensurepip && python.exe -m pip install --upgrade pip" - } else { - $pypyName = $pypyApp.Name - cmd.exe /c "cd /d $pypyArchPath && mklink python.exe $pypyName && python.exe -m ensurepip && python.exe -m pip install --upgrade pip" - } - - # Create pip.exe if missing - $pipPath = Join-Path -Path $pypyArchPath -ChildPath "Scripts/pip.exe" - if (-not (Test-Path $pipPath)) - { - $pip3Path = Join-Path -Path $pypyArchPath -ChildPath "Scripts/pip3.exe" - Copy-Item -Path $pip3Path -Destination $pipPath - } - - if ($LASTEXITCODE -ne 0) - { - Throw "Error happened during PyPy installation" - exit 1 - } - - Write-Host "Create complete file" - New-Item -ItemType File -Path $pypyVersionPath -Name "$architecture.complete" | Out-Null - } - else - { - Write-Host "PyPy application is not found. Failed to expand '$packagePath' archive" - exit 1 - } -} - -# Get PyPy content from toolset -$toolsetVersions = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object Name -eq "PyPy" - -# Get PyPy releases -$pypyVersions = Invoke-RestMethod https://downloads.python.org/pypy/versions.json - -# required for html parsing -$checksums = (Invoke-RestMethod -Uri 'https://www.pypy.org/checksums.html' | ConvertFrom-HTML).SelectNodes('//*[@id="content"]/article/div/pre') - -Write-Host "Starting installation PyPy..." -foreach($toolsetVersion in $toolsetVersions.versions) -{ - # Query latest PyPy version - $latestMajorPyPyVersion = $pypyVersions | - Where-Object {$_.python_version.StartsWith("$toolsetVersion") -and $_.stable -eq $true} | - Select-Object -ExpandProperty files -First 1 | - Where-Object platform -like "win*" - - if ($latestMajorPyPyVersion) - { - $filename = $latestMajorPyPyVersion.filename - Write-Host "Found PyPy '$filename' package" - $tempPyPyPackagePath = Start-DownloadWithRetry -Url $latestMajorPyPyVersion.download_url -Name $filename - - #region Supply chain security - $localFileHash = (Get-FileHash -Path $tempPyPyPackagePath -Algorithm SHA256).Hash - $distributorFileHash = $null - - ForEach($node in $checksums) { - if($node.InnerText -ilike "*${filename}*") { - $distributorFileHash = $node.InnerText.ToString().Split("`n").Where({ $_ -ilike "*${filename}*" }).Split(' ')[0] - } - } - - Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash - #endregion - - Install-PyPy -PackagePath $tempPyPyPackagePath -Architecture $toolsetVersions.arch - } - else - { - Write-Host "Failed to query PyPy version '$toolsetVersion'" - exit 1 - } -} +################################################################################ +## File: Install-PyPy.ps1 +## Team: CI-Build +## Desc: Install PyPy +## Supply chain security: checksum validation +################################################################################ +function Install-PyPy +{ + param( + [String]$PackagePath, + [String]$Architecture + ) + + # Create PyPy toolcache folder + $pypyToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "PyPy" + if (-not (Test-Path $pypyToolcachePath)) { + Write-Host "Create PyPy toolcache folder" + New-Item -ItemType Directory -Path $pypyToolcachePath | Out-Null + } + + # Expand archive with binaries + $packageName = [IO.Path]::GetFileNameWithoutExtension((Split-Path -Path $packagePath -Leaf)) + $tempFolder = Join-Path -Path $pypyToolcachePath -ChildPath $packageName + Extract-7Zip -Path $packagePath -DestinationPath $pypyToolcachePath + + # Get Python version from binaries + $pypyApp = Get-ChildItem -Path "$tempFolder\pypy*.exe" | Where-Object Name -match "pypy(\d+)?.exe" | Select-Object -First 1 + $pythonVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))" + + $pypyFullVersion = & $pypyApp -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))" + Write-Host "Put '$pypyFullVersion' to PYPY_VERSION file" + New-Item -Path "$tempFolder\PYPY_VERSION" -Value $pypyFullVersion | Out-Null + + if ($pythonVersion) + { + Write-Host "Installing PyPy $pythonVersion" + $pypyVersionPath = Join-Path -Path $pypyToolcachePath -ChildPath $pythonVersion + $pypyArchPath = Join-Path -Path $pypyVersionPath -ChildPath $architecture + + Write-Host "Create PyPy '${pythonVersion}' folder in '${pypyVersionPath}'" + New-Item -ItemType Directory -Path $pypyVersionPath -Force | Out-Null + + Write-Host "Move PyPy '${pythonVersion}' files to '${pypyArchPath}'" + Invoke-SBWithRetry -Command { + Move-Item -Path $tempFolder -Destination $pypyArchPath -ErrorAction Stop | Out-Null + } + + Write-Host "Install PyPy '${pythonVersion}' in '${pypyArchPath}'" + if (Test-Path "$pypyArchPath\python.exe") { + cmd.exe /c "cd /d $pypyArchPath && python.exe -m ensurepip && python.exe -m pip install --upgrade pip" + } else { + $pypyName = $pypyApp.Name + cmd.exe /c "cd /d $pypyArchPath && mklink python.exe $pypyName && python.exe -m ensurepip && python.exe -m pip install --upgrade pip" + } + + # Create pip.exe if missing + $pipPath = Join-Path -Path $pypyArchPath -ChildPath "Scripts/pip.exe" + if (-not (Test-Path $pipPath)) + { + $pip3Path = Join-Path -Path $pypyArchPath -ChildPath "Scripts/pip3.exe" + Copy-Item -Path $pip3Path -Destination $pipPath + } + + if ($LASTEXITCODE -ne 0) + { + Throw "Error happened during PyPy installation" + exit 1 + } + + Write-Host "Create complete file" + New-Item -ItemType File -Path $pypyVersionPath -Name "$architecture.complete" | Out-Null + } + else + { + Write-Host "PyPy application is not found. Failed to expand '$packagePath' archive" + exit 1 + } +} + +# Get PyPy content from toolset +$toolsetVersions = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object Name -eq "PyPy" + +# Get PyPy releases +$pypyVersions = Invoke-RestMethod https://downloads.python.org/pypy/versions.json + +# required for html parsing +$checksums = (Invoke-RestMethod -Uri 'https://www.pypy.org/checksums.html' | ConvertFrom-HTML).SelectNodes('//*[@id="content"]/article/div/pre') + +Write-Host "Starting installation PyPy..." +foreach($toolsetVersion in $toolsetVersions.versions) +{ + # Query latest PyPy version + $latestMajorPyPyVersion = $pypyVersions | + Where-Object {$_.python_version.StartsWith("$toolsetVersion") -and $_.stable -eq $true} | + Select-Object -ExpandProperty files -First 1 | + Where-Object platform -like "win*" + + if ($latestMajorPyPyVersion) + { + $filename = $latestMajorPyPyVersion.filename + Write-Host "Found PyPy '$filename' package" + $tempPyPyPackagePath = Start-DownloadWithRetry -Url $latestMajorPyPyVersion.download_url -Name $filename + + #region Supply chain security + $localFileHash = (Get-FileHash -Path $tempPyPyPackagePath -Algorithm SHA256).Hash + $distributorFileHash = $null + + ForEach($node in $checksums) { + if($node.InnerText -ilike "*${filename}*") { + $distributorFileHash = $node.InnerText.ToString().Split("`n").Where({ $_ -ilike "*${filename}*" }).Split(' ')[0] + } + } + + Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash + #endregion + + Install-PyPy -PackagePath $tempPyPyPackagePath -Architecture $toolsetVersions.arch + } + else + { + Write-Host "Failed to query PyPy version '$toolsetVersion'" + exit 1 + } +} diff --git a/images/win/scripts/Installers/Install-R.ps1 b/images/windows/scripts/build/Install-R.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-R.ps1 rename to images/windows/scripts/build/Install-R.ps1 diff --git a/images/win/scripts/Installers/Install-RootCA.ps1 b/images/windows/scripts/build/Install-RootCA.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-RootCA.ps1 rename to images/windows/scripts/build/Install-RootCA.ps1 diff --git a/images/win/scripts/Installers/Install-Ruby.ps1 b/images/windows/scripts/build/Install-Ruby.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Ruby.ps1 rename to images/windows/scripts/build/Install-Ruby.ps1 diff --git a/images/win/scripts/Installers/Install-Runner.ps1 b/images/windows/scripts/build/Install-Runner.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Runner.ps1 rename to images/windows/scripts/build/Install-Runner.ps1 diff --git a/images/win/scripts/Installers/Install-Rust.ps1 b/images/windows/scripts/build/Install-Rust.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Rust.ps1 rename to images/windows/scripts/build/Install-Rust.ps1 diff --git a/images/win/scripts/Installers/Install-SQLOLEDBDriver.ps1 b/images/windows/scripts/build/Install-SQLOLEDBDriver.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-SQLOLEDBDriver.ps1 rename to images/windows/scripts/build/Install-SQLOLEDBDriver.ps1 diff --git a/images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 b/images/windows/scripts/build/Install-SQLPowerShellTools.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-SQLPowerShellTools.ps1 rename to images/windows/scripts/build/Install-SQLPowerShellTools.ps1 diff --git a/images/win/scripts/Installers/Install-Sbt.ps1 b/images/windows/scripts/build/Install-Sbt.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Sbt.ps1 rename to images/windows/scripts/build/Install-Sbt.ps1 diff --git a/images/win/scripts/Installers/Install-Selenium.ps1 b/images/windows/scripts/build/Install-Selenium.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Selenium.ps1 rename to images/windows/scripts/build/Install-Selenium.ps1 diff --git a/images/win/scripts/Installers/Install-ServiceFabricSDK.ps1 b/images/windows/scripts/build/Install-ServiceFabricSDK.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-ServiceFabricSDK.ps1 rename to images/windows/scripts/build/Install-ServiceFabricSDK.ps1 diff --git a/images/win/scripts/Installers/Install-Stack.ps1 b/images/windows/scripts/build/Install-Stack.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Stack.ps1 rename to images/windows/scripts/build/Install-Stack.ps1 diff --git a/images/win/scripts/Installers/Install-Toolset.ps1 b/images/windows/scripts/build/Install-Toolset.ps1 similarity index 97% rename from images/win/scripts/Installers/Install-Toolset.ps1 rename to images/windows/scripts/build/Install-Toolset.ps1 index 0b373dc9..be13e850 100644 --- a/images/win/scripts/Installers/Install-Toolset.ps1 +++ b/images/windows/scripts/build/Install-Toolset.ps1 @@ -1,58 +1,58 @@ -################################################################################ -## File: Install-Toolset.ps1 -## Team: CI-Build -## Desc: Install toolset -################################################################################ - -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13 - -Function Install-Asset { - param( - [Parameter(Mandatory=$true)] - [object] $ReleaseAsset - ) - - $releaseAssetName = [System.IO.Path]::GetFileNameWithoutExtension($ReleaseAsset.filename) - $assetFolderPath = Join-Path $env:TEMP $releaseAssetName - $assetArchivePath = Start-DownloadWithRetry -Url $ReleaseAsset.download_url -Name $ReleaseAsset.filename - - Write-Host "Extract $($ReleaseAsset.filename) content..." - if ($assetArchivePath.EndsWith(".tar.gz")) { - $assetTarPath = $assetArchivePath.TrimEnd(".tar.gz") - Extract-7Zip -Path $assetArchivePath -DestinationPath $assetTarPath - Extract-7Zip -Path $assetTarPath -DestinationPath $assetFolderPath - } else { - Extract-7Zip -Path $assetArchivePath -DestinationPath $assetFolderPath - } - - Write-Host "Invoke installation script..." - Push-Location -Path $assetFolderPath - Invoke-Expression .\setup.ps1 - Pop-Location -} - -# Get toolcache content from toolset -$ToolsToInstall = @("Python", "Node", "Go") - -$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object { $ToolsToInstall -contains $_.Name } - -foreach ($tool in $tools) { - # Get versions manifest for current tool - $assets = Invoke-SBWithRetry -Command { Invoke-RestMethod $tool.url } - - # Get github release asset for each version - foreach ($toolVersion in $tool.versions) { - $asset = $assets | Where-Object version -like $toolVersion ` - | Select-Object -ExpandProperty files ` - | Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $tool.arch) -and ($_.toolset -eq $tool.toolset) } ` - | Select-Object -First 1 - - Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..." - if ($null -ne $asset) { - Install-Asset -ReleaseAsset $asset - } else { - Write-Host "Asset was not found in versions manifest" - exit 1 - } - } +################################################################################ +## File: Install-Toolset.ps1 +## Team: CI-Build +## Desc: Install toolset +################################################################################ + +[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls13 + +Function Install-Asset { + param( + [Parameter(Mandatory=$true)] + [object] $ReleaseAsset + ) + + $releaseAssetName = [System.IO.Path]::GetFileNameWithoutExtension($ReleaseAsset.filename) + $assetFolderPath = Join-Path $env:TEMP $releaseAssetName + $assetArchivePath = Start-DownloadWithRetry -Url $ReleaseAsset.download_url -Name $ReleaseAsset.filename + + Write-Host "Extract $($ReleaseAsset.filename) content..." + if ($assetArchivePath.EndsWith(".tar.gz")) { + $assetTarPath = $assetArchivePath.TrimEnd(".tar.gz") + Extract-7Zip -Path $assetArchivePath -DestinationPath $assetTarPath + Extract-7Zip -Path $assetTarPath -DestinationPath $assetFolderPath + } else { + Extract-7Zip -Path $assetArchivePath -DestinationPath $assetFolderPath + } + + Write-Host "Invoke installation script..." + Push-Location -Path $assetFolderPath + Invoke-Expression .\setup.ps1 + Pop-Location +} + +# Get toolcache content from toolset +$ToolsToInstall = @("Python", "Node", "Go") + +$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache | Where-Object { $ToolsToInstall -contains $_.Name } + +foreach ($tool in $tools) { + # Get versions manifest for current tool + $assets = Invoke-SBWithRetry -Command { Invoke-RestMethod $tool.url } + + # Get github release asset for each version + foreach ($toolVersion in $tool.versions) { + $asset = $assets | Where-Object version -like $toolVersion ` + | Select-Object -ExpandProperty files ` + | Where-Object { ($_.platform -eq $tool.platform) -and ($_.arch -eq $tool.arch) -and ($_.toolset -eq $tool.toolset) } ` + | Select-Object -First 1 + + Write-Host "Installing $($tool.name) $toolVersion $($tool.arch)..." + if ($null -ne $asset) { + Install-Asset -ReleaseAsset $asset + } else { + Write-Host "Asset was not found in versions manifest" + exit 1 + } + } } \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-VCRedist.ps1 b/images/windows/scripts/build/Install-VCRedist.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-VCRedist.ps1 rename to images/windows/scripts/build/Install-VCRedist.ps1 diff --git a/images/win/scripts/Installers/Install-VS.ps1 b/images/windows/scripts/build/Install-VS.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-VS.ps1 rename to images/windows/scripts/build/Install-VS.ps1 diff --git a/images/win/scripts/Installers/Install-Vcpkg.ps1 b/images/windows/scripts/build/Install-Vcpkg.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Vcpkg.ps1 rename to images/windows/scripts/build/Install-Vcpkg.ps1 diff --git a/images/win/scripts/Installers/Install-Vsix.ps1 b/images/windows/scripts/build/Install-Vsix.ps1 similarity index 97% rename from images/win/scripts/Installers/Install-Vsix.ps1 rename to images/windows/scripts/build/Install-Vsix.ps1 index e9170cab..cf132ea8 100644 --- a/images/win/scripts/Installers/Install-Vsix.ps1 +++ b/images/windows/scripts/build/Install-Vsix.ps1 @@ -1,24 +1,24 @@ -################################################################################### -## File: Install-Vsix.ps1 -## Desc: Install the Visual Studio Extensions from toolset.json -################################################################################### - -$toolset = Get-ToolsetContent -$vsixPackagesList = $toolset.visualStudio.vsix -if (-not $vsixPackagesList) { - Write-Host "No extensions to install" - exit 0 -} - -$vsixPackagesList | ForEach-Object { - # Retrieve cdn endpoint to avoid HTTP error 429 https://github.com/actions/runner-images/issues/3074 - $vsixPackage = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_ - if ($vsixPackage.FileName.EndsWith(".vsix")) { - Install-VsixExtension -Url $vsixPackage.DownloadUri -Name $vsixPackage.FileName - } else { - $argumentList = ('/install', '/quiet', '/norestart') - Install-Binary -Url $vsixPackage.DownloadUri -Name $vsixPackage.FileName -ArgumentList $argumentList - } -} - +################################################################################### +## File: Install-Vsix.ps1 +## Desc: Install the Visual Studio Extensions from toolset.json +################################################################################### + +$toolset = Get-ToolsetContent +$vsixPackagesList = $toolset.visualStudio.vsix +if (-not $vsixPackagesList) { + Write-Host "No extensions to install" + exit 0 +} + +$vsixPackagesList | ForEach-Object { + # Retrieve cdn endpoint to avoid HTTP error 429 https://github.com/actions/runner-images/issues/3074 + $vsixPackage = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_ + if ($vsixPackage.FileName.EndsWith(".vsix")) { + Install-VsixExtension -Url $vsixPackage.DownloadUri -Name $vsixPackage.FileName + } else { + $argumentList = ('/install', '/quiet', '/norestart') + Install-Binary -Url $vsixPackage.DownloadUri -Name $vsixPackage.FileName -ArgumentList $argumentList + } +} + Invoke-PesterTests -TestFile "Vsix" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-WDK.ps1 b/images/windows/scripts/build/Install-WDK.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-WDK.ps1 rename to images/windows/scripts/build/Install-WDK.ps1 diff --git a/images/win/scripts/Installers/Install-WebPlatformInstaller.ps1 b/images/windows/scripts/build/Install-WebPlatformInstaller.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-WebPlatformInstaller.ps1 rename to images/windows/scripts/build/Install-WebPlatformInstaller.ps1 diff --git a/images/win/scripts/Installers/Install-WinAppDriver.ps1 b/images/windows/scripts/build/Install-WinAppDriver.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-WinAppDriver.ps1 rename to images/windows/scripts/build/Install-WinAppDriver.ps1 diff --git a/images/win/scripts/Installers/Install-WindowsFeatures.ps1 b/images/windows/scripts/build/Install-WindowsFeatures.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-WindowsFeatures.ps1 rename to images/windows/scripts/build/Install-WindowsFeatures.ps1 diff --git a/images/win/scripts/Installers/Install-WindowsUpdates.ps1 b/images/windows/scripts/build/Install-WindowsUpdates.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-WindowsUpdates.ps1 rename to images/windows/scripts/build/Install-WindowsUpdates.ps1 diff --git a/images/win/scripts/Installers/Install-Wix.ps1 b/images/windows/scripts/build/Install-Wix.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Wix.ps1 rename to images/windows/scripts/build/Install-Wix.ps1 diff --git a/images/win/scripts/Installers/Install-Zstd.ps1 b/images/windows/scripts/build/Install-Zstd.ps1 similarity index 100% rename from images/win/scripts/Installers/Install-Zstd.ps1 rename to images/windows/scripts/build/Install-Zstd.ps1 diff --git a/images/win/scripts/Installers/Run-NGen.ps1 b/images/windows/scripts/build/Run-NGen.ps1 similarity index 98% rename from images/win/scripts/Installers/Run-NGen.ps1 rename to images/windows/scripts/build/Run-NGen.ps1 index c00aa1a4..4ecddd3c 100644 --- a/images/win/scripts/Installers/Run-NGen.ps1 +++ b/images/windows/scripts/build/Run-NGen.ps1 @@ -1,6 +1,6 @@ -Write-Host "NGen: Microsoft.PowerShell.Utility.Activities" -$null = & $env:SystemRoot\Microsoft.NET\Framework64\v4.0.30319\ngen.exe install "Microsoft.PowerShell.Utility.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" -Write-Host "NGen: Framework64" -$null = & $env:SystemRoot\Microsoft.NET\Framework64\v4.0.30319\ngen.exe update -Write-Host "NGen: Framework" +Write-Host "NGen: Microsoft.PowerShell.Utility.Activities" +$null = & $env:SystemRoot\Microsoft.NET\Framework64\v4.0.30319\ngen.exe install "Microsoft.PowerShell.Utility.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" +Write-Host "NGen: Framework64" +$null = & $env:SystemRoot\Microsoft.NET\Framework64\v4.0.30319\ngen.exe update +Write-Host "NGen: Framework" $null = & $env:SystemRoot\Microsoft.NET\Framework\v4.0.30319\ngen.exe update \ No newline at end of file diff --git a/images/win/scripts/Installers/Update-DotnetTLS.ps1 b/images/windows/scripts/build/Update-DotnetTLS.ps1 similarity index 100% rename from images/win/scripts/Installers/Update-DotnetTLS.ps1 rename to images/windows/scripts/build/Update-DotnetTLS.ps1 diff --git a/images/win/scripts/Installers/Update-ImageData.ps1 b/images/windows/scripts/build/Update-ImageData.ps1 similarity index 62% rename from images/win/scripts/Installers/Update-ImageData.ps1 rename to images/windows/scripts/build/Update-ImageData.ps1 index f27b5c7e..fa5abbd9 100644 --- a/images/win/scripts/Installers/Update-ImageData.ps1 +++ b/images/windows/scripts/build/Update-ImageData.ps1 @@ -1,45 +1,45 @@ -$os = Get-CimInstance -ClassName Win32_OperatingSystem -$caption = $os.Caption -$osName = $caption.Substring(0, $caption.LastIndexOf(" ")) -$osEdition = $caption.Substring($caption.LastIndexOf(" ")+1) -$osVersion = $os.Version -$imageVersion = $env:IMAGE_VERSION -$imageVersionComponents = $imageVersion.Split('.') -$imageMajorVersion = $imageVersionComponents[0] -$imageMinorVersion = $imageVersionComponents[1] -$imageDataFile = $env:IMAGEDATA_FILE -$githubUrl="https://github.com/actions/runner-images/blob" - -if (Test-IsWin22) { - $imageLabel = "windows-2022" - $softwareUrl = "${githubUrl}/win22/$imageMajorVersion.$imageMinorVersion/images/win/Windows2022-Readme.md" - $releaseUrl="https://github.com/actions/runner-images/releases/tag/win22%2F$imageMajorVersion.$imageMinorVersion" -} elseif (Test-IsWin19) { - $imageLabel = "windows-2019" - $softwareUrl = "${githubUrl}/win19/$imageMajorVersion.$imageMinorVersion/images/win/Windows2019-Readme.md" - $releaseUrl="https://github.com/actions/runner-images/releases/tag/win19%2F$imageMajorVersion.$imageMinorVersion" -} else { - throw "Invalid platform version is found. Either Windows Server 2019 or 2022 are required" -} - -$json = @" -[ - { - "group": "Operating System", - "detail": "${osName}\n${osVersion}\n${osEdition}" - }, - { - "group": "Runner Image", - "detail": "Image: ${imageLabel}\nVersion: ${imageVersion}\nIncluded Software: ${softwareUrl}\nImage Release: ${releaseUrl}" - } -] -"@ - -$json | Out-File -FilePath $imageDataFile - - -# Set static env vars -setx ImageVersion $env:IMAGE_VERSION /m -setx ImageOS $env:IMAGE_OS /m -setx AGENT_TOOLSDIRECTORY $env:AGENT_TOOLSDIRECTORY /m -setx ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE /m +$os = Get-CimInstance -ClassName Win32_OperatingSystem +$caption = $os.Caption +$osName = $caption.Substring(0, $caption.LastIndexOf(" ")) +$osEdition = $caption.Substring($caption.LastIndexOf(" ") + 1) +$osVersion = $os.Version +$imageVersion = $env:IMAGE_VERSION +$imageVersionComponents = $imageVersion.Split('.') +$imageMajorVersion = $imageVersionComponents[0] +$imageMinorVersion = $imageVersionComponents[1] +$imageDataFile = $env:IMAGEDATA_FILE +$githubUrl = "https://github.com/actions/runner-images/blob" + +if (Test-IsWin22) { + $imageLabel = "windows-2022" + $softwareUrl = "${githubUrl}/win22/$imageMajorVersion.$imageMinorVersion/images/windows/Windows2022-Readme.md" + $releaseUrl = "https://github.com/actions/runner-images/releases/tag/win22%2F$imageMajorVersion.$imageMinorVersion" +} elseif (Test-IsWin19) { + $imageLabel = "windows-2019" + $softwareUrl = "${githubUrl}/win19/$imageMajorVersion.$imageMinorVersion/images/windows/Windows2019-Readme.md" + $releaseUrl = "https://github.com/actions/runner-images/releases/tag/win19%2F$imageMajorVersion.$imageMinorVersion" +} else { + throw "Invalid platform version is found. Either Windows Server 2019 or 2022 are required" +} + +$json = @" +[ + { + "group": "Operating System", + "detail": "${osName}\n${osVersion}\n${osEdition}" + }, + { + "group": "Runner Image", + "detail": "Image: ${imageLabel}\nVersion: ${imageVersion}\nIncluded Software: ${softwareUrl}\nImage Release: ${releaseUrl}" + } +] +"@ + +$json | Out-File -FilePath $imageDataFile + + +# Set static env vars +setx ImageVersion $env:IMAGE_VERSION /m +setx ImageOS $env:IMAGE_OS /m +setx AGENT_TOOLSDIRECTORY $env:AGENT_TOOLSDIRECTORY /m +setx ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE /m diff --git a/images/win/scripts/Installers/Wait-WindowsUpdatesForInstall.ps1 b/images/windows/scripts/build/Wait-WindowsUpdatesForInstall.ps1 similarity index 100% rename from images/win/scripts/Installers/Wait-WindowsUpdatesForInstall.ps1 rename to images/windows/scripts/build/Wait-WindowsUpdatesForInstall.ps1 diff --git a/images/win/scripts/Installers/Warmup-User.ps1 b/images/windows/scripts/build/Warmup-User.ps1 similarity index 100% rename from images/win/scripts/Installers/Warmup-User.ps1 rename to images/windows/scripts/build/Warmup-User.ps1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Android.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.Android.psm1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.Android.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.Android.psm1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.Browsers.psm1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.Browsers.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.Browsers.psm1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.CachedTools.psm1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.CachedTools.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.CachedTools.psm1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.Common.psm1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.Common.psm1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Databases.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.Databases.psm1 similarity index 97% rename from images/win/scripts/SoftwareReport/SoftwareReport.Databases.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.Databases.psm1 index 9d5e612b..9cb6114b 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Databases.psm1 +++ b/images/windows/scripts/docs-gen/SoftwareReport.Databases.psm1 @@ -1,32 +1,32 @@ -function Get-PostgreSQLTable -{ - $pgService = Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'" - $pgPath = $pgService.PathName - $pgRoot = $pgPath.split('"')[1].replace("\bin\pg_ctl.exe", "") - $env:Path += ";${env:PGBIN}" - $pgVersion = (postgres --version).split()[2].Trim() - - return @( - [PSCustomObject]@{ Property = "ServiceName"; Value = $pgService.Name }, - [PSCustomObject]@{ Property = "Version"; Value = $pgVersion }, - [PSCustomObject]@{ Property = "ServiceStatus"; Value = $pgService.State }, - [PSCustomObject]@{ Property = "ServiceStartType"; Value = $pgService.StartMode }, - [PSCustomObject]@{ Property = "EnvironmentVariables"; Value = "`PGBIN=$env:PGBIN`
`PGDATA=$env:PGDATA`
`PGROOT=$env:PGROOT` " }, - [PSCustomObject]@{ Property = "Path"; Value = $pgRoot }, - [PSCustomObject]@{ Property = "UserName"; Value = $env:PGUSER }, - [PSCustomObject]@{ Property = "Password"; Value = $env:PGPASSWORD } - ) -} - -function Get-MongoDBTable -{ - $name = "MongoDB" - $mongoService = Get-Service -Name $name - $mongoVersion = (Get-Command -Name 'mongo').Version.ToString() - return [PSCustomObject]@{ - Version = $mongoVersion - ServiceName = $name - ServiceStatus = $mongoService.Status - ServiceStartType = $mongoService.StartType - } -} +function Get-PostgreSQLTable +{ + $pgService = Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'" + $pgPath = $pgService.PathName + $pgRoot = $pgPath.split('"')[1].replace("\bin\pg_ctl.exe", "") + $env:Path += ";${env:PGBIN}" + $pgVersion = (postgres --version).split()[2].Trim() + + return @( + [PSCustomObject]@{ Property = "ServiceName"; Value = $pgService.Name }, + [PSCustomObject]@{ Property = "Version"; Value = $pgVersion }, + [PSCustomObject]@{ Property = "ServiceStatus"; Value = $pgService.State }, + [PSCustomObject]@{ Property = "ServiceStartType"; Value = $pgService.StartMode }, + [PSCustomObject]@{ Property = "EnvironmentVariables"; Value = "`PGBIN=$env:PGBIN`
`PGDATA=$env:PGDATA`
`PGROOT=$env:PGROOT` " }, + [PSCustomObject]@{ Property = "Path"; Value = $pgRoot }, + [PSCustomObject]@{ Property = "UserName"; Value = $env:PGUSER }, + [PSCustomObject]@{ Property = "Password"; Value = $env:PGPASSWORD } + ) +} + +function Get-MongoDBTable +{ + $name = "MongoDB" + $mongoService = Get-Service -Name $name + $mongoVersion = (Get-Command -Name 'mongo').Version.ToString() + return [PSCustomObject]@{ + Version = $mongoVersion + ServiceName = $name + ServiceStatus = $mongoService.Status + ServiceStartType = $mongoService.StartType + } +} diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/windows/scripts/docs-gen/SoftwareReport.Generator.ps1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 rename to images/windows/scripts/docs-gen/SoftwareReport.Generator.ps1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.Helpers.psm1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.Helpers.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.Helpers.psm1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Java.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.Java.psm1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.Java.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.Java.psm1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.Tools.psm1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.Tools.psm1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.VisualStudio.psm1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.VisualStudio.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.VisualStudio.psm1 diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.WebServers.psm1 b/images/windows/scripts/docs-gen/SoftwareReport.WebServers.psm1 similarity index 100% rename from images/win/scripts/SoftwareReport/SoftwareReport.WebServers.psm1 rename to images/windows/scripts/docs-gen/SoftwareReport.WebServers.psm1 diff --git a/images/win/scripts/ImageHelpers/ChocoHelpers.ps1 b/images/windows/scripts/helpers/ChocoHelpers.ps1 similarity index 96% rename from images/win/scripts/ImageHelpers/ChocoHelpers.ps1 rename to images/windows/scripts/helpers/ChocoHelpers.ps1 index 9405f3eb..46247620 100644 --- a/images/win/scripts/ImageHelpers/ChocoHelpers.ps1 +++ b/images/windows/scripts/helpers/ChocoHelpers.ps1 @@ -1,65 +1,65 @@ -function Choco-Install { - [CmdletBinding()] - param( - [Parameter(Mandatory)] - [string] $PackageName, - [string[]] $ArgumentList, - [int] $RetryCount = 5 - ) - - process { - $count = 1 - while($true) - { - Write-Host "Running [#$count]: choco install $packageName -y $argumentList" - choco install $packageName -y @argumentList --no-progress - - $pkg = choco list --localonly $packageName --exact --all --limitoutput - if ($pkg) { - Write-Host "Package installed: $pkg" - break - } - else { - $count++ - if ($count -ge $retryCount) { - Write-Host "Could not install $packageName after $count attempts" - exit 1 - } - Start-Sleep -Seconds 30 - } - } - } -} - -function Send-RequestToChocolateyPackages { - param( - [Parameter(Mandatory)] - [string] $FilterQuery, - [string] $Url = "https://community.chocolatey.org/api", - [int] $ApiVersion = 2 - ) - - $response = Invoke-RestMethod "$Url/v$ApiVersion/Packages()?$filterQuery" - - return $response -} - -function Get-LatestChocoPackageVersion { - param( - [Parameter(Mandatory)] - [string] $PackageName, - [Parameter(Mandatory)] - [string] $TargetVersion - ) - - $versionNumbers = $TargetVersion.Split(".") - [int]$versionNumbers[-1] += 1 - $incrementedVersion = $versionNumbers -join "." - $filterQuery = "`$filter=(Id eq '$PackageName') and (IsPrerelease eq false) and (Version ge '$TargetVersion') and (Version lt '$incrementedVersion')" - $latestVersion = (Send-RequestToChocolateyPackages -FilterQuery $filterQuery).properties.Version | - Where-Object {$_ -Like "$TargetVersion.*" -or $_ -eq $TargetVersion} | - Sort-Object {[version]$_} | - Select-Object -Last 1 - - return $latestVersion +function Choco-Install { + [CmdletBinding()] + param( + [Parameter(Mandatory)] + [string] $PackageName, + [string[]] $ArgumentList, + [int] $RetryCount = 5 + ) + + process { + $count = 1 + while($true) + { + Write-Host "Running [#$count]: choco install $packageName -y $argumentList" + choco install $packageName -y @argumentList --no-progress + + $pkg = choco list --localonly $packageName --exact --all --limitoutput + if ($pkg) { + Write-Host "Package installed: $pkg" + break + } + else { + $count++ + if ($count -ge $retryCount) { + Write-Host "Could not install $packageName after $count attempts" + exit 1 + } + Start-Sleep -Seconds 30 + } + } + } +} + +function Send-RequestToChocolateyPackages { + param( + [Parameter(Mandatory)] + [string] $FilterQuery, + [string] $Url = "https://community.chocolatey.org/api", + [int] $ApiVersion = 2 + ) + + $response = Invoke-RestMethod "$Url/v$ApiVersion/Packages()?$filterQuery" + + return $response +} + +function Get-LatestChocoPackageVersion { + param( + [Parameter(Mandatory)] + [string] $PackageName, + [Parameter(Mandatory)] + [string] $TargetVersion + ) + + $versionNumbers = $TargetVersion.Split(".") + [int]$versionNumbers[-1] += 1 + $incrementedVersion = $versionNumbers -join "." + $filterQuery = "`$filter=(Id eq '$PackageName') and (IsPrerelease eq false) and (Version ge '$TargetVersion') and (Version lt '$incrementedVersion')" + $latestVersion = (Send-RequestToChocolateyPackages -FilterQuery $filterQuery).properties.Version | + Where-Object {$_ -Like "$TargetVersion.*" -or $_ -eq $TargetVersion} | + Sort-Object {[version]$_} | + Select-Object -Last 1 + + return $latestVersion } \ No newline at end of file diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psd1 b/images/windows/scripts/helpers/ImageHelpers.psd1 similarity index 97% rename from images/win/scripts/ImageHelpers/ImageHelpers.psd1 rename to images/windows/scripts/helpers/ImageHelpers.psd1 index bdb237c0..317f86de 100644 --- a/images/win/scripts/ImageHelpers/ImageHelpers.psd1 +++ b/images/windows/scripts/helpers/ImageHelpers.psd1 @@ -1,107 +1,107 @@ -@{ - -# Script module or binary module file associated with this manifest. -RootModule = 'ImageHelpers.psm1' - -# Version number of this module. -ModuleVersion = '0.0.1' - -# Supported PSEditions -# CompatiblePSEditions = @() - -# ID used to uniquely identify this module -GUID = 'c9334909-16a1-48f1-a94a-c7baf1b961d9' - -# Description of the functionality provided by this module -Description = 'Helper functions for creating vsts images' - -# Minimum version of the Windows PowerShell engine required by this module -# PowerShellVersion = '' - -# Name of the Windows PowerShell host required by this module -# PowerShellHostName = '' - -# Minimum version of the Windows PowerShell host required by this module -# PowerShellHostVersion = '' - -# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -# DotNetFrameworkVersion = '' - -# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. -# CLRVersion = '' - -# Processor architecture (None, X86, Amd64) required by this module -# ProcessorArchitecture = '' - -# Modules that must be imported into the global environment prior to importing this module -# RequiredModules = @() - -# Assemblies that must be loaded prior to importing this module -# RequiredAssemblies = @() - -# Script files (.ps1) that are run in the caller's environment prior to importing this module. -# ScriptsToProcess = @() - -# Type files (.ps1xml) to be loaded when importing this module -# TypesToProcess = @() - -# Format files (.ps1xml) to be loaded when importing this module -# FormatsToProcess = @() - -# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess -# NestedModules = @() - -# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. -FunctionsToExport = '*' - -# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. -CmdletsToExport = '*' - -# Variables to export from this module -VariablesToExport = '*' - -# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. -AliasesToExport = '*' - -# DSC resources to export from this module -# DscResourcesToExport = @() - -# List of all modules packaged with this module -# ModuleList = @() - -# List of all files packaged with this module -# FileList = @() - -# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. -PrivateData = @{ - - PSData = @{ - - # Tags applied to this module. These help with module discovery in online galleries. - # Tags = @() - - # A URL to the license for this module. - # LicenseUri = '' - - # A URL to the main website for this project. - # ProjectUri = '' - - # A URL to an icon representing this module. - # IconUri = '' - - # ReleaseNotes of this module - # ReleaseNotes = '' - - } # End of PSData hashtable - -} # End of PrivateData hashtable - -# HelpInfo URI of this module -# HelpInfoURI = '' - -# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. -# DefaultCommandPrefix = '' - -} - - +@{ + +# Script module or binary module file associated with this manifest. +RootModule = 'ImageHelpers.psm1' + +# Version number of this module. +ModuleVersion = '0.0.1' + +# Supported PSEditions +# CompatiblePSEditions = @() + +# ID used to uniquely identify this module +GUID = 'c9334909-16a1-48f1-a94a-c7baf1b961d9' + +# Description of the functionality provided by this module +Description = 'Helper functions for creating vsts images' + +# Minimum version of the Windows PowerShell engine required by this module +# PowerShellVersion = '' + +# Name of the Windows PowerShell host required by this module +# PowerShellHostName = '' + +# Minimum version of the Windows PowerShell host required by this module +# PowerShellHostVersion = '' + +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' + +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# CLRVersion = '' + +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' + +# Modules that must be imported into the global environment prior to importing this module +# RequiredModules = @() + +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() + +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() + +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() + +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() + +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() + +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = '*' + +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = '*' + +# Variables to export from this module +VariablesToExport = '*' + +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = '*' + +# DSC resources to export from this module +# DscResourcesToExport = @() + +# List of all modules packaged with this module +# ModuleList = @() + +# List of all files packaged with this module +# FileList = @() + +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ + + PSData = @{ + + # Tags applied to this module. These help with module discovery in online galleries. + # Tags = @() + + # A URL to the license for this module. + # LicenseUri = '' + + # A URL to the main website for this project. + # ProjectUri = '' + + # A URL to an icon representing this module. + # IconUri = '' + + # ReleaseNotes of this module + # ReleaseNotes = '' + + } # End of PSData hashtable + +} # End of PrivateData hashtable + +# HelpInfo URI of this module +# HelpInfoURI = '' + +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' + +} + + diff --git a/images/win/scripts/ImageHelpers/ImageHelpers.psm1 b/images/windows/scripts/helpers/ImageHelpers.psm1 similarity index 100% rename from images/win/scripts/ImageHelpers/ImageHelpers.psm1 rename to images/windows/scripts/helpers/ImageHelpers.psm1 diff --git a/images/win/scripts/ImageHelpers/InstallHelpers.ps1 b/images/windows/scripts/helpers/InstallHelpers.ps1 similarity index 100% rename from images/win/scripts/ImageHelpers/InstallHelpers.ps1 rename to images/windows/scripts/helpers/InstallHelpers.ps1 diff --git a/images/win/scripts/ImageHelpers/PathHelpers.ps1 b/images/windows/scripts/helpers/PathHelpers.ps1 similarity index 100% rename from images/win/scripts/ImageHelpers/PathHelpers.ps1 rename to images/windows/scripts/helpers/PathHelpers.ps1 diff --git a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 b/images/windows/scripts/helpers/TestsHelpers.ps1 similarity index 97% rename from images/win/scripts/ImageHelpers/TestsHelpers.ps1 rename to images/windows/scripts/helpers/TestsHelpers.ps1 index c6667de3..f22cd9c2 100644 --- a/images/win/scripts/ImageHelpers/TestsHelpers.ps1 +++ b/images/windows/scripts/helpers/TestsHelpers.ps1 @@ -41,21 +41,21 @@ function Invoke-PesterTests { [string] $TestName ) - $testPath = "C:\image\Tests\${TestFile}.Tests.ps1" + $testPath = "C:\image\tests\${TestFile}.Tests.ps1" if (-not (Test-Path $testPath)) { throw "Unable to find test file '$TestFile' on '$testPath'." } $configuration = [PesterConfiguration] @{ - Run = @{ Path = $testPath; PassThru = $true } - Output = @{ Verbosity = "Detailed"; RenderMode = "Plaintext"} + Run = @{ Path = $testPath; PassThru = $true } + Output = @{ Verbosity = "Detailed"; RenderMode = "Plaintext" } } if ($TestName) { $configuration.Filter.FullName = $TestName } if ($TestFile -eq "*") { $configuration.TestResult.Enabled = $true - $configuration.TestResult.OutputPath = "C:\image\Tests\testResults.xml" + $configuration.TestResult.OutputPath = "C:\image\tests\testResults.xml" } # Update environment variables without reboot diff --git a/images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 b/images/windows/scripts/helpers/VisualStudioHelpers.ps1 similarity index 100% rename from images/win/scripts/ImageHelpers/VisualStudioHelpers.ps1 rename to images/windows/scripts/helpers/VisualStudioHelpers.ps1 diff --git a/images/win/scripts/ImageHelpers/test/ImageHelpers.Tests.ps1 b/images/windows/scripts/helpers/test/ImageHelpers.Tests.ps1 similarity index 100% rename from images/win/scripts/ImageHelpers/test/ImageHelpers.Tests.ps1 rename to images/windows/scripts/helpers/test/ImageHelpers.Tests.ps1 diff --git a/images/win/scripts/ImageHelpers/test/PathHelpers.Tests.ps1 b/images/windows/scripts/helpers/test/PathHelpers.Tests.ps1 similarity index 100% rename from images/win/scripts/ImageHelpers/test/PathHelpers.Tests.ps1 rename to images/windows/scripts/helpers/test/PathHelpers.Tests.ps1 diff --git a/images/win/scripts/Tests/ActionArchiveCache.Tests.ps1 b/images/windows/scripts/tests/ActionArchiveCache.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/ActionArchiveCache.Tests.ps1 rename to images/windows/scripts/tests/ActionArchiveCache.Tests.ps1 diff --git a/images/win/scripts/Tests/Android.Tests.ps1 b/images/windows/scripts/tests/Android.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Android.Tests.ps1 rename to images/windows/scripts/tests/Android.Tests.ps1 diff --git a/images/win/scripts/Tests/Apache.Tests.ps1 b/images/windows/scripts/tests/Apache.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Apache.Tests.ps1 rename to images/windows/scripts/tests/Apache.Tests.ps1 diff --git a/images/win/scripts/Tests/BizTalk.Tests.ps1 b/images/windows/scripts/tests/BizTalk.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/BizTalk.Tests.ps1 rename to images/windows/scripts/tests/BizTalk.Tests.ps1 diff --git a/images/win/scripts/Tests/Browsers.Tests.ps1 b/images/windows/scripts/tests/Browsers.Tests.ps1 similarity index 97% rename from images/win/scripts/Tests/Browsers.Tests.ps1 rename to images/windows/scripts/tests/Browsers.Tests.ps1 index ba5db877..24b65803 100644 --- a/images/win/scripts/Tests/Browsers.Tests.ps1 +++ b/images/windows/scripts/tests/Browsers.Tests.ps1 @@ -1,160 +1,160 @@ -Describe "Chrome" { - Context "WebDriver" { - It "ChromeWebDriver environment variable and path exists" { - $env:ChromeWebDriver | Should -Not -BeNullOrEmpty - $env:ChromeWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\ChromeDriver" - $env:ChromeWebDriver | Should -Exist - } - - It "chromedriver.exe is installed" { - "$env:ChromeWebDriver\chromedriver.exe --version" | Should -ReturnZeroExitCode - } - - It "versioninfo.txt exists" { - "$env:ChromeWebDriver\versioninfo.txt" | Should -Exist - } - } - - Context "Browser" { - $chromeRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" - $chromePath = (Get-ItemProperty $chromeRegPath).'(default)' - - It "Chrome '' registry path exists" -TestCases @{chromeRegPath = $chromeRegPath} { - $chromeRegPath | Should -Exist - } - - It "Chrome VersionInfo registry value exists" -TestCases @{chromePath = $chromePath} { - $versionInfo = (Get-Item $chromePath).VersionInfo - $versionInfo | Should -Not -BeNullOrEmpty - } - - It "gupdate service is stopped" { - $svc = Get-Service -Name gupdate - $svc.Status | Should -BeExactly Stopped - } - - It "gupdatem service is stopped" { - $svc = Get-Service -Name gupdatem - $svc.Status | Should -BeExactly Stopped - } - - It "BlockGoogleUpdate firewall rule exists" { - Get-NetFirewallRule -DisplayName BlockGoogleUpdate | Should -Not -BeNullOrEmpty - } - - It " is installed" -TestCases @{chromePath = $chromePath} { - $chromeName = (Get-Item $chromePath).Name - $chromePath | Should -Exist - $chromeName | Should -BeExactly "chrome.exe" - } - - It "Chrome and Chrome Driver major versions are the same" -TestCases @{chromePath = $chromePath} { - $chromeMajor = (Get-Item $chromePath).VersionInfo.ProductMajorPart - $chromeDriverMajor = (Get-Content $env:ChromeWebDriver\versioninfo.txt).Split(".")[0] - $chromeMajor | Should -BeExactly $chromeDriverMajor - } - } -} - -Describe "Edge" { - Context "WebDriver" { - It "EdgeWebDriver environment variable and path exists" { - $env:EdgeWebDriver | Should -Not -BeNullOrEmpty - $env:EdgeWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\EdgeDriver" - $env:EdgeWebDriver | Should -Exist - } - - It "msedgedriver.exe is installed" { - "$env:EdgeWebDriver\msedgedriver.exe --version" | Should -ReturnZeroExitCode - } - - It "versioninfo.txt exists" { - "$env:EdgeWebDriver\versioninfo.txt" | Should -Exist - } - } - - Context "Browser" { - $edgeRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe" - - It "Edge '' registry path exists" -TestCases @{edgeRegPath = $edgeRegPath} { - $edgeRegPath | Should -Exist - } - - It "Edge VersionInfo registry value exists" -TestCases @{edgeRegPath = $edgeRegPath} { - $versionInfo = (Get-Item (Get-ItemProperty $edgeRegPath).'(Default)').VersionInfo - $versionInfo | Should -Not -BeNullOrEmpty - } - - It "msedge.exe is installed" { - "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" | Should -Exist - } - } -} - -Describe "Firefox" { - Context "WebDriver" { - It "GeckoWebDriver environment variable and path exists" { - $env:GeckoWebDriver | Should -Not -BeNullOrEmpty - $env:GeckoWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\GeckoDriver" - $env:GeckoWebDriver | Should -Exist - } - - It "geckodriver.exe is installed" { - "$env:GeckoWebDriver\geckodriver.exe --version" | Should -ReturnZeroExitCode - } - - It "versioninfo.txt exists" { - "$env:GeckoWebDriver\versioninfo.txt" | Should -Exist - } - } - - Context "Browser" { - $firefoxRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe" - - It "Firefox '' registry path exists" -TestCases @{firefoxRegPath = $firefoxRegPath} { - $firefoxRegPath | Should -Exist - } - - It "Firefox VersionInfo registry value exists" -TestCases @{firefoxRegPath = $firefoxRegPath} { - $versionInfo = (Get-Item (Get-ItemProperty $firefoxRegPath).'(Default)').VersionInfo - $versionInfo | Should -Not -BeNullOrEmpty - } - - It "firefox.exe is installed" { - "$env:ProgramFiles\Mozilla Firefox\firefox.exe" | Should -Exist - } - } -} - -Describe "Internet Explorer" { - Context "WebDriver" { - It "IEWebDriver environment variable and path exists" { - $env:IEWebDriver | Should -Not -BeNullOrEmpty - $env:IEWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\IEDriver" - $env:IEWebDriver | Should -Exist - } - - It "iedriverserver.exe is installed" { - "$env:IEWebDriver\IEDriverServer.exe --version" | Should -ReturnZeroExitCode - } - - It "versioninfo.txt exists" { - "$env:IEWebDriver\versioninfo.txt" | Should -Exist - } - } -} - -Describe "Selenium" { - BeforeAll { - $seleniumBinaryName = (Get-ToolsetContent).selenium.binary_name - $seleniumBinPath = Join-Path "C:\selenium\" "$seleniumBinaryName.jar" - } - - It "Selenium server is installed" { - $seleniumBinPath | Should -Exist - } - - It "SELENIUM_JAR_PATH environment variable exists" { - Get-EnvironmentVariable "SELENIUM_JAR_PATH" | Should -BeExactly "$seleniumBinPath" - } +Describe "Chrome" { + Context "WebDriver" { + It "ChromeWebDriver environment variable and path exists" { + $env:ChromeWebDriver | Should -Not -BeNullOrEmpty + $env:ChromeWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\ChromeDriver" + $env:ChromeWebDriver | Should -Exist + } + + It "chromedriver.exe is installed" { + "$env:ChromeWebDriver\chromedriver.exe --version" | Should -ReturnZeroExitCode + } + + It "versioninfo.txt exists" { + "$env:ChromeWebDriver\versioninfo.txt" | Should -Exist + } + } + + Context "Browser" { + $chromeRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\chrome.exe" + $chromePath = (Get-ItemProperty $chromeRegPath).'(default)' + + It "Chrome '' registry path exists" -TestCases @{chromeRegPath = $chromeRegPath} { + $chromeRegPath | Should -Exist + } + + It "Chrome VersionInfo registry value exists" -TestCases @{chromePath = $chromePath} { + $versionInfo = (Get-Item $chromePath).VersionInfo + $versionInfo | Should -Not -BeNullOrEmpty + } + + It "gupdate service is stopped" { + $svc = Get-Service -Name gupdate + $svc.Status | Should -BeExactly Stopped + } + + It "gupdatem service is stopped" { + $svc = Get-Service -Name gupdatem + $svc.Status | Should -BeExactly Stopped + } + + It "BlockGoogleUpdate firewall rule exists" { + Get-NetFirewallRule -DisplayName BlockGoogleUpdate | Should -Not -BeNullOrEmpty + } + + It " is installed" -TestCases @{chromePath = $chromePath} { + $chromeName = (Get-Item $chromePath).Name + $chromePath | Should -Exist + $chromeName | Should -BeExactly "chrome.exe" + } + + It "Chrome and Chrome Driver major versions are the same" -TestCases @{chromePath = $chromePath} { + $chromeMajor = (Get-Item $chromePath).VersionInfo.ProductMajorPart + $chromeDriverMajor = (Get-Content $env:ChromeWebDriver\versioninfo.txt).Split(".")[0] + $chromeMajor | Should -BeExactly $chromeDriverMajor + } + } +} + +Describe "Edge" { + Context "WebDriver" { + It "EdgeWebDriver environment variable and path exists" { + $env:EdgeWebDriver | Should -Not -BeNullOrEmpty + $env:EdgeWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\EdgeDriver" + $env:EdgeWebDriver | Should -Exist + } + + It "msedgedriver.exe is installed" { + "$env:EdgeWebDriver\msedgedriver.exe --version" | Should -ReturnZeroExitCode + } + + It "versioninfo.txt exists" { + "$env:EdgeWebDriver\versioninfo.txt" | Should -Exist + } + } + + Context "Browser" { + $edgeRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\msedge.exe" + + It "Edge '' registry path exists" -TestCases @{edgeRegPath = $edgeRegPath} { + $edgeRegPath | Should -Exist + } + + It "Edge VersionInfo registry value exists" -TestCases @{edgeRegPath = $edgeRegPath} { + $versionInfo = (Get-Item (Get-ItemProperty $edgeRegPath).'(Default)').VersionInfo + $versionInfo | Should -Not -BeNullOrEmpty + } + + It "msedge.exe is installed" { + "${env:ProgramFiles(x86)}\Microsoft\Edge\Application\msedge.exe" | Should -Exist + } + } +} + +Describe "Firefox" { + Context "WebDriver" { + It "GeckoWebDriver environment variable and path exists" { + $env:GeckoWebDriver | Should -Not -BeNullOrEmpty + $env:GeckoWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\GeckoDriver" + $env:GeckoWebDriver | Should -Exist + } + + It "geckodriver.exe is installed" { + "$env:GeckoWebDriver\geckodriver.exe --version" | Should -ReturnZeroExitCode + } + + It "versioninfo.txt exists" { + "$env:GeckoWebDriver\versioninfo.txt" | Should -Exist + } + } + + Context "Browser" { + $firefoxRegPath = "HKLM:SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\firefox.exe" + + It "Firefox '' registry path exists" -TestCases @{firefoxRegPath = $firefoxRegPath} { + $firefoxRegPath | Should -Exist + } + + It "Firefox VersionInfo registry value exists" -TestCases @{firefoxRegPath = $firefoxRegPath} { + $versionInfo = (Get-Item (Get-ItemProperty $firefoxRegPath).'(Default)').VersionInfo + $versionInfo | Should -Not -BeNullOrEmpty + } + + It "firefox.exe is installed" { + "$env:ProgramFiles\Mozilla Firefox\firefox.exe" | Should -Exist + } + } +} + +Describe "Internet Explorer" { + Context "WebDriver" { + It "IEWebDriver environment variable and path exists" { + $env:IEWebDriver | Should -Not -BeNullOrEmpty + $env:IEWebDriver | Should -BeExactly "C:\SeleniumWebDrivers\IEDriver" + $env:IEWebDriver | Should -Exist + } + + It "iedriverserver.exe is installed" { + "$env:IEWebDriver\IEDriverServer.exe --version" | Should -ReturnZeroExitCode + } + + It "versioninfo.txt exists" { + "$env:IEWebDriver\versioninfo.txt" | Should -Exist + } + } +} + +Describe "Selenium" { + BeforeAll { + $seleniumBinaryName = (Get-ToolsetContent).selenium.binary_name + $seleniumBinPath = Join-Path "C:\selenium\" "$seleniumBinaryName.jar" + } + + It "Selenium server is installed" { + $seleniumBinPath | Should -Exist + } + + It "SELENIUM_JAR_PATH environment variable exists" { + Get-EnvironmentVariable "SELENIUM_JAR_PATH" | Should -BeExactly "$seleniumBinPath" + } } \ No newline at end of file diff --git a/images/win/scripts/Tests/CLI.Tools.Tests.ps1 b/images/windows/scripts/tests/CLI.Tools.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/CLI.Tools.Tests.ps1 rename to images/windows/scripts/tests/CLI.Tools.Tests.ps1 diff --git a/images/win/scripts/Tests/ChocoPackages.Tests.ps1 b/images/windows/scripts/tests/ChocoPackages.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/ChocoPackages.Tests.ps1 rename to images/windows/scripts/tests/ChocoPackages.Tests.ps1 diff --git a/images/win/scripts/Tests/Databases.Tests.ps1 b/images/windows/scripts/tests/Databases.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Databases.Tests.ps1 rename to images/windows/scripts/tests/Databases.Tests.ps1 diff --git a/images/win/scripts/Tests/Docker.Tests.ps1 b/images/windows/scripts/tests/Docker.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Docker.Tests.ps1 rename to images/windows/scripts/tests/Docker.Tests.ps1 diff --git a/images/win/scripts/Tests/DotnetSDK.Tests.ps1 b/images/windows/scripts/tests/DotnetSDK.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/DotnetSDK.Tests.ps1 rename to images/windows/scripts/tests/DotnetSDK.Tests.ps1 diff --git a/images/win/scripts/Tests/Git.Tests.ps1 b/images/windows/scripts/tests/Git.Tests.ps1 similarity index 96% rename from images/win/scripts/Tests/Git.Tests.ps1 rename to images/windows/scripts/tests/Git.Tests.ps1 index 9b71aa0b..00b3d230 100644 --- a/images/win/scripts/Tests/Git.Tests.ps1 +++ b/images/windows/scripts/tests/Git.Tests.ps1 @@ -1,25 +1,25 @@ -Describe "Git" { - $gitTools = 'bash', 'awk', 'git', 'git-lfs' - $gitTestCases = $gitTools | ForEach-Object { - @{ - toolName = $_ - source = [regex]::Escape("$env:ProgramFiles\Git") - } - } - - It " is installed" -TestCases $gitTestCases { - "$toolName --version" | Should -ReturnZeroExitCode - } - - It " is located in ''" -TestCases $gitTestCases { - (Get-Command -Name $toolName).Source | Should -Match $source - } - - It "Git core.symlinks=true option is enabled" { - git config core.symlinks | Should -BeExactly true - } - - It "GCM_INTERACTIVE environment variable should be equal Never" { - $env:GCM_INTERACTIVE | Should -BeExactly Never - } -} +Describe "Git" { + $gitTools = 'bash', 'awk', 'git', 'git-lfs' + $gitTestCases = $gitTools | ForEach-Object { + @{ + toolName = $_ + source = [regex]::Escape("$env:ProgramFiles\Git") + } + } + + It " is installed" -TestCases $gitTestCases { + "$toolName --version" | Should -ReturnZeroExitCode + } + + It " is located in ''" -TestCases $gitTestCases { + (Get-Command -Name $toolName).Source | Should -Match $source + } + + It "Git core.symlinks=true option is enabled" { + git config core.symlinks | Should -BeExactly true + } + + It "GCM_INTERACTIVE environment variable should be equal Never" { + $env:GCM_INTERACTIVE | Should -BeExactly Never + } +} diff --git a/images/win/scripts/Tests/Haskell.Tests.ps1 b/images/windows/scripts/tests/Haskell.Tests.ps1 similarity index 97% rename from images/win/scripts/Tests/Haskell.Tests.ps1 rename to images/windows/scripts/tests/Haskell.Tests.ps1 index fd6b6b2c..6b4b9b5e 100644 --- a/images/win/scripts/Tests/Haskell.Tests.ps1 +++ b/images/windows/scripts/tests/Haskell.Tests.ps1 @@ -1,62 +1,62 @@ -Describe "Haskell" { - $ghcPackagesPath = "c:\ghcup\ghc" - [array]$ghcVersionList = Get-ChildItem -Path $ghcPackagesPath -Filter "*" | ForEach-Object { $_.Name.Trim() } - $ghcCount = $ghcVersionList.Count - $defaultGhcVersion = $ghcVersionList | Sort-Object {[Version]$_} | Select-Object -Last 1 - $ghcDefaultCases = @{ - defaultGhcVersion = $defaultGhcVersion - defaultGhcShortVersion = ([version]$defaultGhcVersion).ToString(3) - } - - $ghcTestCases = $ghcVersionList | ForEach-Object { - $ghcVersion = $_ - $ghcShortVersion = ([version]$ghcVersion).ToString(3) - $binGhcPath = Join-Path $ghcPackagesPath "$ghcShortVersion\bin\ghc.exe" - @{ - ghcVersion = $ghcVersion - ghcShortVersion = $ghcShortVersion - binGhcPath = $binGhcPath - } - } - - $ghcupEnvExists = @( - @{envVar = "GHCUP_INSTALL_BASE_PREFIX"} - @{envVar = "GHCUP_MSYS2"} - ) - - It " environment variable exists" -TestCases $ghcupEnvExists { - Test-Path env:\$envVar - } - - It "Accurate 3 versions of GHC are installed" -TestCases @{ghcCount = $ghcCount} { - $ghcCount | Should -BeExactly 3 - } - - It "GHC is installed" -TestCases $ghcTestCases { - "$binGhcPath --version" | Should -MatchCommandOutput $ghcShortVersion - } - - It "GHC is the default version and should be the latest installed" -TestCases $ghcDefaultCases { - "ghc --version" | Should -MatchCommandOutput $defaultGhcShortVersion - } - - It "Cabal is installed" { - "cabal --version" | Should -ReturnZeroExitCode - } - - It "cabal folder does not exist" { - $env:CABAL_DIR | Should -Not -Exist - } - - It "CABAL_DIR environment variable exists" { - Get-EnvironmentVariable CABAL_DIR | Should -BeExactly "C:\cabal" - } - - It "ghcup is installed" { - "ghcup --version" | Should -ReturnZeroExitCode - } - - It "ghcup can access msys2" { - "ghcup run --mingw-path -- pacman --version" | Should -ReturnZeroExitCode - } -} +Describe "Haskell" { + $ghcPackagesPath = "c:\ghcup\ghc" + [array]$ghcVersionList = Get-ChildItem -Path $ghcPackagesPath -Filter "*" | ForEach-Object { $_.Name.Trim() } + $ghcCount = $ghcVersionList.Count + $defaultGhcVersion = $ghcVersionList | Sort-Object {[Version]$_} | Select-Object -Last 1 + $ghcDefaultCases = @{ + defaultGhcVersion = $defaultGhcVersion + defaultGhcShortVersion = ([version]$defaultGhcVersion).ToString(3) + } + + $ghcTestCases = $ghcVersionList | ForEach-Object { + $ghcVersion = $_ + $ghcShortVersion = ([version]$ghcVersion).ToString(3) + $binGhcPath = Join-Path $ghcPackagesPath "$ghcShortVersion\bin\ghc.exe" + @{ + ghcVersion = $ghcVersion + ghcShortVersion = $ghcShortVersion + binGhcPath = $binGhcPath + } + } + + $ghcupEnvExists = @( + @{envVar = "GHCUP_INSTALL_BASE_PREFIX"} + @{envVar = "GHCUP_MSYS2"} + ) + + It " environment variable exists" -TestCases $ghcupEnvExists { + Test-Path env:\$envVar + } + + It "Accurate 3 versions of GHC are installed" -TestCases @{ghcCount = $ghcCount} { + $ghcCount | Should -BeExactly 3 + } + + It "GHC is installed" -TestCases $ghcTestCases { + "$binGhcPath --version" | Should -MatchCommandOutput $ghcShortVersion + } + + It "GHC is the default version and should be the latest installed" -TestCases $ghcDefaultCases { + "ghc --version" | Should -MatchCommandOutput $defaultGhcShortVersion + } + + It "Cabal is installed" { + "cabal --version" | Should -ReturnZeroExitCode + } + + It "cabal folder does not exist" { + $env:CABAL_DIR | Should -Not -Exist + } + + It "CABAL_DIR environment variable exists" { + Get-EnvironmentVariable CABAL_DIR | Should -BeExactly "C:\cabal" + } + + It "ghcup is installed" { + "ghcup --version" | Should -ReturnZeroExitCode + } + + It "ghcup can access msys2" { + "ghcup run --mingw-path -- pacman --version" | Should -ReturnZeroExitCode + } +} diff --git a/images/win/scripts/Tests/Java.Tests.ps1 b/images/windows/scripts/tests/Java.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Java.Tests.ps1 rename to images/windows/scripts/tests/Java.Tests.ps1 diff --git a/images/win/scripts/Tests/LLVM.Tests.ps1 b/images/windows/scripts/tests/LLVM.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/LLVM.Tests.ps1 rename to images/windows/scripts/tests/LLVM.Tests.ps1 diff --git a/images/win/scripts/Tests/MSYS2.Tests.ps1 b/images/windows/scripts/tests/MSYS2.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/MSYS2.Tests.ps1 rename to images/windows/scripts/tests/MSYS2.Tests.ps1 diff --git a/images/win/scripts/Tests/Miniconda.Tests.ps1 b/images/windows/scripts/tests/Miniconda.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Miniconda.Tests.ps1 rename to images/windows/scripts/tests/Miniconda.Tests.ps1 diff --git a/images/win/scripts/Tests/Nginx.Tests.ps1 b/images/windows/scripts/tests/Nginx.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Nginx.Tests.ps1 rename to images/windows/scripts/tests/Nginx.Tests.ps1 diff --git a/images/win/scripts/Tests/Node.Tests.ps1 b/images/windows/scripts/tests/Node.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Node.Tests.ps1 rename to images/windows/scripts/tests/Node.Tests.ps1 diff --git a/images/win/scripts/Tests/PHP.Tests.ps1 b/images/windows/scripts/tests/PHP.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/PHP.Tests.ps1 rename to images/windows/scripts/tests/PHP.Tests.ps1 diff --git a/images/win/scripts/Tests/PipxPackages.Tests.ps1 b/images/windows/scripts/tests/PipxPackages.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/PipxPackages.Tests.ps1 rename to images/windows/scripts/tests/PipxPackages.Tests.ps1 diff --git a/images/win/scripts/Tests/PowerShellAzModules.Tests.ps1 b/images/windows/scripts/tests/PowerShellAzModules.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/PowerShellAzModules.Tests.ps1 rename to images/windows/scripts/tests/PowerShellAzModules.Tests.ps1 diff --git a/images/win/scripts/Tests/PowerShellModules.Tests.ps1 b/images/windows/scripts/tests/PowerShellModules.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/PowerShellModules.Tests.ps1 rename to images/windows/scripts/tests/PowerShellModules.Tests.ps1 diff --git a/images/win/scripts/Tests/RunAll-Tests.ps1 b/images/windows/scripts/tests/RunAll-Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/RunAll-Tests.ps1 rename to images/windows/scripts/tests/RunAll-Tests.ps1 diff --git a/images/win/scripts/Tests/RunnerCache.tests.ps1 b/images/windows/scripts/tests/RunnerCache.tests.ps1 similarity index 100% rename from images/win/scripts/Tests/RunnerCache.tests.ps1 rename to images/windows/scripts/tests/RunnerCache.tests.ps1 diff --git a/images/win/scripts/Tests/Rust.Tests.ps1 b/images/windows/scripts/tests/Rust.Tests.ps1 similarity index 97% rename from images/win/scripts/Tests/Rust.Tests.ps1 rename to images/windows/scripts/tests/Rust.Tests.ps1 index 3551871b..1814396f 100644 --- a/images/win/scripts/Tests/Rust.Tests.ps1 +++ b/images/windows/scripts/tests/Rust.Tests.ps1 @@ -1,35 +1,35 @@ -Describe "Rust" { - BeforeAll { - $env:RUSTUP_HOME = "C:\Users\Default\.rustup" - $env:CARGO_HOME = "C:\Users\Default\.cargo" - $env:Path += ";$env:CARGO_HOME\bin" - } - - $rustTools = @( - @{ToolName = "rustup"; binPath = "C:\Users\Default\.cargo\bin\rustup.exe"} - @{ToolName = "rustc"; binPath = "C:\Users\Default\.cargo\bin\rustc.exe"} - @{ToolName = "bindgen.exe"; binPath = "C:\Users\Default\.cargo\bin\bindgen.exe"} - @{ToolName = "cbindgen.exe"; binPath = "C:\Users\Default\.cargo\bin\cbindgen.exe"} - @{ToolName = "cargo"; binPath = "C:\Users\Default\.cargo\bin\cargo.exe"} - @{ToolName = "cargo audit"; binPath = "C:\Users\Default\.cargo\bin\cargo-audit.exe"} - @{ToolName = "cargo outdated"; binPath = "C:\Users\Default\.cargo\bin\cargo-outdated.exe"} - ) - - $rustEnvNotExists = @( - @{envVar = "RUSTUP_HOME"} - @{envVar = "CARGO_HOME"} - ) - - It "C:\Users\Default\.rustup and C:\Users\Default\.cargo folders exist" { - "C:\Users\Default\.rustup", "C:\Users\Default\.cargo" | Should -Exist - } - - It " environment variable does not exist" -TestCases $rustEnvNotExists { - [Environment]::GetEnvironmentVariables("Machine").ContainsKey($envVar) | Should -BeFalse - } - - It " is installed to the '' folder" -TestCases $rustTools { - "$ToolName --version" | Should -ReturnZeroExitCode - $binPath | Should -Exist - } -} +Describe "Rust" { + BeforeAll { + $env:RUSTUP_HOME = "C:\Users\Default\.rustup" + $env:CARGO_HOME = "C:\Users\Default\.cargo" + $env:Path += ";$env:CARGO_HOME\bin" + } + + $rustTools = @( + @{ToolName = "rustup"; binPath = "C:\Users\Default\.cargo\bin\rustup.exe"} + @{ToolName = "rustc"; binPath = "C:\Users\Default\.cargo\bin\rustc.exe"} + @{ToolName = "bindgen.exe"; binPath = "C:\Users\Default\.cargo\bin\bindgen.exe"} + @{ToolName = "cbindgen.exe"; binPath = "C:\Users\Default\.cargo\bin\cbindgen.exe"} + @{ToolName = "cargo"; binPath = "C:\Users\Default\.cargo\bin\cargo.exe"} + @{ToolName = "cargo audit"; binPath = "C:\Users\Default\.cargo\bin\cargo-audit.exe"} + @{ToolName = "cargo outdated"; binPath = "C:\Users\Default\.cargo\bin\cargo-outdated.exe"} + ) + + $rustEnvNotExists = @( + @{envVar = "RUSTUP_HOME"} + @{envVar = "CARGO_HOME"} + ) + + It "C:\Users\Default\.rustup and C:\Users\Default\.cargo folders exist" { + "C:\Users\Default\.rustup", "C:\Users\Default\.cargo" | Should -Exist + } + + It " environment variable does not exist" -TestCases $rustEnvNotExists { + [Environment]::GetEnvironmentVariables("Machine").ContainsKey($envVar) | Should -BeFalse + } + + It " is installed to the '' folder" -TestCases $rustTools { + "$ToolName --version" | Should -ReturnZeroExitCode + $binPath | Should -Exist + } +} diff --git a/images/win/scripts/Tests/SSDTExtensions.Tests.ps1 b/images/windows/scripts/tests/SSDTExtensions.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/SSDTExtensions.Tests.ps1 rename to images/windows/scripts/tests/SSDTExtensions.Tests.ps1 diff --git a/images/win/scripts/Tests/Shell.Tests.ps1 b/images/windows/scripts/tests/Shell.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Shell.Tests.ps1 rename to images/windows/scripts/tests/Shell.Tests.ps1 diff --git a/images/win/scripts/Tests/Tools.Tests.ps1 b/images/windows/scripts/tests/Tools.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Tools.Tests.ps1 rename to images/windows/scripts/tests/Tools.Tests.ps1 diff --git a/images/win/scripts/Tests/Toolset.Tests.ps1 b/images/windows/scripts/tests/Toolset.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Toolset.Tests.ps1 rename to images/windows/scripts/tests/Toolset.Tests.ps1 diff --git a/images/win/scripts/Tests/VisualStudio.Tests.ps1 b/images/windows/scripts/tests/VisualStudio.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/VisualStudio.Tests.ps1 rename to images/windows/scripts/tests/VisualStudio.Tests.ps1 diff --git a/images/win/scripts/Tests/Vsix.Tests.ps1 b/images/windows/scripts/tests/Vsix.Tests.ps1 similarity index 97% rename from images/win/scripts/Tests/Vsix.Tests.ps1 rename to images/windows/scripts/tests/Vsix.Tests.ps1 index f09c0861..5c52da61 100644 --- a/images/win/scripts/Tests/Vsix.Tests.ps1 +++ b/images/windows/scripts/tests/Vsix.Tests.ps1 @@ -1,20 +1,20 @@ -Describe "Vsix" { - $toolset = Get-ToolsetContent - $requiredVsixs = $toolset.visualStudio.vsix - - $allPackages = (Get-VisualStudioInstance).Packages - $testCases = $requiredVsixs | ForEach-Object { - $vsix = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_ - @{ - VsixName = $vsix.ExtensionName - VsixId = $vsix.VsixId - AllPackages = $allPackages - } - } - if ($testCases.Count -gt 0) { - It "Extension is installed" -TestCases $testCases { - $objVsix = $AllPackages | Where-Object { $_.id -eq $VsixId } - $objVsix | Should -Not -BeNullOrEmpty - } - } +Describe "Vsix" { + $toolset = Get-ToolsetContent + $requiredVsixs = $toolset.visualStudio.vsix + + $allPackages = (Get-VisualStudioInstance).Packages + $testCases = $requiredVsixs | ForEach-Object { + $vsix = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_ + @{ + VsixName = $vsix.ExtensionName + VsixId = $vsix.VsixId + AllPackages = $allPackages + } + } + if ($testCases.Count -gt 0) { + It "Extension is installed" -TestCases $testCases { + $objVsix = $AllPackages | Where-Object { $_.id -eq $VsixId } + $objVsix | Should -Not -BeNullOrEmpty + } + } } \ No newline at end of file diff --git a/images/win/scripts/Tests/WDK.Tests.ps1 b/images/windows/scripts/tests/WDK.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/WDK.Tests.ps1 rename to images/windows/scripts/tests/WDK.Tests.ps1 diff --git a/images/win/scripts/Tests/WinAppDriver.Tests.ps1 b/images/windows/scripts/tests/WinAppDriver.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/WinAppDriver.Tests.ps1 rename to images/windows/scripts/tests/WinAppDriver.Tests.ps1 diff --git a/images/win/scripts/Tests/WindowsFeatures.Tests.ps1 b/images/windows/scripts/tests/WindowsFeatures.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/WindowsFeatures.Tests.ps1 rename to images/windows/scripts/tests/WindowsFeatures.Tests.ps1 diff --git a/images/win/scripts/Tests/Wix.Tests.ps1 b/images/windows/scripts/tests/Wix.Tests.ps1 similarity index 100% rename from images/win/scripts/Tests/Wix.Tests.ps1 rename to images/windows/scripts/tests/Wix.Tests.ps1 diff --git a/images/win/windows2019.json b/images/windows/templates/windows-2019.json similarity index 52% rename from images/win/windows2019.json rename to images/windows/templates/windows-2019.json index dea37bf8..ce5566b0 100644 --- a/images/win/windows2019.json +++ b/images/windows/templates/windows-2019.json @@ -73,33 +73,30 @@ }, { "type": "file", - "source": "{{ template_dir }}/scripts/ImageHelpers", - "destination": "{{user `helper_script_folder`}}" + "sources": [ + "{{ template_dir }}/../assets", + "{{ template_dir }}/../scripts", + "{{ template_dir }}/../toolsets" + ], + "destination": "{{user `image_folder`}}\\" }, { "type": "file", - "source": "{{ template_dir }}/scripts/SoftwareReport", - "destination": "{{user `image_folder`}}" + "source": "{{ template_dir }}/../../../helpers/software-report-base", + "destination": "{{user `image_folder`}}\\scripts\\docs-gen\\" }, { - "type": "file", - "source": "{{ template_dir }}/../../helpers/software-report-base", - "destination": "{{user `image_folder`}}/SoftwareReport/" - }, - { - "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-2019.json", - "destination": "{{user `image_folder`}}\\toolset.json" + "type": "powershell", + "inline": [ + "Move-Item '{{user `image_folder`}}\\assets\\post-gen' 'C:\\post-generation'", + "Remove-Item -Recurse '{{user `image_folder`}}\\assets'", + "Move-Item '{{user `image_folder`}}\\scripts\\docs-gen' '{{user `image_folder`}}\\SoftwareReport'", + "Move-Item '{{user `image_folder`}}\\scripts\\helpers' '{{user `helper_script_folder`}}\\ImageHelpers'", + "Move-Item '{{user `image_folder`}}\\scripts\\tests' '{{user `image_folder`}}\\tests'", + "Remove-Item -Recurse '{{user `image_folder`}}\\scripts'", + "Move-Item '{{user `image_folder`}}\\toolsets\\toolset-2019.json' '{{user `image_folder`}}\\toolset.json'", + "Remove-Item -Recurse '{{user `image_folder`}}\\toolsets'" + ] }, { "type": "windows-shell", @@ -131,7 +128,7 @@ 3010 ], "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-NET48.ps1" + "{{ template_dir }}/../scripts/build/Install-NET48.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" @@ -150,14 +147,14 @@ "IMAGEDATA_FILE={{user `imagedata_file`}}" ], "scripts": [ - "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1", - "{{ template_dir }}/scripts/Installers/Configure-PowerShell.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" + "{{ template_dir }}/../scripts/build/Configure-Antivirus.ps1", + "{{ template_dir }}/../scripts/build/Configure-PowerShell.ps1", + "{{ template_dir }}/../scripts/build/Install-PowerShellModules.ps1", + "{{ template_dir }}/../scripts/build/Install-WindowsFeatures.ps1", + "{{ template_dir }}/../scripts/build/Install-Choco.ps1", + "{{ template_dir }}/../scripts/build/Initialize-VM.ps1", + "{{ template_dir }}/../scripts/build/Update-ImageData.ps1", + "{{ template_dir }}/../scripts/build/Update-DotnetTLS.ps1" ], "execution_policy": "unrestricted" }, @@ -168,13 +165,13 @@ { "type": "powershell", "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-VCRedist.ps1", - "{{ template_dir }}/scripts/Installers/Install-Docker.ps1", - "{{ template_dir }}/scripts/Installers/Install-Docker-WinCred.ps1", - "{{ template_dir }}/scripts/Installers/Install-Docker-Compose.ps1", - "{{ template_dir }}/scripts/Installers/Install-PowershellCore.ps1", - "{{ template_dir }}/scripts/Installers/Install-WebPlatformInstaller.ps1", - "{{ template_dir }}/scripts/Installers/Install-Runner.ps1" + "{{ template_dir }}/../scripts/build/Install-VCRedist.ps1", + "{{ template_dir }}/../scripts/build/Install-Docker.ps1", + "{{ template_dir }}/../scripts/build/Install-Docker-WinCred.ps1", + "{{ template_dir }}/../scripts/build/Install-Docker-Compose.ps1", + "{{ template_dir }}/../scripts/build/Install-PowershellCore.ps1", + "{{ template_dir }}/../scripts/build/Install-WebPlatformInstaller.ps1", + "{{ template_dir }}/../scripts/build/Install-Runner.ps1" ] }, { @@ -188,9 +185,9 @@ 3010 ], "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-VS.ps1", - "{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1", - "{{ template_dir }}/scripts/Installers/Install-NET48-devpack.ps1" + "{{ template_dir }}/../scripts/build/Install-VS.ps1", + "{{ template_dir }}/../scripts/build/Install-KubernetesTools.ps1", + "{{ template_dir }}/../scripts/build/Install-NET48-devpack.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" @@ -198,21 +195,21 @@ { "type": "powershell", "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-Wix.ps1", - "{{ template_dir }}/scripts/Installers/Install-WDK.ps1", - "{{ 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-CommonUtils.ps1", - "{{ template_dir }}/scripts/Installers/Install-JavaTools.ps1", - "{{ template_dir }}/scripts/Installers/Install-Kotlin.ps1", - "{{ template_dir }}/scripts/Installers/Install-OpenSSL.ps1" + "{{ template_dir }}/../scripts/build/Install-Wix.ps1", + "{{ template_dir }}/../scripts/build/Install-WDK.ps1", + "{{ template_dir }}/../scripts/build/Install-Vsix.ps1", + "{{ template_dir }}/../scripts/build/Install-AzureCli.ps1", + "{{ template_dir }}/../scripts/build/Install-AzureDevOpsCli.ps1", + "{{ template_dir }}/../scripts/build/Install-CommonUtils.ps1", + "{{ template_dir }}/../scripts/build/Install-JavaTools.ps1", + "{{ template_dir }}/../scripts/build/Install-Kotlin.ps1", + "{{ template_dir }}/../scripts/build/Install-OpenSSL.ps1" ] }, { "type": "powershell", "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-ServiceFabricSDK.ps1" + "{{ template_dir }}/../scripts/build/Install-ServiceFabricSDK.ps1" ], "execution_policy": "remotesigned" }, @@ -229,67 +226,67 @@ { "type": "powershell", "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-ActionArchiveCache.ps1", - "{{ 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-NodeLts.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-Sbt.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-SQLOLEDBDriver.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-Miniconda.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-NSIS.ps1", - "{{ template_dir }}/scripts/Installers/Install-CloudFoundryCli.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-GoogleCloudCLI.ps1", - "{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1", - "{{ template_dir }}/scripts/Installers/Install-BizTalkBuildComponent.ps1", - "{{ template_dir }}/scripts/Installers/Disable-JITDebugger.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", - "{{ template_dir }}/scripts/Installers/Install-LLVM.ps1" + "{{ template_dir }}/../scripts/build/Install-ActionArchiveCache.ps1", + "{{ template_dir }}/../scripts/build/Install-Ruby.ps1", + "{{ template_dir }}/../scripts/build/Install-PyPy.ps1", + "{{ template_dir }}/../scripts/build/Install-Toolset.ps1", + "{{ template_dir }}/../scripts/build/Configure-Toolset.ps1", + "{{ template_dir }}/../scripts/build/Install-NodeLts.ps1", + "{{ template_dir }}/../scripts/build/Install-AndroidSDK.ps1", + "{{ template_dir }}/../scripts/build/Install-AzureModules.ps1", + "{{ template_dir }}/../scripts/build/Install-Pipx.ps1", + "{{ template_dir }}/../scripts/build/Install-PipxPackages.ps1", + "{{ template_dir }}/../scripts/build/Install-Git.ps1", + "{{ template_dir }}/../scripts/build/Install-GitHub-CLI.ps1", + "{{ template_dir }}/../scripts/build/Install-PHP.ps1", + "{{ template_dir }}/../scripts/build/Install-Rust.ps1", + "{{ template_dir }}/../scripts/build/Install-Sbt.ps1", + "{{ template_dir }}/../scripts/build/Install-Chrome.ps1", + "{{ template_dir }}/../scripts/build/Install-Edge.ps1", + "{{ template_dir }}/../scripts/build/Install-Firefox.ps1", + "{{ template_dir }}/../scripts/build/Install-Selenium.ps1", + "{{ template_dir }}/../scripts/build/Install-IEWebDriver.ps1", + "{{ template_dir }}/../scripts/build/Install-Apache.ps1", + "{{ template_dir }}/../scripts/build/Install-Nginx.ps1", + "{{ template_dir }}/../scripts/build/Install-Msys2.ps1", + "{{ template_dir }}/../scripts/build/Install-WinAppDriver.ps1", + "{{ template_dir }}/../scripts/build/Install-R.ps1", + "{{ template_dir }}/../scripts/build/Install-AWS.ps1", + "{{ template_dir }}/../scripts/build/Install-DACFx.ps1", + "{{ template_dir }}/../scripts/build/Install-MysqlCli.ps1", + "{{ template_dir }}/../scripts/build/Install-SQLPowerShellTools.ps1", + "{{ template_dir }}/../scripts/build/Install-SQLOLEDBDriver.ps1", + "{{ template_dir }}/../scripts/build/Install-DotnetSDK.ps1", + "{{ template_dir }}/../scripts/build/Install-Mingw64.ps1", + "{{ template_dir }}/../scripts/build/Install-Haskell.ps1", + "{{ template_dir }}/../scripts/build/Install-Stack.ps1", + "{{ template_dir }}/../scripts/build/Install-Miniconda.ps1", + "{{ template_dir }}/../scripts/build/Install-AzureCosmosDbEmulator.ps1", + "{{ template_dir }}/../scripts/build/Install-Mercurial.ps1", + "{{ template_dir }}/../scripts/build/Install-Zstd.ps1", + "{{ template_dir }}/../scripts/build/Install-NSIS.ps1", + "{{ template_dir }}/../scripts/build/Install-CloudFoundryCli.ps1", + "{{ template_dir }}/../scripts/build/Install-Vcpkg.ps1", + "{{ template_dir }}/../scripts/build/Install-PostgreSQL.ps1", + "{{ template_dir }}/../scripts/build/Install-Bazel.ps1", + "{{ template_dir }}/../scripts/build/Install-AliyunCli.ps1", + "{{ template_dir }}/../scripts/build/Install-RootCA.ps1", + "{{ template_dir }}/../scripts/build/Install-MongoDB.ps1", + "{{ template_dir }}/../scripts/build/Install-GoogleCloudCLI.ps1", + "{{ template_dir }}/../scripts/build/Install-CodeQLBundle.ps1", + "{{ template_dir }}/../scripts/build/Install-BizTalkBuildComponent.ps1", + "{{ template_dir }}/../scripts/build/Disable-JITDebugger.ps1", + "{{ template_dir }}/../scripts/build/Configure-DynamicPort.ps1", + "{{ template_dir }}/../scripts/build/Configure-GDIProcessHandleQuota.ps1", + "{{ template_dir }}/../scripts/build/Configure-Shell.ps1", + "{{ template_dir }}/../scripts/build/Enable-DeveloperMode.ps1", + "{{ template_dir }}/../scripts/build/Install-LLVM.ps1" ] }, { "type": "powershell", "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-WindowsUpdates.ps1" + "{{ template_dir }}/../scripts/build/Install-WindowsUpdates.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" @@ -304,14 +301,14 @@ "type": "powershell", "pause_before": "2m", "scripts": [ - "{{ template_dir }}/scripts/Installers/Wait-WindowsUpdatesForInstall.ps1", - "{{ template_dir }}/scripts/Tests/RunAll-Tests.ps1" + "{{ template_dir }}/../scripts/build/Wait-WindowsUpdatesForInstall.ps1", + "{{ template_dir }}/../scripts/tests/RunAll-Tests.ps1" ] }, { "type": "powershell", "inline": [ - "if (-not (Test-Path {{user `image_folder`}}\\Tests\\testResults.xml)) { throw '{{user `image_folder`}}\\Tests\\testResults.xml not found' }" + "if (-not (Test-Path {{user `image_folder`}}\\tests\\testResults.xml)) { throw '{{user `image_folder`}}\\tests\\testResults.xml not found' }" ] }, { @@ -333,22 +330,22 @@ { "type": "file", "source": "C:\\software-report.md", - "destination": "{{ template_dir }}/Windows2019-Readme.md", + "destination": "{{ template_dir }}/../Windows2019-Readme.md", "direction": "download" }, { "type": "file", "source": "C:\\software-report.json", - "destination": "{{ template_dir }}/software-report.json", + "destination": "{{ template_dir }}/../software-report.json", "direction": "download" }, { "type": "powershell", "skip_clean": true, "scripts": [ - "{{ template_dir }}/scripts/Installers/Run-NGen.ps1", - "{{ template_dir }}/scripts/Installers/Finalize-VM.ps1", - "{{ template_dir }}/scripts/Installers/Warmup-User.ps1" + "{{ template_dir }}/../scripts/build/Run-NGen.ps1", + "{{ template_dir }}/../scripts/build/Finalize-VM.ps1", + "{{ template_dir }}/../scripts/build/Warmup-User.ps1" ], "environment_vars": [ "INSTALL_USER={{user `install_user`}}" diff --git a/images/win/windows2022.json b/images/windows/templates/windows-2022.json similarity index 54% rename from images/win/windows2022.json rename to images/windows/templates/windows-2022.json index 1ab93251..bfa4de3d 100644 --- a/images/win/windows2022.json +++ b/images/windows/templates/windows-2022.json @@ -73,33 +73,30 @@ }, { "type": "file", - "source": "{{ template_dir }}/scripts/ImageHelpers", - "destination": "{{user `helper_script_folder`}}" + "sources": [ + "{{ template_dir }}/../assets", + "{{ template_dir }}/../scripts", + "{{ template_dir }}/../toolsets" + ], + "destination": "{{user `image_folder`}}\\" }, { "type": "file", - "source": "{{ template_dir }}/scripts/SoftwareReport", - "destination": "{{user `image_folder`}}" + "source": "{{ template_dir }}/../../../helpers/software-report-base", + "destination": "{{user `image_folder`}}\\scripts\\docs-gen\\" }, { - "type": "file", - "source": "{{ template_dir }}/../../helpers/software-report-base", - "destination": "{{user `image_folder`}}/SoftwareReport/" - }, - { - "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": "powershell", + "inline": [ + "Move-Item '{{user `image_folder`}}\\assets\\post-gen' 'C:\\post-generation'", + "Remove-Item -Recurse '{{user `image_folder`}}\\assets'", + "Move-Item '{{user `image_folder`}}\\scripts\\docs-gen' '{{user `image_folder`}}\\SoftwareReport'", + "Move-Item '{{user `image_folder`}}\\scripts\\helpers' '{{user `helper_script_folder`}}\\ImageHelpers'", + "Move-Item '{{user `image_folder`}}\\scripts\\tests' '{{user `image_folder`}}\\tests'", + "Remove-Item -Recurse '{{user `image_folder`}}\\scripts'", + "Move-Item '{{user `image_folder`}}\\toolsets\\toolset-2022.json' '{{user `image_folder`}}\\toolset.json'", + "Remove-Item -Recurse '{{user `image_folder`}}\\toolsets'" + ] }, { "type": "windows-shell", @@ -134,14 +131,14 @@ "IMAGEDATA_FILE={{user `imagedata_file`}}" ], "scripts": [ - "{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1", - "{{ template_dir }}/scripts/Installers/Configure-PowerShell.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" + "{{ template_dir }}/../scripts/build/Configure-Antivirus.ps1", + "{{ template_dir }}/../scripts/build/Configure-PowerShell.ps1", + "{{ template_dir }}/../scripts/build/Install-PowerShellModules.ps1", + "{{ template_dir }}/../scripts/build/Install-WindowsFeatures.ps1", + "{{ template_dir }}/../scripts/build/Install-Choco.ps1", + "{{ template_dir }}/../scripts/build/Initialize-VM.ps1", + "{{ template_dir }}/../scripts/build/Update-ImageData.ps1", + "{{ template_dir }}/../scripts/build/Update-DotnetTLS.ps1" ], "execution_policy": "unrestricted" }, @@ -154,12 +151,12 @@ { "type": "powershell", "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-Docker.ps1", - "{{ template_dir }}/scripts/Installers/Install-Docker-WinCred.ps1", - "{{ template_dir }}/scripts/Installers/Install-Docker-Compose.ps1", - "{{ template_dir }}/scripts/Installers/Install-PowershellCore.ps1", - "{{ template_dir }}/scripts/Installers/Install-WebPlatformInstaller.ps1", - "{{ template_dir }}/scripts/Installers/Install-Runner.ps1" + "{{ template_dir }}/../scripts/build/Install-Docker.ps1", + "{{ template_dir }}/../scripts/build/Install-Docker-WinCred.ps1", + "{{ template_dir }}/../scripts/build/Install-Docker-Compose.ps1", + "{{ template_dir }}/../scripts/build/Install-PowershellCore.ps1", + "{{ template_dir }}/../scripts/build/Install-WebPlatformInstaller.ps1", + "{{ template_dir }}/../scripts/build/Install-Runner.ps1" ] }, { @@ -173,8 +170,8 @@ 3010 ], "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-VS.ps1", - "{{ template_dir }}/scripts/Installers/Install-KubernetesTools.ps1" + "{{ template_dir }}/../scripts/build/Install-VS.ps1", + "{{ template_dir }}/../scripts/build/Install-KubernetesTools.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" @@ -188,21 +185,21 @@ "type": "powershell", "pause_before": "2m", "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-Wix.ps1", - "{{ template_dir }}/scripts/Installers/Install-WDK.ps1", - "{{ 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-CommonUtils.ps1", - "{{ template_dir }}/scripts/Installers/Install-JavaTools.ps1", - "{{ template_dir }}/scripts/Installers/Install-Kotlin.ps1", - "{{ template_dir }}/scripts/Installers/Install-OpenSSL.ps1" + "{{ template_dir }}/../scripts/build/Install-Wix.ps1", + "{{ template_dir }}/../scripts/build/Install-WDK.ps1", + "{{ template_dir }}/../scripts/build/Install-Vsix.ps1", + "{{ template_dir }}/../scripts/build/Install-AzureCli.ps1", + "{{ template_dir }}/../scripts/build/Install-AzureDevOpsCli.ps1", + "{{ template_dir }}/../scripts/build/Install-CommonUtils.ps1", + "{{ template_dir }}/../scripts/build/Install-JavaTools.ps1", + "{{ template_dir }}/../scripts/build/Install-Kotlin.ps1", + "{{ template_dir }}/../scripts/build/Install-OpenSSL.ps1" ] }, { "type": "powershell", "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-ServiceFabricSDK.ps1" + "{{ template_dir }}/../scripts/build/Install-ServiceFabricSDK.ps1" ], "execution_policy": "remotesigned" }, @@ -219,64 +216,64 @@ { "type": "powershell", "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-ActionArchiveCache.ps1", - "{{ 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-NodeLts.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-Sbt.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-SQLOLEDBDriver.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-Miniconda.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-NSIS.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/build/Install-ActionArchiveCache.ps1", + "{{ template_dir }}/../scripts/build/Install-Ruby.ps1", + "{{ template_dir }}/../scripts/build/Install-PyPy.ps1", + "{{ template_dir }}/../scripts/build/Install-Toolset.ps1", + "{{ template_dir }}/../scripts/build/Configure-Toolset.ps1", + "{{ template_dir }}/../scripts/build/Install-NodeLts.ps1", + "{{ template_dir }}/../scripts/build/Install-AndroidSDK.ps1", + "{{ template_dir }}/../scripts/build/Install-AzureModules.ps1", + "{{ template_dir }}/../scripts/build/Install-Pipx.ps1", + "{{ template_dir }}/../scripts/build/Install-PipxPackages.ps1", + "{{ template_dir }}/../scripts/build/Install-Git.ps1", + "{{ template_dir }}/../scripts/build/Install-GitHub-CLI.ps1", + "{{ template_dir }}/../scripts/build/Install-PHP.ps1", + "{{ template_dir }}/../scripts/build/Install-Rust.ps1", + "{{ template_dir }}/../scripts/build/Install-Sbt.ps1", + "{{ template_dir }}/../scripts/build/Install-Chrome.ps1", + "{{ template_dir }}/../scripts/build/Install-Edge.ps1", + "{{ template_dir }}/../scripts/build/Install-Firefox.ps1", + "{{ template_dir }}/../scripts/build/Install-Selenium.ps1", + "{{ template_dir }}/../scripts/build/Install-IEWebDriver.ps1", + "{{ template_dir }}/../scripts/build/Install-Apache.ps1", + "{{ template_dir }}/../scripts/build/Install-Nginx.ps1", + "{{ template_dir }}/../scripts/build/Install-Msys2.ps1", + "{{ template_dir }}/../scripts/build/Install-WinAppDriver.ps1", + "{{ template_dir }}/../scripts/build/Install-R.ps1", + "{{ template_dir }}/../scripts/build/Install-AWS.ps1", + "{{ template_dir }}/../scripts/build/Install-DACFx.ps1", + "{{ template_dir }}/../scripts/build/Install-MysqlCli.ps1", + "{{ template_dir }}/../scripts/build/Install-SQLPowerShellTools.ps1", + "{{ template_dir }}/../scripts/build/Install-SQLOLEDBDriver.ps1", + "{{ template_dir }}/../scripts/build/Install-DotnetSDK.ps1", + "{{ template_dir }}/../scripts/build/Install-Mingw64.ps1", + "{{ template_dir }}/../scripts/build/Install-Haskell.ps1", + "{{ template_dir }}/../scripts/build/Install-Stack.ps1", + "{{ template_dir }}/../scripts/build/Install-Miniconda.ps1", + "{{ template_dir }}/../scripts/build/Install-AzureCosmosDbEmulator.ps1", + "{{ template_dir }}/../scripts/build/Install-Mercurial.ps1", + "{{ template_dir }}/../scripts/build/Install-Zstd.ps1", + "{{ template_dir }}/../scripts/build/Install-NSIS.ps1", + "{{ template_dir }}/../scripts/build/Install-Vcpkg.ps1", + "{{ template_dir }}/../scripts/build/Install-PostgreSQL.ps1", + "{{ template_dir }}/../scripts/build/Install-Bazel.ps1", + "{{ template_dir }}/../scripts/build/Install-AliyunCli.ps1", + "{{ template_dir }}/../scripts/build/Install-RootCA.ps1", + "{{ template_dir }}/../scripts/build/Install-MongoDB.ps1", + "{{ template_dir }}/../scripts/build/Install-CodeQLBundle.ps1", + "{{ template_dir }}/../scripts/build/Disable-JITDebugger.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", - "{{ template_dir }}/scripts/Installers/Install-LLVM.ps1" + "{{ template_dir }}/../scripts/build/Install-WindowsUpdates.ps1", + "{{ template_dir }}/../scripts/build/Configure-DynamicPort.ps1", + "{{ template_dir }}/../scripts/build/Configure-GDIProcessHandleQuota.ps1", + "{{ template_dir }}/../scripts/build/Configure-Shell.ps1", + "{{ template_dir }}/../scripts/build/Enable-DeveloperMode.ps1", + "{{ template_dir }}/../scripts/build/Install-LLVM.ps1" ], "elevated_user": "{{user `install_user`}}", "elevated_password": "{{user `install_password`}}" @@ -291,14 +288,14 @@ "type": "powershell", "pause_before": "2m", "scripts": [ - "{{ template_dir }}/scripts/Installers/Wait-WindowsUpdatesForInstall.ps1", - "{{ template_dir }}/scripts/Tests/RunAll-Tests.ps1" + "{{ template_dir }}/../scripts/build/Wait-WindowsUpdatesForInstall.ps1", + "{{ template_dir }}/../scripts/tests/RunAll-Tests.ps1" ] }, { "type": "powershell", "inline": [ - "if (-not (Test-Path {{user `image_folder`}}\\Tests\\testResults.xml)) { throw '{{user `image_folder`}}\\Tests\\testResults.xml not found' }" + "if (-not (Test-Path {{user `image_folder`}}\\tests\\testResults.xml)) { throw '{{user `image_folder`}}\\tests\\testResults.xml not found' }" ] }, { @@ -320,22 +317,22 @@ { "type": "file", "source": "C:\\software-report.md", - "destination": "{{ template_dir }}/Windows2022-Readme.md", + "destination": "{{ template_dir }}/../Windows2022-Readme.md", "direction": "download" }, { "type": "file", "source": "C:\\software-report.json", - "destination": "{{ template_dir }}/software-report.json", + "destination": "{{ template_dir }}/../software-report.json", "direction": "download" }, { "type": "powershell", "skip_clean": true, "scripts": [ - "{{ template_dir }}/scripts/Installers/Run-NGen.ps1", - "{{ template_dir }}/scripts/Installers/Finalize-VM.ps1", - "{{ template_dir }}/scripts/Installers/Warmup-User.ps1" + "{{ template_dir }}/../scripts/build/Run-NGen.ps1", + "{{ template_dir }}/../scripts/build/Finalize-VM.ps1", + "{{ template_dir }}/../scripts/build/Warmup-User.ps1" ], "environment_vars": [ "INSTALL_USER={{user `install_user`}}" diff --git a/images/win/toolsets/toolset-2019.json b/images/windows/toolsets/toolset-2019.json similarity index 100% rename from images/win/toolsets/toolset-2019.json rename to images/windows/toolsets/toolset-2019.json diff --git a/images/win/toolsets/toolset-2022.json b/images/windows/toolsets/toolset-2022.json similarity index 100% rename from images/win/toolsets/toolset-2022.json rename to images/windows/toolsets/toolset-2022.json