mirror of
https://github.com/actions/runner-images.git
synced 2025-12-29 05:17:11 +08:00
[Windows] Implement new directories hierarchy (#8616)
This commit is contained in:
committed by
GitHub
parent
84a7deae24
commit
d1f2c9a3be
39
images/windows/scripts/build/Configure-Antivirus.ps1
Normal file
39
images/windows/scripts/build/Configure-Antivirus.ps1
Normal file
@@ -0,0 +1,39 @@
|
||||
Write-Host "Disable Windows Defender..."
|
||||
$avPreference = @(
|
||||
@{DisableArchiveScanning = $true}
|
||||
@{DisableAutoExclusions = $true}
|
||||
@{DisableBehaviorMonitoring = $true}
|
||||
@{DisableBlockAtFirstSeen = $true}
|
||||
@{DisableCatchupFullScan = $true}
|
||||
@{DisableCatchupQuickScan = $true}
|
||||
@{DisableIntrusionPreventionSystem = $true}
|
||||
@{DisableIOAVProtection = $true}
|
||||
@{DisablePrivacyMode = $true}
|
||||
@{DisableScanningNetworkFiles = $true}
|
||||
@{DisableScriptScanning = $true}
|
||||
@{MAPSReporting = 0}
|
||||
@{PUAProtection = 0}
|
||||
@{SignatureDisableUpdateOnStartupWithoutEngine = $true}
|
||||
@{SubmitSamplesConsent = 2}
|
||||
@{ScanAvgCPULoadFactor = 5; ExclusionPath = @("D:\", "C:\")}
|
||||
@{DisableRealtimeMonitoring = $true}
|
||||
@{ScanScheduleDay = 8}
|
||||
)
|
||||
|
||||
$avPreference += @(
|
||||
@{EnableControlledFolderAccess = "Disable"}
|
||||
@{EnableNetworkProtection = "Disabled"}
|
||||
)
|
||||
|
||||
$avPreference | Foreach-Object {
|
||||
$avParams = $_
|
||||
Set-MpPreference @avParams
|
||||
}
|
||||
|
||||
# https://github.com/actions/runner-images/issues/4277
|
||||
# https://docs.microsoft.com/en-us/microsoft-365/security/defender-endpoint/microsoft-defender-antivirus-compatibility?view=o365-worldwide
|
||||
$atpRegPath = 'HKLM:\SOFTWARE\Policies\Microsoft\Windows Advanced Threat Protection'
|
||||
if (Test-Path $atpRegPath) {
|
||||
Write-Host "Set Microsoft Defender Antivirus to passive mode"
|
||||
Set-ItemProperty -Path $atpRegPath -Name 'ForceDefenderPassiveMode' -Value '1' -Type 'DWORD'
|
||||
}
|
||||
14
images/windows/scripts/build/Configure-DynamicPort.ps1
Normal file
14
images/windows/scripts/build/Configure-DynamicPort.ps1
Normal file
@@ -0,0 +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
|
||||
|
||||
Invoke-PesterTests -TestFile "WindowsFeatures" -TestName "DynamicPorts"
|
||||
@@ -0,0 +1,9 @@
|
||||
# https://docs.microsoft.com/en-us/windows/win32/sysinfo/gdi-objects
|
||||
# This value can be set to a number between 256 and 65,536
|
||||
|
||||
$defaultValue = 20000
|
||||
Write-Host "Set the GDIProcessHandleQuota value to $defaultValue"
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows" -Name GDIProcessHandleQuota -Value $defaultValue
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion\Windows" -Name GDIProcessHandleQuota -Value $defaultValue
|
||||
|
||||
Invoke-PesterTests -TestFile "WindowsFeatures" -TestName "GDIProcessHandleQuota"
|
||||
38
images/windows/scripts/build/Configure-PowerShell.ps1
Normal file
38
images/windows/scripts/build/Configure-PowerShell.ps1
Normal file
@@ -0,0 +1,38 @@
|
||||
################################################################################
|
||||
## File: Configure-Powershell.ps1
|
||||
## Desc: Manage PowerShell configuration
|
||||
################################################################################
|
||||
|
||||
#region System
|
||||
Write-Host "Setup PowerShellGet"
|
||||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
|
||||
|
||||
# Specifies the installation policy
|
||||
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
|
||||
|
||||
Write-Host 'Warmup PSModuleAnalysisCachePath (speedup first powershell invocation by 20s)'
|
||||
$PSModuleAnalysisCachePath = 'C:\PSModuleAnalysisCachePath\ModuleAnalysisCache'
|
||||
|
||||
[Environment]::SetEnvironmentVariable('PSModuleAnalysisCachePath', $PSModuleAnalysisCachePath, [System.EnvironmentVariableTarget]::Machine)
|
||||
# make variable to be available in the current session
|
||||
${env:PSModuleAnalysisCachePath} = $PSModuleAnalysisCachePath
|
||||
|
||||
$null = New-Item -Path $PSModuleAnalysisCachePath -ItemType 'File' -Force
|
||||
#endregion
|
||||
|
||||
#region User (current user, image generation only)
|
||||
if (-not (Test-Path $profile)) {
|
||||
New-Item $profile -ItemType File -Force
|
||||
}
|
||||
|
||||
@"
|
||||
if ( -not(Get-Module -ListAvailable -Name PowerHTML)) {
|
||||
Install-Module PowerHTML -Scope CurrentUser
|
||||
}
|
||||
|
||||
if ( -not(Get-Module -Name PowerHTML)) {
|
||||
Import-Module PowerHTML
|
||||
}
|
||||
"@ | Add-Content -Path $profile -Force
|
||||
|
||||
#endregion
|
||||
19
images/windows/scripts/build/Configure-Shell.ps1
Normal file
19
images/windows/scripts/build/Configure-Shell.ps1
Normal file
@@ -0,0 +1,19 @@
|
||||
# Create shells folder
|
||||
$shellPath = "C:\shells"
|
||||
New-Item -Path $shellPath -ItemType Directory | Out-Null
|
||||
|
||||
# add a wrapper for C:\msys64\usr\bin\bash.exe
|
||||
@'
|
||||
@echo off
|
||||
setlocal
|
||||
IF NOT DEFINED MSYS2_PATH_TYPE set MSYS2_PATH_TYPE=strict
|
||||
IF NOT DEFINED MSYSTEM set MSYSTEM=mingw64
|
||||
set CHERE_INVOKING=1
|
||||
C:\msys64\usr\bin\bash.exe -leo pipefail %*
|
||||
'@ | Out-File -FilePath "$shellPath\msys2bash.cmd" -Encoding ascii
|
||||
|
||||
# gitbash <--> C:\Program Files\Git\bin\bash.exe
|
||||
New-Item -ItemType SymbolicLink -Path "$shellPath\gitbash.exe" -Target "$env:ProgramFiles\Git\bin\bash.exe" | Out-Null
|
||||
|
||||
# wslbash <--> C:\Windows\System32\bash.exe
|
||||
New-Item -ItemType SymbolicLink -Path "$shellPath\wslbash.exe" -Target "$env:SystemRoot\System32\bash.exe" | Out-Null
|
||||
78
images/windows/scripts/build/Configure-Toolset.ps1
Normal file
78
images/windows/scripts/build/Configure-Toolset.ps1
Normal file
@@ -0,0 +1,78 @@
|
||||
################################################################################
|
||||
## File: Configure-Toolset.ps1
|
||||
## Team: CI-Build
|
||||
## Desc: Configure Toolset
|
||||
################################################################################
|
||||
|
||||
Function Set-DefaultVariables
|
||||
{
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[object] $EnvVars,
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string] $ToolVersionPath
|
||||
)
|
||||
|
||||
$templates = $EnvVars.pathTemplates
|
||||
foreach ($template in $templates)
|
||||
{
|
||||
$toolSystemPath = $template -f $ToolVersionPath
|
||||
Add-MachinePathItem -PathItem $toolSystemPath | Out-Null
|
||||
}
|
||||
|
||||
if (-not ([string]::IsNullOrEmpty($EnvVars.defaultVariable)))
|
||||
{
|
||||
setx $toolEnvVars.defaultVariable $ToolVersionPath /M | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
# Define executables for cached tools
|
||||
$toolsEnvironmentVariables = @{
|
||||
Python = @{
|
||||
pathTemplates = @(
|
||||
"{0}",
|
||||
"{0}\Scripts"
|
||||
)
|
||||
}
|
||||
go = @{
|
||||
pathTemplates = @(
|
||||
"{0}\bin"
|
||||
)
|
||||
variableTemplate = "GOROOT_{0}_{1}_X64"
|
||||
}
|
||||
}
|
||||
|
||||
$toolsToConfigure = @("Python", "Go")
|
||||
$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache `
|
||||
| Where-Object { $toolsToConfigure -contains $_.name }
|
||||
|
||||
Write-Host "Configure toolset tools environment..."
|
||||
foreach ($tool in $tools)
|
||||
{
|
||||
$toolEnvVars = $toolsEnvironmentVariables[$tool.name]
|
||||
|
||||
if (-not ([string]::IsNullOrEmpty($toolEnvVars.variableTemplate)))
|
||||
{
|
||||
foreach ($version in $tool.versions)
|
||||
{
|
||||
Write-Host "Set $($tool.name) $version environment variable..."
|
||||
|
||||
$foundVersionArchPath = Get-ToolsetToolFullPath -Name $tool.name -Version $version -Arch $tool.arch
|
||||
$envName = $toolEnvVars.variableTemplate -f $version.Split(".")
|
||||
|
||||
setx $envName $foundVersionArchPath /M | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
if (-not ([string]::IsNullOrEmpty($tool.default)))
|
||||
{
|
||||
Write-Host "Use $($tool.name) $($tool.default) as a system $($tool.name)..."
|
||||
|
||||
$toolVersionPath = Get-ToolsetToolFullPath -Name $tool.name -Version $tool.default -Arch $tool.arch
|
||||
|
||||
Set-DefaultVariables -ToolVersionPath $toolVersionPath -EnvVars $toolEnvVars
|
||||
}
|
||||
}
|
||||
|
||||
Invoke-PesterTests -TestFile "Toolset"
|
||||
16
images/windows/scripts/build/Disable-JITDebugger.ps1
Normal file
16
images/windows/scripts/build/Disable-JITDebugger.ps1
Normal file
@@ -0,0 +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)
|
||||
New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting\Consent" -Name DefaultConsent -Value 1 -Type DWORD -Force
|
||||
13
images/windows/scripts/build/Enable-DeveloperMode.ps1
Normal file
13
images/windows/scripts/build/Enable-DeveloperMode.ps1
Normal file
@@ -0,0 +1,13 @@
|
||||
################################################################################
|
||||
## File: Enable-DeveloperMode.ps1
|
||||
## Desc: Enables Developer Mode by toggling registry setting. Developer Mode is required to enable certain tools (e.g. WinAppDriver).
|
||||
################################################################################
|
||||
|
||||
# Create AppModelUnlock if it doesn't exist, required for enabling Developer Mode
|
||||
$RegistryKeyPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock"
|
||||
if (-not(Test-Path -Path $RegistryKeyPath)) {
|
||||
New-Item -Path $RegistryKeyPath -ItemType Directory -Force
|
||||
}
|
||||
|
||||
# Add registry value to enable Developer Mode
|
||||
New-ItemProperty -Path $RegistryKeyPath -Name AllowDevelopmentWithoutDevLicense -PropertyType DWORD -Value 1
|
||||
151
images/windows/scripts/build/Finalize-VM.ps1
Normal file
151
images/windows/scripts/build/Finalize-VM.ps1
Normal file
@@ -0,0 +1,151 @@
|
||||
################################################################################
|
||||
## File: Finalize-VM.ps1
|
||||
## Desc: Clean up temp folders after installs to save space
|
||||
################################################################################
|
||||
|
||||
Write-Host "Cleanup WinSxS"
|
||||
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
|
||||
|
||||
# Sets the default install version to v1 for new distributions
|
||||
# https://github.com/actions/runner-images/issues/5760
|
||||
if (Test-IsWin22) {
|
||||
Write-Host "Sets the default install version to v1 for new distributions"
|
||||
Add-DefaultItem -DefaultVariable "DefaultVersion" -Value 1 -Name "DEFAULT\Software\Microsoft\Windows\CurrentVersion\Lxss" -Kind "DWord"
|
||||
}
|
||||
|
||||
Write-Host "Clean up various directories"
|
||||
@(
|
||||
"$env:SystemDrive\Recovery",
|
||||
"$env:SystemRoot\logs",
|
||||
"$env:SystemRoot\winsxs\manifestcache",
|
||||
"$env:SystemRoot\Temp",
|
||||
"$env:SystemDrive\Users\$env:INSTALL_USER\AppData\Local\Temp",
|
||||
"$env:TEMP"
|
||||
) | ForEach-Object {
|
||||
if (Test-Path $_) {
|
||||
Write-Host "Removing $_"
|
||||
cmd /c "takeown /d Y /R /f $_ 2>&1" | Out-Null
|
||||
cmd /c "icacls $_ /grant:r administrators:f /t /c /q 2>&1" | Out-Null
|
||||
Remove-Item $_ -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
$winInstallDir = "$env:SystemRoot\Installer"
|
||||
New-Item -Path $winInstallDir -ItemType Directory -Force | Out-Null
|
||||
|
||||
# Remove AllUsersAllHosts profile
|
||||
Remove-Item $profile.AllUsersAllHosts -Force -ErrorAction SilentlyContinue | Out-Null
|
||||
|
||||
# Clean yarn and npm cache
|
||||
cmd /c "yarn cache clean 2>&1" | Out-Null
|
||||
cmd /c "npm cache clean --force 2>&1" | Out-Null
|
||||
|
||||
# allow msi to write to temp folder
|
||||
# see https://github.com/actions/runner-images/issues/1704
|
||||
cmd /c "icacls $env:SystemRoot\Temp /grant Users:f /t /c /q 2>&1" | Out-Null
|
||||
|
||||
# Registry settings
|
||||
$registrySettings = @(
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"; Name = "AUOptions"; Value = 1; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"; Name = "NoAutoUpdate"; Value = 1; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"; Name = "DoNotConnectToWindowsUpdateInternetLocations"; Value = 1; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate"; Name = "DisableWindowsUpdateAccess"; Value = 1; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Device Metadata"; Name = "PreventDeviceMetadataFromNetwork"; Value = 1; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"; Name = "AllowTelemetry"; Value = 0; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\SQMClient\Windows"; Name = "CEIPEnable"; Value = 0; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat"; Name = "AITEnable"; Value = 0; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat"; Name = "DisableUAR"; Value = 1; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\Software\Policies\Microsoft\Windows\DataCollection"; Name = "AllowTelemetry"; Value = 0; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Wow6432Node\Policies\Microsoft\Windows\DataCollection"; Name = "AllowTelemetry"; Value = 0; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\Maintenance"; Name = "MaintenanceDisabled"; Value = 1; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\MRT"; Name = "DontOfferThroughWUAU"; Value = 1; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\MRT"; Name = "DontReportInfectionInformation"; Value = 1; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search"; Name = "AllowCortana"; Value = 0; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SYSTEM\CurrentControlSet\Control"; Name = "ServicesPipeTimeout"; Value = 120000; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SYSTEM\CurrentControlSet\Control\WMI\AutoLogger\AutoLogger-Diagtrack-Listener"; Name = "Start"; Value = 0; PropertyType = "DWORD"}
|
||||
@{Path = "HKLM:\SYSTEM\CurrentControlSet\Control\WMI\AutoLogger\SQMLogger"; Name = "Start"; Value = 0; PropertyType = "DWORD"}
|
||||
)
|
||||
|
||||
$registrySettings | ForEach-Object {
|
||||
$regPath = $PSItem.Path
|
||||
New-ItemPath -Path $regPath
|
||||
New-ItemProperty @PSItem -Force -ErrorAction Ignore
|
||||
} | Out-Null
|
||||
|
||||
# Disable Template Services / User Services added by Desktop Experience
|
||||
$regUserServicesToDisables = @(
|
||||
"HKLM:\SYSTEM\CurrentControlSet\Services\CDPUserSvc"
|
||||
"HKLM:\SYSTEM\CurrentControlSet\Services\OneSyncSvc"
|
||||
"HKLM:\SYSTEM\CurrentControlSet\Services\PimIndexMaintenanceSvc"
|
||||
"HKLM:\SYSTEM\CurrentControlSet\Services\UnistoreSvc"
|
||||
"HKLM:\SYSTEM\CurrentControlSet\Services\UserDataSvc"
|
||||
)
|
||||
|
||||
$regUserServicesToDisables | ForEach-Object {
|
||||
$regPath = $_
|
||||
New-ItemPath -Path $regPath
|
||||
New-ItemProperty -Path $regPath -Name "Start" -Value 4 -PropertyType DWORD -Force -ErrorAction Ignore
|
||||
New-ItemProperty -Path $regPath -Name "UserServiceFlags" -Value 0 -PropertyType DWORD -Force -ErrorAction Ignore
|
||||
} | Out-Null
|
||||
|
||||
|
||||
Write-Host 'Disable Windows Update Service'
|
||||
Set-ItemProperty -Path HKLM:\System\CurrentControlSet\Services\wuauserv -Name Start -Value 4 -Force
|
||||
|
||||
# Disabled services
|
||||
$servicesToDisable = @(
|
||||
'wuauserv'
|
||||
'DiagTrack'
|
||||
'dmwappushservice'
|
||||
'PcaSvc'
|
||||
'SysMain'
|
||||
'gupdate'
|
||||
'gupdatem'
|
||||
'StorSvc'
|
||||
)
|
||||
|
||||
$servicesToDisable | Stop-SvcWithErrHandling
|
||||
$servicesToDisable | Set-SvcWithErrHandling -Arguments @{StartupType = "Disabled"}
|
||||
|
||||
# Disable scheduled tasks
|
||||
$allTasksInTaskPath = @(
|
||||
"\"
|
||||
"\Microsoft\Azure\Security\"
|
||||
"\Microsoft\VisualStudio\"
|
||||
"\Microsoft\VisualStudio\Updates\"
|
||||
"\Microsoft\Windows\Application Experience\"
|
||||
"\Microsoft\Windows\ApplicationData\"
|
||||
"\Microsoft\Windows\Autochk\"
|
||||
"\Microsoft\Windows\Chkdsk\"
|
||||
"\Microsoft\Windows\Customer Experience Improvement Program\"
|
||||
"\Microsoft\Windows\Data Integrity Scan\"
|
||||
"\Microsoft\Windows\Defrag\"
|
||||
"\Microsoft\Windows\Diagnosis\"
|
||||
"\Microsoft\Windows\DiskCleanup\"
|
||||
"\Microsoft\Windows\DiskDiagnostic\"
|
||||
"\Microsoft\Windows\Maintenance\"
|
||||
"\Microsoft\Windows\PI\"
|
||||
"\Microsoft\Windows\Power Efficiency Diagnostics\"
|
||||
"\Microsoft\Windows\Server Manager\"
|
||||
"\Microsoft\Windows\Speech\"
|
||||
"\Microsoft\Windows\UpdateOrchestrator\"
|
||||
"\Microsoft\Windows\Windows Error Reporting\"
|
||||
"\Microsoft\Windows\WindowsUpdate\"
|
||||
"\Microsoft\XblGameSave\"
|
||||
)
|
||||
|
||||
$allTasksInTaskPath | ForEach-Object {
|
||||
Get-ScheduledTask -TaskPath $_ -ErrorAction Ignore | Disable-ScheduledTask -ErrorAction Ignore
|
||||
} | Out-Null
|
||||
|
||||
$disableTaskNames = @(
|
||||
@{TaskPath = "\Microsoft\Windows\.NET Framework\"; TaskName = ".NET Framework NGEN v4.0.30319"}
|
||||
@{TaskPath = "\Microsoft\Windows\.NET Framework\"; TaskName = ".NET Framework NGEN v4.0.30319 64"}
|
||||
@{TaskPath = "\Microsoft\Windows\AppID\"; TaskName = "SmartScreenSpecific"}
|
||||
)
|
||||
|
||||
$disableTaskNames | ForEach-Object {
|
||||
Disable-ScheduledTask @PSItem -ErrorAction Ignore
|
||||
} | Out-Null
|
||||
|
||||
Write-Host "Finalize-VM.ps1 - completed"
|
||||
79
images/windows/scripts/build/Initialize-VM.ps1
Normal file
79
images/windows/scripts/build/Initialize-VM.ps1
Normal file
@@ -0,0 +1,79 @@
|
||||
################################################################################
|
||||
## File: Initialize-VM.ps1
|
||||
## Desc: VM initialization script, machine level configuration
|
||||
################################################################################
|
||||
|
||||
function Disable-InternetExplorerESC {
|
||||
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
|
||||
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
|
||||
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force
|
||||
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force
|
||||
|
||||
$ieProcess = Get-Process -Name Explorer -ErrorAction SilentlyContinue
|
||||
|
||||
if ($ieProcess){
|
||||
Stop-Process -Name Explorer -Force -ErrorAction Continue
|
||||
}
|
||||
|
||||
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled."
|
||||
}
|
||||
|
||||
function Disable-InternetExplorerWelcomeScreen {
|
||||
$AdminKey = "HKLM:\Software\Policies\Microsoft\Internet Explorer\Main"
|
||||
New-Item -Path $AdminKey -Value 1 -Force
|
||||
Set-ItemProperty -Path $AdminKey -Name "DisableFirstRunCustomize" -Value 1 -Force
|
||||
Write-Host "Disabled IE Welcome screen"
|
||||
}
|
||||
|
||||
function Disable-UserAccessControl {
|
||||
Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000 -Force
|
||||
Write-Host "User Access Control (UAC) has been disabled."
|
||||
}
|
||||
|
||||
function Disable-WindowsUpdate {
|
||||
$AutoUpdatePath = "HKLM:SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU"
|
||||
If (Test-Path -Path $AutoUpdatePath) {
|
||||
Set-ItemProperty -Path $AutoUpdatePath -Name NoAutoUpdate -Value 1
|
||||
Write-Host "Disabled Windows Update"
|
||||
} else {
|
||||
Write-Host "Windows Update key does not exist"
|
||||
}
|
||||
}
|
||||
|
||||
# Enable $ErrorActionPreference='Stop' for AllUsersAllHosts
|
||||
Add-Content -Path $profile.AllUsersAllHosts -Value '$ErrorActionPreference="Stop"'
|
||||
|
||||
Write-Host "Disable Server Manager on Logon"
|
||||
Get-ScheduledTask -TaskName ServerManager | Disable-ScheduledTask
|
||||
|
||||
Write-Host "Disable 'Allow your PC to be discoverable by other PCs' popup"
|
||||
New-Item -Path HKLM:\System\CurrentControlSet\Control\Network -Name NewNetworkWindowOff -Force
|
||||
|
||||
Write-Host 'Disable Windows Update Medic Service'
|
||||
Set-ItemProperty -Path HKLM:\System\CurrentControlSet\Services\WaaSMedicSvc -Name Start -Value 4 -Force
|
||||
|
||||
Write-Host "Disable Windows Update"
|
||||
Disable-WindowsUpdate
|
||||
|
||||
Write-Host "Disable UAC"
|
||||
Disable-UserAccessControl
|
||||
|
||||
Write-Host "Disable IE Welcome Screen"
|
||||
Disable-InternetExplorerWelcomeScreen
|
||||
|
||||
Write-Host "Disable IE ESC"
|
||||
Disable-InternetExplorerESC
|
||||
|
||||
Write-Host "Setting local execution policy"
|
||||
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine -ErrorAction Continue | Out-Null
|
||||
Get-ExecutionPolicy -List
|
||||
|
||||
Write-Host "Enable long path behavior"
|
||||
# See https://docs.microsoft.com/en-us/windows/desktop/fileio/naming-a-file#maximum-path-length-limitation
|
||||
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
|
||||
|
||||
# Expand disk size of OS drive
|
||||
$driveLetter = "C"
|
||||
$size = Get-PartitionSupportedSize -DriveLetter $driveLetter
|
||||
Resize-Partition -DriveLetter $driveLetter -Size $size.SizeMax
|
||||
Get-Volume | Select-Object DriveLetter, SizeRemaining, Size | Sort-Object DriveLetter
|
||||
30
images/windows/scripts/build/Install-AWS.ps1
Normal file
30
images/windows/scripts/build/Install-AWS.ps1
Normal file
@@ -0,0 +1,30 @@
|
||||
################################################################################
|
||||
## File: Install-AWS.ps1
|
||||
## Desc: Install AWS tools(AWS CLI, Session Manager Plugin for the AWS CLI, AWS SAM CLI)
|
||||
## Supply chain security: AWS CLI - managed by package manager, Session Manager Plugin for the AWS CLI - missing, AWS SAM CLI - checksum validation
|
||||
################################################################################
|
||||
|
||||
# Install AWS CLI
|
||||
Choco-Install -PackageName awscli
|
||||
|
||||
# Install Session Manager Plugin for the AWS CLI
|
||||
$sessionManagerName = "SessionManagerPluginSetup.exe"
|
||||
$sessionManagerUrl = "https://s3.amazonaws.com/session-manager-downloads/plugin/latest/windows/$sessionManagerName"
|
||||
$sessionManagerSignatureThumbprint = "FF457E5732E98A9F156E657F8CC7C4432507C3BB"
|
||||
Install-Binary -Url $sessionManagerUrl -Name $sessionManagerName -ArgumentList ("/silent", "/install") -ExpectedSignature $sessionManagerSignatureThumbprint
|
||||
$env:Path = $env:Path + ";$env:ProgramFiles\Amazon\SessionManagerPlugin\bin"
|
||||
|
||||
# Install AWS SAM CLI
|
||||
$packageName = "AWS_SAM_CLI_64_PY3.msi"
|
||||
$packageUrl = "https://github.com/awslabs/aws-sam-cli/releases/latest/download/$packageName"
|
||||
$packagePath = Start-DownloadWithRetry -Url $packageUrl -Name $packageName
|
||||
|
||||
#region Supply chain security - AWS SAM CLI
|
||||
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||
$externalHash = Get-HashFromGitHubReleaseBody -RepoOwner "awslabs" -RepoName "aws-sam-cli" -FileName $packageName
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
Install-Binary -FilePath $packagePath
|
||||
|
||||
Invoke-PesterTests -TestFile "CLI.Tools" -TestName "AWS"
|
||||
21
images/windows/scripts/build/Install-ActionArchiveCache.ps1
Normal file
21
images/windows/scripts/build/Install-ActionArchiveCache.ps1
Normal file
@@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
## File: Install-ActionArchiveCache.ps1
|
||||
## Desc: Download latest release from https://github.com/actions/action-versions
|
||||
## and un-zip to C:\actionarchivecache
|
||||
## Maintainer: #actions-runtime and @TingluoHuang
|
||||
################################################################################
|
||||
|
||||
if (-not (Test-Path $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE))
|
||||
{
|
||||
Write-Host "Creating action archive cache folder"
|
||||
New-Item -ItemType Directory -Path $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE | Out-Null
|
||||
}
|
||||
|
||||
$downloadUrl = Get-GitHubPackageDownloadUrl -RepoOwner "actions" -RepoName "action-versions" -Version "latest" -UrlFilter "*/v{Version}/action-versions.zip"
|
||||
Write-Host "Download Latest action-versions archive from $downloadUrl"
|
||||
$actionVersionsArchivePath = Start-DownloadWithRetry -Url $downloadUrl -Name "action-versions.zip"
|
||||
|
||||
Write-Host "Expand action-versions archive"
|
||||
Extract-7Zip -Path $actionVersionsArchivePath -DestinationPath $env:ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE
|
||||
|
||||
Invoke-PesterTests -TestFile "ActionArchiveCache"
|
||||
29
images/windows/scripts/build/Install-AliyunCli.ps1
Normal file
29
images/windows/scripts/build/Install-AliyunCli.ps1
Normal file
@@ -0,0 +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"
|
||||
138
images/windows/scripts/build/Install-AndroidSDK.ps1
Normal file
138
images/windows/scripts/build/Install-AndroidSDK.ps1
Normal file
@@ -0,0 +1,138 @@
|
||||
################################################################################
|
||||
## File: Install-AndroidSDK.ps1
|
||||
## Desc: Install and update Android SDK and tools
|
||||
## Supply chain security: checksum validation
|
||||
################################################################################
|
||||
|
||||
# get packages to install from the toolset
|
||||
$androidToolset = (Get-ToolsetContent).android
|
||||
# Newer version(s) require Java 11 by default
|
||||
# See https://github.com/actions/runner-images/issues/6960
|
||||
$cmdlineToolsUrl = $androidToolset.commandline_tools_url
|
||||
$cmdlineToolsArchPath = Start-DownloadWithRetry -Url $cmdlineToolsUrl -Name "cmdline-tools.zip"
|
||||
|
||||
#region Supply chain security
|
||||
$localFileHash = (Get-FileHash -Path $cmdlineToolsArchPath -Algorithm SHA256).Hash
|
||||
|
||||
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $androidToolset.hash
|
||||
#endregion
|
||||
|
||||
$sdkInstallRoot = "C:\Program Files (x86)\Android\android-sdk"
|
||||
$sdkRoot = "C:\Android\android-sdk"
|
||||
Extract-7Zip -Path $cmdlineToolsArchPath -DestinationPath "${sdkInstallRoot}\cmdline-tools"
|
||||
|
||||
# cmdline tools should be installed in ${sdkInstallRoot}\cmdline-tools\latest\bin, but archive contains ${sdkInstallRoot}\cmdline-tools\bin
|
||||
# we need to create the proper folder structure
|
||||
Invoke-SBWithRetry -Command {
|
||||
Rename-Item "${sdkInstallRoot}\cmdline-tools\cmdline-tools" "latest" -ErrorAction Stop
|
||||
}
|
||||
|
||||
# ANDROID_NDK_PATH/HOME should not contain spaces. Otherwise, the script ndk-build.cmd gives an error https://github.com/actions/runner-images/issues/1122
|
||||
# create "C:\Android" directory and a hardlink inside pointed to sdk in Program Files
|
||||
New-Item -Path "C:\Android" -ItemType Directory
|
||||
New-Item -Path "$sdkRoot" -ItemType SymbolicLink -Value "$sdkInstallRoot"
|
||||
$sdkManager = "$sdkRoot\cmdline-tools\latest\bin\sdkmanager.bat"
|
||||
|
||||
# Install the standard Android SDK licenses. Currently, there isn't a better way to do this,
|
||||
# so we are base64-encoded a zip of the licenses directory from another installation.
|
||||
# To create this base64 string, create a zip file that contains nothing but a 'licenses' folder,
|
||||
# which folder contains the accepted license files found in 'C:\Program Files (x86)\Android\android-sdk\licenses'.
|
||||
# Then, run this in PowerShell:
|
||||
# $LicensesZipFileName = 'C:\Program Files (x86)\Android\android-sdk\Licenses.zip'
|
||||
# $base64Content = [Convert]::ToBase64String([IO.File]::ReadAllBytes($LicensesZipFileName))
|
||||
# echo $base64Content
|
||||
# Another possible solution that works in powershell core:
|
||||
# Write-Ouptut "y" | $sdkManager <packagename>
|
||||
$licenseContentBase64 = "UEsDBBQAAAAAAKNK11IAAAAAAAAAAAAAAAAJAAAAbGljZW5zZXMvUEsDBAoAAAAAAJ1K11K7n0IrKgAAACoAAAAhAAAAbGljZW5zZXMvYW5kcm9pZC1nb29nbGV0di1saWNlbnNlDQo2MDEwODViOTRjZDc3ZjBiNTRmZjg2NDA2OTU3MDk5ZWJlNzljNGQ2UEsDBAoAAAAAAKBK11LzQumJKgAAACoAAAAkAAAAbGljZW5zZXMvYW5kcm9pZC1zZGstYXJtLWRidC1saWNlbnNlDQo4NTlmMzE3Njk2ZjY3ZWYzZDdmMzBhNTBhNTU2MGU3ODM0YjQzOTAzUEsDBAoAAAAAAKFK11IKSOJFKgAAACoAAAAcAAAAbGljZW5zZXMvYW5kcm9pZC1zZGstbGljZW5zZQ0KMjQzMzNmOGE2M2I2ODI1ZWE5YzU1MTRmODNjMjgyOWIwMDRkMWZlZVBLAwQKAAAAAACiStdSec1a4SoAAAAqAAAAJAAAAGxpY2Vuc2VzL2FuZHJvaWQtc2RrLXByZXZpZXctbGljZW5zZQ0KODQ4MzFiOTQwOTY0NmE5MThlMzA1NzNiYWI0YzljOTEzNDZkOGFiZFBLAwQKAAAAAACiStdSk6vQKCoAAAAqAAAAGwAAAGxpY2Vuc2VzL2dvb2dsZS1nZGstbGljZW5zZQ0KMzNiNmEyYjY0NjA3ZjExYjc1OWYzMjBlZjlkZmY0YWU1YzQ3ZDk3YVBLAwQKAAAAAACiStdSrE3jESoAAAAqAAAAJAAAAGxpY2Vuc2VzL2ludGVsLWFuZHJvaWQtZXh0cmEtbGljZW5zZQ0KZDk3NWY3NTE2OThhNzdiNjYyZjEyNTRkZGJlZWQzOTAxZTk3NmY1YVBLAwQKAAAAAACjStdSkb1vWioAAAAqAAAAJgAAAGxpY2Vuc2VzL21pcHMtYW5kcm9pZC1zeXNpbWFnZS1saWNlbnNlDQplOWFjYWI1YjVmYmI1NjBhNzJjZmFlY2NlODk0Njg5NmZmNmFhYjlkUEsBAj8AFAAAAAAAo0rXUgAAAAAAAAAAAAAAAAkAJAAAAAAAAAAQAAAAAAAAAGxpY2Vuc2VzLwoAIAAAAAAAAQAYACIHOBcRaNcBIgc4FxFo1wHBTVQTEWjXAVBLAQI/AAoAAAAAAJ1K11K7n0IrKgAAACoAAAAhACQAAAAAAAAAIAAAACcAAABsaWNlbnNlcy9hbmRyb2lkLWdvb2dsZXR2LWxpY2Vuc2UKACAAAAAAAAEAGACUEFUTEWjXAZQQVRMRaNcB6XRUExFo1wFQSwECPwAKAAAAAACgStdS80LpiSoAAAAqAAAAJAAkAAAAAAAAACAAAACQAAAAbGljZW5zZXMvYW5kcm9pZC1zZGstYXJtLWRidC1saWNlbnNlCgAgAAAAAAABABgAsEM0FBFo1wGwQzQUEWjXAXb1MxQRaNcBUEsBAj8ACgAAAAAAoUrXUgpI4kUqAAAAKgAAABwAJAAAAAAAAAAgAAAA/AAAAGxpY2Vuc2VzL2FuZHJvaWQtc2RrLWxpY2Vuc2UKACAAAAAAAAEAGAAsMGUVEWjXASwwZRURaNcB5whlFRFo1wFQSwECPwAKAAAAAACiStdSec1a4SoAAAAqAAAAJAAkAAAAAAAAACAAAABgAQAAbGljZW5zZXMvYW5kcm9pZC1zZGstcHJldmlldy1saWNlbnNlCgAgAAAAAAABABgA7s3WFRFo1wHuzdYVEWjXAfGm1hURaNcBUEsBAj8ACgAAAAAAokrXUpOr0CgqAAAAKgAAABsAJAAAAAAAAAAgAAAAzAEAAGxpY2Vuc2VzL2dvb2dsZS1nZGstbGljZW5zZQoAIAAAAAAAAQAYAGRDRxYRaNcBZENHFhFo1wFfHEcWEWjXAVBLAQI/AAoAAAAAAKJK11KsTeMRKgAAACoAAAAkACQAAAAAAAAAIAAAAC8CAABsaWNlbnNlcy9pbnRlbC1hbmRyb2lkLWV4dHJhLWxpY2Vuc2UKACAAAAAAAAEAGADGsq0WEWjXAcayrRYRaNcBxrKtFhFo1wFQSwECPwAKAAAAAACjStdSkb1vWioAAAAqAAAAJgAkAAAAAAAAACAAAACbAgAAbGljZW5zZXMvbWlwcy1hbmRyb2lkLXN5c2ltYWdlLWxpY2Vuc2UKACAAAAAAAAEAGAA4LjgXEWjXATguOBcRaNcBIgc4FxFo1wFQSwUGAAAAAAgACACDAwAACQMAAAAA"
|
||||
$licenseContent = [System.Convert]::FromBase64String($licenseContentBase64)
|
||||
Set-Content -Path "$sdkInstallRoot\android-sdk-licenses.zip" -Value $licenseContent -Encoding Byte
|
||||
Extract-7Zip -Path "$sdkInstallRoot\android-sdk-licenses.zip" -DestinationPath $sdkInstallRoot
|
||||
|
||||
# install platform-tools
|
||||
$platformToolsPath = Join-Path -Path $sdkInstallRoot -ChildPath "platform-tools"
|
||||
# Remove outdated platform-tools that was brought by Visual Studio Android package
|
||||
if (Test-Path $platformToolsPath)
|
||||
{
|
||||
Write-Host "Removing previous platform-tools installation from Visual Studio component"
|
||||
Remove-Item $platformToolsPath -Recurse -Force
|
||||
}
|
||||
|
||||
Install-AndroidSDKPackages -AndroidSDKManagerPath $sdkManager `
|
||||
-AndroidSDKRootPath $sdkRoot `
|
||||
-AndroidPackages "platform-tools"
|
||||
|
||||
# get packages info
|
||||
$androidPackages = Get-AndroidPackages -AndroidSDKManagerPath $sdkManager
|
||||
|
||||
# platforms
|
||||
[int]$platformMinVersion = $androidToolset.platform_min_version
|
||||
$platformList = Get-AndroidPackagesByVersion -AndroidPackages $androidPackages `
|
||||
-PrefixPackageName "platforms;" `
|
||||
-MinimumVersion $platformMinVersion `
|
||||
-Delimiter "-" `
|
||||
-Index 1
|
||||
|
||||
# build-tools
|
||||
[version]$buildToolsMinVersion = $androidToolset.build_tools_min_version
|
||||
$buildToolsList = Get-AndroidPackagesByVersion -AndroidPackages $androidPackages `
|
||||
-PrefixPackageName "build-tools;" `
|
||||
-MinimumVersion $buildToolsMinVersion `
|
||||
-Delimiter ";" `
|
||||
-Index 1
|
||||
|
||||
Install-AndroidSDKPackages -AndroidSDKManagerPath $sdkManager `
|
||||
-AndroidSDKRootPath $sdkRoot `
|
||||
-AndroidPackages $platformList
|
||||
|
||||
Install-AndroidSDKPackages -AndroidSDKManagerPath $sdkManager `
|
||||
-AndroidSDKRootPath $sdkRoot `
|
||||
-AndroidPackages $buildToolsList
|
||||
|
||||
Install-AndroidSDKPackages -AndroidSDKManagerPath $sdkManager `
|
||||
-AndroidSDKRootPath $sdkRoot `
|
||||
-AndroidPackages $androidToolset.extra_list `
|
||||
-PrefixPackageName "extras;"
|
||||
|
||||
Install-AndroidSDKPackages -AndroidSDKManagerPath $sdkManager `
|
||||
-AndroidSDKRootPath $sdkRoot `
|
||||
-AndroidPackages $androidToolset.addon_list `
|
||||
-PrefixPackageName "add-ons;"
|
||||
|
||||
Install-AndroidSDKPackages -AndroidSDKManagerPath $sdkManager `
|
||||
-AndroidSDKRootPath $sdkRoot `
|
||||
-AndroidPackages $androidToolset.additional_tools
|
||||
|
||||
# NDKs
|
||||
$ndkMajorVersions = $androidToolset.ndk.versions
|
||||
$ndkDefaultMajorVersion = $androidToolset.ndk.default
|
||||
$ndkLatestMajorVersion = $ndkMajorVersions | Select-Object -Last 1
|
||||
|
||||
$androidNDKs = $ndkMajorVersions | Foreach-Object {
|
||||
Get-AndroidPackagesByName -AndroidPackages $androidPackages -PrefixPackageName "ndk;$_" | Sort-Object -Unique | Select-Object -Last 1
|
||||
}
|
||||
|
||||
Install-AndroidSDKPackages -AndroidSDKManagerPath $sdkManager `
|
||||
-AndroidSDKRootPath $sdkRoot `
|
||||
-AndroidPackages $androidNDKs
|
||||
|
||||
$ndkLatestVersion = ($androidNDKs | Where-Object { $_ -match "ndk;$ndkLatestMajorVersion" }).Split(';')[1]
|
||||
$ndkDefaultVersion = ($androidNDKs | Where-Object { $_ -match "ndk;$ndkDefaultMajorVersion" }).Split(';')[1]
|
||||
$ndkRoot = "$sdkRoot\ndk\$ndkDefaultVersion"
|
||||
|
||||
# Create env variables
|
||||
setx ANDROID_HOME $sdkRoot /M
|
||||
setx ANDROID_SDK_ROOT $sdkRoot /M
|
||||
# ANDROID_NDK, ANDROID_NDK_HOME, and ANDROID_NDK_ROOT variables should be set as many customer builds depend on them https://github.com/actions/runner-images/issues/5879
|
||||
setx ANDROID_NDK $ndkRoot /M
|
||||
setx ANDROID_NDK_HOME $ndkRoot /M
|
||||
setx ANDROID_NDK_ROOT $ndkRoot /M
|
||||
|
||||
$ndkLatestPath = "$sdkRoot\ndk\$ndkLatestVersion"
|
||||
if (Test-Path $ndkLatestPath) {
|
||||
setx ANDROID_NDK_LATEST_HOME $ndkLatestPath /M
|
||||
} else {
|
||||
Write-Host "Latest NDK $ndkLatestVersion is not installed at path $ndkLatestPath"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Invoke-PesterTests -TestFile "Android"
|
||||
21
images/windows/scripts/build/Install-Apache.ps1
Normal file
21
images/windows/scripts/build/Install-Apache.ps1
Normal file
@@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
## File: Install-Apache.ps1
|
||||
## Desc: Install Apache HTTP Server
|
||||
################################################################################
|
||||
|
||||
# Stop w3svc service
|
||||
Stop-Service -Name w3svc | Out-Null
|
||||
|
||||
# Install latest apache in chocolatey
|
||||
$installDir = "C:\tools"
|
||||
Choco-Install -PackageName apache-httpd -ArgumentList "--force", "--params", "/installLocation:$installDir /port:80"
|
||||
|
||||
# Stop and disable Apache service
|
||||
Stop-Service -Name Apache
|
||||
Set-Service Apache -StartupType Disabled
|
||||
|
||||
# Start w3svc service
|
||||
Start-Service -Name w3svc | Out-Null
|
||||
|
||||
# Invoke Pester Tests
|
||||
Invoke-PesterTests -TestFile "Apache"
|
||||
35
images/windows/scripts/build/Install-AzureCli.ps1
Normal file
35
images/windows/scripts/build/Install-AzureCli.ps1
Normal file
@@ -0,0 +1,35 @@
|
||||
################################################################################
|
||||
## File: Install-AzureCli.ps1
|
||||
## Desc: Install Azure CLI
|
||||
################################################################################
|
||||
|
||||
Write-Host 'Install the latest Azure CLI release'
|
||||
|
||||
$azureCliConfigPath = 'C:\azureCli'
|
||||
# Store azure-cli cache outside of the provisioning user's profile
|
||||
[Environment]::SetEnvironmentVariable('AZURE_CONFIG_DIR', $azureCliConfigPath, [System.EnvironmentVariableTarget]::Machine)
|
||||
# make variable to be available in the current session
|
||||
${env:AZURE_CONFIG_DIR} = $azureCliConfigPath
|
||||
|
||||
$azCliUrl = 'https://aka.ms/installazurecliwindowsx64'
|
||||
$azCliSignatureThumbprint = "72105B6D5F370B62FD5C82F1512F7AD7DEE5F2C0"
|
||||
Install-Binary -Url $azCliUrl -Name 'azure-cli.msi' -ExpectedSignature $azCliSignatureThumbprint
|
||||
|
||||
$azureCliExtensionPath = Join-Path $Env:CommonProgramFiles 'AzureCliExtensionDirectory'
|
||||
$null = New-Item -ItemType 'Directory' -Path $azureCliExtensionPath
|
||||
|
||||
[Environment]::SetEnvironmentVariable('AZURE_EXTENSION_DIR', $azureCliExtensionPath, [System.EnvironmentVariableTarget]::Machine)
|
||||
# make variable to be available in the current session
|
||||
${env:AZURE_EXTENSION_DIR} = $azureCliExtensionPath
|
||||
|
||||
# Warm-up Azure CLI
|
||||
|
||||
Write-Host "Warmup 'az'"
|
||||
|
||||
$env:PATH = [Environment]::GetEnvironmentVariable('PATH', 'Machine')
|
||||
az --help | Out-Null
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Command 'az --help' failed"
|
||||
}
|
||||
|
||||
Invoke-PesterTests -TestFile 'CLI.Tools' -TestName 'Azure CLI'
|
||||
@@ -0,0 +1,12 @@
|
||||
####################################################################################
|
||||
## File: Install-AzureCosmosDbEmulator.ps1
|
||||
## Desc: Install Azure CosmosDb Emulator
|
||||
####################################################################################
|
||||
|
||||
$InstallerName = "AzureCosmosDBEmulator.msi"
|
||||
$InstallerUrl = "https://aka.ms/cosmosdb-emulator"
|
||||
$SignatureThumbprint = "F372C27F6E052A6BE8BAB3112B465C692196CD6F"
|
||||
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ExpectedSignature $SignatureThumbprint
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Azure Cosmos DB Emulator"
|
||||
43
images/windows/scripts/build/Install-AzureDevOpsCli.ps1
Normal file
43
images/windows/scripts/build/Install-AzureDevOpsCli.ps1
Normal file
@@ -0,0 +1,43 @@
|
||||
################################################################################
|
||||
## File: Install-AzureDevOpsCli.ps1
|
||||
## Desc: Install Azure DevOps CLI
|
||||
################################################################################
|
||||
|
||||
$azureDevOpsCliConfigPath = 'C:\azureDevOpsCli'
|
||||
# Store azure-devops-cli cache outside of the provisioning user's profile
|
||||
[Environment]::SetEnvironmentVariable('AZURE_DEVOPS_EXT_CONFIG_DIR', $azureDevOpsCliConfigPath, [System.EnvironmentVariableTarget]::Machine)
|
||||
# make variable to be available in the current session
|
||||
${env:AZURE_DEVOPS_EXT_CONFIG_DIR} = $azureDevOpsCliConfigPath
|
||||
|
||||
$azureDevOpsCliCachePath = Join-Path $azureDevOpsCliConfigPath 'cache'
|
||||
$null = New-Item -ItemType 'Directory' -Path $azureDevOpsCliCachePath
|
||||
|
||||
[Environment]::SetEnvironmentVariable('AZURE_DEVOPS_CACHE_DIR', $azureDevOpsCliCachePath, [System.EnvironmentVariableTarget]::Machine)
|
||||
# make variable to be available in the current session
|
||||
${env:AZURE_DEVOPS_CACHE_DIR} = $azureDevOpsCliCachePath
|
||||
|
||||
az extension add -n azure-devops
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
throw "Command 'az extension add -n azure-devops' failed"
|
||||
}
|
||||
|
||||
# Warm-up Azure DevOps CLI
|
||||
|
||||
Write-Host "Warmup 'az-devops'"
|
||||
@('devops', 'pipelines', 'boards', 'repos', 'artifacts') | ForEach-Object {
|
||||
|
||||
az $_ --help
|
||||
if ($LASTEXITCODE -ne 0)
|
||||
{
|
||||
throw "Command 'az $_ --help' failed"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
# calling az devops login to force it to install `keyring`. Login will actually fail, redirecting error to null
|
||||
Write-Output 'fake token' | az devops login | Out-Null
|
||||
# calling az devops logout to be sure no credentials remain.
|
||||
az devops logout | out-null
|
||||
|
||||
Invoke-PesterTests -TestFile 'CLI.Tools' -TestName 'Azure DevOps CLI'
|
||||
53
images/windows/scripts/build/Install-AzureModules.ps1
Normal file
53
images/windows/scripts/build/Install-AzureModules.ps1
Normal file
@@ -0,0 +1,53 @@
|
||||
################################################################################
|
||||
## File: Install-AzureModules.ps1
|
||||
## Desc: PowerShell modules used by AzureFileCopy@4, AzureFileCopy@5, AzurePowerShell@4, AzurePowerShell@5 tasks
|
||||
## Supply chain security: package manager
|
||||
################################################################################
|
||||
|
||||
# The correct Modules need to be saved in C:\Modules
|
||||
$installPSModulePath = "C:\\Modules"
|
||||
if (-not (Test-Path -LiteralPath $installPSModulePath))
|
||||
{
|
||||
Write-Host "Creating ${installPSModulePath} folder to store PowerShell Azure modules..."
|
||||
$null = New-Item -Path $installPSModulePath -ItemType Directory
|
||||
}
|
||||
|
||||
# Get modules content from toolset
|
||||
$modules = (Get-ToolsetContent).azureModules
|
||||
|
||||
$psModuleMachinePath = ""
|
||||
|
||||
foreach ($module in $modules)
|
||||
{
|
||||
$moduleName = $module.name
|
||||
|
||||
Write-Host "Installing ${moduleName} to the ${installPSModulePath} path..."
|
||||
foreach ($version in $module.versions)
|
||||
{
|
||||
$modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}"
|
||||
Write-Host " - $version [$modulePath]"
|
||||
Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop
|
||||
}
|
||||
|
||||
foreach ($version in $module.zip_versions)
|
||||
{
|
||||
$modulePath = Join-Path -Path $installPSModulePath -ChildPath "${moduleName}_${version}"
|
||||
Save-Module -Path $modulePath -Name $moduleName -RequiredVersion $version -Force -ErrorAction Stop
|
||||
Compress-Archive -Path $modulePath -DestinationPath "${modulePath}.zip"
|
||||
Remove-Item $modulePath -Recurse -Force
|
||||
}
|
||||
# Append default tool version to machine path
|
||||
if ($null -ne $module.default)
|
||||
{
|
||||
$defaultVersion = $module.default
|
||||
|
||||
Write-Host "Use ${moduleName} ${defaultVersion} as default version..."
|
||||
$psModuleMachinePath += "${installPSModulePath}\${moduleName}_${defaultVersion};"
|
||||
}
|
||||
}
|
||||
|
||||
# Add modules to the PSModulePath
|
||||
$psModuleMachinePath += $env:PSModulePath
|
||||
[Environment]::SetEnvironmentVariable("PSModulePath", $psModuleMachinePath, "Machine")
|
||||
|
||||
Invoke-PesterTests -TestFile "PowerShellAzModules" -TestName "AzureModules"
|
||||
10
images/windows/scripts/build/Install-Bazel.ps1
Normal file
10
images/windows/scripts/build/Install-Bazel.ps1
Normal file
@@ -0,0 +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
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Bazel"
|
||||
@@ -0,0 +1,88 @@
|
||||
################################################################################
|
||||
## File: Install-BizTalkBuildComponent.ps1
|
||||
## Desc: Install BizTalk Project Build Component
|
||||
################################################################################
|
||||
|
||||
function Install-Msi
|
||||
{
|
||||
<#
|
||||
.SYNOPSIS
|
||||
A helper function to install executables.
|
||||
|
||||
.DESCRIPTION
|
||||
install .exe or .msi binaries from specified Path.
|
||||
|
||||
.PARAMETER MsiPath
|
||||
Msi or exe path. Required parameter.
|
||||
|
||||
.PARAMETER LogPath
|
||||
The log file path where installation will write log to. Required parameter.
|
||||
|
||||
.EXAMPLE
|
||||
Install-Msi -MsiPath "c:\temp\abc.msi" -LogPath "c:\abc.log"
|
||||
#>
|
||||
|
||||
Param
|
||||
(
|
||||
[Parameter(Mandatory)]
|
||||
[String] $MsiPath,
|
||||
[Parameter(Mandatory)]
|
||||
[String] $LogPath
|
||||
)
|
||||
|
||||
try
|
||||
{
|
||||
$filePath = "msiexec.exe"
|
||||
|
||||
Write-Host "Starting Install $MsiPath..."
|
||||
$ArgumentList = ('/i', $MsiPath, '/QN', '/norestart', "/l*v",$LogPath)
|
||||
$process = Start-Process -FilePath $filePath -ArgumentList $ArgumentList -Wait -PassThru -Verb runAs
|
||||
|
||||
$exitCode = $process.ExitCode
|
||||
if ($exitCode -eq 0 -or $exitCode -eq 3010)
|
||||
{
|
||||
Write-Host "Installation for $MsiPath is successful."
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Non zero exit code returned by $MsiPath installation process: $exitCode"
|
||||
Get-Content $LogPath | Write-Host
|
||||
exit $exitCode
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host "Failed to install $MsiPath : $($_.Exception.Message)"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
$bizTalkBuildComponentUri = "https://aka.ms/BuildComponentSetup.EN"
|
||||
|
||||
# Download
|
||||
Write-Host "BizTalk Project Build Component download..."
|
||||
$setupZipFile = Start-DownloadWithRetry -Url $bizTalkBuildComponentUri -Name "BuildComponentSetup.EN.zip"
|
||||
|
||||
# Unzip
|
||||
$setupPath = "C:\BizTalkBuildComponent"
|
||||
if (-not (Test-Path -Path $setupPath)) {
|
||||
$null = New-Item -Path $setupPath -ItemType Directory -Force
|
||||
}
|
||||
|
||||
Write-Host "Unzip $setupZipFile to $setupPath..."
|
||||
Extract-7Zip -Path $setupZipFile -DestinationPath $setupPath
|
||||
Remove-Item $setupZipFile
|
||||
|
||||
# Verify signature
|
||||
$BuildComponentSignatureThumbprint = "8740DF4ACB749640AD318E4BE842F72EC651AD80"
|
||||
Test-FileSignature -FilePath "$setupPath\Bootstrap.msi" -ExpectedThumbprint $BuildComponentSignatureThumbprint
|
||||
Test-FileSignature -FilePath "$setupPath\BuildComponentSetup.msi" -ExpectedThumbprint $BuildComponentSignatureThumbprint
|
||||
|
||||
# Install
|
||||
Install-Msi -MsiPath "$setupPath\Bootstrap.msi" -LogPath "$setupPath\bootstrap.log"
|
||||
Install-Msi -MsiPath "$setupPath\BuildComponentSetup.msi" -LogPath "$setupPath\buildComponentSetup.log"
|
||||
|
||||
Remove-Item $setupPath -Recurse -Force
|
||||
|
||||
# Test
|
||||
Invoke-PesterTests -TestFile "BizTalk" -TestName "BizTalk Build Component Setup"
|
||||
31
images/windows/scripts/build/Install-Choco.ps1
Normal file
31
images/windows/scripts/build/Install-Choco.ps1
Normal file
@@ -0,0 +1,31 @@
|
||||
Write-Host "Set TLS1.2"
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
|
||||
|
||||
Write-Host "Install chocolatey"
|
||||
$chocoExePath = 'C:\ProgramData\Chocolatey\bin'
|
||||
|
||||
# Add to system PATH
|
||||
$systemPath = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::Machine)
|
||||
$systemPath += ';' + $chocoExePath
|
||||
[Environment]::SetEnvironmentVariable("PATH", $systemPath, [System.EnvironmentVariableTarget]::Machine)
|
||||
|
||||
# Update local process' path
|
||||
$userPath = [Environment]::GetEnvironmentVariable('Path', [System.EnvironmentVariableTarget]::User)
|
||||
if ($userPath) {
|
||||
$env:Path = $systemPath + ";" + $userPath
|
||||
} else {
|
||||
$env:Path = $systemPath
|
||||
}
|
||||
|
||||
# Verify and run choco installer
|
||||
$signatureThumbprint = "83AC7D88C66CB8680BCE802E0F0F5C179722764B"
|
||||
$InstallScriptPath = Start-DownloadWithRetry -Url 'https://chocolatey.org/install.ps1'
|
||||
Test-FileSignature -FilePath $InstallScriptPath -ExpectedThumbprint $signatureThumbprint
|
||||
Invoke-Expression $InstallScriptPath
|
||||
|
||||
# Turn off confirmation
|
||||
choco feature enable -n allowGlobalConfirmation
|
||||
|
||||
# Initialize environmental variable ChocolateyToolsLocation by invoking choco Get-ToolsLocation function
|
||||
Import-Module "$env:ChocolateyInstall\helpers\chocolateyInstaller.psm1" -Force
|
||||
Get-ToolsLocation
|
||||
88
images/windows/scripts/build/Install-Chrome.ps1
Normal file
88
images/windows/scripts/build/Install-Chrome.ps1
Normal file
@@ -0,0 +1,88 @@
|
||||
################################################################################
|
||||
## File: Install-Chrome.ps1
|
||||
## Desc: Install Google Chrome
|
||||
################################################################################
|
||||
|
||||
# Download and install latest Chrome browser
|
||||
$ChromeSignatureThumbprint = "2673EA6CC23BEFFDA49AC715B121544098A1284C"
|
||||
$ChromeInstallerFile = "googlechromestandaloneenterprise64.msi"
|
||||
$ChromeInstallerUrl = "https://dl.google.com/tag/s/dl/chrome/install/${ChromeInstallerFile}"
|
||||
Install-Binary -Url $ChromeInstallerUrl -Name $ChromeInstallerFile -ArgumentList @() -ExpectedSignature $ChromeSignatureThumbprint
|
||||
|
||||
# Prepare firewall rules
|
||||
Write-Host "Adding the firewall rule for Google update blocking..."
|
||||
New-NetFirewallRule -DisplayName "BlockGoogleUpdate" -Direction Outbound -Action Block -Program "C:\Program Files (x86)\Google\Update\GoogleUpdate.exe"
|
||||
|
||||
$GoogleSvcs = ('gupdate','gupdatem')
|
||||
$GoogleSvcs | Stop-SvcWithErrHandling -StopOnError
|
||||
$GoogleSvcs | Set-SvcWithErrHandling -Arguments @{StartupType = "Disabled"}
|
||||
|
||||
$regGoogleUpdatePath = "HKLM:\SOFTWARE\Policies\Google\Update"
|
||||
$regGoogleUpdateChrome = "HKLM:\SOFTWARE\Policies\Google\Chrome"
|
||||
($regGoogleUpdatePath, $regGoogleUpdateChrome) | ForEach-Object {
|
||||
New-Item -Path $_ -Force
|
||||
}
|
||||
|
||||
$regGoogleParameters = @(
|
||||
@{ Name = "AutoUpdateCheckPeriodMinutes"; Value = 00000000},
|
||||
@{ Name = "UpdateDefault"; Value = 00000000 },
|
||||
@{ Name = "DisableAutoUpdateChecksCheckboxValue"; Value = 00000001 },
|
||||
@{ Name = "Update{8A69D345-D564-463C-AFF1-A69D9E530F96}"; Value = 00000000 },
|
||||
@{ Path = $regGoogleUpdateChrome; Name = "DefaultBrowserSettingEnabled"; Value = 00000000 }
|
||||
)
|
||||
|
||||
$regGoogleParameters | ForEach-Object {
|
||||
$Arguments = $_
|
||||
if (-not ($Arguments.Path))
|
||||
{
|
||||
$Arguments.Add("Path", $regGoogleUpdatePath)
|
||||
}
|
||||
$Arguments.Add("Force", $true)
|
||||
New-ItemProperty @Arguments
|
||||
}
|
||||
|
||||
# Install Chrome WebDriver
|
||||
Write-Host "Install Chrome WebDriver..."
|
||||
$ChromeDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\ChromeDriver"
|
||||
if (-not (Test-Path -Path $ChromeDriverPath))
|
||||
{
|
||||
New-Item -Path $ChromeDriverPath -ItemType Directory -Force
|
||||
}
|
||||
|
||||
Write-Host "Get the Chrome WebDriver download URL..."
|
||||
$RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
|
||||
$ChromePath = (Get-ItemProperty "$RegistryPath\chrome.exe").'(default)'
|
||||
[version]$ChromeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($ChromePath).ProductVersion
|
||||
$ChromeBuild = "$($ChromeVersion.Major).$($ChromeVersion.Minor).$($ChromeVersion.Build)"
|
||||
$ChromeDriverVersionsUrl = "https://googlechromelabs.github.io/chrome-for-testing/latest-patch-versions-per-build-with-downloads.json"
|
||||
|
||||
Write-Host "Chrome version is $ChromeVersion"
|
||||
$ChromeDriverVersions = Invoke-RestMethod -Uri $ChromeDriverVersionsUrl
|
||||
$ChromeDriverVersion = $ChromeDriverVersions.builds.$ChromeBuild
|
||||
|
||||
if (-not ($ChromeDriverVersion)) {
|
||||
$availableVersions = $ChromeDriverVersions.builds | Get-Member | Select-Object -ExpandProperty Name
|
||||
Write-Host "Available chromedriver builds are $availableVersions"
|
||||
Throw "Can't determine chromedriver version that matches chrome build $ChromeBuild"
|
||||
}
|
||||
|
||||
$ChromeDriverVersion.version | Out-File -FilePath "$ChromeDriverPath\versioninfo.txt" -Force;
|
||||
|
||||
Write-Host "Chrome WebDriver version to install is $($ChromeDriverVersion.version)"
|
||||
$ChromeDriverZipDownloadUrl = ($ChromeDriverVersion.downloads.chromedriver | Where-Object platform -eq "win64").url
|
||||
|
||||
Write-Host "Download Chrome WebDriver from $ChromeDriverZipDownloadUrl..."
|
||||
$ChromeDriverArchPath = Start-DownloadWithRetry -Url $ChromeDriverZipDownloadUrl
|
||||
|
||||
Write-Host "Expand Chrome WebDriver archive (without using directory names)..."
|
||||
Extract-7Zip -Path $ChromeDriverArchPath -DestinationPath $ChromeDriverPath -ExtractMethod "e"
|
||||
|
||||
Write-Host "Setting the environment variables..."
|
||||
setx ChromeWebDriver "$ChromeDriverPath" /M
|
||||
|
||||
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\'
|
||||
$PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path'
|
||||
$PathValue += ";$ChromeDriverPath\"
|
||||
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue
|
||||
|
||||
Invoke-PesterTests -TestFile "Browsers" -TestName "Chrome"
|
||||
27
images/windows/scripts/build/Install-CloudFoundryCli.ps1
Normal file
27
images/windows/scripts/build/Install-CloudFoundryCli.ps1
Normal file
@@ -0,0 +1,27 @@
|
||||
################################################################################
|
||||
## File: Install-CloudFoundryCli.ps1
|
||||
## Desc: Install Cloud Foundry CLI
|
||||
################################################################################
|
||||
|
||||
# Download the latest cf cli exe
|
||||
$CloudFoundryCliName = "cf-cli.zip"
|
||||
$CloudFoundryCliUrl = "https://packages.cloudfoundry.org/stable?release=windows64-exe&source=github"
|
||||
|
||||
$CloudFoundryArchPath = Start-DownloadWithRetry -Url $CloudFoundryCliUrl -Name $CloudFoundryCliName
|
||||
|
||||
# Create directory for cf cli
|
||||
$CloudFoundryCliPath = "C:\cf-cli"
|
||||
New-Item -Path $CloudFoundryCliPath -ItemType Directory -Force
|
||||
|
||||
# Extract the zip archive
|
||||
Write-Host "Extracting cf cli..."
|
||||
Extract-7Zip -Path $CloudFoundryArchPath -DestinationPath $CloudFoundryCliPath
|
||||
|
||||
# Add cf to path
|
||||
Add-MachinePathItem $CloudFoundryCliPath
|
||||
|
||||
# Validate cf signature
|
||||
$CloudFoundrySignatureThumbprint = "4C69EDD13930ED01B83DD1D17B09C434DC1F2177"
|
||||
Test-FileSignature -FilePath "$CloudFoundryCliPath\cf.exe" -ExpectedThumbprint $CloudFoundrySignatureThumbprint
|
||||
|
||||
Invoke-PesterTests -TestFile "CLI.Tools" -TestName "CloudFoundry CLI"
|
||||
36
images/windows/scripts/build/Install-CodeQLBundle.ps1
Normal file
36
images/windows/scripts/build/Install-CodeQLBundle.ps1
Normal file
@@ -0,0 +1,36 @@
|
||||
################################################################################
|
||||
## File: Install-CodeQLBundle.ps1
|
||||
## Desc: Install the CodeQL CLI Bundle to the toolcache.
|
||||
################################################################################
|
||||
|
||||
# Retrieve the CLI version of the latest CodeQL bundle.
|
||||
$Defaults = (Invoke-RestMethod "https://raw.githubusercontent.com/github/codeql-action/v2/src/defaults.json")
|
||||
$CliVersion = $Defaults.cliVersion
|
||||
$TagName = "codeql-bundle-v" + $CliVersion
|
||||
|
||||
Write-Host "Downloading CodeQL bundle $($CliVersion)..."
|
||||
# Note that this is the all-platforms CodeQL bundle, to support scenarios where customers run
|
||||
# different operating systems within containers.
|
||||
$CodeQLBundlePath = Start-DownloadWithRetry -Url "https://github.com/github/codeql-action/releases/download/$($TagName)/codeql-bundle.tar.gz" -Name "codeql-bundle.tar.gz"
|
||||
$DownloadDirectoryPath = (Get-Item $CodeQLBundlePath).Directory.FullName
|
||||
|
||||
$CodeQLToolcachePath = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath $CliVersion | Join-Path -ChildPath "x64"
|
||||
New-Item -Path $CodeQLToolcachePath -ItemType Directory -Force | Out-Null
|
||||
|
||||
Write-Host "Unpacking the downloaded CodeQL bundle archive..."
|
||||
Extract-7Zip -Path $CodeQLBundlePath -DestinationPath $DownloadDirectoryPath
|
||||
$UnGzipedCodeQLBundlePath = Join-Path $DownloadDirectoryPath "codeql-bundle.tar"
|
||||
Extract-7Zip -Path $UnGzipedCodeQLBundlePath -DestinationPath $CodeQLToolcachePath
|
||||
|
||||
Write-Host "CodeQL bundle at $($CodeQLToolcachePath) contains the following directories:"
|
||||
Get-ChildItem -Path $CodeQLToolcachePath -Depth 2
|
||||
|
||||
# Touch a file to indicate to the CodeQL Action that this bundle shipped with the toolcache. This is
|
||||
# to support overriding the CodeQL version specified in defaults.json on GitHub Enterprise.
|
||||
New-Item -ItemType file (Join-Path $CodeQLToolcachePath -ChildPath "pinned-version")
|
||||
|
||||
# Touch a file to indicate to the toolcache that setting up CodeQL is complete.
|
||||
New-Item -ItemType file "$CodeQLToolcachePath.complete"
|
||||
|
||||
# Test that the tools have been extracted successfully.
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "CodeQL Bundle"
|
||||
8
images/windows/scripts/build/Install-CommonUtils.ps1
Normal file
8
images/windows/scripts/build/Install-CommonUtils.ps1
Normal file
@@ -0,0 +1,8 @@
|
||||
$commonPackages = (Get-ToolsetContent).choco.common_packages
|
||||
|
||||
foreach ($package in $commonPackages)
|
||||
{
|
||||
Choco-Install -PackageName $package.name -ArgumentList $package.args
|
||||
}
|
||||
|
||||
Invoke-PesterTests -TestFile "ChocoPackages"
|
||||
12
images/windows/scripts/build/Install-DACFx.ps1
Normal file
12
images/windows/scripts/build/Install-DACFx.ps1
Normal file
@@ -0,0 +1,12 @@
|
||||
####################################################################################
|
||||
## File: Install-DACFx.ps1
|
||||
## Desc: Install SQL Server® Data-Tier Application Framework (DacFx) for Windows
|
||||
####################################################################################
|
||||
|
||||
$InstallerName = "DacFramework.msi"
|
||||
$InstallerUrl = "https://aka.ms/dacfx-msi"
|
||||
$SignatureThumbprint = "72105B6D5F370B62FD5C82F1512F7AD7DEE5F2C0"
|
||||
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ExpectedSignature $SignatureThumbprint
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "DACFx"
|
||||
17
images/windows/scripts/build/Install-Docker-Compose.ps1
Normal file
17
images/windows/scripts/build/Install-Docker-Compose.ps1
Normal file
@@ -0,0 +1,17 @@
|
||||
################################################################################
|
||||
## File: Install-Docker-Compose.ps1
|
||||
## Desc: Install Docker Compose.
|
||||
## Supply chain security: Docker Compose v1 - by package manager
|
||||
################################################################################
|
||||
|
||||
Write-Host "Install-Package Docker-Compose v1"
|
||||
$versionToInstall = Get-LatestChocoPackageVersion -TargetVersion "1.29" -PackageName "docker-compose"
|
||||
Choco-Install -PackageName docker-compose -ArgumentList "--version=$versionToInstall"
|
||||
|
||||
Write-Host "Install-Package Docker-Compose v2"
|
||||
$dockerComposev2Url = "https://github.com/docker/compose/releases/latest/download/docker-compose-windows-x86_64.exe"
|
||||
$cliPluginsDir = "C:\ProgramData\docker\cli-plugins"
|
||||
New-Item -Path $cliPluginsDir -ItemType Directory
|
||||
Start-DownloadWithRetry -Url $dockerComposev2Url -Name docker-compose.exe -DownloadPath $cliPluginsDir
|
||||
|
||||
Invoke-PesterTests -TestFile "Docker" -TestName "DockerCompose"
|
||||
35
images/windows/scripts/build/Install-Docker-WinCred.ps1
Normal file
35
images/windows/scripts/build/Install-Docker-WinCred.ps1
Normal file
@@ -0,0 +1,35 @@
|
||||
################################################################################
|
||||
## File: Install-Docker-WinCred.ps1
|
||||
## Desc: Install Docker credential helper.
|
||||
## Supply chain security: checksum validation
|
||||
################################################################################
|
||||
|
||||
#region functions
|
||||
function Get-DockerWincredHash {
|
||||
Param (
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $Release
|
||||
)
|
||||
|
||||
$hashURL = "https://github.com/docker/docker-credential-helpers/releases/download/${Release}/checksums.txt"
|
||||
(Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*docker-credential-wincred-${Release}.windows-amd64.exe*" }).Split(' ')[0]
|
||||
}
|
||||
#endregion
|
||||
|
||||
Write-Host "Install docker-wincred"
|
||||
$dockerCredLatestRelease = Invoke-RestMethod -Uri "https://api.github.com/repos/docker/docker-credential-helpers/releases/latest"
|
||||
$dockerCredDownloadUrl = $dockerCredLatestRelease.assets.browser_download_url -match "docker-credential-wincred-.+\.exe" | Select-Object -First 1
|
||||
Start-DownloadWithRetry -Url $dockerCredDownloadUrl -DownloadPath "C:\Windows\System32" -Name "docker-credential-wincred.exe"
|
||||
|
||||
#region Supply chain security
|
||||
$distributor_file_hash = Get-DockerWincredHash -Release $dockerCredLatestRelease.name
|
||||
$local_file_hash = (Get-FileHash -Path 'C:\Windows\System32\docker-credential-wincred.exe' -Algorithm SHA256).Hash
|
||||
|
||||
if ($local_file_hash -ne $distributor_file_hash) {
|
||||
Write-Host "hash must be equal to: ${distributor_file_hash}"
|
||||
Write-Host "actual hash is: ${local_file_hash}"
|
||||
throw 'Checksum verification failed, please rerun install'
|
||||
}
|
||||
#endregion
|
||||
|
||||
Invoke-PesterTests -TestFile "Docker" -TestName "DockerWinCred"
|
||||
56
images/windows/scripts/build/Install-Docker.ps1
Normal file
56
images/windows/scripts/build/Install-Docker.ps1
Normal file
@@ -0,0 +1,56 @@
|
||||
################################################################################
|
||||
## File: Install-Docker.ps1
|
||||
## Desc: Install Docker.
|
||||
## Must be an independent step because it requires a restart before we
|
||||
## can continue.
|
||||
################################################################################
|
||||
|
||||
Write-Host "Get latest Moby release"
|
||||
$mobyLatestReleaseVersion = (Invoke-RestMethod -Uri "https://api.github.com/repos/moby/moby/releases/latest").tag_name.Trim("v")
|
||||
$dockerceUrl = "https://download.docker.com/win/static/stable/x86_64/"
|
||||
$dockerceBinaries = Invoke-WebRequest -Uri $dockerceUrl -UseBasicParsing
|
||||
|
||||
Write-Host "Check Moby version $mobyLatestReleaseVersion"
|
||||
$mobyRelease = $dockerceBinaries.Links.href -match "${mobyLatestReleaseVersion}\.zip" | Select-Object -Last 1
|
||||
if (-not $mobyRelease) {
|
||||
Write-Host "Release not found for $mobyLatestRelease version"
|
||||
$versions = [regex]::Matches($dockerceBinaries.Links.href, "docker-(\d+\.\d+\.\d+)\.zip") | Sort-Object { [version]$_.Groups[1].Value }
|
||||
$mobyRelease = $versions | Select-Object -ExpandProperty Value -Last 1
|
||||
Write-Host "Found $mobyRelease"
|
||||
}
|
||||
$mobyReleaseUrl = $dockerceUrl + $mobyRelease
|
||||
|
||||
Write-Host "Install Moby $mobyRelease..."
|
||||
$mobyArchivePath = Start-DownloadWithRetry -Url $mobyReleaseUrl -Name $mobyRelease
|
||||
Expand-Archive -Path $mobyArchivePath -DestinationPath $env:TEMP
|
||||
$dockerPath = "$env:TEMP\docker\docker.exe"
|
||||
$dockerdPath = "$env:TEMP\docker\dockerd.exe"
|
||||
|
||||
Write-Host "Install Docker CE"
|
||||
$instScriptUrl = "https://raw.githubusercontent.com/microsoft/Windows-Containers/Main/helpful_tools/Install-DockerCE/install-docker-ce.ps1"
|
||||
$instScriptPath = Start-DownloadWithRetry -Url $instScriptUrl -Name "install-docker-ce.ps1"
|
||||
& $instScriptPath -DockerPath $dockerPath -DockerDPath $dockerdPath
|
||||
if ($LastExitCode -ne 0) {
|
||||
Write-Host "Docker installation failed with exit code $LastExitCode"
|
||||
exit $exitCode
|
||||
}
|
||||
|
||||
# Fix AZ CLI DOCKER_COMMAND_ERROR
|
||||
# cli.azure.cli.command_modules.acr.custom: Could not run 'docker.exe' command.
|
||||
# https://github.com/Azure/azure-cli/issues/18766
|
||||
New-Item -ItemType SymbolicLink -Path "C:\Windows\SysWOW64\docker.exe" -Target "C:\Windows\System32\docker.exe"
|
||||
|
||||
Write-Host "Download docker images"
|
||||
$dockerImages = (Get-ToolsetContent).docker.images
|
||||
foreach ($dockerImage in $dockerImages) {
|
||||
Write-Host "Pulling docker image $dockerImage ..."
|
||||
docker pull $dockerImage
|
||||
|
||||
if (!$?) {
|
||||
Write-Host "Docker pull failed with a non-zero exit code"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Invoke-PesterTests -TestFile "Docker" -TestName "Docker"
|
||||
Invoke-PesterTests -TestFile "Docker" -TestName "DockerImages"
|
||||
141
images/windows/scripts/build/Install-DotnetSDK.ps1
Normal file
141
images/windows/scripts/build/Install-DotnetSDK.ps1
Normal file
@@ -0,0 +1,141 @@
|
||||
################################################################################
|
||||
## File: Install-DotnetSDK.ps1
|
||||
## Desc: Install all released versions of the dotnet sdk and populate package
|
||||
## cache. Should run after VS and Node
|
||||
## Supply chain security: checksum validation
|
||||
################################################################################
|
||||
|
||||
# Set environment variables
|
||||
Set-SystemVariable -SystemVariable DOTNET_MULTILEVEL_LOOKUP -Value "0"
|
||||
Set-SystemVariable -SystemVariable DOTNET_NOLOGO -Value "1"
|
||||
Set-SystemVariable -SystemVariable DOTNET_SKIP_FIRST_TIME_EXPERIENCE -Value "1"
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
|
||||
|
||||
#region "Functions"
|
||||
function Get-SDKVersionsToInstall (
|
||||
$DotnetVersion
|
||||
) {
|
||||
$releaseJson = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${DotnetVersion}/releases.json"
|
||||
$releasesJsonPath = Start-DownloadWithRetry -Url $releaseJson -Name "releases-${DotnetVersion}.json"
|
||||
$currentReleases = Get-Content -Path $releasesJsonPath | ConvertFrom-Json
|
||||
# filtering out the preview/rc releases
|
||||
$currentReleases = $currentReleases.'releases' | Where-Object { !$_.'release-version'.Contains('-') }
|
||||
|
||||
$sdks = @()
|
||||
ForEach ($release in $currentReleases)
|
||||
{
|
||||
$sdks += $release.'sdk'
|
||||
$sdks += $release.'sdks'
|
||||
}
|
||||
|
||||
return $sdks.version | Sort-Object { [Version] $_ } -Unique `
|
||||
| Group-Object { $_.Substring(0, $_.LastIndexOf('.') + 2) } `
|
||||
| Foreach-Object { $_.Group[-1] }
|
||||
}
|
||||
|
||||
function Invoke-Warmup (
|
||||
$SdkVersion
|
||||
) {
|
||||
# warm up dotnet for first time experience
|
||||
$projectTypes = @('console', 'mstest', 'web', 'mvc', 'webapi')
|
||||
$projectTypes | ForEach-Object {
|
||||
$template = $_
|
||||
$projectPath = Join-Path -Path C:\temp -ChildPath $template
|
||||
New-Item -Path $projectPath -Force -ItemType Directory
|
||||
Push-Location -Path $projectPath
|
||||
& $env:ProgramFiles\dotnet\dotnet.exe new globaljson --sdk-version "$sdkVersion"
|
||||
& $env:ProgramFiles\dotnet\dotnet.exe new $template
|
||||
Pop-Location
|
||||
Remove-Item $projectPath -Force -Recurse
|
||||
}
|
||||
}
|
||||
|
||||
function InstallSDKVersion (
|
||||
$SdkVersion,
|
||||
$dotnetVersion,
|
||||
$Warmup
|
||||
)
|
||||
{
|
||||
if (!(Test-Path -Path "C:\Program Files\dotnet\sdk\$sdkVersion"))
|
||||
{
|
||||
Write-Host "Installing dotnet $sdkVersion"
|
||||
$ZipPath = [System.IO.Path]::combine([System.IO.Path]::GetTempPath(), [System.IO.Path]::GetRandomFileName())
|
||||
.\dotnet-install.ps1 -Version $sdkVersion -InstallDir $(Join-Path -Path $env:ProgramFiles -ChildPath 'dotnet') -ZipPath $ZipPath -KeepZip
|
||||
|
||||
#region Supply chain security
|
||||
$distributorFileHash = (Invoke-RestMethod -Uri "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/$dotnetVersion/releases.json").releases.sdks.Where({$_.version -eq $SdkVersion}).files.Where({ $_.name -eq 'dotnet-sdk-win-x64.zip'}).hash
|
||||
$localFileHash = (Get-FileHash -Path $ZipPath -Algorithm 'SHA512').Hash
|
||||
|
||||
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
|
||||
#endregion
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Sdk version $sdkVersion already installed"
|
||||
}
|
||||
|
||||
if ($Warmup) {
|
||||
Invoke-Warmup -SdkVersion $SdkVersion
|
||||
}
|
||||
}
|
||||
|
||||
function InstallAllValidSdks()
|
||||
{
|
||||
# Consider all channels except preview/eol channels.
|
||||
# Sort the channels in ascending order
|
||||
$dotnetToolset = (Get-ToolsetContent).dotnet
|
||||
$dotnetVersions = $dotnetToolset.versions
|
||||
$warmup = $dotnetToolset.warmup
|
||||
|
||||
# Download installation script.
|
||||
$installationName = "dotnet-install.ps1"
|
||||
$installationUrl = "https://dot.net/v1/${installationName}"
|
||||
Start-DownloadWithRetry -Url $installationUrl -Name $installationName -DownloadPath ".\"
|
||||
|
||||
ForEach ($dotnetVersion in $dotnetVersions)
|
||||
{
|
||||
$sdkVersionsToInstall = Get-SDKVersionsToInstall -DotnetVersion $dotnetVersion
|
||||
|
||||
ForEach ($sdkVersion in $sdkVersionsToInstall)
|
||||
{
|
||||
InstallSDKVersion -SdkVersion $sdkVersion -DotnetVersion $dotnetVersion -Warmup $warmup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function InstallTools()
|
||||
{
|
||||
$dotnetTools = (Get-ToolsetContent).dotnet.tools
|
||||
|
||||
ForEach ($dotnetTool in $dotnetTools)
|
||||
{
|
||||
dotnet tool install $($dotnetTool.name) --tool-path "C:\Users\Default\.dotnet\tools" --add-source https://api.nuget.org/v3/index.json | Out-Null
|
||||
}
|
||||
}
|
||||
|
||||
function RunPostInstallationSteps()
|
||||
{
|
||||
# Add dotnet to PATH
|
||||
Add-MachinePathItem "C:\Program Files\dotnet"
|
||||
|
||||
# Remove NuGet Folder
|
||||
$nugetPath = "$env:APPDATA\NuGet"
|
||||
if (Test-Path $nugetPath) {
|
||||
Remove-Item -Path $nugetPath -Force -Recurse
|
||||
}
|
||||
|
||||
# Generate and copy new NuGet.Config config
|
||||
dotnet nuget list source | Out-Null
|
||||
Copy-Item -Path $nugetPath -Destination C:\Users\Default\AppData\Roaming -Force -Recurse
|
||||
|
||||
# Add %USERPROFILE%\.dotnet\tools to USER PATH
|
||||
Add-DefaultPathItem "%USERPROFILE%\.dotnet\tools"
|
||||
}
|
||||
#endregion
|
||||
|
||||
InstallAllValidSdks
|
||||
RunPostInstallationSteps
|
||||
InstallTools
|
||||
|
||||
Invoke-PesterTests -TestFile "DotnetSDK"
|
||||
49
images/windows/scripts/build/Install-Edge.ps1
Normal file
49
images/windows/scripts/build/Install-Edge.ps1
Normal file
@@ -0,0 +1,49 @@
|
||||
################################################################################
|
||||
## File: Install-Edge.ps1
|
||||
## Desc: Configure Edge browser and install Edge WebDriver
|
||||
################################################################################
|
||||
|
||||
# Disable Edge auto-updates
|
||||
Rename-Item -Path "C:\Program Files (x86)\Microsoft\EdgeUpdate\MicrosoftEdgeUpdate.exe" -NewName "Disabled_MicrosoftEdgeUpdate.exe" -ErrorAction Stop
|
||||
|
||||
# Install Microsoft Edge WebDriver
|
||||
Write-Host "Install Edge WebDriver..."
|
||||
$EdgeDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\EdgeDriver"
|
||||
if (-not (Test-Path -Path $EdgeDriverPath))
|
||||
{
|
||||
New-Item -Path $EdgeDriverPath -ItemType Directory -Force
|
||||
}
|
||||
|
||||
Write-Host "Get the Microsoft Edge WebDriver version..."
|
||||
$RegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"
|
||||
$EdgePath = (Get-ItemProperty "$RegistryPath\msedge.exe").'(default)'
|
||||
[version]$EdgeVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo($EdgePath).ProductVersion
|
||||
$EdgeDriverVersionUrl = "https://msedgedriver.azureedge.net/LATEST_RELEASE_$($EdgeVersion.Major)_WINDOWS"
|
||||
|
||||
$EdgeDriverVersionFile = Start-DownloadWithRetry -Url $EdgeDriverVersionUrl -Name "versioninfo.txt" -DownloadPath $EdgeDriverPath
|
||||
|
||||
Write-Host "Download Microsoft Edge WebDriver..."
|
||||
$EdgeDriverLatestVersion = Get-Content -Path $EdgeDriverVersionFile
|
||||
$EdgeDriverArchName = "edgedriver_win64.zip"
|
||||
|
||||
|
||||
$EdgeDriverDownloadUrl = "https://msedgedriver.azureedge.net/${EdgeDriverLatestVersion}/${EdgeDriverArchName}"
|
||||
|
||||
$EdgeDriverArchPath = Start-DownloadWithRetry -Url $EdgeDriverDownloadUrl -Name $EdgeDriverArchName
|
||||
|
||||
Write-Host "Expand Microsoft Edge WebDriver archive..."
|
||||
Extract-7Zip -Path $EdgeDriverArchPath -DestinationPath $EdgeDriverPath
|
||||
|
||||
#Validate the EdgeDriver signature
|
||||
$EdgeDriverSignatureThumbprint = ("7C94971221A799907BB45665663BBFD587BAC9F8", "70E52D50651BB9E8DC08DE566C4DD5713833B038")
|
||||
Test-FileSignature -FilePath "$EdgeDriverPath\msedgedriver.exe" -ExpectedThumbprint $EdgeDriverSignatureThumbprint
|
||||
|
||||
Write-Host "Setting the environment variables..."
|
||||
setx EdgeWebDriver "$EdgeDriverPath" /M
|
||||
|
||||
$regEnvKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\'
|
||||
$PathValue = Get-ItemPropertyValue -Path $regEnvKey -Name 'Path'
|
||||
$PathValue += ";$EdgeDriverPath\"
|
||||
Set-ItemProperty -Path $regEnvKey -Name 'Path' -Value $PathValue
|
||||
|
||||
Invoke-PesterTests -TestFile "Browsers" -TestName "Edge"
|
||||
63
images/windows/scripts/build/Install-Firefox.ps1
Normal file
63
images/windows/scripts/build/Install-Firefox.ps1
Normal file
@@ -0,0 +1,63 @@
|
||||
################################################################################
|
||||
## File: Install-Firefox.ps1
|
||||
## Desc: Install Mozilla Firefox
|
||||
## Supply chain security: Firefox browser - checksum validation
|
||||
################################################################################
|
||||
|
||||
# Install and configure Firefox browser
|
||||
Write-Host "Install latest Firefox browser..."
|
||||
$VersionsManifest = Invoke-RestMethod "https://product-details.mozilla.org/1.0/firefox_versions.json"
|
||||
$InstallerUrl = "https://download.mozilla.org/?product=firefox-$($VersionsManifest.LATEST_FIREFOX_VERSION)&os=win64&lang=en-US"
|
||||
$packagePath = Start-DownloadWithRetry -Url $InstallerUrl -Name "FirefoxSetup.exe"
|
||||
|
||||
#region Supply chain security - Stack
|
||||
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||
$hashUrl = "https://archive.mozilla.org/pub/firefox/releases/$($VersionsManifest.LATEST_FIREFOX_VERSION)/SHA256SUMS"
|
||||
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*win64/en-US/Firefox Setup*exe*" }).Split(' ')[0]
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
Install-Binary -FilePath $packagePath -ArgumentList "/silent", "/install"
|
||||
|
||||
Write-Host "Disable autoupdate..."
|
||||
$FirefoxDirectoryPath = Join-Path $env:ProgramFiles "Mozilla Firefox"
|
||||
New-Item -path $FirefoxDirectoryPath -Name 'mozilla.cfg' -Value '//
|
||||
pref("browser.shell.checkDefaultBrowser", false);
|
||||
pref("app.update.enabled", false);' -ItemType file -force
|
||||
|
||||
$FirefoxPreferencesFolder = Join-Path $FirefoxDirectoryPath "defaults\pref"
|
||||
New-Item -path $FirefoxPreferencesFolder -Name 'local-settings.js' -Value 'pref("general.config.obscure_value", 0);
|
||||
pref("general.config.filename", "mozilla.cfg");' -ItemType file -force
|
||||
|
||||
# Download and install Gecko WebDriver
|
||||
Write-Host "Install Gecko WebDriver..."
|
||||
$GeckoDriverPath = "$($env:SystemDrive)\SeleniumWebDrivers\GeckoDriver"
|
||||
if (-not (Test-Path -Path $GeckoDriverPath))
|
||||
{
|
||||
New-Item -Path $GeckoDriverPath -ItemType Directory -Force
|
||||
}
|
||||
|
||||
Write-Host "Get the Gecko WebDriver version..."
|
||||
$GeckoDriverJson = Invoke-RestMethod "https://api.github.com/repos/mozilla/geckodriver/releases/latest"
|
||||
$GeckoDriverWindowsAsset = $GeckoDriverJson.assets | Where-Object { $_.name -Match "win64" } | Select-Object -First 1
|
||||
$GeckoDriverVersion = $GeckoDriverJson.tag_name
|
||||
$GeckoDriverVersion.Substring(1) | Out-File -FilePath "$GeckoDriverPath\versioninfo.txt" -Force;
|
||||
|
||||
Write-Host "Download Gecko WebDriver WebDriver..."
|
||||
$GeckoDriverArchName = $GeckoDriverWindowsAsset.name
|
||||
$GeckoDriverDownloadUrl = $GeckoDriverWindowsAsset.browser_download_url
|
||||
|
||||
$GeckoDriverArchPath = Start-DownloadWithRetry -Url $GeckoDriverDownloadUrl -Name $GeckoDriverArchName
|
||||
|
||||
Write-Host "Expand Gecko WebDriver archive..."
|
||||
Extract-7Zip -Path $GeckoDriverArchPath -DestinationPath $GeckoDriverPath
|
||||
|
||||
# Validate Gecko WebDriver signature
|
||||
$GeckoDriverSignatureThumbprint = "1326B39C3D5D2CA012F66FB439026F7B59CB1974"
|
||||
Test-FileSignature -FilePath "$GeckoDriverPath/geckodriver.exe" -ExpectedThumbprint $GeckoDriverSignatureThumbprint
|
||||
|
||||
Write-Host "Setting the environment variables..."
|
||||
Add-MachinePathItem -PathItem $GeckoDriverPath
|
||||
setx GeckoWebDriver "$GeckoDriverPath" /M
|
||||
|
||||
Invoke-PesterTests -TestFile "Browsers" -TestName "Firefox"
|
||||
48
images/windows/scripts/build/Install-Git.ps1
Normal file
48
images/windows/scripts/build/Install-Git.ps1
Normal file
@@ -0,0 +1,48 @@
|
||||
################################################################################
|
||||
## File: Install-Git.ps1
|
||||
## Desc: Install Git for Windows
|
||||
## Supply chain security: Git - checksum validation, Hub CLI - managed by package manager
|
||||
################################################################################
|
||||
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
||||
|
||||
# Install the latest version of Git for Windows
|
||||
$repoURL = "https://api.github.com/repos/git-for-windows/git/releases/latest"
|
||||
$gitReleases = Invoke-RestMethod $repoURL
|
||||
[string]$downloadUrl = $gitReleases.assets.browser_download_url -match "Git-.+-64-bit.exe"
|
||||
$installerFile = Split-Path $downloadUrl -Leaf
|
||||
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name $installerFile
|
||||
|
||||
#region Supply chain security - Git
|
||||
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||
$externalHash = Get-HashFromGitHubReleaseBody -Url $RepoURL -FileName $installerFile
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
Install-Binary -FilePath $packagePath `
|
||||
-ArgumentList (
|
||||
"/VERYSILENT", `
|
||||
"/NORESTART", `
|
||||
"/NOCANCEL", `
|
||||
"/SP-", `
|
||||
"/CLOSEAPPLICATIONS", `
|
||||
"/RESTARTAPPLICATIONS", `
|
||||
"/o:PathOption=CmdTools", `
|
||||
"/o:BashTerminalOption=ConHost", `
|
||||
"/o:EnableSymlinks=Enabled", `
|
||||
"/COMPONENTS=gitlfs")
|
||||
|
||||
Update-SessionEnvironment
|
||||
|
||||
git config --system --add safe.directory "*"
|
||||
|
||||
# Disable GCM machine-wide
|
||||
[Environment]::SetEnvironmentVariable("GCM_INTERACTIVE", "Never", [System.EnvironmentVariableTarget]::Machine)
|
||||
|
||||
# Add to PATH
|
||||
Add-MachinePathItem "C:\Program Files\Git\bin"
|
||||
|
||||
# Add well-known SSH host keys to ssh_known_hosts
|
||||
ssh-keyscan -t rsa,ecdsa,ed25519 github.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts"
|
||||
ssh-keyscan -t rsa ssh.dev.azure.com >> "C:\Program Files\Git\etc\ssh\ssh_known_hosts"
|
||||
|
||||
Invoke-PesterTests -TestFile "Git"
|
||||
26
images/windows/scripts/build/Install-GitHub-CLI.ps1
Normal file
26
images/windows/scripts/build/Install-GitHub-CLI.ps1
Normal file
@@ -0,0 +1,26 @@
|
||||
################################################################################
|
||||
## File: Install-GitHub-CLI.ps1
|
||||
## Desc: Install GitHub CLI
|
||||
## Supply chain security: GitHub CLI - checksum validation
|
||||
################################################################################
|
||||
|
||||
Write-Host "Get the latest gh version..."
|
||||
|
||||
$repoUrl = "https://api.github.com/repos/cli/cli/releases/latest"
|
||||
$installerFile = "gh_windows_amd64.msi"
|
||||
$assets = (Invoke-RestMethod -Uri $repoUrl).assets
|
||||
$downloadUrl = ($assets.browser_download_url -match "windows_amd64.msi") | Select-Object -First 1
|
||||
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -Name $installerFile
|
||||
|
||||
#region Supply chain security - GitHub CLI
|
||||
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||
$hashUrl = ($assets.browser_download_url -match "checksums.txt") | Select-Object -First 1
|
||||
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*windows_amd64.msi*" }).Split(' ')[0]
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
Install-Binary -FilePath $packagePath
|
||||
|
||||
Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI"
|
||||
|
||||
Invoke-PesterTests -TestFile "CLI.Tools" -TestName "GitHub CLI"
|
||||
13
images/windows/scripts/build/Install-GoogleCloudCLI.ps1
Normal file
13
images/windows/scripts/build/Install-GoogleCloudCLI.ps1
Normal file
@@ -0,0 +1,13 @@
|
||||
################################################################################
|
||||
## File: Install-GoogleCloudCLI.ps1
|
||||
## Desc: Install Google Cloud CLI
|
||||
################################################################################
|
||||
|
||||
# https://cloud.google.com/sdk/docs/downloads-interactive
|
||||
$googleCloudCLIInstaller = "https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe"
|
||||
$argumentList = @("/S", "/allusers", "/noreporting")
|
||||
$googleCloudCLISignatureThumbprint = "2673EA6CC23BEFFDA49AC715B121544098A1284C"
|
||||
|
||||
Install-Binary -Url $googleCloudCLIInstaller -Name "GoogleCloudSDKInstaller.exe" -ArgumentList $argumentList -ExpectedSignature $googleCloudCLISignatureThumbprint
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "GoogleCloudCLI"
|
||||
55
images/windows/scripts/build/Install-Haskell.ps1
Normal file
55
images/windows/scripts/build/Install-Haskell.ps1
Normal file
@@ -0,0 +1,55 @@
|
||||
################################################################################
|
||||
## File: Install-Haskell.ps1
|
||||
## Desc: Install Haskell for Windows
|
||||
################################################################################
|
||||
Import-Module "$env:ChocolateyInstall\helpers\chocolateyProfile.psm1"
|
||||
|
||||
# install minimal ghcup, utilizing pre-installed msys2 at C:\msys64
|
||||
Write-Host 'Installing ghcup...'
|
||||
$msysPath = "C:\msys64"
|
||||
$ghcupPrefix = "C:\"
|
||||
$cabalDir = "C:\cabal"
|
||||
|
||||
$ghcupDownloadURL = "https://downloads.haskell.org/~ghcup/x86_64-mingw64-ghcup.exe"
|
||||
|
||||
# If you want to install a specific version of ghcup, uncomment the following lines
|
||||
# $ghver = "0.1.19.4"
|
||||
# $ghcupDownloadURL = "https://downloads.haskell.org/~ghcup/${ghver}/x86_64-mingw64-ghcup-${ghver}.exe"
|
||||
|
||||
# Other option is to download ghcup from GitHub releases:
|
||||
# https://github.com/haskell/ghcup-hs/releases/latest
|
||||
|
||||
New-Item -Path "$ghcupPrefix\ghcup" -ItemType 'directory' -ErrorAction SilentlyContinue | Out-Null
|
||||
New-Item -Path "$ghcupPrefix\ghcup\bin" -ItemType 'directory' -ErrorAction SilentlyContinue | Out-Null
|
||||
Start-DownloadWithRetry -Url $ghcupDownloadURL -Name "ghcup.exe" -DownloadPath "$ghcupPrefix\ghcup\bin"
|
||||
|
||||
Set-SystemVariable "GHCUP_INSTALL_BASE_PREFIX" $ghcupPrefix
|
||||
Set-SystemVariable "GHCUP_MSYS2" $msysPath
|
||||
Set-SystemVariable "CABAL_DIR" $cabalDir
|
||||
Add-MachinePathItem "$ghcupPrefix\ghcup\bin"
|
||||
Add-MachinePathItem "$cabalDir\bin"
|
||||
|
||||
Update-SessionEnvironment
|
||||
|
||||
# Get 3 latest versions of GHC
|
||||
$Versions = ghcup list -t ghc -r | Where-Object {$_ -notlike "prerelease"}
|
||||
$VersionsOutput = [Version[]]($Versions | ForEach-Object{ $_.Split(' ')[1]; })
|
||||
$LatestMajorMinor = $VersionsOutput | Group-Object { $_.ToString(2) } | Sort-Object { [Version]$_.Name } | Select-Object -last 3
|
||||
$VersionsList = $LatestMajorMinor | ForEach-Object { $_.Group | Select-Object -Last 1 } | Sort-Object
|
||||
|
||||
# The latest version will be installed as a default
|
||||
ForEach ($version in $VersionsList)
|
||||
{
|
||||
Write-Host "Installing ghc $version..."
|
||||
ghcup install ghc $version
|
||||
ghcup set ghc $version
|
||||
}
|
||||
|
||||
# Add default version of GHC to path
|
||||
$DefaultGhcVersion = $VersionsList | Select-Object -Last 1
|
||||
ghcup set ghc $DefaultGhcVersion
|
||||
|
||||
Write-Host 'Installing cabal...'
|
||||
ghcup install cabal latest
|
||||
|
||||
Invoke-PesterTests -TestFile 'Haskell'
|
||||
38
images/windows/scripts/build/Install-IEWebDriver.ps1
Normal file
38
images/windows/scripts/build/Install-IEWebDriver.ps1
Normal file
@@ -0,0 +1,38 @@
|
||||
################################################################################
|
||||
## File: Install-IEWebDriver.ps1
|
||||
## Desc: Install IE Web Driver
|
||||
################################################################################
|
||||
|
||||
$seleniumMajorVersion = (Get-ToolsetContent).selenium.version
|
||||
$ieDriverUrl = Get-GitHubPackageDownloadUrl `
|
||||
-RepoOwner "SeleniumHQ" `
|
||||
-RepoName "selenium" `
|
||||
-BinaryName "IEDriverServer_x64" `
|
||||
-Version $seleniumMajorVersion `
|
||||
-UrlFilter "*{BinaryName}_{Version}.zip" `
|
||||
-LatestReleaseOnly $false
|
||||
|
||||
# Download IE selenium driver
|
||||
try {
|
||||
Write-Host "Selenium IEDriverServer download and install..."
|
||||
$driverZipFile = Start-DownloadWithRetry -Url $ieDriverUrl -Name "SeleniumWebDrivers.zip"
|
||||
} catch {
|
||||
Write-Error "[!] Failed to download $ieDriverUrl"
|
||||
exit 1
|
||||
}
|
||||
|
||||
$ieDriverPath = "C:\SeleniumWebDrivers\IEDriver"
|
||||
if (-not (Test-Path -Path $ieDriverPath)) {
|
||||
$null = New-Item -Path $ieDriverPath -ItemType Directory -Force
|
||||
}
|
||||
|
||||
Extract-7Zip -Path $driverZipFile -DestinationPath $ieDriverPath
|
||||
Remove-Item $driverZipFile
|
||||
|
||||
Write-Host "Get the IEDriver version..."
|
||||
(Get-Item "$ieDriverPath\IEDriverServer.exe").VersionInfo.FileVersion | Out-File -FilePath "$ieDriverPath\versioninfo.txt"
|
||||
|
||||
Write-Host "Setting the IEWebDriver environment variables"
|
||||
setx IEWebDriver $ieDriverPath /M
|
||||
|
||||
Invoke-PesterTests -TestFile "Browsers" -TestName "Internet Explorer"
|
||||
148
images/windows/scripts/build/Install-JavaTools.ps1
Normal file
148
images/windows/scripts/build/Install-JavaTools.ps1
Normal file
@@ -0,0 +1,148 @@
|
||||
################################################################################
|
||||
## File: Install-JavaTools.ps1
|
||||
## Desc: Install various JDKs and java tools
|
||||
## Supply chain security: JDK - checksum validation
|
||||
################################################################################
|
||||
|
||||
function Set-JavaPath {
|
||||
param (
|
||||
[string] $Version,
|
||||
[string] $Architecture = "x64",
|
||||
[switch] $Default
|
||||
)
|
||||
|
||||
$javaPathPattern = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "Java_Temurin-Hotspot_jdk/${Version}*/${Architecture}"
|
||||
$javaPath = (Get-Item -Path $javaPathPattern).FullName
|
||||
|
||||
if ([string]::IsNullOrEmpty($javaPath)) {
|
||||
Write-Host "Not found path to Java '${Version}'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
Write-Host "Set 'JAVA_HOME_${Version}_X64' environmental variable as $javaPath"
|
||||
setx JAVA_HOME_${Version}_X64 $javaPath /M
|
||||
|
||||
if ($Default) {
|
||||
# Clean up any other Java folders from PATH to make sure that they won't conflict with each other
|
||||
$currentPath = Get-MachinePath
|
||||
|
||||
$pathSegments = $currentPath.Split(';')
|
||||
$newPathSegments = @()
|
||||
|
||||
foreach ($pathSegment in $pathSegments) {
|
||||
if ($pathSegment -notlike '*java*') {
|
||||
$newPathSegments += $pathSegment
|
||||
}
|
||||
}
|
||||
|
||||
$newPath = [string]::Join(';', $newPathSegments)
|
||||
$newPath = $javaPath + '\bin;' + $newPath
|
||||
|
||||
Write-Host "Add $javaPath\bin to PATH"
|
||||
Set-MachinePath -NewPath $newPath
|
||||
|
||||
Write-Host "Set JAVA_HOME environmental variable as $javaPath"
|
||||
setx JAVA_HOME $javaPath /M
|
||||
}
|
||||
}
|
||||
|
||||
function Install-JavaJDK {
|
||||
param(
|
||||
[string] $JDKVersion,
|
||||
[string] $Architecture = "x64"
|
||||
)
|
||||
|
||||
# Get Java version from api
|
||||
$assetUrl = Invoke-RestMethod -Uri "https://api.adoptium.net/v3/assets/latest/${JDKVersion}/hotspot"
|
||||
|
||||
$asset = $assetUrl | Where-Object {
|
||||
$_.binary.os -eq "windows" `
|
||||
-and $_.binary.architecture -eq $Architecture `
|
||||
-and $_.binary.image_type -eq "jdk"
|
||||
}
|
||||
|
||||
# Download and extract java binaries to temporary folder
|
||||
$downloadUrl = $asset.binary.package.link
|
||||
$archivePath = Start-DownloadWithRetry -Url $downloadUrl -Name $([IO.Path]::GetFileName($downloadUrl))
|
||||
|
||||
#region Supply chain security - JDK
|
||||
$fileHash = (Get-FileHash -Path $archivePath -Algorithm SHA256).Hash
|
||||
$externalHash = $asset.binary.package.checksum
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
# We have to replace '+' sign in the version to '-' due to the issue with incorrect path in Android builds https://github.com/actions/runner-images/issues/3014
|
||||
$fullJavaVersion = $asset.version.semver -replace '\+', '-'
|
||||
# Remove 'LTS' suffix from the version if present
|
||||
$fullJavaVersion = $fullJavaVersion -replace '\.LTS$', ''
|
||||
# Create directories in toolcache path
|
||||
$javaToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "Java_Temurin-Hotspot_jdk"
|
||||
$javaVersionPath = Join-Path -Path $javaToolcachePath -ChildPath $fullJavaVersion
|
||||
$javaArchPath = Join-Path -Path $javaVersionPath -ChildPath $Architecture
|
||||
|
||||
if (-not (Test-Path $javaToolcachePath)) {
|
||||
Write-Host "Creating Temurin-Hotspot toolcache folder"
|
||||
New-Item -ItemType Directory -Path $javaToolcachePath | Out-Null
|
||||
}
|
||||
|
||||
Write-Host "Creating Java '${fullJavaVersion}' folder in '${javaVersionPath}'"
|
||||
New-Item -ItemType Directory -Path $javaVersionPath -Force | Out-Null
|
||||
|
||||
# Complete the installation by extracting Java binaries to toolcache and creating the complete file
|
||||
Extract-7Zip -Path $archivePath -DestinationPath $javaVersionPath
|
||||
Invoke-SBWithRetry -Command {
|
||||
Get-ChildItem -Path $javaVersionPath | Rename-Item -NewName $javaArchPath -ErrorAction Stop
|
||||
}
|
||||
New-Item -ItemType File -Path $javaVersionPath -Name "$Architecture.complete" | Out-Null
|
||||
}
|
||||
|
||||
$toolsetJava = (Get-ToolsetContent).java
|
||||
$defaultVersion = $toolsetJava.default
|
||||
$jdkVersionsToInstall = $toolsetJava.versions
|
||||
|
||||
foreach ($jdkVersionToInstall in $jdkVersionsToInstall) {
|
||||
$isDefaultVersion = $jdkVersionToInstall -eq $defaultVersion
|
||||
|
||||
Install-JavaJDK -JDKVersion $jdkVersionToInstall
|
||||
|
||||
if ($isDefaultVersion) {
|
||||
Set-JavaPath -Version $jdkVersionToInstall -Default
|
||||
} else {
|
||||
Set-JavaPath -Version $jdkVersionToInstall
|
||||
}
|
||||
}
|
||||
|
||||
# Install Java tools
|
||||
# Force chocolatey to ignore dependencies on Ant and Maven or else they will download the Oracle JDK
|
||||
Choco-Install -PackageName ant -ArgumentList "-i"
|
||||
# Maven 3.9.x has multiple compatibilities problems
|
||||
$toolsetMavenVersion = (Get-ToolsetContent).maven.version
|
||||
$versionToInstall = Get-LatestChocoPackageVersion -TargetVersion $toolsetMavenVersion -PackageName "maven"
|
||||
|
||||
Choco-Install -PackageName maven -ArgumentList "--version=$versionToInstall"
|
||||
Choco-Install -PackageName gradle
|
||||
|
||||
# Add maven env variables to Machine
|
||||
[string]$m2 = (Get-MachinePath).Split(";") -match "maven"
|
||||
$maven_opts = '-Xms256m'
|
||||
|
||||
$m2_repo = 'C:\ProgramData\m2'
|
||||
New-Item -Path $m2_repo -ItemType Directory -Force | Out-Null
|
||||
|
||||
setx M2 $m2 /M
|
||||
setx M2_REPO $m2_repo /M
|
||||
setx MAVEN_OPTS $maven_opts /M
|
||||
|
||||
# Download cobertura jars
|
||||
$uri = 'https://repo1.maven.org/maven2/net/sourceforge/cobertura/cobertura/2.1.1/cobertura-2.1.1-bin.zip'
|
||||
$sha256sum = '79479DDE416B082F38ECD1F2F7C6DEBD4D0C2249AF80FD046D1CE05D628F2EC6'
|
||||
$coberturaPath = "C:\cobertura-2.1.1"
|
||||
|
||||
$archivePath = Start-DownloadWithRetry -Url $uri -Name "cobertura.zip"
|
||||
$fileHash = (Get-FileHash -Path $archivePath -Algorithm SHA256).Hash
|
||||
Use-ChecksumComparison $fileHash $sha256sum
|
||||
Extract-7Zip -Path $archivePath -DestinationPath "C:\"
|
||||
|
||||
setx COBERTURA_HOME $coberturaPath /M
|
||||
|
||||
Invoke-PesterTests -TestFile "Java"
|
||||
27
images/windows/scripts/build/Install-Kotlin.ps1
Normal file
27
images/windows/scripts/build/Install-Kotlin.ps1
Normal file
@@ -0,0 +1,27 @@
|
||||
################################################################################
|
||||
## File: Install-Kotlin.ps1
|
||||
## Desc: Install Kotlin
|
||||
## Supply chain security: Kotlin - checksum validation
|
||||
################################################################################
|
||||
|
||||
# Install Kotlin
|
||||
$kotlinVersion = (Get-ToolsetContent).kotlin.version
|
||||
$kotlinBinaryName = (Get-ToolsetContent).kotlin.binary_name
|
||||
|
||||
$kotlinDownloadUrl = Get-GitHubPackageDownloadUrl -RepoOwner "JetBrains" -RepoName "kotlin" -BinaryName $kotlinBinaryName -Version $kotlinVersion -UrlFilter "*{BinaryName}-{Version}.zip"
|
||||
$kotlinInstallerPath = Start-DownloadWithRetry -Url $kotlinDownloadUrl -Name "$kotlinBinaryName.zip"
|
||||
|
||||
#region Supply chain security
|
||||
$fileHash = (Get-FileHash -Path $kotlinInstallerPath -Algorithm SHA256).Hash
|
||||
$externalHash = Get-HashFromGitHubReleaseBody -RepoOwner "JetBrains" -RepoName "kotlin" -FileName "$kotlinBinaryName-*.zip" -Version $kotlinVersion -WordNumber 2
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
Write-Host "Expand Kotlin archive"
|
||||
$kotlinPath = "C:\tools"
|
||||
Extract-7Zip -Path $kotlinInstallerPath -DestinationPath $kotlinPath
|
||||
|
||||
# Add to PATH
|
||||
Add-MachinePathItem "$kotlinPath\kotlinc\bin"
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Kotlin"
|
||||
34
images/windows/scripts/build/Install-KubernetesTools.ps1
Normal file
34
images/windows/scripts/build/Install-KubernetesTools.ps1
Normal file
@@ -0,0 +1,34 @@
|
||||
################################################################################
|
||||
## File: Install-KubernetesTools.ps1
|
||||
## Desc: Install tools for K8s.
|
||||
## Supply chain security: GitHub Kind - checksum validation, Kubectl, Helm, Minikube - by package manager
|
||||
################################################################################
|
||||
|
||||
Write-Host "Install Kind"
|
||||
# Choco installation can't be used because it depends on docker-desktop
|
||||
$repoUrl = 'https://api.github.com/repos/kubernetes-sigs/kind/releases/latest'
|
||||
$assets = (Invoke-RestMethod -Uri $repoUrl).assets
|
||||
[System.String] $kindDownloadLink = $assets.browser_download_url -match "kind-windows-amd64$"
|
||||
$destFilePath = "C:\ProgramData\kind"
|
||||
$null = New-Item -Path $destFilePath -ItemType Directory -Force
|
||||
$packagePath = Start-DownloadWithRetry -Url $kindDownloadLink -Name "kind.exe" -DownloadPath $destFilePath
|
||||
|
||||
#region Supply chain security - Kind
|
||||
$fileHash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||
$hashUrl = ($assets.browser_download_url -match "kind-windows-amd64.sha256sum") | Select-Object -First 1
|
||||
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*kind-windows-amd64*" }).Split(' ')[0]
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
Add-MachinePathItem $destFilePath
|
||||
|
||||
Write-Host "Install Kubectl"
|
||||
Choco-Install -PackageName kubernetes-cli
|
||||
|
||||
Write-Host "Install Helm"
|
||||
Choco-Install -PackageName kubernetes-helm
|
||||
|
||||
Write-Host "Install Minikube"
|
||||
Choco-Install -PackageName minikube
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "KubernetesTools"
|
||||
10
images/windows/scripts/build/Install-LLVM.ps1
Normal file
10
images/windows/scripts/build/Install-LLVM.ps1
Normal file
@@ -0,0 +1,10 @@
|
||||
################################################################################
|
||||
## File: Install-LLVM.ps1
|
||||
## Desc: Install the latest stable version of llvm and clang compilers
|
||||
################################################################################
|
||||
|
||||
$llvmVersion = (Get-ToolsetContent).llvm.version
|
||||
$latestChocoVersion = Get-LatestChocoPackageVersion -TargetVersion $llvmVersion -PackageName "llvm"
|
||||
Choco-Install -PackageName llvm -ArgumentList '--version', $latestChocoVersion
|
||||
|
||||
Invoke-PesterTests -TestFile "LLVM"
|
||||
12
images/windows/scripts/build/Install-Mercurial.ps1
Normal file
12
images/windows/scripts/build/Install-Mercurial.ps1
Normal file
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
## File: Install-Mercurial.ps1
|
||||
## Desc: Install Mercurial
|
||||
################################################################################
|
||||
|
||||
Choco-Install -PackageName hg -ArgumentList "--version", "5.0.0"
|
||||
|
||||
$hgPath = "${env:ProgramFiles}\Mercurial\"
|
||||
Add-MachinePathItem $hgPath
|
||||
$env:Path = Get-MachinePath
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Mercurial"
|
||||
72
images/windows/scripts/build/Install-Mingw64.ps1
Normal file
72
images/windows/scripts/build/Install-Mingw64.ps1
Normal file
@@ -0,0 +1,72 @@
|
||||
################################################################################
|
||||
## File: Install-Mingw64.ps1
|
||||
## Desc: Install GNU tools for Windows
|
||||
################################################################################
|
||||
|
||||
if (Test-IsWin19) {
|
||||
# If Windows 2019, install version 8.1.0 form sourceforge
|
||||
$baseUrl = "https://sourceforge.net/projects/mingw-w64/files"
|
||||
|
||||
$("mingw32", "mingw64") | ForEach-Object {
|
||||
if ($_ -eq "mingw32") {
|
||||
$url = "$baseUrl/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/8.1.0/threads-posix/dwarf/i686-8.1.0-release-posix-dwarf-rt_v6-rev0.7z/download"
|
||||
$sha256sum = 'adb84b70094c0225dd30187ff995e311d19424b1eb8f60934c60e4903297f946'
|
||||
} elseif ($_ -eq "mingw64") {
|
||||
$url = "$baseUrl/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/8.1.0/threads-posix/seh/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z/download"
|
||||
$sha256sum = '853970527b5de4a55ec8ca4d3fd732c00ae1c69974cc930c82604396d43e79f8'
|
||||
} else {
|
||||
throw "Unknown architecture $_"
|
||||
}
|
||||
|
||||
$packagePath = Start-DownloadWithRetry -Url $url -Name "$_.7z"
|
||||
$hash = Get-FileHash -Path $packagePath -Algorithm SHA256
|
||||
if ($hash.Hash -ne $sha256sum) {
|
||||
throw "Checksum verification failed for $packagePath"
|
||||
}
|
||||
Extract-7Zip -Path $packagePath -DestinationPath "C:\"
|
||||
|
||||
# Make a copy of mingw-make.exe to make.exe, which is a more discoverable name
|
||||
# and so the same command line can be used on Windows as on macOS and Linux
|
||||
$path = "C:\$_\bin\mingw32-make.exe" | Get-Item
|
||||
Copy-Item -Path $path -Destination (Join-Path $path.Directory 'make.exe')
|
||||
}
|
||||
|
||||
Add-MachinePathItem "C:\mingw64\bin"
|
||||
|
||||
} else {
|
||||
$version = (Get-ToolsetContent).mingw.version
|
||||
$runtime = (Get-ToolsetContent).mingw.runtime
|
||||
|
||||
$("mingw32", "mingw64") | ForEach-Object {
|
||||
if ($_ -eq "mingw32") {
|
||||
$arch = "i686"
|
||||
$threads = "posix"
|
||||
$exceptions = "dwarf"
|
||||
} elseif ($_ -eq "mingw64") {
|
||||
$arch = "x86_64"
|
||||
$threads = "posix"
|
||||
$exceptions = "seh"
|
||||
} else {
|
||||
throw "Unknown architecture $_"
|
||||
}
|
||||
|
||||
$url = Get-GitHubPackageDownloadUrl `
|
||||
-RepoOwner "niXman" `
|
||||
-RepoName "mingw-builds-binaries" `
|
||||
-BinaryName "" `
|
||||
-Version $version `
|
||||
-UrlFilter "*$arch-{Version}-release-$threads-$exceptions-$runtime-*.7z"
|
||||
|
||||
$packagePath = Start-DownloadWithRetry -Url $url -Name "$_.7z"
|
||||
Extract-7Zip -Path $packagePath -DestinationPath "C:\"
|
||||
|
||||
# Make a copy of mingw-make.exe to make.exe, which is a more discoverable name
|
||||
# and so the same command line can be used on Windows as on macOS and Linux
|
||||
$path = "C:\$_\bin\mingw32-make.exe" | Get-Item
|
||||
Copy-Item -Path $path -Destination (Join-Path $path.Directory 'make.exe')
|
||||
}
|
||||
|
||||
Add-MachinePathItem "C:\mingw64\bin"
|
||||
}
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Mingw64"
|
||||
32
images/windows/scripts/build/Install-Miniconda.ps1
Normal file
32
images/windows/scripts/build/Install-Miniconda.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
################################################################################
|
||||
## File: Install-Miniconda.ps1
|
||||
## Desc: Install the latest version of Miniconda and set $env:CONDA
|
||||
## Supply chain security: checksum validation
|
||||
################################################################################
|
||||
|
||||
$CondaDestination = "C:\Miniconda"
|
||||
|
||||
# Install the latest Miniconda
|
||||
$InstallerName = "Miniconda3-latest-Windows-x86_64.exe"
|
||||
$InstallerUrl = "https://repo.anaconda.com/miniconda/${InstallerName}"
|
||||
$ArgumentList = ("/S", "/AddToPath=0", "/RegisterPython=0", "/D=$CondaDestination")
|
||||
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList
|
||||
Set-SystemVariable -SystemVariable "CONDA" -Value $CondaDestination
|
||||
|
||||
#region Supply chain security
|
||||
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} $installerName) -Algorithm SHA256).Hash
|
||||
$distributorFileHash = $null
|
||||
|
||||
$checksums = (Invoke-RestMethod -Uri 'https://repo.anaconda.com/miniconda/' | ConvertFrom-HTML).SelectNodes('//html/body/table/tr')
|
||||
|
||||
ForEach($node in $checksums) {
|
||||
if ($node.ChildNodes[1].InnerText -eq $InstallerName) {
|
||||
$distributorFileHash = $node.ChildNodes[7].InnerText
|
||||
}
|
||||
}
|
||||
|
||||
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
|
||||
#endregion
|
||||
|
||||
Invoke-PesterTests -TestFile "Miniconda"
|
||||
44
images/windows/scripts/build/Install-MongoDB.ps1
Normal file
44
images/windows/scripts/build/Install-MongoDB.ps1
Normal file
@@ -0,0 +1,44 @@
|
||||
####################################################################################
|
||||
## File: Install-MongoDB.ps1
|
||||
## Desc: Install MongoDB
|
||||
####################################################################################
|
||||
|
||||
# Install mongodb package
|
||||
$toolsetVersion = (Get-ToolsetContent).mongodb.version
|
||||
|
||||
$getMongoReleases = Invoke-WebRequest -Uri "mongodb.com/docs/manual/release-notes/$toolsetVersion/" -UseBasicParsing
|
||||
$TargetReleases = $getMongoReleases.Links.href | Where-Object {$_ -like "#$toolsetVersion*---*"}
|
||||
|
||||
$MinorVersions = @()
|
||||
foreach ($release in $TargetReleases) {
|
||||
if ($release -notlike "*upcoming*") {
|
||||
$pattern = '\d+\.\d+\.\d+'
|
||||
$version = $release | Select-String -Pattern $pattern -AllMatches | ForEach-Object { $_.Matches } | ForEach-Object { $_.Value }
|
||||
$MinorVersions += $version
|
||||
}
|
||||
}
|
||||
|
||||
$LatestVersion = $MinorVersions[0]
|
||||
|
||||
$installDir = "c:\PROGRA~1\MongoDB"
|
||||
$binaryName = "mongodb-windows-x86_64-$LatestVersion-signed.msi"
|
||||
$downloadURL = "https://fastdl.mongodb.org/windows/$BinaryName"
|
||||
$installArg = "INSTALLLOCATION=$installDir ADDLOCAL=all"
|
||||
Install-Binary -Url $downloadURL -Name $binaryName -ArgumentList ("/q","/i","${env:Temp}\$binaryName", $installArg) -ExpectedSignature (Get-ToolsetContent).mongodb.signature
|
||||
|
||||
|
||||
# Add mongodb to the PATH
|
||||
$mongodbService = "mongodb"
|
||||
$mongoPath = (Get-CimInstance Win32_Service -Filter "Name LIKE '$mongodbService'").PathName
|
||||
$mongoBin = Split-Path -Path $mongoPath.split('"')[1]
|
||||
Add-MachinePathItem "$mongoBin"
|
||||
|
||||
# Wait for mongodb service running
|
||||
$svc = Get-Service $mongodbService
|
||||
$svc.WaitForStatus('Running','00:01:00')
|
||||
|
||||
# Stop and disable mongodb service
|
||||
Stop-Service -Name $mongodbService
|
||||
Set-Service $mongodbService -StartupType Disabled
|
||||
|
||||
Invoke-PesterTests -TestFile "Databases" -TestName "MongoDB"
|
||||
99
images/windows/scripts/build/Install-Msys2.ps1
Normal file
99
images/windows/scripts/build/Install-Msys2.ps1
Normal file
@@ -0,0 +1,99 @@
|
||||
################################################################################
|
||||
## File: Install-Msys2.ps1
|
||||
## Desc: Install Msys2 and 64 & 32 bit gcc, cmake, & llvm
|
||||
################################################################################
|
||||
|
||||
# References
|
||||
# https://github.com/msys2/MINGW-packages/blob/master/azure-pipelines.yml
|
||||
# https://packages.msys2.org/group/
|
||||
|
||||
$dash = "-" * 40
|
||||
$origPath = $env:PATH
|
||||
|
||||
function Install-Msys2 {
|
||||
$msys2_release = "https://api.github.com/repos/msys2/msys2-installer/releases/latest"
|
||||
$assets = (Invoke-RestMethod -Uri $msys2_release).assets
|
||||
$msys2Uri = ($assets | Where-Object { $_.name -match "^msys2-x86_64" -and $_.name.EndsWith(".exe") }).browser_download_url
|
||||
|
||||
# Download the latest msys2 x86_64, filename includes release date
|
||||
Write-Host "Starting msys2 download using $($msys2Uri.split('/')[-1])"
|
||||
$msys2File = Start-DownloadWithRetry -Url $msys2Uri
|
||||
Write-Host "Finished download"
|
||||
|
||||
#region Supply chain security - Kind
|
||||
$fileHash = (Get-FileHash -Path $msys2File -Algorithm SHA256).Hash
|
||||
$hashUrl = ($assets.browser_download_url -match "msys2-checksums.txt") | Select-Object -First 1
|
||||
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*msys2-x86_64*" }).Split(' ')[0]
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
# extract tar.xz to C:\
|
||||
Write-Host "Starting msys2 installation"
|
||||
& $msys2File in --confirm-command --accept-messages --root C:/msys64
|
||||
Remove-Item $msys2File
|
||||
}
|
||||
|
||||
function Install-Msys2Packages($Packages) {
|
||||
if (-not $Packages) {
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "`n$dash Install msys2 packages"
|
||||
pacman.exe -S --noconfirm --needed --noprogressbar $Packages
|
||||
taskkill /f /fi "MODULES eq msys-2.0.dll"
|
||||
|
||||
Write-Host "`n$dash Remove p7zip/7z package due to conflicts"
|
||||
pacman.exe -R --noconfirm --noprogressbar p7zip
|
||||
}
|
||||
|
||||
function Install-MingwPackages($Packages) {
|
||||
if (-not $Packages) {
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "`n$dash Install mingw packages"
|
||||
$archs = $Packages.arch
|
||||
|
||||
foreach ($arch in $archs) {
|
||||
Write-Host "Installing $arch packages"
|
||||
$archPackages = $toolsetContent.mingw | Where-Object { $_.arch -eq $arch }
|
||||
$runtimePackages = $archPackages.runtime_packages.name | ForEach-Object { "${arch}-$_" }
|
||||
$additionalPackages = $archPackages.additional_packages | ForEach-Object { "${arch}-$_" }
|
||||
$packagesToInstall = $runtimePackages + $additionalPackages
|
||||
Write-Host "The following packages will be installed: $packagesToInstall"
|
||||
pacman.exe -S --noconfirm --needed --noprogressbar $packagesToInstall
|
||||
}
|
||||
|
||||
# clean all packages to decrease image size
|
||||
Write-Host "`n$dash Clean packages"
|
||||
pacman.exe -Scc --noconfirm
|
||||
|
||||
$pkgs = pacman.exe -Q
|
||||
|
||||
foreach ($arch in $archs)
|
||||
{
|
||||
Write-Host "`n$dash Installed $arch packages"
|
||||
$pkgs | grep ^${arch}-
|
||||
}
|
||||
}
|
||||
|
||||
Install-Msys2
|
||||
|
||||
# Add msys2 bin tools folders to PATH temporary
|
||||
$env:PATH = "C:\msys64\mingw64\bin;C:\msys64\usr\bin;$origPath"
|
||||
|
||||
Write-Host "`n$dash pacman --noconfirm -Syyuu"
|
||||
pacman.exe -Syyuu --noconfirm
|
||||
taskkill /f /fi "MODULES eq msys-2.0.dll"
|
||||
Write-Host "`n$dash pacman --noconfirm -Syuu (2nd pass)"
|
||||
pacman.exe -Syuu --noconfirm
|
||||
taskkill /f /fi "MODULES eq msys-2.0.dll"
|
||||
|
||||
$toolsetContent = (Get-ToolsetContent).MsysPackages
|
||||
Install-Msys2Packages -Packages $toolsetContent.msys2
|
||||
Install-MingwPackages -Packages $toolsetContent.mingw
|
||||
|
||||
$env:PATH = $origPath
|
||||
Write-Host "`nMSYS2 installation completed"
|
||||
|
||||
Invoke-PesterTests -TestFile "MSYS2"
|
||||
33
images/windows/scripts/build/Install-MysqlCli.ps1
Normal file
33
images/windows/scripts/build/Install-MysqlCli.ps1
Normal file
@@ -0,0 +1,33 @@
|
||||
################################################################################
|
||||
## File: Install-MysqlCli.ps1
|
||||
## Desc: Install Mysql CLI
|
||||
################################################################################
|
||||
|
||||
# Installing visual c++ redistibutable package.
|
||||
$InstallerName = "vcredist_x64.exe"
|
||||
$InstallerURI = "https://download.microsoft.com/download/0/5/6/056dcda9-d667-4e27-8001-8a0c6971d6b1/${InstallerName}"
|
||||
$ArgumentList = ("/install", "/quiet", "/norestart")
|
||||
$InstallerSignatureThumbrint = "3BDA323E552DB1FDE5F4FBEE75D6D5B2B187EEDC"
|
||||
|
||||
Install-Binary -Url $InstallerURI -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature $InstallerSignatureThumbrint
|
||||
|
||||
# Downloading mysql
|
||||
[version]$MysqlVersion = (Get-ToolsetContent).mysql.version
|
||||
$MysqlVersionMajorMinor = $MysqlVersion.ToString(2)
|
||||
|
||||
if ($MysqlVersion.Build -lt 0) {
|
||||
$MysqlVersion = (Invoke-RestMethod -Uri "https://dev.mysql.com/downloads/mysql/${MysqlVersionMajorMinor}.html" -Headers @{ 'User-Agent'='curl/8.4.0' } |
|
||||
Select-String -Pattern "${MysqlVersionMajorMinor}\.\d+").Matches.Value
|
||||
}
|
||||
|
||||
$MysqlVersionFull = $MysqlVersion.ToString()
|
||||
$MysqlVersionUrl = "https://cdn.mysql.com/Downloads/MySQL-${MysqlVersionMajorMinor}/mysql-${MysqlVersionFull}-winx64.msi"
|
||||
|
||||
Install-Binary -Url $MysqlVersionUrl -Name "mysql-${MysqlVersionFull}-winx64.msi" -ExpectedSignature (Get-ToolsetContent).mysql.signature
|
||||
|
||||
# Adding mysql in system environment path
|
||||
$MysqlPath = $(Get-ChildItem -Path "C:\PROGRA~1\MySQL" -Directory)[0].FullName
|
||||
|
||||
Add-MachinePathItem "${MysqlPath}\bin"
|
||||
|
||||
Invoke-PesterTests -TestFile "Databases" -TestName "MySQL"
|
||||
14
images/windows/scripts/build/Install-NET48-devpack.ps1
Normal file
14
images/windows/scripts/build/Install-NET48-devpack.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
################################################################################
|
||||
## File: Install-NET48-devpack.ps1
|
||||
## Desc: Install .NET 4.8 devpack
|
||||
################################################################################
|
||||
|
||||
# .NET 4.8 Dev pack
|
||||
$InstallerName = "ndp48-devpack-enu.exe"
|
||||
$InstallerUrl = "https://download.visualstudio.microsoft.com/download/pr/014120d7-d689-4305-befd-3cb711108212/0307177e14752e359fde5423ab583e43/${InstallerName}"
|
||||
$InstallerSignatureThumbprint = "C82273A065EC470FB1EBDE846A91E6FFB29E9C12"
|
||||
$ArgumentList = ("Setup", "/passive", "/norestart")
|
||||
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature $InstallerSignatureThumbprint
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "NET48"
|
||||
12
images/windows/scripts/build/Install-NET48.ps1
Normal file
12
images/windows/scripts/build/Install-NET48.ps1
Normal file
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
## File: Install-NET48.ps1
|
||||
## Desc: Install .NET 4.8
|
||||
################################################################################
|
||||
|
||||
# .NET 4.8 Dev pack
|
||||
$InstallerName = "ndp48-x86-x64-allos-enu.exe"
|
||||
$InstallerUrl = "https://download.visualstudio.microsoft.com/download/pr/2d6bb6b2-226a-4baa-bdec-798822606ff1/8494001c276a4b96804cde7829c04d7f/${InstallerName}"
|
||||
$InstallerSignatureThumbprint = "ABDCA79AF9DD48A0EA702AD45260B3C03093FB4B"
|
||||
$ArgumentList = ("Setup", "/passive", "/norestart")
|
||||
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature $InstallerSignatureThumbprint
|
||||
15
images/windows/scripts/build/Install-NSIS.ps1
Normal file
15
images/windows/scripts/build/Install-NSIS.ps1
Normal file
@@ -0,0 +1,15 @@
|
||||
################################################################################
|
||||
## File: Install-NSIS.ps1
|
||||
## Desc: Install NSIS
|
||||
## Supply chain security: NSIS - managed by package manager
|
||||
################################################################################
|
||||
|
||||
$NsisVersion = (Get-ToolsetContent).nsis.version
|
||||
|
||||
Choco-Install -PackageName nsis -ArgumentList "--version", "$NsisVersion"
|
||||
|
||||
$NsisPath = "${env:ProgramFiles(x86)}\NSIS\"
|
||||
Add-MachinePathItem $NsisPath
|
||||
$env:Path = Get-MachinePath
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "NSIS"
|
||||
21
images/windows/scripts/build/Install-Nginx.ps1
Normal file
21
images/windows/scripts/build/Install-Nginx.ps1
Normal file
@@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
## File: Install-Nginx.ps1
|
||||
## Desc: Install Nginx
|
||||
################################################################################
|
||||
|
||||
# Stop w3svc service
|
||||
Stop-Service -Name w3svc | Out-Null
|
||||
|
||||
# Install latest nginx in chocolatey
|
||||
$installDir = "C:\tools"
|
||||
Choco-Install -PackageName nginx -ArgumentList "--force", "--params", "/installLocation:$installDir /port:80"
|
||||
|
||||
# Stop and disable Nginx service
|
||||
Stop-Service -Name nginx
|
||||
Set-Service nginx -StartupType Disabled
|
||||
|
||||
# Start w3svc service
|
||||
Start-Service -Name w3svc | Out-Null
|
||||
|
||||
# Invoke Pester Tests
|
||||
Invoke-PesterTests -TestFile "Nginx"
|
||||
32
images/windows/scripts/build/Install-NodeLts.ps1
Normal file
32
images/windows/scripts/build/Install-NodeLts.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
################################################################################
|
||||
## File: Install-NodeLts.ps1
|
||||
## Desc: Install nodejs-lts and other common node tools.
|
||||
## Must run after python is configured
|
||||
################################################################################
|
||||
|
||||
$PrefixPath = 'C:\npm\prefix'
|
||||
$CachePath = 'C:\npm\cache'
|
||||
|
||||
New-Item -Path $PrefixPath -Force -ItemType Directory
|
||||
New-Item -Path $CachePath -Force -ItemType Directory
|
||||
|
||||
$defaultVersion = (Get-ToolsetContent).node.default
|
||||
$versionToInstall = Get-LatestChocoPackageVersion -TargetVersion $defaultVersion -PackageName "nodejs"
|
||||
|
||||
Choco-Install -PackageName nodejs -ArgumentList "--version=$versionToInstall"
|
||||
|
||||
Add-MachinePathItem $PrefixPath
|
||||
$env:Path = Get-MachinePath
|
||||
|
||||
setx npm_config_prefix $PrefixPath /M
|
||||
$env:npm_config_prefix = $PrefixPath
|
||||
|
||||
npm config set cache $CachePath --global
|
||||
npm config set registry https://registry.npmjs.org/
|
||||
|
||||
$globalNpmPackages = (Get-ToolsetContent).npm.global_packages
|
||||
$globalNpmPackages | ForEach-Object {
|
||||
npm install -g $_.name
|
||||
}
|
||||
|
||||
Invoke-PesterTests -TestFile "Node"
|
||||
52
images/windows/scripts/build/Install-OpenSSL.ps1
Normal file
52
images/windows/scripts/build/Install-OpenSSL.ps1
Normal file
@@ -0,0 +1,52 @@
|
||||
################################################################################
|
||||
## File: Install-OpenSSL.ps1
|
||||
## Desc: Install win64-openssl.
|
||||
## Supply chain security: checksum validation
|
||||
################################################################################
|
||||
|
||||
$arch = 'INTEL'
|
||||
$bits = '64'
|
||||
$light = $false
|
||||
$installer = "exe"
|
||||
$version = (Get-ToolsetContent).openssl.version
|
||||
$installDir = "$Env:ProgramFiles\OpenSSL"
|
||||
|
||||
# Fetch available installers list
|
||||
$jsonUrl = 'https://raw.githubusercontent.com/slproweb/opensslhashes/master/win32_openssl_hashes.json'
|
||||
|
||||
$installersAvailable = (Invoke-RestMethod $jsonUrl).files
|
||||
|
||||
$distributor_file_hash = $null
|
||||
$installerUrl = $null
|
||||
$installerName = $null
|
||||
|
||||
$installersAvailable | Get-Member -MemberType NoteProperty | ForEach-Object {
|
||||
$key = $_.Name
|
||||
if(($installersAvailable.$key.light -eq $light) -and ($installersAvailable.$key.arch -eq $arch) -and ($installersAvailable.$key.bits -eq $bits) -and ($installersAvailable.$key.installer -eq $installer) -and ($installersAvailable.$key.basever -eq $version)) {
|
||||
$installerUrl = $installersAvailable.$key.url
|
||||
$installerName = $key
|
||||
$distributor_file_hash = $installersAvailable.$key.sha512
|
||||
}
|
||||
}
|
||||
|
||||
# Invoke installation
|
||||
|
||||
$installerArgs = '/silent', '/sp-', '/suppressmsgboxes', "/DIR=`"$installDir`""
|
||||
Install-Binary -Url "$installerUrl" -Name "$installerName" -ArgumentList $installerArgs
|
||||
|
||||
#region Supply chain security
|
||||
Write-Verbose "Performing checksum verification"
|
||||
$local_file_hash = (Get-FileHash -Path (Join-Path ${env:TEMP} $installerName) -Algorithm SHA512).Hash
|
||||
|
||||
if ($local_file_hash -ne $distributor_file_hash) {
|
||||
Write-Host "hash must be equal to: ${distributor_file_hash}"
|
||||
Write-Host "actual hash is: ${local_file_hash}"
|
||||
throw 'Checksum verification failed, please rerun install'
|
||||
}
|
||||
#endregion
|
||||
|
||||
# Update PATH
|
||||
Add-MachinePathItem "$installDir\bin"
|
||||
$env:Path = Get-MachinePath
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "OpenSSL"
|
||||
22
images/windows/scripts/build/Install-PHP.ps1
Normal file
22
images/windows/scripts/build/Install-PHP.ps1
Normal file
@@ -0,0 +1,22 @@
|
||||
################################################################################
|
||||
## File: Install-PHP.ps1
|
||||
## Desc: Install PHP
|
||||
################################################################################
|
||||
|
||||
# Install latest PHP in chocolatey
|
||||
$installDir = "c:\tools\php"
|
||||
$phpMajorMinor = (Get-ToolsetContent).php.version
|
||||
$phpVersionToInstall = Get-LatestChocoPackageVersion -TargetVersion $phpMajorMinor -PackageName "php"
|
||||
Choco-Install -PackageName php -ArgumentList "--params", "/InstallDir:$installDir", "--version=$phpVersionToInstall"
|
||||
|
||||
# Install latest Composer in chocolatey
|
||||
Choco-Install -PackageName composer -ArgumentList "--ia", "/DEV=$installDir /PHP=$installDir"
|
||||
|
||||
# update path to extensions and enable curl and mbstring extensions, and enable php openssl extensions.
|
||||
((Get-Content -path $installDir\php.ini -Raw) -replace ';extension=curl','extension=curl' -replace ';extension=mbstring','extension=mbstring' -replace ';extension_dir = "ext"','extension_dir = "ext"' -replace ';extension=openssl','extension=openssl') | Set-Content -Path $installDir\php.ini
|
||||
|
||||
# Set the PHPROOT environment variable.
|
||||
setx PHPROOT $installDir /M
|
||||
|
||||
# Invoke Pester Tests
|
||||
Invoke-PesterTests -TestFile "PHP"
|
||||
14
images/windows/scripts/build/Install-Pipx.ps1
Normal file
14
images/windows/scripts/build/Install-Pipx.ps1
Normal file
@@ -0,0 +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
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Pipx"
|
||||
12
images/windows/scripts/build/Install-PipxPackages.ps1
Normal file
12
images/windows/scripts/build/Install-PipxPackages.ps1
Normal file
@@ -0,0 +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
|
||||
}
|
||||
}
|
||||
Invoke-PesterTests -TestFile "PipxPackages"
|
||||
82
images/windows/scripts/build/Install-PostgreSQL.ps1
Normal file
82
images/windows/scripts/build/Install-PostgreSQL.ps1
Normal file
@@ -0,0 +1,82 @@
|
||||
# Define user and password for PostgreSQL database
|
||||
$pgUser = "postgres"
|
||||
$pgPwd = "root"
|
||||
|
||||
# Prepare environment variable for validation
|
||||
Set-SystemVariable -SystemVariable PGUSER -Value $pgUser
|
||||
Set-SystemVariable -SystemVariable PGPASSWORD -Value $pgPwd
|
||||
|
||||
# Define latest available version to install based on version specified in the toolset
|
||||
$toolsetVersion = (Get-ToolsetContent).postgresql.version
|
||||
$getPostgreReleases = Invoke-WebRequest -Uri "https://git.postgresql.org/gitweb/?p=postgresql.git;a=tags" -UseBasicParsing
|
||||
# Getting all links matched to the pattern (e.g.a=log;h=refs/tags/REL_14)
|
||||
$TargetReleases = $getPostgreReleases.Links.href | Where-Object {$_ -match "a=log;h=refs/tags/REL_$toolsetVersion"}
|
||||
[Int32]$OutNumber = $null
|
||||
$MinorVersions = @()
|
||||
foreach ($release in $TargetReleases) {
|
||||
$version = $release.split('/')[-1]
|
||||
# Checking if the latest symbol of the release version is actually a number. If yes, add to $MinorVersions array
|
||||
if ([Int32]::TryParse($($version.Split('_')[-1]),[ref]$OutNumber)){
|
||||
$MinorVersions += $OutNumber
|
||||
}
|
||||
}
|
||||
# Sorting and getting the last one
|
||||
$TargetMinorVersions = ($MinorVersions | Sort-Object)[-1]
|
||||
|
||||
# Install latest PostgreSQL
|
||||
# In order to get rid of error messages (we know we will have them), force ErrorAction to SilentlyContinue
|
||||
$ErrorActionOldValue = $ErrorActionPreference
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
# Starting from number 9 and going down, check if the installer is available. If yes, break the loop.
|
||||
# If an installer with $TargetMinorVersions is not to be found, the $TargetMinorVersions will be decreased by 1
|
||||
$increment = 9
|
||||
do {
|
||||
$url = "https://get.enterprisedb.com/postgresql/postgresql-$toolsetVersion.$TargetMinorVersions-$increment-windows-x64.exe"
|
||||
$checkaccess = [System.Net.WebRequest]::Create($url)
|
||||
$response = $null
|
||||
$response = $checkaccess.GetResponse()
|
||||
if ($response) {
|
||||
$InstallerUrl = $response.ResponseUri.OriginalString
|
||||
} elseif (!$response -and ($increment -eq 0)) {
|
||||
$increment = 9
|
||||
$TargetMinorVersions--
|
||||
} else {
|
||||
$increment--
|
||||
}
|
||||
} while (!$response)
|
||||
# Return the previous value of ErrorAction and invoke Install-Binary function
|
||||
$ErrorActionPreference = $ErrorActionOldValue
|
||||
$InstallerName = $InstallerUrl.Split('/')[-1]
|
||||
$ArgumentList = ("--install_runtimes 0","--superpassword root","--enable_acledit 1","--unattendedmodeui none","--mode unattended")
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature (Get-ToolsetContent).postgresql.signature
|
||||
|
||||
# Get Path to pg_ctl.exe
|
||||
$pgPath = (Get-CimInstance Win32_Service -Filter "Name LIKE 'postgresql-%'").PathName
|
||||
|
||||
# Parse output of command above to obtain pure path
|
||||
$pgBin = Split-Path -Path $pgPath.split('"')[1]
|
||||
$pgRoot = Split-Path -Path $pgPath.split('"')[5]
|
||||
$pgData = Join-Path $pgRoot "data"
|
||||
|
||||
# Validate PostgreSQL installation
|
||||
$pgReadyPath = Join-Path $pgBin "pg_isready.exe"
|
||||
$pgReady = Start-Process -FilePath $pgReadyPath -Wait -PassThru
|
||||
$exitCode = $pgReady.ExitCode
|
||||
|
||||
if ($exitCode -ne 0)
|
||||
{
|
||||
Write-Host -Object "PostgreSQL is not ready. Exitcode: $exitCode"
|
||||
exit $exitCode
|
||||
}
|
||||
|
||||
# Added PostgreSQL environment variable
|
||||
Set-SystemVariable -SystemVariable PGBIN -Value $pgBin
|
||||
Set-SystemVariable -SystemVariable PGROOT -Value $pgRoot
|
||||
Set-SystemVariable -SystemVariable PGDATA -Value $pgData
|
||||
|
||||
# Stop and disable PostgreSQL service
|
||||
$pgService = Get-Service -Name postgresql*
|
||||
Stop-Service -InputObject $pgService
|
||||
Set-Service -InputObject $pgService -StartupType Disabled
|
||||
|
||||
Invoke-PesterTests -TestFile "Databases" -TestName "PostgreSQL"
|
||||
26
images/windows/scripts/build/Install-PowerShellModules.ps1
Normal file
26
images/windows/scripts/build/Install-PowerShellModules.ps1
Normal file
@@ -0,0 +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"
|
||||
70
images/windows/scripts/build/Install-PowershellCore.ps1
Normal file
70
images/windows/scripts/build/Install-PowershellCore.ps1
Normal file
@@ -0,0 +1,70 @@
|
||||
################################################################################
|
||||
## File: Install-PowershellCore.ps1
|
||||
## Desc: Install PowerShell Core
|
||||
## Supply chain security: checksum validation
|
||||
################################################################################
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
#region functions
|
||||
Function Get-PowerShellCoreHash
|
||||
{
|
||||
Param (
|
||||
[Parameter(Mandatory = $True)]
|
||||
[string] $Release
|
||||
)
|
||||
|
||||
$hashURL = "https://github.com/PowerShell/PowerShell/releases/download/v${Release}/hashes.sha256"
|
||||
(Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*PowerShell-${Release}-win-x64.msi*" }).Split(' ')[0]
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
|
||||
$null = New-Item -ItemType Directory -Path $tempDir -Force -ErrorAction SilentlyContinue
|
||||
try {
|
||||
$originalValue = [Net.ServicePointManager]::SecurityProtocol
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
$metadata = Invoke-RestMethod https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/metadata.json
|
||||
$release = $metadata.LTSReleaseTag[0] -replace '^v'
|
||||
$packageName = "PowerShell-${release}-win-x64.msi"
|
||||
|
||||
$downloadURL = "https://github.com/PowerShell/PowerShell/releases/download/v${release}/${packageName}"
|
||||
Write-Verbose "About to download package from '$downloadURL'" -Verbose
|
||||
|
||||
$packagePath = Join-Path -Path $tempDir -ChildPath $packageName
|
||||
Invoke-WebRequest -Uri $downloadURL -OutFile $packagePath
|
||||
|
||||
#region Supply chain security
|
||||
Write-Verbose "Performing checksum verification"
|
||||
|
||||
$distributor_file_hash = Get-PowerShellCoreHash -Release $release
|
||||
$local_file_hash = (Get-FileHash -Path $packagePath -Algorithm SHA256).Hash
|
||||
|
||||
if ($local_file_hash -ne $distributor_file_hash) {
|
||||
Write-Host "hash must be equal to: ${distributor_file_hash}"
|
||||
Write-Host "actual hash is: ${local_file_hash}"
|
||||
throw 'Checksum verification failed, please rerun install'
|
||||
}
|
||||
#endregion
|
||||
|
||||
Write-Verbose "Performing quiet install"
|
||||
$ArgumentList=@("/i", $packagePath, "/quiet")
|
||||
$process = Start-Process msiexec -ArgumentList $ArgumentList -Wait -PassThru
|
||||
if ($process.exitcode -ne 0) {
|
||||
throw "Quiet install failed, please rerun install without -Quiet switch or ensure you have administrator rights"
|
||||
}
|
||||
} finally {
|
||||
# Restore original value
|
||||
[Net.ServicePointManager]::SecurityProtocol = $originalValue
|
||||
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
# about_update_notifications
|
||||
# While the update check happens during the first session in a given 24-hour period, for performance reasons,
|
||||
# the notification will only be shown on the start of subsequent sessions.
|
||||
# Also for performance reasons, the check will not start until at least 3 seconds after the session begins.
|
||||
[System.Environment]::SetEnvironmentVariable("POWERSHELL_UPDATECHECK", "Off", [System.EnvironmentVariableTarget]::Machine)
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "PowerShell Core"
|
||||
124
images/windows/scripts/build/Install-PyPy.ps1
Normal file
124
images/windows/scripts/build/Install-PyPy.ps1
Normal file
@@ -0,0 +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
|
||||
}
|
||||
}
|
||||
11
images/windows/scripts/build/Install-R.ps1
Normal file
11
images/windows/scripts/build/Install-R.ps1
Normal file
@@ -0,0 +1,11 @@
|
||||
################################################################################
|
||||
## File: Install-R.ps1
|
||||
## Desc: Install R for Windows
|
||||
################################################################################
|
||||
|
||||
Choco-Install R.Project
|
||||
Choco-Install rtools
|
||||
|
||||
$rscriptPath = Resolve-Path "C:\Program Files\R\*\bin\x64"
|
||||
Add-MachinePathItem $rscriptPath
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "R"
|
||||
148
images/windows/scripts/build/Install-RootCA.ps1
Normal file
148
images/windows/scripts/build/Install-RootCA.ps1
Normal file
@@ -0,0 +1,148 @@
|
||||
# https://www.sysadmins.lv/blog-en/how-to-retrieve-certificate-purposes-property-with-cryptoapi-and-powershell.aspx
|
||||
# https://www.sysadmins.lv/blog-en/dump-authroot-and-disallowed-certificates-with-powershell.aspx
|
||||
# https://www.sysadmins.lv/blog-en/constraining-extended-key-usages-in-microsoft-windows.aspx
|
||||
|
||||
function Add-ExtendedCertType {
|
||||
$signature = @"
|
||||
[DllImport("Crypt32.dll", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
public static extern bool CertGetCertificateContextProperty(
|
||||
IntPtr pCertContext,
|
||||
uint dwPropId,
|
||||
Byte[] pvData,
|
||||
ref uint pcbData
|
||||
);
|
||||
|
||||
[DllImport("Crypt32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern bool CertSetCertificateContextProperty(
|
||||
IntPtr pCertContext,
|
||||
int dwPropId,
|
||||
uint dwFlags,
|
||||
IntPtr pvData
|
||||
);
|
||||
"@
|
||||
|
||||
Add-Type -MemberDefinition $signature -Namespace PKI -Name Cert
|
||||
}
|
||||
|
||||
function Get-CertificatesWithoutPropId {
|
||||
# List installed certificates
|
||||
$certs = Get-ChildItem -Path Cert:\LocalMachine\Root
|
||||
|
||||
Write-Host "Certificates without CERT_NOT_BEFORE_FILETIME_PROP_ID property"
|
||||
$certsWithoutPropId = @{}
|
||||
$certs | ForEach-Object -Process {
|
||||
$certHandle = $_.Handle
|
||||
$isPropertySet = [PKI.Cert]::CertGetCertificateContextProperty(
|
||||
$certHandle, $CERT_NOT_BEFORE_FILETIME_PROP_ID, $null, [ref]$null
|
||||
)
|
||||
if (-not $isPropertySet) {
|
||||
Write-Host "Subject: $($_.Subject)"
|
||||
$certsWithoutPropId[$_.Thumbprint] = $null
|
||||
}
|
||||
}
|
||||
$certsWithoutPropId
|
||||
}
|
||||
|
||||
function Invoke-WithRetry {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Runs $command block until $BreakCondition or $RetryCount is reached.
|
||||
#>
|
||||
|
||||
param([ScriptBlock]$Command, [ScriptBlock] $BreakCondition, [int] $RetryCount=5, [int] $Sleep=10)
|
||||
|
||||
$c = 0
|
||||
while($c -lt $RetryCount){
|
||||
$result = & $Command
|
||||
if(& $BreakCondition){
|
||||
break
|
||||
}
|
||||
Start-Sleep $Sleep
|
||||
$c++
|
||||
}
|
||||
$result
|
||||
}
|
||||
|
||||
function Import-SSTFromWU {
|
||||
# Serialized Certificate Store File
|
||||
$sstFile = "$env:TEMP\roots.sst"
|
||||
# Generate SST from Windows Update
|
||||
$result = Invoke-WithRetry { certutil.exe -generateSSTFromWU $sstFile } {$LASTEXITCODE -eq 0}
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "[Error]: failed to generate $sstFile sst file`n$result"
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
$result = certutil.exe -dump $sstFile
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "[Error]: failed to dump $sstFile sst file`n$result"
|
||||
exit $LASTEXITCODE
|
||||
}
|
||||
|
||||
try {
|
||||
Import-Certificate -FilePath $sstFile -CertStoreLocation Cert:\LocalMachine\Root
|
||||
} catch {
|
||||
Write-Host "[Error]: failed to import ROOT CA`n$_"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Clear-CertificatesPropId {
|
||||
param([hashtable]$CertsWithoutPropId)
|
||||
|
||||
# List installed certificates
|
||||
$certs = Get-ChildItem -Path Cert:\LocalMachine\Root
|
||||
|
||||
# Clear property CERT_NOT_BEFORE_FILETIME_PROP_ID
|
||||
$certs | ForEach-Object -Process {
|
||||
$thumbprint = $_.Thumbprint
|
||||
if ($certsWithoutPropId.ContainsKey($thumbprint)) {
|
||||
$subject = $_.Subject
|
||||
$certHandle = $_.Handle
|
||||
$result = [PKI.Cert]::CertSetCertificateContextProperty(
|
||||
$certHandle, $CERT_NOT_BEFORE_FILETIME_PROP_ID, 0, [System.IntPtr]::Zero
|
||||
)
|
||||
if ($result) {
|
||||
Write-Host "[Success] Clear CERT_NOT_BEFORE_FILETIME_PROP_ID property $subject"
|
||||
} else {
|
||||
Write-Host "[Fail] Clear CERT_NOT_BEFORE_FILETIME_PROP_ID property $subject"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Disable-RootAutoUpdate {
|
||||
Write-Host "Disable auto root update mechanism"
|
||||
$regPath = "HKLM:\Software\Policies\Microsoft\SystemCertificates\AuthRoot"
|
||||
$regKey = "DisableRootAutoUpdate"
|
||||
|
||||
# Create the registry key if it doesn't exist
|
||||
if (-not (Test-Path $regPath)) {
|
||||
Write-Verbose "Creating $regPath"
|
||||
New-Item $regPath | Out-Null
|
||||
}
|
||||
|
||||
Set-ItemProperty $regPath -Name $regKey -Type DWord -Value 1
|
||||
}
|
||||
|
||||
# Property to remove
|
||||
$CERT_NOT_BEFORE_FILETIME_PROP_ID = 126
|
||||
|
||||
# Add extended cert type
|
||||
Add-ExtendedCertType
|
||||
|
||||
# Get certificates without property CERT_NOT_BEFORE_FILETIME_PROP_ID
|
||||
$certsWithoutPropId = Get-CertificatesWithoutPropId
|
||||
|
||||
# Download and install the latest version of root ca list
|
||||
Import-SSTFromWU
|
||||
|
||||
# Clear property CERT_NOT_BEFORE_FILETIME_PROP_ID
|
||||
if ($certsWithoutPropId.Count -gt 0) {
|
||||
Clear-CertificatesPropId -CertsWithoutPropId $certsWithoutPropId
|
||||
} else {
|
||||
Write-Host "Nothing to clear"
|
||||
}
|
||||
|
||||
# Disable auto root update mechanism
|
||||
Disable-RootAutoUpdate
|
||||
130
images/windows/scripts/build/Install-Ruby.ps1
Normal file
130
images/windows/scripts/build/Install-Ruby.ps1
Normal file
@@ -0,0 +1,130 @@
|
||||
################################################################################
|
||||
## File: Install-Ruby.ps1
|
||||
## Desc: Install rubyinstaller2
|
||||
################################################################################
|
||||
|
||||
function Get-RubyVersions
|
||||
{
|
||||
param (
|
||||
[System.String] $Arch = "x64",
|
||||
[System.String] $Extension = "7z",
|
||||
[System.String] $ReleasesAmount = "50"
|
||||
)
|
||||
|
||||
$uri = "https://api.github.com/repos/oneclick/rubyinstaller2/releases?per_page=$ReleasesAmount"
|
||||
try
|
||||
{
|
||||
$versionLists = @{}
|
||||
$assets = (Invoke-RestMethod -Uri $uri).Where{ -not $_.prerelease }.assets
|
||||
$7zArchives = $assets.Where{ $_.name.EndsWith("$Arch.$Extension") }
|
||||
$majorMinorGroups = $7zArchives | Group-Object { $_.name.Replace("rubyinstaller-", "").Substring(0, 3) }
|
||||
foreach($majorMinorGroup in $majorMinorGroups)
|
||||
{
|
||||
$group = $majorMinorGroup.Group
|
||||
$sortVersions = $group | Sort-Object {[Version]$_.name.Replace("rubyinstaller-", "").Replace("-$Arch.$Extension","").Replace("-",".")}
|
||||
$latestVersion = $sortVersions | Select-Object -Last 1
|
||||
$versionLists[$majorMinorGroup.Name] = $latestVersion.browser_download_url
|
||||
|
||||
}
|
||||
return $versionLists
|
||||
}
|
||||
catch
|
||||
{
|
||||
Write-Host "Unable to send request to the '$uri'. Error: '$_'"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
# Most of this logic is from
|
||||
# https://github.com/ruby/setup-ruby/blob/master/windows.js
|
||||
function Install-Ruby
|
||||
{
|
||||
param(
|
||||
[String]$PackagePath,
|
||||
[String]$Architecture = "x64"
|
||||
)
|
||||
|
||||
# Create Ruby toolcache folder
|
||||
$rubyToolcachePath = Join-Path -Path $env:AGENT_TOOLSDIRECTORY -ChildPath "Ruby"
|
||||
if (-not (Test-Path $rubyToolcachePath))
|
||||
{
|
||||
Write-Host "Creating Ruby toolcache folder"
|
||||
New-Item -ItemType Directory -Path $rubyToolcachePath | Out-Null
|
||||
}
|
||||
|
||||
# Expand archive with binaries
|
||||
$packageName = [IO.Path]::GetFileNameWithoutExtension((Split-Path -Path $PackagePath -Leaf))
|
||||
$tempFolder = Join-Path -Path $rubyToolcachePath -ChildPath $packageName
|
||||
Extract-7Zip -Path $PackagePath -DestinationPath $rubyToolcachePath
|
||||
|
||||
# Get Ruby version from binaries
|
||||
$rubyVersion = & "$tempFolder\bin\ruby.exe" -e "print RUBY_VERSION"
|
||||
|
||||
if ($rubyVersion)
|
||||
{
|
||||
Write-Host "Installing Ruby $rubyVersion"
|
||||
$rubyVersionPath = Join-Path -Path $rubyToolcachePath -ChildPath $rubyVersion
|
||||
$rubyArchPath = Join-Path -Path $rubyVersionPath -ChildPath $Architecture
|
||||
|
||||
Write-Host "Creating Ruby '${rubyVersion}' folder in '${rubyVersionPath}'"
|
||||
New-Item -ItemType Directory -Path $rubyVersionPath -Force | Out-Null
|
||||
|
||||
Write-Host "Moving Ruby '${rubyVersion}' files to '${rubyArchPath}'"
|
||||
Invoke-SBWithRetry -Command {
|
||||
Move-Item -Path $tempFolder -Destination $rubyArchPath -ErrorAction Stop | Out-Null
|
||||
}
|
||||
|
||||
Write-Host "Removing Ruby '${rubyVersion}' documentation '${rubyArchPath}\share\doc' folder"
|
||||
Remove-Item -Path "${rubyArchPath}\share\doc" -Force -Recurse -ErrorAction Ignore
|
||||
|
||||
Write-Host "Creating complete file"
|
||||
New-Item -ItemType File -Path $rubyVersionPath -Name "$Architecture.complete" | Out-Null
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Ruby application is not found. Failed to expand '$PackagePath' archive"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
function Set-DefaultRubyVersion
|
||||
{
|
||||
param(
|
||||
[Parameter(Mandatory=$true)]
|
||||
[System.Version] $Version,
|
||||
[System.String] $Arch = "x64"
|
||||
)
|
||||
|
||||
$rubyPath = Join-Path $env:AGENT_TOOLSDIRECTORY "/Ruby/${Version}*/${Arch}/bin"
|
||||
$rubyDir = (Get-Item -Path $rubyPath).FullName
|
||||
|
||||
Write-Host "Use Ruby ${Version} as a system Ruby"
|
||||
Add-MachinePathItem -PathItem $rubyDir | Out-Null
|
||||
}
|
||||
|
||||
# Install Ruby
|
||||
$rubyTools = (Get-ToolsetContent).toolcache | Where-Object { $_.name -eq "Ruby" }
|
||||
$rubyToolVersions = $rubyTools.versions
|
||||
|
||||
# Get Ruby versions from the repo
|
||||
$rubyLatestMajorVersions = Get-RubyVersions
|
||||
|
||||
Write-Host "Starting installation Ruby..."
|
||||
foreach($rubyVersion in $rubyToolVersions)
|
||||
{
|
||||
Write-Host "Starting Ruby $rubyVersion installation"
|
||||
# Get url for the latest major Ruby version
|
||||
$url = $rubyLatestMajorVersions[$rubyVersion]
|
||||
if ($url)
|
||||
{
|
||||
$tempRubyPackagePath = Start-DownloadWithRetry -Url $url
|
||||
Install-Ruby -PackagePath $tempRubyPackagePath
|
||||
}
|
||||
else
|
||||
{
|
||||
Write-Host "Url not found for the '$rubyVersion' version"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Set-DefaultRubyVersion -Version $rubyTools.default -Arch $rubyTools.arch
|
||||
14
images/windows/scripts/build/Install-Runner.ps1
Normal file
14
images/windows/scripts/build/Install-Runner.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
################################################################################
|
||||
## File: Install-Runner.ps1
|
||||
## Desc: Install Runner for GitHub Actions
|
||||
## Supply chain security: none
|
||||
################################################################################
|
||||
|
||||
Write-Host "Download latest Runner for GitHub Actions"
|
||||
$release = Invoke-RestMethod -Uri "https://api.github.com/repos/actions/runner/releases/latest"
|
||||
$version = $release.tag_name.Trim("v")
|
||||
$downloadUrl = ($release.assets.browser_download_url -ilike "*actions-runner-win-x64-${version}.zip*") | Select-Object -First 1
|
||||
New-Item -Path "C:\ProgramData\runner" -ItemType Directory
|
||||
$packagePath = Start-DownloadWithRetry -Url $downloadUrl -DownloadPath "C:\ProgramData\runner"
|
||||
|
||||
Invoke-PesterTests -TestFile "RunnerCache"
|
||||
43
images/windows/scripts/build/Install-Rust.ps1
Normal file
43
images/windows/scripts/build/Install-Rust.ps1
Normal file
@@ -0,0 +1,43 @@
|
||||
################################################################################
|
||||
## File: Install-Rust.ps1
|
||||
## Desc: Install Rust for Windows
|
||||
## Supply chain security: checksum validation for bootstrap, managed by rustup for workloads
|
||||
################################################################################
|
||||
|
||||
# Rust Env
|
||||
$env:RUSTUP_HOME = "C:\Users\Default\.rustup"
|
||||
$env:CARGO_HOME = "C:\Users\Default\.cargo"
|
||||
|
||||
# Download the latest rustup-init.exe for Windows x64
|
||||
# See https://rustup.rs/#
|
||||
$rustupPath = Start-DownloadWithRetry -Url "https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe" -Name "rustup-init.exe"
|
||||
|
||||
#region Supply chain security
|
||||
$localFileHash = (Get-FileHash -Path (Join-Path ${env:TEMP} 'rustup-init.exe') -Algorithm SHA256).Hash
|
||||
$distributorFileHash = (Invoke-RestMethod -Uri 'https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe.sha256').Trim()
|
||||
|
||||
Use-ChecksumComparison -LocalFileHash $localFileHash -DistributorFileHash $distributorFileHash
|
||||
#endregion
|
||||
|
||||
# Install Rust by running rustup-init.exe (disabling the confirmation prompt with -y)
|
||||
& $rustupPath -y --default-toolchain=stable --profile=minimal
|
||||
|
||||
# Add %USERPROFILE%\.cargo\bin to USER PATH
|
||||
Add-DefaultPathItem "%USERPROFILE%\.cargo\bin"
|
||||
# Add Rust binaries to the path
|
||||
$env:Path += ";$env:CARGO_HOME\bin"
|
||||
|
||||
# Add i686 target for building 32-bit binaries
|
||||
rustup target add i686-pc-windows-msvc
|
||||
|
||||
# Add target for building mingw-w64 binaries
|
||||
rustup target add x86_64-pc-windows-gnu
|
||||
|
||||
# Install common tools
|
||||
rustup component add rustfmt clippy
|
||||
cargo install --locked bindgen-cli cbindgen cargo-audit cargo-outdated
|
||||
|
||||
# Cleanup Cargo crates cache
|
||||
Remove-Item "${env:CARGO_HOME}\registry\*" -Recurse -Force
|
||||
|
||||
Invoke-PesterTests -TestFile "Rust"
|
||||
9
images/windows/scripts/build/Install-SQLOLEDBDriver.ps1
Normal file
9
images/windows/scripts/build/Install-SQLOLEDBDriver.ps1
Normal file
@@ -0,0 +1,9 @@
|
||||
################################################################################
|
||||
## File: Install-SQLOLEDBDriver.ps1
|
||||
## Desc: Install SQL OLEDB Driver
|
||||
################################################################################
|
||||
|
||||
$binaryDownloadPath = Start-DownloadWithRetry "https://go.microsoft.com/fwlink/?linkid=2242656" "msoledbsql.msi"
|
||||
$binarySignatureThumbprint = "6E78B3DCE2998F6C2457C3E54DA90A01034916AE"
|
||||
$ArgumentList = ("/i", "$binaryDownloadPath", "ADDLOCAL=ALL", "IACCEPTMSOLEDBSQLLICENSETERMS=YES", "/qn")
|
||||
Install-Binary -FilePath $binaryDownloadPath -ArgumentList $ArgumentList -ExpectedSignature $binarySignatureThumbprint
|
||||
20
images/windows/scripts/build/Install-SQLPowerShellTools.ps1
Normal file
20
images/windows/scripts/build/Install-SQLPowerShellTools.ps1
Normal file
@@ -0,0 +1,20 @@
|
||||
################################################################################
|
||||
## File: Install-SQLPowerShellTools.ps1
|
||||
## Desc: Install SQL PowerShell tool
|
||||
################################################################################
|
||||
|
||||
$BaseUrl = "https://download.microsoft.com/download/B/1/7/B1783FE9-717B-4F78-A39A-A2E27E3D679D/ENU/x64"
|
||||
$SignatureThumbrint = "9ACA9419E53D3C9E56396DD2335FF683A8B0B8F3"
|
||||
|
||||
# install required MSIs
|
||||
$SQLSysClrTypesName = "SQLSysClrTypes.msi"
|
||||
$SQLSysClrTypesUrl = "${BaseUrl}/${SQLSysClrTypesName}"
|
||||
Install-Binary -Url $SQLSysClrTypesUrl -Name $SQLSysClrTypesName -ExpectedSignature $SignatureThumbrint
|
||||
|
||||
$SharedManagementObjectsName = "SharedManagementObjects.msi"
|
||||
$SharedManagementObjectsUrl = "${BaseUrl}/${SharedManagementObjectsName}"
|
||||
Install-Binary -Url $SharedManagementObjectsUrl -Name $SharedManagementObjectsName -ExpectedSignature $SignatureThumbrint
|
||||
|
||||
$PowerShellToolsName = "PowerShellTools.msi"
|
||||
$PowerShellToolsUrl = "${BaseUrl}/${PowerShellToolsName}"
|
||||
Install-Binary -Url $PowerShellToolsUrl -Name $PowerShellToolsName -ExpectedSignature $SignatureThumbrint
|
||||
15
images/windows/scripts/build/Install-Sbt.ps1
Normal file
15
images/windows/scripts/build/Install-Sbt.ps1
Normal file
@@ -0,0 +1,15 @@
|
||||
################################################################################
|
||||
## File: Install-Sbt.ps1
|
||||
## Desc: Install sbt for Windows
|
||||
################################################################################
|
||||
|
||||
# Install the latest version of sbt.
|
||||
# See https://chocolatey.org/packages/sbt
|
||||
Choco-Install -PackageName sbt
|
||||
|
||||
$env:SBT_HOME="${env:ProgramFiles(x86)}\sbt"
|
||||
|
||||
# Add sbt binaries to the path
|
||||
Add-MachinePathItem "$env:SBT_HOME\bin"
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Sbt"
|
||||
32
images/windows/scripts/build/Install-Selenium.ps1
Normal file
32
images/windows/scripts/build/Install-Selenium.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
################################################################################
|
||||
## File: Install-Selenium.ps1
|
||||
## Desc: Install Selenium Server standalone
|
||||
################################################################################
|
||||
|
||||
# Create Selenium directory
|
||||
$seleniumDirectory = "C:\selenium\"
|
||||
New-Item -ItemType directory -Path $seleniumDirectory
|
||||
|
||||
# Download Selenium
|
||||
$seleniumMajorVersion = (Get-ToolsetContent).selenium.version
|
||||
$seleniumBinaryName = (Get-ToolsetContent).selenium.binary_name
|
||||
$seleniumFileName = "$seleniumBinaryName.jar"
|
||||
|
||||
$seleniumDownloadUrl = Get-GitHubPackageDownloadUrl `
|
||||
-RepoOwner "SeleniumHQ" `
|
||||
-RepoName "selenium" `
|
||||
-BinaryName "$seleniumBinaryName" `
|
||||
-Version $seleniumMajorVersion `
|
||||
-UrlFilter "*{BinaryName}-{Version}.jar"
|
||||
|
||||
Start-DownloadWithRetry -Url $seleniumDownloadUrl -Name $seleniumFileName -DownloadPath $seleniumDirectory
|
||||
|
||||
# Create an empty file to retrive Selenium version
|
||||
$seleniumFullVersion = $seleniumDownloadUrl.Split("-")[1].Split("/")[0]
|
||||
New-Item -Path $seleniumDirectory -Name "$seleniumBinaryName-$seleniumFullVersion"
|
||||
|
||||
# Add SELENIUM_JAR_PATH environment variable
|
||||
$seleniumBinPath = Join-Path $seleniumDirectory $seleniumFileName
|
||||
setx "SELENIUM_JAR_PATH" "$($seleniumBinPath)" /M
|
||||
|
||||
Invoke-PesterTests -TestFile "Browsers" -TestName "Selenium"
|
||||
25
images/windows/scripts/build/Install-ServiceFabricSDK.ps1
Normal file
25
images/windows/scripts/build/Install-ServiceFabricSDK.ps1
Normal file
@@ -0,0 +1,25 @@
|
||||
################################################################################
|
||||
## File: Install-ServiceFabricSDK.ps1
|
||||
## Desc: Install webpicmd and then the service fabric sdk
|
||||
## must be install after Visual Studio
|
||||
################################################################################
|
||||
|
||||
# Creating 'Installer' cache folder if it doesn't exist
|
||||
New-Item -Path 'C:\Windows\Installer' -ItemType Directory -Force
|
||||
|
||||
# Get Service Fabric components versions
|
||||
$serviceFabricRuntimeVersion = (Get-ToolsetContent).serviceFabric.runtime.version
|
||||
$serviceFabricSDKVersion = (Get-ToolsetContent).serviceFabric.sdk.version
|
||||
|
||||
# Install Service Fabric Runtime for Windows
|
||||
$InstallerName = "MicrosoftServiceFabric.${serviceFabricRuntimeVersion}.exe"
|
||||
$InstallerUrl = "https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/${InstallerName}"
|
||||
$ArgumentList = ("/accepteula ","/quiet","/force")
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ArgumentList $ArgumentList -ExpectedSignature (Get-ToolsetContent).serviceFabric.runtime.signature
|
||||
|
||||
# Install Service Fabric SDK
|
||||
$InstallerName = "MicrosoftServiceFabricSDK.${serviceFabricSDKVersion}.msi"
|
||||
$InstallerUrl = "https://download.microsoft.com/download/b/8/a/b8a2fb98-0ec1-41e5-be98-9d8b5abf7856/${InstallerName}"
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ExpectedSignature (Get-ToolsetContent).serviceFabric.sdk.signature
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "ServiceFabricSDK"
|
||||
32
images/windows/scripts/build/Install-Stack.ps1
Normal file
32
images/windows/scripts/build/Install-Stack.ps1
Normal file
@@ -0,0 +1,32 @@
|
||||
################################################################################
|
||||
## File: Install-Stack.ps1
|
||||
## Desc: Install Stack for Windows
|
||||
## Supply chain security: Stack - checksum validation
|
||||
################################################################################
|
||||
|
||||
Write-Host "Get the latest Stack version..."
|
||||
$StackReleasesJson = Invoke-RestMethod "https://api.github.com/repos/commercialhaskell/stack/releases/latest"
|
||||
$Version = $StackReleasesJson.name.TrimStart("v")
|
||||
$DownloadFilePattern = "windows-x86_64.zip"
|
||||
$DownloadUrl = $StackReleasesJson.assets | Where-Object { $_.name.EndsWith($DownloadFilePattern) } | Select-Object -ExpandProperty "browser_download_url" -First 1
|
||||
|
||||
Write-Host "Download stack archive"
|
||||
$StackToolcachePath = Join-Path $Env:AGENT_TOOLSDIRECTORY "stack\$Version"
|
||||
$DestinationPath = Join-Path $StackToolcachePath "x64"
|
||||
$StackArchivePath = Start-DownloadWithRetry -Url $DownloadUrl
|
||||
|
||||
#region Supply chain security - Stack
|
||||
$fileHash = (Get-FileHash -Path $StackArchivePath -Algorithm SHA256).Hash
|
||||
$hashUrl = $StackReleasesJson.assets | Where-Object { $_.name.EndsWith("$DownloadFilePattern.sha256") } | Select-Object -ExpandProperty "browser_download_url" -First 1
|
||||
$externalHash = (Invoke-RestMethod -Uri $hashURL).ToString().Split("`n").Where({ $_ -ilike "*$DownloadFilePattern*" }).Split(' ')[0]
|
||||
Use-ChecksumComparison $fileHash $externalHash
|
||||
#endregion
|
||||
|
||||
Write-Host "Expand stack archive"
|
||||
Extract-7Zip -Path $StackArchivePath -DestinationPath $DestinationPath
|
||||
|
||||
New-Item -Name "x64.complete" -Path $StackToolcachePath
|
||||
|
||||
Add-MachinePathItem -PathItem $DestinationPath
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Stack"
|
||||
58
images/windows/scripts/build/Install-Toolset.ps1
Normal file
58
images/windows/scripts/build/Install-Toolset.ps1
Normal file
@@ -0,0 +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
|
||||
}
|
||||
}
|
||||
}
|
||||
16
images/windows/scripts/build/Install-VCRedist.ps1
Normal file
16
images/windows/scripts/build/Install-VCRedist.ps1
Normal file
@@ -0,0 +1,16 @@
|
||||
################################################################################
|
||||
## File: Install-VCRedist.ps1
|
||||
## Desc: Install Visual C++ Redistributable
|
||||
################################################################################
|
||||
|
||||
$vc2010x86Name = "vcredist_x86.exe"
|
||||
$vc2010x86URI = "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/${vc2010x86Name}"
|
||||
$vc2010x64Name = "vcredist_x64.exe"
|
||||
$vc2010x64URI = "https://download.microsoft.com/download/1/6/5/165255E7-1014-4D0A-B094-B6A430A6BFFC/${Vc2010x64Name}"
|
||||
$argumentList = ("/install", "/quiet", "/norestart")
|
||||
$vcSignatureThumbprint = "ABDCA79AF9DD48A0EA702AD45260B3C03093FB4B"
|
||||
|
||||
Install-Binary -Url $vc2010x86URI -Name $vc2010x86Name -ArgumentList $argumentList -ExpectedSignature $vcSignatureThumbprint
|
||||
Install-Binary -Url $vc2010x64URI -Name $vc2010x64Name -ArgumentList $argumentList -ExpectedSignature $vcSignatureThumbprint
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "VCRedist"
|
||||
59
images/windows/scripts/build/Install-VS.ps1
Normal file
59
images/windows/scripts/build/Install-VS.ps1
Normal file
@@ -0,0 +1,59 @@
|
||||
################################################################################
|
||||
## File: Install-VS.ps1
|
||||
## Desc: Install Visual Studio
|
||||
################################################################################
|
||||
|
||||
$toolset = Get-ToolsetContent
|
||||
|
||||
# Install VS
|
||||
Install-VisualStudio `
|
||||
-Version $toolset.visualStudio.subversion `
|
||||
-Edition $toolset.visualStudio.edition `
|
||||
-Channel $toolset.visualStudio.channel `
|
||||
-RequiredComponents $toolset.visualStudio.workloads `
|
||||
-ExtraArgs "--allWorkloads --includeRecommended --remove Component.CPython3.x64" `
|
||||
-SignatureThumbprint $toolset.visualStudio.signature
|
||||
|
||||
# Find the version of VS installed for this instance
|
||||
# Only supports a single instance
|
||||
$vsProgramData = Get-Item -Path "C:\ProgramData\Microsoft\VisualStudio\Packages\_Instances"
|
||||
$instanceFolders = Get-ChildItem -Path $vsProgramData.FullName
|
||||
|
||||
if ($instanceFolders -is [array])
|
||||
{
|
||||
Write-Host "More than one instance installed"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Updating content of MachineState.json file to disable autoupdate of VSIX extensions
|
||||
$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath
|
||||
$newContent = '{"Extensions":[{"Key":"1e906ff5-9da8-4091-a299-5c253c55fdc9","Value":{"ShouldAutoUpdate":false}},{"Key":"Microsoft.VisualStudio.Web.AzureFunctions","Value":{"ShouldAutoUpdate":false}}],"ShouldAutoUpdate":false,"ShouldCheckForUpdates":false}'
|
||||
Set-Content -Path "$vsInstallRoot\Common7\IDE\Extensions\MachineState.json" -Value $newContent
|
||||
|
||||
if (Test-IsWin19) {
|
||||
|
||||
# Install Windows 10 SDK version 10.0.14393.795
|
||||
$sdkSignatureThumbprint = "C91545B333C52C4465DE8B90A3FAF4E1D9C58DFA"
|
||||
$sdkUrl = "https://go.microsoft.com/fwlink/p/?LinkId=838916"
|
||||
$sdkFileName = "sdksetup14393.exe"
|
||||
$argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit")
|
||||
Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList -ExpectedSignature $sdkSignatureThumbprint
|
||||
|
||||
# Install Windows 11 SDK version 10.0.22621.0
|
||||
$sdkSignatureThumbprint = "E4C5C5FCDB68B930EE4E19BC25D431EF6D864C51"
|
||||
$sdkUrl = "https://go.microsoft.com/fwlink/p/?linkid=2196241"
|
||||
$sdkFileName = "sdksetup22621.exe"
|
||||
$argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64")
|
||||
Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList -ExpectedSignature $sdkSignatureThumbprint
|
||||
}
|
||||
|
||||
if (Test-IsWin22) {
|
||||
# Install Windows 10 SDK version 10.0.17763
|
||||
$sdkSignatureThumbprint = "7535269B94C1FEA4A5EF6D808E371DA242F27936"
|
||||
$sdkUrl = "https://go.microsoft.com/fwlink/p/?LinkID=2033908"
|
||||
$sdkFileName = "sdksetup17763.exe"
|
||||
$argumentList = ("/q", "/norestart", "/ceip off", "/features OptionId.UWPManaged OptionId.UWPCPP OptionId.UWPLocalized OptionId.DesktopCPPx86 OptionId.DesktopCPPx64 OptionId.DesktopCPParm64")
|
||||
Install-Binary -Url $sdkUrl -Name $sdkFileName -ArgumentList $argumentList -ExpectedSignature $sdkSignatureThumbprint
|
||||
}
|
||||
|
||||
Invoke-PesterTests -TestFile "VisualStudio"
|
||||
21
images/windows/scripts/build/Install-Vcpkg.ps1
Normal file
21
images/windows/scripts/build/Install-Vcpkg.ps1
Normal file
@@ -0,0 +1,21 @@
|
||||
################################################################################
|
||||
## File: Install-Vcpkg.ps1
|
||||
## Desc: Install vcpkg
|
||||
################################################################################
|
||||
|
||||
$Uri = 'https://github.com/Microsoft/vcpkg.git'
|
||||
$InstallDir = 'C:\vcpkg'
|
||||
$VcpkgExecPath = 'vcpkg.exe'
|
||||
|
||||
git clone $Uri $InstallDir -q
|
||||
|
||||
# Build and integrate vcpkg
|
||||
Invoke-Expression "$InstallDir\bootstrap-vcpkg.bat"
|
||||
Invoke-Expression "$InstallDir\$VcpkgExecPath integrate install"
|
||||
|
||||
# Add vcpkg to system environment
|
||||
Add-MachinePathItem $InstallDir
|
||||
$env:Path = Get-MachinePath
|
||||
setx VCPKG_INSTALLATION_ROOT $InstallDir /M
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Vcpkg"
|
||||
24
images/windows/scripts/build/Install-Vsix.ps1
Normal file
24
images/windows/scripts/build/Install-Vsix.ps1
Normal file
@@ -0,0 +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
|
||||
}
|
||||
}
|
||||
|
||||
Invoke-PesterTests -TestFile "Vsix"
|
||||
36
images/windows/scripts/build/Install-WDK.ps1
Normal file
36
images/windows/scripts/build/Install-WDK.ps1
Normal file
@@ -0,0 +1,36 @@
|
||||
################################################################################
|
||||
## File: Install-WDK.ps1
|
||||
## Desc: Install the Windows Driver Kit
|
||||
################################################################################
|
||||
|
||||
# Requires Windows SDK with the same version number as the WDK
|
||||
if (Test-IsWin22) {
|
||||
# SDK available through Visual Studio
|
||||
$wdkUrl = "https://go.microsoft.com/fwlink/?linkid=2196230"
|
||||
$FilePath = "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2022\*\WDK.vsix"
|
||||
$wdkSignatureThumbprint = "DE2396BCEB7E3CD13BF3D370424A560F97CABDE7"
|
||||
} elseif (Test-IsWin19) {
|
||||
$winSdkUrl = "https://go.microsoft.com/fwlink/?linkid=2173743"
|
||||
$wdkUrl = "https://go.microsoft.com/fwlink/?linkid=2166289"
|
||||
$FilePath = "C:\Program Files (x86)\Windows Kits\10\Vsix\VS2019\WDK.vsix"
|
||||
$wdkSignatureThumbprint = "914A09C2E02C696AF394048BCB8D95449BCD5B9E"
|
||||
$winSdkSignatureThumbprint = "44796EB5BD439B4BFB078E1DC2F8345AE313CBB1"
|
||||
} else {
|
||||
throw "Invalid version of Visual Studio is found. Either 2019 or 2022 are required"
|
||||
}
|
||||
|
||||
$argumentList = ("/features", "+", "/quiet")
|
||||
|
||||
if (Test-IsWin19) {
|
||||
# `winsdksetup.exe /features + /quiet` installs all features without showing the GUI
|
||||
Install-Binary -Url $winSdkUrl -Name "winsdksetup.exe" -ArgumentList $argumentList -ExpectedSignature $winSdkSignatureThumbprint
|
||||
}
|
||||
|
||||
# `wdksetup.exe /features + /quiet` installs all features without showing the GUI
|
||||
Install-Binary -Url $wdkUrl -Name "wdksetup.exe" -ArgumentList $argumentList -ExpectedSignature $wdkSignatureThumbprint
|
||||
|
||||
# Need to install the VSIX to get the build targets when running VSBuild
|
||||
$FilePath = Resolve-Path -Path $FilePath
|
||||
Install-VsixExtension -FilePath $FilePath -Name "WDK.vsix" -InstallOnly
|
||||
|
||||
Invoke-PesterTests -TestFile "WDK"
|
||||
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
## File: Install-WebPI.ps1
|
||||
## Desc: Install WebPlatformInstaller
|
||||
################################################################################
|
||||
|
||||
# Download and install WebPlatformInstaller
|
||||
$webPlatformInstallerFile = "WebPlatformInstaller_x64_en-US.msi"
|
||||
$webPlatformInstallerUrl = "http://go.microsoft.com/fwlink/?LinkId=287166"
|
||||
$webPlatformInstallerSignatureThumbprint = "C3A3D43788E7ABCD287CB4F5B6583043774F99D2"
|
||||
Install-Binary -Url $webPlatformInstallerUrl -Name $webPlatformInstallerFile -ExpectedSignature $webPlatformInstallerSignatureThumbprint
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "WebPlatformInstaller"
|
||||
14
images/windows/scripts/build/Install-WinAppDriver.ps1
Normal file
14
images/windows/scripts/build/Install-WinAppDriver.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
####################################################################################
|
||||
## File: Install-WinAppDriver.ps1
|
||||
## Desc: Install Windows Application Driver (WinAppDriver)
|
||||
####################################################################################
|
||||
|
||||
$LatestReleaseUrl = 'https://api.github.com/repos/microsoft/WinAppDriver/releases/latest'
|
||||
$InstallerUrl = (Invoke-RestMethod -Uri $LatestReleaseUrl).assets.browser_download_url
|
||||
$InstallerName = "WindowsApplicationDriver.msi"
|
||||
$InstallerSignatureThumbprint = "2485A7AFA98E178CB8F30C9838346B514AEA4769"
|
||||
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
Install-Binary -Url $InstallerUrl -Name $InstallerName -ExpectedSignature $InstallerSignatureThumbprint
|
||||
|
||||
Invoke-PesterTests -TestFile "WinAppDriver" -TestName "WinAppDriver"
|
||||
30
images/windows/scripts/build/Install-WindowsFeatures.ps1
Normal file
30
images/windows/scripts/build/Install-WindowsFeatures.ps1
Normal file
@@ -0,0 +1,30 @@
|
||||
$windowsFeatures = (Get-ToolsetContent).windowsFeatures
|
||||
|
||||
foreach ($feature in $windowsFeatures) {
|
||||
if ($feature.optionalFeature) {
|
||||
Write-Host "Activating Windows Optional Feature '$($feature.name)'..."
|
||||
Enable-WindowsOptionalFeature -Online -FeatureName $feature.name -NoRestart
|
||||
|
||||
$resultSuccess = $?
|
||||
} else {
|
||||
Write-Host "Activating Windows Feature '$($feature.name)'..."
|
||||
$Arguments = @{
|
||||
Name = $feature.name
|
||||
IncludeAllSubFeature = [System.Convert]::ToBoolean($feature.includeAllSubFeatures)
|
||||
IncludeManagementTools = [System.Convert]::ToBoolean($feature.includeManagementTools)
|
||||
}
|
||||
$result = Install-WindowsFeature @Arguments
|
||||
|
||||
$resultSuccess = $result.Success
|
||||
}
|
||||
|
||||
if ($resultSuccess) {
|
||||
Write-Host "Windows Feature '$($feature.name)' was activated successfully"
|
||||
} else {
|
||||
throw "Failed to activate Windows Feature '$($feature.name)'"
|
||||
}
|
||||
}
|
||||
|
||||
# it improves Android emulator launch on Windows Server
|
||||
# https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/manage/manage-hyper-v-scheduler-types
|
||||
bcdedit /set hypervisorschedulertype root
|
||||
39
images/windows/scripts/build/Install-WindowsUpdates.ps1
Normal file
39
images/windows/scripts/build/Install-WindowsUpdates.ps1
Normal file
@@ -0,0 +1,39 @@
|
||||
################################################################################
|
||||
## File: Install-WindowsUpdates.ps1
|
||||
## Desc: Install Windows Updates.
|
||||
## Should be run at end, just before SoftwareReport and Finalize-VM.ps1.
|
||||
################################################################################
|
||||
|
||||
function Install-WindowsUpdates {
|
||||
Write-Host "Starting wuauserv"
|
||||
Start-Service -Name wuauserv -PassThru | Out-Host
|
||||
|
||||
# Temporarily exclude Windows update KB5001148 since it throws an error.
|
||||
# The KB5001148 itself is quite old and looks like not needed (https://support.microsoft.com/en-us/topic/kb5001148-visual-studio-client-detector-utility-for-administrator-updates-ad593454-547c-43c3-b5a3-6f201ae63f03)
|
||||
Write-Host "Getting list of available windows updates"
|
||||
Get-WindowsUpdate -MicrosoftUpdate -NotKBArticleID "KB5001148" -OutVariable updates | Out-Host
|
||||
|
||||
if ( -not $updates ) {
|
||||
Write-Host "There are no windows updates to install"
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Installing windows updates"
|
||||
Get-WindowsUpdate -MicrosoftUpdate -NotKBArticleID "KB5001148" -AcceptAll -Install -IgnoreUserInput -IgnoreReboot | Out-Host
|
||||
|
||||
Write-Host "Validating windows updates installation and skip Microsoft Defender Antivirus"
|
||||
# Azure service can automatic updates AV engine(Microsoft.Azure.Security.AntimalwareSignature.AntimalwareConfiguration)
|
||||
# Get-WUHistory doesn't support Windows Server 2022
|
||||
$wuHistory = Get-WindowsUpdatesHistory | Where-Object { $_.Status -in ("Successful", "InProgress") }
|
||||
$wuFail = $updates[0] | Where-Object Title -notmatch "Microsoft Defender Antivirus" | Where-Object { -not ($wuHistory.Title -match $_.KB) }
|
||||
|
||||
if ( $wuFail ) {
|
||||
Write-Host "Windows updates failed to install: $($wuFail.KB)"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
|
||||
Install-WindowsUpdates
|
||||
|
||||
# Create complete windows update file
|
||||
New-Item -Path $env:windir -Name WindowsUpdateDone.txt -ItemType File | Out-Null
|
||||
8
images/windows/scripts/build/Install-Wix.ps1
Normal file
8
images/windows/scripts/build/Install-Wix.ps1
Normal file
@@ -0,0 +1,8 @@
|
||||
################################################################################
|
||||
## File: Install-Wix.ps1
|
||||
## Desc: Install WIX.
|
||||
################################################################################
|
||||
|
||||
Choco-Install -PackageName wixtoolset -ArgumentList "--force"
|
||||
|
||||
Invoke-PesterTests -TestFile "Wix"
|
||||
28
images/windows/scripts/build/Install-Zstd.ps1
Normal file
28
images/windows/scripts/build/Install-Zstd.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
################################################################################
|
||||
## File: Install-zstd.ps1
|
||||
## Desc: Install zstd
|
||||
################################################################################
|
||||
|
||||
$url = "https://api.github.com/repos/facebook/zstd/releases/latest"
|
||||
# Explicitly set type to string since match returns array by default
|
||||
[System.String] $zstdLatest = (Invoke-RestMethod -Uri $url).assets.browser_download_url -match "zstd-.+-win64.zip$"
|
||||
$zstdArchivePath = Start-DownloadWithRetry -Url $zstdLatest -Name "zstd-win64.zip"
|
||||
|
||||
$toolPath = "C:\tools"
|
||||
$zstdPath = Join-Path $toolPath zstd
|
||||
$zstdParentName = [IO.Path]::GetFileNameWithoutExtension($zstdLatest)
|
||||
$filesInArchive = 7z l $zstdArchivePath | Out-String
|
||||
|
||||
if ($filesInArchive.Contains($zstdParentName)) {
|
||||
Extract-7Zip -Path $zstdArchivePath -DestinationPath $toolPath
|
||||
Invoke-SBWithRetry -Command {
|
||||
Move-Item -Path "${zstdPath}*" -Destination $zstdPath -ErrorAction Stop
|
||||
}
|
||||
} else {
|
||||
Extract-7Zip -Path $zstdArchivePath -DestinationPath $zstdPath
|
||||
}
|
||||
|
||||
# Add zstd-win64 to PATH
|
||||
Add-MachinePathItem $zstdPath
|
||||
|
||||
Invoke-PesterTests -TestFile "Tools" -TestName "Zstd"
|
||||
6
images/windows/scripts/build/Run-NGen.ps1
Normal file
6
images/windows/scripts/build/Run-NGen.ps1
Normal file
@@ -0,0 +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"
|
||||
$null = & $env:SystemRoot\Microsoft.NET\Framework\v4.0.30319\ngen.exe update
|
||||
16
images/windows/scripts/build/Update-DotnetTLS.ps1
Normal file
16
images/windows/scripts/build/Update-DotnetTLS.ps1
Normal file
@@ -0,0 +1,16 @@
|
||||
################################################################################
|
||||
## File: Update-DotnetTLS.ps1
|
||||
## Desc: Update DotNetFramework security protocol to TLS 1.2
|
||||
################################################################################
|
||||
|
||||
$registryPath = "HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319"
|
||||
$name = "SchUseStrongCrypto"
|
||||
$value = "1"
|
||||
if(Test-Path $registryPath){
|
||||
Set-ItemProperty -Path $registryPath -Name $name -Value $value -Type DWORD
|
||||
}
|
||||
|
||||
$registryPath = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319"
|
||||
if(Test-Path $registryPath){
|
||||
Set-ItemProperty -Path $registryPath -Name $name -Value $value -Type DWORD
|
||||
}
|
||||
45
images/windows/scripts/build/Update-ImageData.ps1
Normal file
45
images/windows/scripts/build/Update-ImageData.ps1
Normal file
@@ -0,0 +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/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
|
||||
@@ -0,0 +1,12 @@
|
||||
################################################################################
|
||||
## File: Wait-WindowsUpdatesForInstall.ps1
|
||||
## Desc: Wait for installation windows updates to complete
|
||||
################################################################################
|
||||
|
||||
Invoke-SBWithRetry -RetryCount 10 -RetryIntervalSeconds 120 -Command {
|
||||
$inProgress = Get-WindowsUpdatesHistory | Where-Object Status -eq "InProgress" | Where-Object Title -notmatch "Microsoft Defender Antivirus"
|
||||
if ( $inProgress ) {
|
||||
$title = $inProgress.Title -join "`n"
|
||||
throw "InProgress: $title"
|
||||
}
|
||||
}
|
||||
34
images/windows/scripts/build/Warmup-User.ps1
Normal file
34
images/windows/scripts/build/Warmup-User.ps1
Normal file
@@ -0,0 +1,34 @@
|
||||
################################################################################
|
||||
## File: Warmup-User.ps1
|
||||
## Desc: Performs user part of warm up and moves data to C:\Users\Default
|
||||
################################################################################
|
||||
|
||||
#
|
||||
# more: https://github.com/actions/runner-images-internal/issues/5320
|
||||
# https://github.com/actions/runner-images/issues/5301#issuecomment-1648292990
|
||||
#
|
||||
|
||||
Write-Host "Warmup 'devenv.exe /updateconfiguration'"
|
||||
|
||||
$vsInstallRoot = (Get-VisualStudioInstance).InstallationPath
|
||||
$devEnvPath = "$vsInstallRoot\Common7\IDE\devenv.exe"
|
||||
|
||||
cmd.exe /c "`"$devEnvPath`" /updateconfiguration"
|
||||
|
||||
# we are fine if some file is locked and cannot be copied
|
||||
Copy-Item ${env:USERPROFILE}\AppData\Local\Microsoft\VisualStudio -Destination c:\users\default\AppData\Local\Microsoft\VisualStudio -Recurse -ErrorAction SilentlyContinue
|
||||
|
||||
reg.exe load HKLM\DEFAULT c:\users\default\ntuser.dat
|
||||
reg.exe copy HKCU\Software\Microsoft\VisualStudio HKLM\DEFAULT\Software\Microsoft\VisualStudio /s
|
||||
|
||||
# disable TSVNCache.exe
|
||||
$registryKeyPath = 'HKCU:\Software\TortoiseSVN'
|
||||
if (-not(Test-Path -Path $registryKeyPath)) {
|
||||
New-Item -Path $registryKeyPath -ItemType Directory -Force
|
||||
}
|
||||
|
||||
New-ItemProperty -Path $RegistryKeyPath -Name CacheType -PropertyType DWORD -Value 0
|
||||
reg.exe copy HKCU\Software\TortoiseSVN HKLM\DEFAULT\Software\TortoiseSVN /s
|
||||
|
||||
reg.exe unload HKLM\DEFAULT
|
||||
Write-Host "Warmup-User.ps1 - completed"
|
||||
189
images/windows/scripts/docs-gen/SoftwareReport.Android.psm1
Normal file
189
images/windows/scripts/docs-gen/SoftwareReport.Android.psm1
Normal file
@@ -0,0 +1,189 @@
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking
|
||||
|
||||
function Split-TableRowByColumns {
|
||||
param(
|
||||
[string] $Row
|
||||
)
|
||||
return $Row.Split("|") | ForEach-Object { $_.trim() }
|
||||
}
|
||||
|
||||
function Get-AndroidSDKRoot {
|
||||
param(
|
||||
[string] $ComponentName
|
||||
)
|
||||
$path = Join-Path $env:ANDROID_HOME $ComponentName
|
||||
return "Location $path"
|
||||
}
|
||||
|
||||
function Get-AndroidSDKManagerPath {
|
||||
return Join-Path $env:ANDROID_HOME "cmdline-tools\latest\bin\sdkmanager.bat"
|
||||
}
|
||||
|
||||
function Get-AndroidInstalledPackages {
|
||||
$androidSDKManagerPath = Get-AndroidSDKManagerPath
|
||||
$androidSDKManagerList = cmd /c "$androidSDKManagerPath --list_installed 2>&1"
|
||||
$androidSDKManagerList = $androidSDKManagerList -notmatch "Warning"
|
||||
return $androidSDKManagerList
|
||||
}
|
||||
|
||||
function Build-AndroidTable {
|
||||
$packageInfo = Get-AndroidInstalledPackages
|
||||
return @(
|
||||
@{
|
||||
"Package" = "Android Command Line Tools"
|
||||
"Version" = Get-AndroidCommandLineToolsVersion
|
||||
},
|
||||
@{
|
||||
"Package" = "Android Emulator"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Emulator"
|
||||
},
|
||||
@{
|
||||
"Package" = "Android SDK Build-tools"
|
||||
"Version" = Get-AndroidBuildToolVersions -PackageInfo $packageInfo
|
||||
},
|
||||
@{
|
||||
"Package" = "Android SDK Platforms"
|
||||
"Version" = Get-AndroidPlatformVersions -PackageInfo $packageInfo
|
||||
},
|
||||
@{
|
||||
"Package" = "Android SDK Platform-Tools"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Platform-Tools"
|
||||
},
|
||||
@{
|
||||
"Package" = "Android SDK Tools"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android SDK Tools"
|
||||
},
|
||||
@{
|
||||
"Package" = "Android Support Repository"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Android Support Repository"
|
||||
},
|
||||
@{
|
||||
"Package" = "CMake"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "cmake"
|
||||
},
|
||||
@{
|
||||
"Package" = "Google APIs"
|
||||
"Version" = Get-AndroidGoogleAPIsVersions -PackageInfo $packageInfo
|
||||
},
|
||||
@{
|
||||
"Package" = "Google Play services"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Play services"
|
||||
},
|
||||
@{
|
||||
"Package" = "Google Repository"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "Google Repository"
|
||||
},
|
||||
@{
|
||||
"Package" = "NDK"
|
||||
"Version" = Get-AndroidNdkVersions -PackageInfo $packageInfo
|
||||
},
|
||||
@{
|
||||
"Package" = "SDK Patch Applier v4"
|
||||
"Version" = Get-AndroidPackageVersions -PackageInfo $packageInfo -MatchedString "SDK Patch Applier v4"
|
||||
}
|
||||
) | Where-Object { $_.Version } | ForEach-Object {
|
||||
[PSCustomObject] @{
|
||||
"Package Name" = $_.Package
|
||||
"Version" = $_.Version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-AndroidPackageVersions {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[object] $PackageInfo,
|
||||
[Parameter(Mandatory)]
|
||||
[object] $MatchedString
|
||||
)
|
||||
|
||||
$versions = $packageInfo | Where-Object { $_ -Match $MatchedString } | ForEach-Object {
|
||||
$packageInfoParts = Split-TableRowByColumns $_
|
||||
return $packageInfoParts[1]
|
||||
}
|
||||
return ($versions -Join "<br>")
|
||||
}
|
||||
|
||||
function Get-AndroidPlatformVersions {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[object] $PackageInfo
|
||||
)
|
||||
|
||||
$versions = $packageInfo | Where-Object { $_ -Match "Android SDK Platform " } | ForEach-Object {
|
||||
$packageInfoParts = Split-TableRowByColumns $_
|
||||
$revision = $packageInfoParts[1]
|
||||
$version = $packageInfoParts[0].split(";")[1]
|
||||
return "$version (rev $revision)"
|
||||
}
|
||||
[array]::Reverse($versions)
|
||||
return ($versions -Join "<br>")
|
||||
}
|
||||
|
||||
function Get-AndroidCommandLineToolsVersion {
|
||||
$commandLineTools = Get-AndroidSDKManagerPath
|
||||
(cmd /c "$commandLineTools --version 2>NUL" | Out-String).Trim() -match "(?<version>^(\d+\.){1,}\d+$)" | Out-Null
|
||||
$commandLineToolsVersion = $Matches.Version
|
||||
return $commandLineToolsVersion
|
||||
}
|
||||
|
||||
function Get-AndroidBuildToolVersions {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[object] $PackageInfo
|
||||
)
|
||||
|
||||
$versions = $packageInfo | Where-Object { $_ -Match "Android SDK Build-Tools" } | ForEach-Object {
|
||||
$packageInfoParts = Split-TableRowByColumns $_
|
||||
return $packageInfoParts[1]
|
||||
}
|
||||
$groupVersions = @()
|
||||
$versions | ForEach-Object {
|
||||
$majorVersion = $_.Split(".")[0]
|
||||
$groupVersions += $versions | Where-Object { $_.StartsWith($majorVersion) } | Join-String -Separator " "
|
||||
}
|
||||
return ($groupVersions | Sort-Object -Descending -Unique | Join-String -Separator "<br>")
|
||||
}
|
||||
|
||||
function Get-AndroidGoogleAPIsVersions {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[object] $PackageInfo
|
||||
)
|
||||
|
||||
$versions = $packageInfo | Where-Object { $_ -Match "addon-google_apis" } | ForEach-Object {
|
||||
$packageInfoParts = Split-TableRowByColumns $_
|
||||
return $packageInfoParts[0].split(";")[1]
|
||||
}
|
||||
return ($versions -Join "<br>")
|
||||
}
|
||||
|
||||
function Get-AndroidNdkVersions {
|
||||
param (
|
||||
[Parameter(Mandatory)]
|
||||
[object] $PackageInfo
|
||||
)
|
||||
|
||||
$ndkDefaultFullVersion = Get-ChildItem $env:ANDROID_NDK_HOME -Name
|
||||
|
||||
$versions = $packageInfo | Where-Object { $_ -Match "ndk;" } | ForEach-Object {
|
||||
$version = (Split-TableRowByColumns $_)[1]
|
||||
if ($version -eq $ndkDefaultFullVersion) {
|
||||
$version += " (default)"
|
||||
}
|
||||
$version
|
||||
}
|
||||
return ($versions -Join "<br>")
|
||||
}
|
||||
|
||||
function Build-AndroidEnvironmentTable {
|
||||
$androidVersions = Get-Item env:ANDROID_*
|
||||
|
||||
$shoulddResolveLink = 'ANDROID_NDK', 'ANDROID_NDK_HOME', 'ANDROID_NDK_ROOT', 'ANDROID_NDK_LATEST_HOME'
|
||||
return $androidVersions | Sort-Object -Property Name | ForEach-Object {
|
||||
[PSCustomObject] @{
|
||||
"Name" = $_.Name
|
||||
"Value" = if ($shoulddResolveLink.Contains($_.Name )) { Get-PathWithLink($_.Value) } else {$_.Value}
|
||||
}
|
||||
}
|
||||
}
|
||||
100
images/windows/scripts/docs-gen/SoftwareReport.Browsers.psm1
Normal file
100
images/windows/scripts/docs-gen/SoftwareReport.Browsers.psm1
Normal file
@@ -0,0 +1,100 @@
|
||||
$browsers = @{
|
||||
chrome = @{
|
||||
Name="Google Chrome";
|
||||
File="chrome.exe"
|
||||
};
|
||||
edge = @{
|
||||
Name="Microsoft Edge";
|
||||
File="msedge.exe"
|
||||
};
|
||||
firefox = @{
|
||||
Name="Mozilla Firefox";
|
||||
File="firefox.exe"
|
||||
}
|
||||
}
|
||||
|
||||
$webDrivers = @{
|
||||
chrome = @{
|
||||
Name="Chrome Driver";
|
||||
Path="C:\SeleniumWebDrivers\ChromeDriver"
|
||||
};
|
||||
edge = @{
|
||||
Name="Microsoft Edge Driver";
|
||||
Path="C:\SeleniumWebDrivers\EdgeDriver"
|
||||
};
|
||||
firefox = @{
|
||||
Name="Gecko Driver";
|
||||
Path="C:\SeleniumWebDrivers\GeckoDriver"
|
||||
};
|
||||
iexplorer = @{
|
||||
Name="IE Driver";
|
||||
Path="C:\SeleniumWebDrivers\IEDriver"
|
||||
}
|
||||
}
|
||||
|
||||
function Build-BrowserSection {
|
||||
return @(
|
||||
$(Get-BrowserVersion -Browser "chrome"),
|
||||
$(Get-SeleniumWebDriverVersion -Driver "chrome"),
|
||||
$(Get-BrowserVersion -Browser "edge"),
|
||||
$(Get-SeleniumWebDriverVersion -Driver "edge"),
|
||||
$(Get-BrowserVersion -Browser "firefox"),
|
||||
$(Get-SeleniumWebDriverVersion -Driver "firefox"),
|
||||
$(Get-SeleniumWebDriverVersion -Driver "iexplorer"),
|
||||
$(Get-SeleniumVersion)
|
||||
)
|
||||
}
|
||||
|
||||
function Get-BrowserVersion {
|
||||
param(
|
||||
[string] $Browser
|
||||
)
|
||||
$browserName = $browsers.$Browser.Name
|
||||
$browserFile = $browsers.$Browser.File
|
||||
$registryKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\$browserFile"
|
||||
$browserVersion = (Get-Item (Get-ItemProperty $registryKey)."(Default)").VersionInfo.FileVersion
|
||||
return [ToolVersionNode]::new($browserName, $browserVersion)
|
||||
}
|
||||
|
||||
function Get-SeleniumWebDriverVersion {
|
||||
param(
|
||||
[string] $Driver
|
||||
)
|
||||
$driverName = $webDrivers.$Driver.Name
|
||||
$driverPath = $webDrivers.$Driver.Path
|
||||
$versionFileName = "versioninfo.txt";
|
||||
$webDriverVersion = Get-Content -Path "$driverPath\$versionFileName"
|
||||
return [ToolVersionNode]::new($driverName, $webDriverVersion)
|
||||
}
|
||||
|
||||
function Get-SeleniumVersion {
|
||||
$seleniumBinaryName = (Get-ToolsetContent).selenium.binary_name
|
||||
$fullSeleniumVersion = (Get-ChildItem "C:\selenium\${seleniumBinaryName}-*").Name -replace "${seleniumBinaryName}-"
|
||||
return [ToolVersionNode]::new("Selenium server", $fullSeleniumVersion)
|
||||
}
|
||||
|
||||
function Build-BrowserWebdriversEnvironmentTable {
|
||||
return @(
|
||||
@{
|
||||
"Name" = "CHROMEWEBDRIVER"
|
||||
"Value" = $env:CHROMEWEBDRIVER
|
||||
},
|
||||
@{
|
||||
"Name" = "EDGEWEBDRIVER"
|
||||
"Value" = $env:EDGEWEBDRIVER
|
||||
},
|
||||
@{
|
||||
"Name" = "GECKOWEBDRIVER"
|
||||
"Value" = $env:GECKOWEBDRIVER
|
||||
},
|
||||
@{
|
||||
"Name" = "SELENIUM_JAR_PATH"
|
||||
"Value" = $env:SELENIUM_JAR_PATH
|
||||
}
|
||||
) | ForEach-Object {
|
||||
[PSCustomObject] @{
|
||||
"Name" = $_.Name
|
||||
"Value" = $_.Value
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
function Get-ToolcacheGoVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Go"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
}
|
||||
|
||||
function Get-ToolcacheNodeVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Node"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
}
|
||||
|
||||
function Get-ToolcachePythonVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Python"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
}
|
||||
|
||||
function Get-ToolcacheRubyVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Ruby"
|
||||
return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
|
||||
}
|
||||
|
||||
function Get-ToolcachePyPyVersions {
|
||||
$toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "PyPy"
|
||||
Get-ChildItem -Path $toolcachePath -Name | Sort-Object { [Version] $_ } | ForEach-Object {
|
||||
$pypyRootPath = Join-Path $toolcachePath $_ "x86"
|
||||
[string]$pypyVersionOutput = & "$pypyRootPath\python.exe" -c "import sys;print(sys.version)"
|
||||
$pypyVersionOutput -match "^([\d\.]+) \(.+\) \[PyPy ([\d\.]+\S*) .+]$" | Out-Null
|
||||
return "{0} [PyPy {1}]" -f $Matches[1], $Matches[2]
|
||||
}
|
||||
}
|
||||
|
||||
function Build-CachedToolsSection
|
||||
{
|
||||
return @(
|
||||
[ToolVersionsListNode]::new("Go", $(Get-ToolcacheGoVersions), '^\d+\.\d+', 'List'),
|
||||
[ToolVersionsListNode]::new("Node.js", $(Get-ToolcacheNodeVersions), '^\d+', 'List'),
|
||||
[ToolVersionsListNode]::new("Python", $(Get-ToolcachePythonVersions), '^\d+\.\d+', 'List'),
|
||||
[ToolVersionsListNode]::new("PyPy", $(Get-ToolcachePyPyVersions), '^\d+\.\d+', 'List'),
|
||||
[ToolVersionsListNode]::new("Ruby", $(Get-ToolcacheRubyVersions), '^\d+\.\d+', 'List')
|
||||
)
|
||||
}
|
||||
328
images/windows/scripts/docs-gen/SoftwareReport.Common.psm1
Normal file
328
images/windows/scripts/docs-gen/SoftwareReport.Common.psm1
Normal file
@@ -0,0 +1,328 @@
|
||||
function Initialize-RustEnvironment {
|
||||
$env:RUSTUP_HOME = "C:\Users\Default\.rustup"
|
||||
$env:CARGO_HOME = "C:\Users\Default\.cargo"
|
||||
$env:Path += ";$env:CARGO_HOME\bin"
|
||||
}
|
||||
|
||||
function Get-OSName {
|
||||
return (Get-CimInstance -ClassName Win32_OperatingSystem).Caption | Take-Part -Part 1,2,3
|
||||
}
|
||||
|
||||
function Get-OSVersion {
|
||||
$OSVersion = (Get-CimInstance -ClassName Win32_OperatingSystem).Version
|
||||
$OSBuild = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion' UBR).UBR
|
||||
return "$OSVersion Build $OSBuild"
|
||||
}
|
||||
|
||||
function Build-OSInfoSection {
|
||||
$osInfoNode = [HeaderNode]::new($(Get-OSName))
|
||||
$osInfoNode.AddToolVersion("OS Version:", $(Get-OSVersion))
|
||||
$osInfoNode.AddToolVersion("Image Version:", $env:IMAGE_VERSION)
|
||||
return $osInfoNode
|
||||
}
|
||||
|
||||
function Get-BashVersion {
|
||||
bash --% -c 'echo ${BASH_VERSION}'
|
||||
}
|
||||
|
||||
function Get-RustVersion {
|
||||
rustc --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-RustupVersion {
|
||||
cmd /c "rustup --version 2>NUL" | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-RustCargoVersion {
|
||||
cargo --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-RustdocVersion {
|
||||
rustdoc --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-RustfmtVersion {
|
||||
rustfmt --version | Take-Part -Part 1 | Take-Part -Part 0 -Delimiter ('-')
|
||||
}
|
||||
|
||||
function Get-RustClippyVersion {
|
||||
cargo clippy --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-BindgenVersion {
|
||||
bindgen --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-CbindgenVersion {
|
||||
cbindgen --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-CargoAuditVersion {
|
||||
cargo-audit --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-CargoOutdatedVersion {
|
||||
cargo outdated --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-PythonVersion {
|
||||
python --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-PowershellCoreVersion {
|
||||
pwsh --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-RubyVersion {
|
||||
ruby --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-GoVersion {
|
||||
go version | Take-Part -Part 2 | Take-Part -Part 1 -Delimiter ('o')
|
||||
}
|
||||
|
||||
function Get-KotlinVersion {
|
||||
cmd /c "kotlinc -version 2>&1" | Take-Part -Part 2
|
||||
}
|
||||
|
||||
function Get-PHPVersion {
|
||||
php --version | Out-String | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-JuliaVersion {
|
||||
julia --version | Take-Part -Part 2
|
||||
}
|
||||
|
||||
function Get-LLVMVersion {
|
||||
(clang --version) -match "clang" | Take-Part -Part 2
|
||||
}
|
||||
|
||||
function Get-PerlVersion {
|
||||
($(perl --version) | Out-String) -match "\(v(?<version>\d+\.\d+\.\d+)\)" | Out-Null
|
||||
$perlVersion = $Matches.Version
|
||||
return $perlVersion
|
||||
}
|
||||
|
||||
function Get-NodeVersion {
|
||||
node --version | Take-Part -Part 0 -Delimiter ('v')
|
||||
}
|
||||
|
||||
function Get-ChocoVersion {
|
||||
choco --version
|
||||
}
|
||||
|
||||
function Get-VcpkgVersion {
|
||||
$commitId = git -C "C:\vcpkg" rev-parse --short HEAD
|
||||
return "(build from commit $commitId)"
|
||||
}
|
||||
|
||||
function Get-NPMVersion {
|
||||
npm -version
|
||||
}
|
||||
|
||||
function Get-YarnVersion {
|
||||
yarn -version
|
||||
}
|
||||
|
||||
function Get-RubyGemsVersion {
|
||||
gem --version
|
||||
}
|
||||
|
||||
function Get-HelmVersion {
|
||||
($(helm version --short) | Out-String) -match "v(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$helmVersion = $Matches.Version
|
||||
return $helmVersion
|
||||
}
|
||||
|
||||
function Get-PipVersion {
|
||||
(pip --version) -match "pip" | Take-Part -Part 1,4,5
|
||||
}
|
||||
|
||||
function Get-CondaVersion {
|
||||
$condaVersion = ((& "$env:CONDA\Scripts\conda.exe" --version) -replace "^conda").Trim()
|
||||
return "$condaVersion (pre-installed on the image but not added to PATH)"
|
||||
}
|
||||
|
||||
function Get-ComposerVersion {
|
||||
composer --version | Take-Part -Part 2
|
||||
}
|
||||
|
||||
function Get-NugetVersion {
|
||||
(nuget help) -match "Nuget Version" | Take-Part -Part 2
|
||||
}
|
||||
|
||||
function Get-AntVersion {
|
||||
ant -version | Take-Part -Part 3
|
||||
}
|
||||
|
||||
function Get-MavenVersion {
|
||||
(mvn -version) -match "Apache Maven" | Take-Part -Part 2
|
||||
}
|
||||
|
||||
function Get-GradleVersion {
|
||||
($(gradle -version) | Out-String) -match "Gradle (?<version>\d+\.\d+)" | Out-Null
|
||||
$gradleVersion = $Matches.Version
|
||||
return $gradleVersion
|
||||
}
|
||||
|
||||
function Get-SbtVersion {
|
||||
(sbt -version) -match "sbt script" | Take-Part -Part 3
|
||||
}
|
||||
|
||||
function Get-DotnetSdks {
|
||||
$sdksRawList = dotnet --list-sdks
|
||||
$sdkVersions = $sdksRawList | Foreach-Object {$_.Split()[0]}
|
||||
$sdkPath = $sdksRawList[0].Split(' ', 2)[1] -replace '\[|]'
|
||||
[PSCustomObject]@{
|
||||
Versions = $sdkVersions
|
||||
Path = $sdkPath
|
||||
}
|
||||
}
|
||||
|
||||
function Get-DotnetTools {
|
||||
$env:Path += ";C:\Users\Default\.dotnet\tools"
|
||||
$dotnetTools = (Get-ToolsetContent).dotnet.tools
|
||||
|
||||
$toolsList = @()
|
||||
|
||||
foreach ($dotnetTool in $dotnetTools) {
|
||||
$version = Invoke-Expression $dotnetTool.getversion
|
||||
$toolsList += [ToolVersionNode]::new($dotnetTool.name, $version)
|
||||
}
|
||||
return $toolsList
|
||||
}
|
||||
|
||||
function Get-DotnetRuntimes {
|
||||
$runtimesRawList = dotnet --list-runtimes
|
||||
$runtimesRawList | Group-Object {$_.Split()[0]} | ForEach-Object {
|
||||
$runtimeName = $_.Name
|
||||
$runtimeVersions = $_.Group | Foreach-Object {$_.split()[1]}
|
||||
$runtimePath = $_.Group[0].Split(' ', 3)[2] -replace '\[|]'
|
||||
[PSCustomObject]@{
|
||||
"Runtime" = $runtimeName
|
||||
"Versions" = $runtimeVersions
|
||||
"Path" = $runtimePath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-DotnetFrameworkVersions {
|
||||
$path = "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\*\*\NETFX * Tools"
|
||||
return Get-ChildItem -Path $path -Directory | ForEach-Object { $_.Name | Take-Part -Part 1 }
|
||||
}
|
||||
|
||||
function Get-PowerShellAzureModules {
|
||||
[Array] $result = @()
|
||||
$defaultAzureModuleVersion = "2.1.0"
|
||||
|
||||
[Array] $azInstalledModules = Get-ChildItem -Path "C:\Modules\az_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] }
|
||||
if ($azInstalledModules.Count -gt 0) {
|
||||
$result += [ToolVersionsListNode]::new("Az", $($azInstalledModules), '^\d+\.\d+', "Inline")
|
||||
}
|
||||
|
||||
[Array] $azureInstalledModules = Get-ChildItem -Path "C:\Modules\azure_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] } | ForEach-Object { if ($_ -eq $defaultAzureModuleVersion) { "$($_) (Default)" } else { $_ } }
|
||||
if ($azureInstalledModules.Count -gt 0) {
|
||||
$result += [ToolVersionsListNode]::new("Azure", $($azureInstalledModules), '^\d+\.\d+', "Inline")
|
||||
}
|
||||
|
||||
[Array] $azurermInstalledModules = Get-ChildItem -Path "C:\Modules\azurerm_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] } | ForEach-Object { if ($_ -eq $defaultAzureModuleVersion) { "$($_) (Default)" } else { $_ } }
|
||||
if ($azurermInstalledModules.Count -gt 0) {
|
||||
$result += [ToolVersionsListNode]::new("AzureRM", $($azurermInstalledModules), '^\d+\.\d+', "Inline")
|
||||
}
|
||||
|
||||
[Array] $azCachedModules = Get-ChildItem -Path "C:\Modules\az_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] }
|
||||
if ($azCachedModules.Count -gt 0) {
|
||||
$result += [ToolVersionsListNode]::new("Az (Cached)", $($azCachedModules), '^\d+\.\d+', "Inline")
|
||||
}
|
||||
|
||||
[Array] $azureCachedModules = Get-ChildItem -Path "C:\Modules\azure_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] }
|
||||
if ($azureCachedModules.Count -gt 0) {
|
||||
$result += [ToolVersionsListNode]::new("Azure (Cached)", $($azureCachedModules), '^\d+\.\d+', "Inline")
|
||||
}
|
||||
|
||||
[Array] $azurermCachedModules = Get-ChildItem -Path "C:\Modules\azurerm_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] }
|
||||
if ($azurermCachedModules.Count -gt 0) {
|
||||
$result += [ToolVersionsListNode]::new("AzureRM (Cached)", $($azurermCachedModules), '^\d+\.\d+', "Inline")
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
function Get-PowerShellModules {
|
||||
[Array] $result = @()
|
||||
|
||||
$result += Get-PowerShellAzureModules
|
||||
|
||||
$result += (Get-ToolsetContent).powershellModules.name | Sort-Object | ForEach-Object {
|
||||
$moduleName = $_
|
||||
$moduleVersions = Get-Module -Name $moduleName -ListAvailable | Select-Object -ExpandProperty Version | Sort-Object -Unique
|
||||
return [ToolVersionsListNode]::new($moduleName, $moduleVersions, '^\d+', "Inline")
|
||||
}
|
||||
|
||||
return $result
|
||||
}
|
||||
|
||||
function Get-CachedDockerImages {
|
||||
return (docker images --digests --format "* {{.Repository}}:{{.Tag}}").Split("*") | Where-Object { $_ }
|
||||
}
|
||||
|
||||
function Get-CachedDockerImagesTableData {
|
||||
$allImages = docker images --digests --format "*{{.Repository}}:{{.Tag}}|{{.Digest}} |{{.CreatedAt}}"
|
||||
if (-not $allImages) {
|
||||
return $null
|
||||
}
|
||||
|
||||
$allImages.Split("*") | Where-Object { $_ } | ForEach-Object {
|
||||
$parts = $_.Split("|")
|
||||
[PSCustomObject] @{
|
||||
"Repository:Tag" = $parts[0]
|
||||
"Digest" = $parts[1]
|
||||
"Created" = $parts[2].split(' ')[0]
|
||||
}
|
||||
} | Sort-Object -Property "Repository:Tag"
|
||||
}
|
||||
|
||||
function Get-ShellTarget {
|
||||
return Get-ChildItem C:\shells -File | Select-Object Name, @{n="Target";e={
|
||||
if ($_.Name -eq "msys2bash.cmd") {
|
||||
"C:\msys64\usr\bin\bash.exe"
|
||||
} else {
|
||||
@($_.Target)[0]
|
||||
}
|
||||
}} | Sort-Object Name
|
||||
}
|
||||
|
||||
function Get-PacmanVersion {
|
||||
$msys2BinDir = "C:\msys64\usr\bin"
|
||||
$pacmanPath = Join-Path $msys2BinDir "pacman.exe"
|
||||
$rawVersion = & $pacmanPath --version
|
||||
$rawVersion.Split([System.Environment]::NewLine)[1] -match "\d+\.\d+(\.\d+)?" | Out-Null
|
||||
$pacmanVersion = $matches[0]
|
||||
return $pacmanVersion
|
||||
}
|
||||
|
||||
function Get-YAMLLintVersion {
|
||||
yamllint --version | Take-Part -Part 1
|
||||
}
|
||||
|
||||
function Get-BizTalkVersion {
|
||||
$bizTalkReg = Get-ItemProperty "HKLM:\SOFTWARE\WOW6432Node\Microsoft\BizTalk Server\3.0"
|
||||
return [ToolVersionNode]::new($bizTalkReg.ProductName, $bizTalkReg.ProductVersion)
|
||||
}
|
||||
|
||||
function Get-PipxVersion {
|
||||
pipx --version
|
||||
}
|
||||
|
||||
function Build-PackageManagementEnvironmentTable {
|
||||
return @(
|
||||
[PSCustomObject] @{
|
||||
"Name" = "VCPKG_INSTALLATION_ROOT"
|
||||
"Value" = $env:VCPKG_INSTALLATION_ROOT
|
||||
},
|
||||
[PSCustomObject] @{
|
||||
"Name" = "CONDA"
|
||||
"Value" = $env:CONDA
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +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` <br> `PGDATA=$env:PGDATA` <br> `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
|
||||
}
|
||||
}
|
||||
239
images/windows/scripts/docs-gen/SoftwareReport.Generator.ps1
Normal file
239
images/windows/scripts/docs-gen/SoftwareReport.Generator.ps1
Normal file
@@ -0,0 +1,239 @@
|
||||
using module ./software-report-base/SoftwareReport.psm1
|
||||
using module ./software-report-base/SoftwareReport.Nodes.psm1
|
||||
|
||||
$global:ErrorActionPreference = "Stop"
|
||||
$global:ProgressPreference = "SilentlyContinue"
|
||||
$ErrorView = "NormalView"
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Android.psm1") -DisableNameChecking
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Browsers.psm1") -DisableNameChecking
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.CachedTools.psm1") -DisableNameChecking
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Common.psm1") -DisableNameChecking
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Databases.psm1") -DisableNameChecking
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Helpers.psm1") -DisableNameChecking
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Tools.psm1") -DisableNameChecking
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.Java.psm1") -DisableNameChecking
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.WebServers.psm1") -DisableNameChecking
|
||||
Import-Module (Join-Path $PSScriptRoot "SoftwareReport.VisualStudio.psm1") -DisableNameChecking
|
||||
|
||||
# Software report
|
||||
$softwareReport = [SoftwareReport]::new($(Build-OSInfoSection))
|
||||
$optionalFeatures = $softwareReport.Root.AddHeader("Windows features")
|
||||
$optionalFeatures.AddToolVersion("Windows Subsystem for Linux (WSLv1):", "Enabled")
|
||||
$installedSoftware = $softwareReport.Root.AddHeader("Installed Software")
|
||||
|
||||
# Language and Runtime
|
||||
$languageAndRuntime = $installedSoftware.AddHeader("Language and Runtime")
|
||||
$languageAndRuntime.AddToolVersion("Bash", $(Get-BashVersion))
|
||||
$languageAndRuntime.AddToolVersion("Go", $(Get-GoVersion))
|
||||
$languageAndRuntime.AddToolVersion("Julia", $(Get-JuliaVersion))
|
||||
$languageAndRuntime.AddToolVersion("Kotlin", $(Get-KotlinVersion))
|
||||
$languageAndRuntime.AddToolVersion("LLVM", $(Get-LLVMVersion))
|
||||
$languageAndRuntime.AddToolVersion("Node", $(Get-NodeVersion))
|
||||
$languageAndRuntime.AddToolVersion("Perl", $(Get-PerlVersion))
|
||||
$languageAndRuntime.AddToolVersion("PHP", $(Get-PHPVersion))
|
||||
$languageAndRuntime.AddToolVersion("Python", $(Get-PythonVersion))
|
||||
$languageAndRuntime.AddToolVersion("Ruby", $(Get-RubyVersion))
|
||||
|
||||
# Package Management
|
||||
$packageManagement = $installedSoftware.AddHeader("Package Management")
|
||||
$packageManagement.AddToolVersion("Chocolatey", $(Get-ChocoVersion))
|
||||
$packageManagement.AddToolVersion("Composer", $(Get-ComposerVersion))
|
||||
$packageManagement.AddToolVersion("Helm", $(Get-HelmVersion))
|
||||
$packageManagement.AddToolVersion("Miniconda", $(Get-CondaVersion))
|
||||
$packageManagement.AddToolVersion("NPM", $(Get-NPMVersion))
|
||||
$packageManagement.AddToolVersion("NuGet", $(Get-NugetVersion))
|
||||
$packageManagement.AddToolVersion("pip", $(Get-PipVersion))
|
||||
$packageManagement.AddToolVersion("Pipx", $(Get-PipxVersion))
|
||||
$packageManagement.AddToolVersion("RubyGems", $(Get-RubyGemsVersion))
|
||||
$packageManagement.AddToolVersion("Vcpkg", $(Get-VcpkgVersion))
|
||||
$packageManagement.AddToolVersion("Yarn", $(Get-YarnVersion))
|
||||
|
||||
$packageManagement.AddHeader("Environment variables").AddTable($(Build-PackageManagementEnvironmentTable))
|
||||
|
||||
# Project Management
|
||||
$projectManagement = $installedSoftware.AddHeader("Project Management")
|
||||
$projectManagement.AddToolVersion("Ant", $(Get-AntVersion))
|
||||
$projectManagement.AddToolVersion("Gradle", $(Get-GradleVersion))
|
||||
$projectManagement.AddToolVersion("Maven", $(Get-MavenVersion))
|
||||
$projectManagement.AddToolVersion("sbt", $(Get-SbtVersion))
|
||||
|
||||
# Tools
|
||||
$tools = $installedSoftware.AddHeader("Tools")
|
||||
$tools.AddToolVersion("7zip", $(Get-7zipVersion))
|
||||
$tools.AddToolVersion("aria2", $(Get-Aria2Version))
|
||||
$tools.AddToolVersion("azcopy", $(Get-AzCopyVersion))
|
||||
$tools.AddToolVersion("Bazel", $(Get-BazelVersion))
|
||||
$tools.AddToolVersion("Bazelisk", $(Get-BazeliskVersion))
|
||||
$tools.AddToolVersion("Bicep", $(Get-BicepVersion))
|
||||
$tools.AddToolVersion("Cabal", $(Get-CabalVersion))
|
||||
$tools.AddToolVersion("CMake", $(Get-CMakeVersion))
|
||||
$tools.AddToolVersion("CodeQL Action Bundle", $(Get-CodeQLBundleVersion))
|
||||
$tools.AddToolVersion("Docker", $(Get-DockerVersion))
|
||||
$tools.AddToolVersion("Docker Compose v1", $(Get-DockerComposeVersion))
|
||||
$tools.AddToolVersion("Docker Compose v2", $(Get-DockerComposeVersionV2))
|
||||
$tools.AddToolVersion("Docker-wincred", $(Get-DockerWincredVersion))
|
||||
$tools.AddToolVersion("ghc", $(Get-GHCVersion))
|
||||
$tools.AddToolVersion("Git", $(Get-GitVersion))
|
||||
$tools.AddToolVersion("Git LFS", $(Get-GitLFSVersion))
|
||||
if (Test-IsWin19) {
|
||||
$tools.AddToolVersion("Google Cloud CLI", $(Get-GoogleCloudCLIVersion))
|
||||
}
|
||||
$tools.AddToolVersion("ImageMagick", $(Get-ImageMagickVersion))
|
||||
$tools.AddToolVersion("InnoSetup", $(Get-InnoSetupVersion))
|
||||
$tools.AddToolVersion("jq", $(Get-JQVersion))
|
||||
$tools.AddToolVersion("Kind", $(Get-KindVersion))
|
||||
$tools.AddToolVersion("Kubectl", $(Get-KubectlVersion))
|
||||
$tools.AddToolVersion("Mercurial", $(Get-MercurialVersion))
|
||||
$tools.AddToolVersion("gcc", $(Get-GCCVersion))
|
||||
$tools.AddToolVersion("gdb", $(Get-GDBVersion))
|
||||
$tools.AddToolVersion("GNU Binutils", $(Get-GNUBinutilsVersion))
|
||||
$tools.AddToolVersion("Newman", $(Get-NewmanVersion))
|
||||
$tools.AddToolVersion("NSIS", $(Get-NSISVersion))
|
||||
$tools.AddToolVersion("OpenSSL", $(Get-OpenSSLVersion))
|
||||
$tools.AddToolVersion("Packer", $(Get-PackerVersion))
|
||||
if (Test-IsWin19) {
|
||||
$tools.AddToolVersion("Parcel", $(Get-ParcelVersion))
|
||||
}
|
||||
$tools.AddToolVersion("Pulumi", $(Get-PulumiVersion))
|
||||
$tools.AddToolVersion("R", $(Get-RVersion))
|
||||
$tools.AddToolVersion("Service Fabric SDK", $(Get-ServiceFabricSDKVersion))
|
||||
$tools.AddToolVersion("Stack", $(Get-StackVersion))
|
||||
$tools.AddToolVersion("Subversion (SVN)", $(Get-SVNVersion))
|
||||
$tools.AddToolVersion("Swig", $(Get-SwigVersion))
|
||||
$tools.AddToolVersion("VSWhere", $(Get-VSWhereVersion))
|
||||
$tools.AddToolVersion("WinAppDriver", $(Get-WinAppDriver))
|
||||
$tools.AddToolVersion("WiX Toolset", $(Get-WixVersion))
|
||||
$tools.AddToolVersion("yamllint", $(Get-YAMLLintVersion))
|
||||
$tools.AddToolVersion("zstd", $(Get-ZstdVersion))
|
||||
|
||||
# CLI Tools
|
||||
$cliTools = $installedSoftware.AddHeader("CLI Tools")
|
||||
$cliTools.AddToolVersion("Alibaba Cloud CLI", $(Get-AlibabaCLIVersion))
|
||||
$cliTools.AddToolVersion("AWS CLI", $(Get-AWSCLIVersion))
|
||||
$cliTools.AddToolVersion("AWS SAM CLI", $(Get-AWSSAMVersion))
|
||||
$cliTools.AddToolVersion("AWS Session Manager CLI", $(Get-AWSSessionManagerVersion))
|
||||
$cliTools.AddToolVersion("Azure CLI", $(Get-AzureCLIVersion))
|
||||
$cliTools.AddToolVersion("Azure DevOps CLI extension", $(Get-AzureDevopsExtVersion))
|
||||
if (Test-IsWin19) {
|
||||
$cliTools.AddToolVersion("Cloud Foundry CLI", $(Get-CloudFoundryVersion))
|
||||
}
|
||||
$cliTools.AddToolVersion("GitHub CLI", $(Get-GHVersion))
|
||||
|
||||
# Rust Tools
|
||||
Initialize-RustEnvironment
|
||||
$rustTools = $installedSoftware.AddHeader("Rust Tools")
|
||||
$rustTools.AddToolVersion("Cargo", $(Get-RustCargoVersion))
|
||||
$rustTools.AddToolVersion("Rust", $(Get-RustVersion))
|
||||
$rustTools.AddToolVersion("Rustdoc", $(Get-RustdocVersion))
|
||||
$rustTools.AddToolVersion("Rustup", $(Get-RustupVersion))
|
||||
|
||||
$rustToolsPackages = $rustTools.AddHeader("Packages")
|
||||
$rustToolsPackages.AddToolVersion("bindgen", $(Get-BindgenVersion))
|
||||
$rustToolsPackages.AddToolVersion("cargo-audit", $(Get-CargoAuditVersion))
|
||||
$rustToolsPackages.AddToolVersion("cargo-outdated", $(Get-CargoOutdatedVersion))
|
||||
$rustToolsPackages.AddToolVersion("cbindgen", $(Get-CbindgenVersion))
|
||||
$rustToolsPackages.AddToolVersion("Clippy", $(Get-RustClippyVersion))
|
||||
$rustToolsPackages.AddToolVersion("Rustfmt", $(Get-RustfmtVersion))
|
||||
|
||||
# Browsers and Drivers
|
||||
$browsersAndWebdrivers = $installedSoftware.AddHeader("Browsers and Drivers")
|
||||
$browsersAndWebdrivers.AddNodes($(Build-BrowserSection))
|
||||
$browsersAndWebdrivers.AddHeader("Environment variables").AddTable($(Build-BrowserWebdriversEnvironmentTable))
|
||||
|
||||
# Java
|
||||
$installedSoftware.AddHeader("Java").AddTable($(Get-JavaVersions))
|
||||
|
||||
# Shells
|
||||
$installedSoftware.AddHeader("Shells").AddTable($(Get-ShellTarget))
|
||||
|
||||
# MSYS2
|
||||
$msys2 = $installedSoftware.AddHeader("MSYS2")
|
||||
$msys2.AddToolVersion("Pacman", $(Get-PacmanVersion))
|
||||
|
||||
$notes = @'
|
||||
Location: C:\msys64
|
||||
|
||||
Note: MSYS2 is pre-installed on image but not added to PATH.
|
||||
'@
|
||||
$msys2.AddHeader("Notes").AddNote($notes)
|
||||
|
||||
# BizTalk Server
|
||||
if (Test-IsWin19)
|
||||
{
|
||||
$installedSoftware.AddHeader("BizTalk Server").AddNode($(Get-BizTalkVersion))
|
||||
}
|
||||
|
||||
# Cached Tools
|
||||
$installedSoftware.AddHeader("Cached Tools").AddNodes($(Build-CachedToolsSection))
|
||||
|
||||
# Databases
|
||||
$databases = $installedSoftware.AddHeader("Databases")
|
||||
$databases.AddHeader("PostgreSQL").AddTable($(Get-PostgreSQLTable))
|
||||
$databases.AddHeader("MongoDB").AddTable($(Get-MongoDBTable))
|
||||
|
||||
# Database tools
|
||||
$databaseTools = $installedSoftware.AddHeader("Database tools")
|
||||
$databaseTools.AddToolVersion("Azure CosmosDb Emulator", $(Get-AzCosmosDBEmulatorVersion))
|
||||
$databaseTools.AddToolVersion("DacFx", $(Get-DacFxVersion))
|
||||
$databaseTools.AddToolVersion("MySQL", $(Get-MySQLVersion))
|
||||
$databaseTools.AddToolVersion("SQL OLEDB Driver", $(Get-SQLOLEDBDriverVersion))
|
||||
$databaseTools.AddToolVersion("SQLPS", $(Get-SQLPSVersion))
|
||||
|
||||
# Web Servers
|
||||
$installedSoftware.AddHeader("Web Servers").AddTable($(Build-WebServersSection))
|
||||
|
||||
# Visual Studio
|
||||
$vsTable = Get-VisualStudioVersion
|
||||
$visualStudio = $installedSoftware.AddHeader($vsTable.Name)
|
||||
$visualStudio.AddTable($vsTable)
|
||||
|
||||
$workloads = $visualStudio.AddHeader("Workloads, components and extensions")
|
||||
$workloads.AddTable((Get-VisualStudioComponents) + (Get-VisualStudioExtensions))
|
||||
|
||||
$msVisualCpp = $visualStudio.AddHeader("Microsoft Visual C++")
|
||||
$msVisualCpp.AddTable($(Get-VisualCPPComponents))
|
||||
|
||||
$visualStudio.AddToolVersionsList("Installed Windows SDKs", $(Get-WindowsSDKs).Versions, '^.+')
|
||||
|
||||
# .NET Core Tools
|
||||
$netCoreTools = $installedSoftware.AddHeader(".NET Core Tools")
|
||||
if (Test-IsWin19) {
|
||||
# Visual Studio 2019 brings own version of .NET Core which is different from latest official version
|
||||
$netCoreTools.AddToolVersionsListInline(".NET Core SDK", $(Get-DotnetSdks).Versions, '^\d+\.\d+\.\d{2}')
|
||||
} else {
|
||||
$netCoreTools.AddToolVersionsListInline(".NET Core SDK", $(Get-DotnetSdks).Versions, '^\d+\.\d+\.\d')
|
||||
}
|
||||
$netCoreTools.AddToolVersionsListInline(".NET Framework", $(Get-DotnetFrameworkVersions), '^.+')
|
||||
Get-DotnetRuntimes | ForEach-Object {
|
||||
$netCoreTools.AddToolVersionsListInline($_.Runtime, $_.Versions, '^.+')
|
||||
}
|
||||
$netCoreTools.AddNodes($(Get-DotnetTools))
|
||||
|
||||
# PowerShell Tools
|
||||
$psTools = $installedSoftware.AddHeader("PowerShell Tools")
|
||||
$psTools.AddToolVersion("PowerShell", $(Get-PowershellCoreVersion))
|
||||
|
||||
$psModules = $psTools.AddHeader("Powershell Modules")
|
||||
$psModules.AddNodes($(Get-PowerShellModules))
|
||||
|
||||
$azPsNotes = @'
|
||||
Azure PowerShell module 2.1.0 and AzureRM PowerShell module 2.1.0 are installed
|
||||
and are available via 'Get-Module -ListAvailable'.
|
||||
All other versions are saved but not installed.
|
||||
'@
|
||||
$psModules.AddNote($azPsNotes)
|
||||
|
||||
# Android
|
||||
$android = $installedSoftware.AddHeader("Android")
|
||||
$android.AddTable($(Build-AndroidTable))
|
||||
|
||||
$android.AddHeader("Environment variables").AddTable($(Build-AndroidEnvironmentTable))
|
||||
|
||||
# Cached Docker images
|
||||
$installedSoftware.AddHeader("Cached Docker images").AddTable($(Get-CachedDockerImagesTableData))
|
||||
|
||||
# Generate reports
|
||||
$softwareReport.ToJson() | Out-File -FilePath "C:\software-report.json" -Encoding UTF8NoBOM
|
||||
$softwareReport.ToMarkdown() | Out-File -FilePath "C:\software-report.md" -Encoding UTF8NoBOM
|
||||
30
images/windows/scripts/docs-gen/SoftwareReport.Helpers.psm1
Normal file
30
images/windows/scripts/docs-gen/SoftwareReport.Helpers.psm1
Normal file
@@ -0,0 +1,30 @@
|
||||
function Get-LinkTarget {
|
||||
param (
|
||||
[string] $inputPath
|
||||
)
|
||||
$link = Get-Item $inputPath | Select-Object -ExpandProperty Target
|
||||
if ($link) {
|
||||
return " -> $link"
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
function Get-PathWithLink {
|
||||
param (
|
||||
[string] $inputPath
|
||||
)
|
||||
$link = Get-LinkTarget($inputPath)
|
||||
return "${inputPath}${link}"
|
||||
}
|
||||
|
||||
function Take-Part {
|
||||
param (
|
||||
[Parameter(ValueFromPipeline)]
|
||||
[string] $toolOutput,
|
||||
[string] $Delimiter = " ",
|
||||
[int[]] $Part
|
||||
)
|
||||
$parts = $toolOutput.Split($Delimiter, [System.StringSplitOptions]::RemoveEmptyEntries)
|
||||
$selectedParts = $parts[$Part]
|
||||
return [string]::Join($Delimiter, $selectedParts)
|
||||
}
|
||||
22
images/windows/scripts/docs-gen/SoftwareReport.Java.psm1
Normal file
22
images/windows/scripts/docs-gen/SoftwareReport.Java.psm1
Normal file
@@ -0,0 +1,22 @@
|
||||
function Get-JavaVersions {
|
||||
$defaultJavaPath = $env:JAVA_HOME
|
||||
$javaVersions = Get-Item env:JAVA_HOME_*_X64
|
||||
$sortRules = @{
|
||||
Expression = { [Int32]$_.Name.Split("_")[2] }
|
||||
Descending = $false
|
||||
}
|
||||
|
||||
return $javaVersions | Sort-Object $sortRules | ForEach-Object {
|
||||
$javaPath = $_.Value
|
||||
# Take semver from the java path
|
||||
# The path contains '-' sign in the version number instead of '+' due to the following issue, need to substitute it back https://github.com/actions/runner-images/issues/3014
|
||||
$versionInPath = (Split-Path $javaPath) -replace "\w:\\.*\\"
|
||||
$version = $versionInPath -replace '-', '+'
|
||||
$defaultPostfix = ($javaPath -eq $defaultJavaPath) ? " (default)" : ""
|
||||
|
||||
[PSCustomObject] @{
|
||||
"Version" = $version + $defaultPostfix
|
||||
"Environment Variable" = $_.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
321
images/windows/scripts/docs-gen/SoftwareReport.Tools.psm1
Normal file
321
images/windows/scripts/docs-gen/SoftwareReport.Tools.psm1
Normal file
@@ -0,0 +1,321 @@
|
||||
function Get-Aria2Version {
|
||||
(aria2c -v | Out-String) -match "(?<version>(\d+\.){1,}\d+)" | Out-Null
|
||||
$aria2Version = $Matches.Version
|
||||
return $aria2Version
|
||||
}
|
||||
|
||||
function Get-AzCosmosDBEmulatorVersion {
|
||||
$regKey = gci HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | gp | ? { $_.DisplayName -eq 'Azure Cosmos DB Emulator' }
|
||||
$installDir = $regKey.InstallLocation
|
||||
$exeFilePath = Join-Path $installDir 'CosmosDB.Emulator.exe'
|
||||
$version = (Get-Item $exeFilePath).VersionInfo.FileVersion
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-BazelVersion {
|
||||
((cmd /c "bazel --version 2>&1") | Out-String) -match "bazel (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$bazelVersion = $Matches.Version
|
||||
return $bazelVersion
|
||||
}
|
||||
|
||||
function Get-BazeliskVersion {
|
||||
((cmd /c "bazelisk version 2>&1") | Out-String) -match "Bazelisk version: v(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$bazeliskVersion = $Matches.Version
|
||||
return $bazeliskVersion
|
||||
}
|
||||
|
||||
function Get-BicepVersion {
|
||||
(bicep --version | Out-String) -match "bicep cli version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$bicepVersion = $Matches.Version
|
||||
return $bicepVersion
|
||||
}
|
||||
|
||||
function Get-RVersion {
|
||||
($(cmd /c "Rscript --version 2>&1") | Out-String) -match "Rscript .* version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$rVersion = $Matches.Version
|
||||
return $rVersion
|
||||
}
|
||||
|
||||
function Get-CMakeVersion {
|
||||
($(cmake -version) | Out-String) -match "cmake version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$cmakeVersion = $Matches.Version
|
||||
return $cmakeVersion
|
||||
}
|
||||
|
||||
function Get-CodeQLBundleVersion {
|
||||
$CodeQLVersionsWildcard = Join-Path $Env:AGENT_TOOLSDIRECTORY -ChildPath "CodeQL" | Join-Path -ChildPath "*"
|
||||
$CodeQLVersionPath = Get-ChildItem $CodeQLVersionsWildcard | Select-Object -First 1 -Expand FullName
|
||||
$CodeQLPath = Join-Path $CodeQLVersionPath -ChildPath "x64" | Join-Path -ChildPath "codeql" | Join-Path -ChildPath "codeql.exe"
|
||||
$CodeQLVersion = & $CodeQLPath version --quiet
|
||||
return $CodeQLVersion
|
||||
}
|
||||
|
||||
function Get-DockerVersion {
|
||||
$dockerVersion = $(docker version --format "{{.Server.Version}}")
|
||||
return $dockerVersion
|
||||
}
|
||||
|
||||
function Get-DockerComposeVersion {
|
||||
$dockerComposeVersion = docker-compose version --short
|
||||
return $dockerComposeVersion
|
||||
}
|
||||
|
||||
function Get-DockerComposeVersionV2 {
|
||||
$dockerComposeVersion = docker compose version --short
|
||||
return $dockerComposeVersion
|
||||
}
|
||||
|
||||
function Get-DockerWincredVersion {
|
||||
$dockerCredVersion = docker-credential-wincred version | Take-Part -Part 2 | Take-Part -Part 0 -Delimiter "v"
|
||||
return $dockerCredVersion
|
||||
}
|
||||
|
||||
function Get-GitVersion {
|
||||
$gitVersion = git --version | Take-Part -Part -1
|
||||
return $gitVersion
|
||||
}
|
||||
|
||||
function Get-GitLFSVersion {
|
||||
$(git-lfs version) -match "git-lfs\/(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$gitLfsVersion = $Matches.Version
|
||||
return $gitLfsVersion
|
||||
}
|
||||
|
||||
function Get-InnoSetupVersion {
|
||||
$innoSetupVersion = $(choco list innosetup) | Select-String -Pattern "InnoSetup"
|
||||
return ($innoSetupVersion -replace "^InnoSetup").Trim()
|
||||
}
|
||||
|
||||
function Get-JQVersion {
|
||||
$jqVersion = ($(jq --version) -Split "jq-")[1]
|
||||
return $jqVersion
|
||||
}
|
||||
|
||||
function Get-KubectlVersion {
|
||||
$kubectlVersion = (kubectl version --client --output=json | ConvertFrom-Json).clientVersion.gitVersion.Replace('v','')
|
||||
return $kubectlVersion
|
||||
}
|
||||
|
||||
function Get-KindVersion {
|
||||
$(kind version) -match "kind v(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$kindVersion = $Matches.Version
|
||||
return $kindVersion
|
||||
}
|
||||
|
||||
function Get-GCCVersion {
|
||||
(gcc --version | Select-String -Pattern "gcc.exe") -match "(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$mingwVersion = $Matches.Version
|
||||
return $mingwVersion
|
||||
}
|
||||
|
||||
function Get-GDBVersion {
|
||||
(gdb --version | Select-String -Pattern "GNU gdb") -match "(?<version>\d+\.\d+)" | Out-Null
|
||||
$mingwVersion = $Matches.Version
|
||||
return $mingwVersion
|
||||
}
|
||||
|
||||
function Get-GNUBinutilsVersion {
|
||||
(ld --version | Select-String -Pattern "GNU Binutils") -match "(?<version>\d+\.\d+)" | Out-Null
|
||||
$mingwVersion = $Matches.Version
|
||||
return $mingwVersion
|
||||
}
|
||||
|
||||
function Get-MySQLVersion {
|
||||
$mysqlCommand = Get-Command -Name "mysql"
|
||||
$mysqlVersion = $mysqlCommand.Version.ToString()
|
||||
return $mysqlVersion
|
||||
}
|
||||
|
||||
function Get-SQLOLEDBDriverVersion {
|
||||
$SQLOLEDBDriverVersion = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSOLEDBSQL' InstalledVersion).InstalledVersion
|
||||
return $SQLOLEDBDriverVersion
|
||||
}
|
||||
|
||||
function Get-MercurialVersion {
|
||||
($(hg --version) | Out-String) -match "version (?<version>\d+\.\d+\.?\d*)" | Out-Null
|
||||
$mercurialVersion = $Matches.Version
|
||||
return $mercurialVersion
|
||||
}
|
||||
|
||||
function Get-NSISVersion {
|
||||
$nsisVersion = &"c:\Program Files (x86)\NSIS\makensis.exe" "/Version"
|
||||
return $nsisVersion.TrimStart("v")
|
||||
}
|
||||
|
||||
function Get-OpenSSLVersion {
|
||||
$(openssl version) -match "OpenSSL (?<version>\d+\.\d+\.\d+\w?) " | Out-Null
|
||||
$opensslVersion = $Matches.Version
|
||||
return $opensslVersion
|
||||
}
|
||||
|
||||
function Get-PackerVersion {
|
||||
$packerVersion = packer --version
|
||||
return $packerVersion
|
||||
}
|
||||
|
||||
function Get-ParcelVersion {
|
||||
$parcelVersion = parcel --version
|
||||
return "$parcelVersion"
|
||||
}
|
||||
|
||||
function Get-PulumiVersion {
|
||||
return (pulumi version).TrimStart("v")
|
||||
}
|
||||
|
||||
function Get-SQLPSVersion {
|
||||
$module = Get-Module -Name SQLPS -ListAvailable
|
||||
$version = $module.Version
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-SVNVersion {
|
||||
$svnVersion = $(svn --version --quiet)
|
||||
return $svnVersion
|
||||
}
|
||||
|
||||
function Get-VSWhereVersion {
|
||||
($(Get-Command -Name vswhere).FileVersionInfo.ProductVersion) -match "(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$vswhereVersion = $Matches.Version
|
||||
return $vswhereVersion
|
||||
}
|
||||
|
||||
function Get-WinAppDriver {
|
||||
$winAppDriverVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe").FileVersion
|
||||
return $winAppDriverVersion
|
||||
}
|
||||
|
||||
function Get-WixVersion {
|
||||
$regKey = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||
$installedApplications = Get-ItemProperty -Path $regKey
|
||||
$wixToolsetVersion = ($installedApplications | Where-Object { $_.BundleCachePath -imatch ".*\\WiX\d*\.exe$" } | Select-Object -First 1).DisplayName
|
||||
return ($wixToolsetVersion -replace "^WiX Toolset v").Trim()
|
||||
}
|
||||
|
||||
function Get-ZstdVersion {
|
||||
$(zstd --version) -match "v(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$zstdVersion = $Matches.Version
|
||||
return $zstdVersion
|
||||
}
|
||||
|
||||
function Get-AzureCLIVersion {
|
||||
$azureCLIVersion = $(az version) | ConvertFrom-Json | Foreach{ $_."azure-cli" }
|
||||
return $azureCLIVersion
|
||||
}
|
||||
|
||||
function Get-AzCopyVersion {
|
||||
return ($(azcopy --version) -replace "^azcopy version").Trim()
|
||||
}
|
||||
|
||||
function Get-AzureDevopsExtVersion {
|
||||
$azureDevExtVersion = (az version | ConvertFrom-Json | ForEach-Object { $_."extensions" })."azure-devops"
|
||||
return $azureDevExtVersion
|
||||
}
|
||||
|
||||
function Get-AWSCLIVersion {
|
||||
$(aws --version) -match "aws-cli\/(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$awscliVersion = $Matches.Version
|
||||
return $awscliVersion
|
||||
}
|
||||
|
||||
function Get-AWSSAMVersion {
|
||||
$(sam --version) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$awssamVersion = $Matches.Version
|
||||
return $awssamVersion
|
||||
}
|
||||
|
||||
function Get-AWSSessionManagerVersion {
|
||||
$awsSessionManagerVersion = $(session-manager-plugin --version)
|
||||
return $awsSessionManagerVersion
|
||||
}
|
||||
|
||||
function Get-AlibabaCLIVersion {
|
||||
$alicliVersion = $(aliyun version)
|
||||
return $alicliVersion
|
||||
}
|
||||
|
||||
function Get-CloudFoundryVersion {
|
||||
$(cf version) -match "(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$cfVersion = $Matches.Version
|
||||
return $cfVersion
|
||||
}
|
||||
|
||||
function Get-7zipVersion {
|
||||
(7z | Out-String) -match "7-Zip (?<version>\d+\.\d+\.?\d*)" | Out-Null
|
||||
$version = $Matches.Version
|
||||
return $version
|
||||
}
|
||||
|
||||
function Get-GHCVersion {
|
||||
((ghc --version) | Out-String) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$ghcVersion = $Matches.Version
|
||||
return $ghcVersion
|
||||
}
|
||||
|
||||
function Get-CabalVersion {
|
||||
((cabal --version) | Out-String) -match "version (?<version>\d+\.\d+\.\d+\.\d+)" | Out-Null
|
||||
$cabalVersion = $Matches.Version
|
||||
return $cabalVersion
|
||||
}
|
||||
|
||||
function Get-StackVersion {
|
||||
((stack --version --quiet) | Out-String) -match "Version (?<version>\d+\.\d+\.\d+)," | Out-Null
|
||||
$stackVersion = $Matches.Version
|
||||
return $stackVersion
|
||||
}
|
||||
|
||||
function Get-GoogleCloudCLIVersion {
|
||||
return (((cmd /c "gcloud --version") -match "Google Cloud SDK") -replace "Google Cloud SDK").Trim()
|
||||
}
|
||||
|
||||
function Get-ServiceFabricSDKVersion {
|
||||
$serviceFabricSDKVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Service Fabric\' -Name FabricVersion
|
||||
return $serviceFabricSDKVersion
|
||||
}
|
||||
|
||||
function Get-NewmanVersion {
|
||||
return $(newman --version)
|
||||
}
|
||||
|
||||
function Get-GHVersion {
|
||||
($(gh --version) | Select-String -Pattern "gh version") -match "gh version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$ghVersion = $Matches.Version
|
||||
return $ghVersion
|
||||
}
|
||||
|
||||
function Get-VisualCPPComponents {
|
||||
$regKeys = @(
|
||||
"HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||
"HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||
)
|
||||
$vcpp = Get-ItemProperty -Path $regKeys | Where-Object DisplayName -like "Microsoft Visual C++*"
|
||||
$vcpp | Sort-Object DisplayName, DisplayVersion | ForEach-Object {
|
||||
$isMatch = $_.DisplayName -match "^(?<Name>Microsoft Visual C\+\+ \d{4})\s+(?<Arch>\w{3})\s+(?<Ext>.+)\s+-"
|
||||
if ($isMatch) {
|
||||
$name = '{0} {1}' -f $matches["Name"], $matches["Ext"]
|
||||
$arch = $matches["Arch"].ToLower()
|
||||
$version = $_.DisplayVersion
|
||||
[PSCustomObject]@{
|
||||
Name = $name
|
||||
Architecture = $arch
|
||||
Version = $version
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Get-DacFxVersion {
|
||||
$dacfxversion = & "$env:ProgramFiles\Microsoft SQL Server\160\DAC\bin\sqlpackage.exe" /version
|
||||
return $dacfxversion
|
||||
}
|
||||
|
||||
function Get-SwigVersion {
|
||||
(swig -version | Out-String) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
$swigVersion = $Matches.Version
|
||||
return $swigVersion
|
||||
}
|
||||
|
||||
function Get-ImageMagickVersion {
|
||||
(magick -version | Select-String -Pattern "Version") -match "(?<version>\d+\.\d+\.\d+-\d+)" | Out-Null
|
||||
$magickVersion = $Matches.Version
|
||||
return $magickVersion
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
function Get-VisualStudioVersion {
|
||||
$vsInstance = Get-VisualStudioInstance
|
||||
[PSCustomObject]@{
|
||||
Name = $vsInstance.DisplayName
|
||||
Version = $vsInstance.InstallationVersion
|
||||
Path = $vsInstance.InstallationPath
|
||||
}
|
||||
}
|
||||
|
||||
function Get-SDKVersion {
|
||||
$regKey = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||
$installedApplications = Get-ItemProperty -Path $regKey
|
||||
($installedApplications | Where-Object { $_.DisplayName -eq 'Windows SDK' } | Select-Object -First 1).DisplayVersion
|
||||
}
|
||||
|
||||
function Get-WDKVersion {
|
||||
$regKey = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
|
||||
$installedApplications = Get-ItemProperty -Path $regKey
|
||||
($installedApplications | Where-Object { $_.DisplayName -eq 'Windows Driver Kit' } | Select-Object -First 1).DisplayVersion
|
||||
}
|
||||
|
||||
function Get-VisualStudioExtensions {
|
||||
$vsPackages = (Get-VisualStudioInstance).Packages
|
||||
|
||||
# Additional vsixs
|
||||
$toolset = Get-ToolsetContent
|
||||
$vsixUrls = $toolset.visualStudio.vsix
|
||||
if ($vsixUrls)
|
||||
{
|
||||
$vsixs = $vsixUrls | ForEach-Object {
|
||||
$vsix = Get-VsixExtenstionFromMarketplace -ExtensionMarketPlaceName $_
|
||||
|
||||
$vsixVersion = ($vsPackages | Where-Object {$_.Id -match $vsix.VsixId -and $_.type -eq 'vsix'}).Version
|
||||
@{
|
||||
Package = $vsix.ExtensionName
|
||||
Version = $vsixVersion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# SDK
|
||||
$sdkVersion = Get-SDKVersion
|
||||
$sdkPackages = @(
|
||||
@{Package = 'Windows Software Development Kit'; Version = $sdkVersion}
|
||||
)
|
||||
|
||||
# WDK
|
||||
$wdkVersion = Get-WDKVersion
|
||||
$wdkExtensionVersion = Get-VSExtensionVersion -packageName 'Microsoft.Windows.DriverKit'
|
||||
$wdkPackages = @(
|
||||
@{Package = 'Windows Driver Kit'; Version = $wdkVersion}
|
||||
@{Package = 'Windows Driver Kit Visual Studio Extension'; Version = $wdkExtensionVersion}
|
||||
)
|
||||
|
||||
$extensions = @(
|
||||
$vsixs
|
||||
$ssdtPackages
|
||||
$sdkPackages
|
||||
$wdkPackages
|
||||
)
|
||||
|
||||
$extensions | Foreach-Object {
|
||||
[PSCustomObject]$_
|
||||
} | Select-Object Package, Version | Sort-Object Package
|
||||
}
|
||||
|
||||
function Get-WindowsSDKs {
|
||||
$path = "${env:ProgramFiles(x86)}\Windows Kits\10\Extension SDKs\WindowsDesktop"
|
||||
return [PSCustomObject]@{
|
||||
Path = $path
|
||||
Versions = $(Get-ChildItem $path).Name
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
function Get-ApachePath {
|
||||
return Join-Path "C:\tools\" (Get-Item C:\tools\apache*).Name
|
||||
}
|
||||
|
||||
function Get-NginxPath {
|
||||
return Join-Path "C:\tools\" (Get-Item C:\tools\nginx*).Name
|
||||
}
|
||||
|
||||
function Get-ApacheVersion {
|
||||
$apacheBinPath = Join-Path (Get-ApachePath) "\bin\httpd"
|
||||
(. $apacheBinPath -V | Select-String -Pattern "Apache/") -match "Apache/(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
return $Matches.Version
|
||||
}
|
||||
|
||||
function Get-NginxVersion {
|
||||
$nginxBinPath = Join-Path (Get-NginxPath) "nginx"
|
||||
(cmd /c "$nginxBinPath -v 2>&1") -match "nginx/(?<version>\d+\.\d+\.\d+)" | Out-Null
|
||||
return $Matches.Version
|
||||
}
|
||||
|
||||
function Get-ApacheSection
|
||||
{
|
||||
$name = "Apache"
|
||||
$apachePort = "80"
|
||||
$apacheService = Get-Service -Name $name
|
||||
$apacheVersion = Get-ApacheVersion
|
||||
$apacheConfigFile = Join-Path (Get-ApachePath) "\conf\httpd.conf"
|
||||
return [PSCustomObject]@{
|
||||
Name = $name
|
||||
Version = $apacheVersion
|
||||
ConfigFile = $apacheConfigFile
|
||||
ServiceName = $apacheService.Name
|
||||
ServiceStatus = $apacheService.Status
|
||||
ListenPort = $apachePort
|
||||
}
|
||||
}
|
||||
|
||||
function Get-NginxSection
|
||||
{
|
||||
$name = "Nginx"
|
||||
$nginxPort = "80"
|
||||
$nginxService = Get-Service -Name $name
|
||||
$nginxVersion = Get-NginxVersion
|
||||
$nginxConfigFile = Join-Path (Get-NginxPath) "\conf\nginx.conf"
|
||||
return [PSCustomObject]@{
|
||||
Name = $name
|
||||
Version = $nginxVersion
|
||||
ConfigFile = $nginxConfigFile
|
||||
ServiceName = $nginxService.Name
|
||||
ServiceStatus = $nginxService.Status
|
||||
ListenPort = $nginxPort
|
||||
}
|
||||
}
|
||||
|
||||
function Build-WebServersSection {
|
||||
return @(
|
||||
(Get-ApacheSection),
|
||||
(Get-NginxSection)
|
||||
)
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user