Files
runner-images-sangeeth/images/win/scripts/SoftwareReport/SoftwareReport.Tools.psm1
Andrew Brown 89ee433676 Update MinGW on Windows 2022 (#5729)
* Update MinGW on Windows 2022

Previously, the GitHub virtual environments only had MinGW v8.1.0
installed. That version was released in October of 2018 and, since then,
MinGW has released versions all the way up to v11.2.0. This change
updates the MinGW version to the latest available on Chocolatey for the
Windows 2022 environment. Windows 2019 retains the current v8.1.0
version. Fixes #5530.

* Update MinGW documentation

* Additionally update win-2016 version

* Revert "Update MinGW documentation"

This reverts commit cb7a72ff0f33f8a5bbda15be677b348a05f9fee0.

* fix: modify the pattern used for retrieving the MinGW version
2022-06-16 18:15:38 +03:00

306 lines
10 KiB
PowerShell

function Get-Aria2Version {
(aria2c -v | Out-String) -match "(?<version>(\d+\.){1,}\d+)" | Out-Null
$aria2Version = $Matches.Version
return "aria2 $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 "Azure CosmosDb Emulator $version"
}
function Get-BazelVersion {
((cmd /c "bazel --version 2>&1") | Out-String) -match "bazel (?<version>\d+\.\d+\.\d+)" | Out-Null
$bazelVersion = $Matches.Version
return "Bazel $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 "Bazelisk $bazeliskVersion"
}
function Get-BicepVersion {
(bicep --version | Out-String) -match "bicep cli version (?<version>\d+\.\d+\.\d+)" | Out-Null
$bicepVersion = $Matches.Version
return "Bicep $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 "R $rVersion"
}
function Get-CMakeVersion {
($(cmake -version) | Out-String) -match "cmake version (?<version>\d+\.\d+\.\d+)" | Out-Null
$cmakeVersion = $Matches.Version
return "CMake $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 "CodeQL Action Bundle $CodeQLVersion"
}
function Get-DockerVersion {
$dockerVersion = $(docker version --format "{{.Server.Version}}")
return "Docker $dockerVersion"
}
function Get-DockerComposeVersion {
$dockerComposeVersion = docker-compose version --short
return "Docker Compose v1 $dockerComposeVersion"
}
function Get-DockerComposeVersionV2 {
$dockerComposeVersion = docker compose version --short
return "Docker Compose v2 $dockerComposeVersion"
}
function Get-DockerWincredVersion {
$dockerCredVersion = $(docker-credential-wincred version)
return "Docker-wincred $dockerCredVersion"
}
function Get-GitVersion {
$gitVersion = git --version | Take-Part -Part -1
return "Git $gitVersion"
}
function Get-GitLFSVersion {
$(git-lfs version) -match "git-lfs\/(?<version>\d+\.\d+\.\d+)" | Out-Null
$gitLfsVersion = $Matches.Version
return "Git LFS $gitLfsVersion"
}
function Get-InnoSetupVersion {
return $(choco list --local-only innosetup) | Select-String -Pattern "InnoSetup"
}
function Get-JQVersion {
$jqVersion = ($(jq --version) -Split "jq-")[1]
return "jq $jqVersion"
}
function Get-KubectlVersion {
$kubectlVersion = (kubectl version --client --output=json | ConvertFrom-Json).clientVersion.gitVersion.Replace('v','')
return "Kubectl $kubectlVersion"
}
function Get-KindVersion {
$(kind version) -match "kind v(?<version>\d+\.\d+\.\d+)" | Out-Null
$kindVersion = $Matches.Version
return "Kind $kindVersion"
}
function Get-MinGWVersion {
(gcc --version | Select-String -Pattern "MinGW-W64") -match "(?<version>\d+\.\d+\.\d+)" | Out-Null
$mingwVersion = $Matches.Version
return "Mingw-w64 $mingwVersion"
}
function Get-MySQLVersion {
$mysqlCommand = Get-Command -Name "mysql"
$mysqlVersion = $mysqlCommand.Version.ToString()
return "MySQL $mysqlVersion"
}
function Get-SQLOLEDBDriverVersion {
$SQLOLEDBDriverVersion = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSOLEDBSQL' InstalledVersion).InstalledVersion
return "SQL OLEDB Driver $SQLOLEDBDriverVersion"
}
function Get-MercurialVersion {
($(hg --version) | Out-String) -match "version (?<version>\d+\.\d+\.?\d*)" | Out-Null
$mercurialVersion = $Matches.Version
return "Mercurial $mercurialVersion"
}
function Get-NSISVersion {
$nsisVersion = &"c:\Program Files (x86)\NSIS\makensis.exe" "/Version"
return "NSIS $nsisVersion"
}
function Get-OpenSSLVersion {
$(openssl version) -match "OpenSSL (?<version>\d+\.\d+\.\d+\w?) " | Out-Null
$opensslVersion = $Matches.Version
return "OpenSSL $opensslVersion"
}
function Get-PackerVersion {
# Packer 1.7.1 has a bug and outputs version to stderr instead of stdout https://github.com/hashicorp/packer/issues/10855
($(cmd /c "packer --version 2>&1") | Out-String) -match "(?<version>(\d+.){2}\d+)" | Out-Null
$packerVersion = $Matches.Version
return "Packer $packerVersion"
}
function Get-ParcelVersion {
$parcelVersion = parcel --version
return "Parcel $parcelVersion"
}
function Get-PulumiVersion {
return "Pulumi $(pulumi version)"
}
function Get-SQLPSVersion {
$module = Get-Module -Name SQLPS -ListAvailable
$version = $module.Version
return "SQLPS $version"
}
function Get-SVNVersion {
$svnVersion = $(svn --version --quiet)
return "Subversion (SVN) $svnVersion"
}
function Get-VSWhereVersion {
($(Get-Command -Name vswhere).FileVersionInfo.ProductVersion) -match "(?<version>\d+\.\d+\.\d+)" | Out-Null
$vswhereVersion = $Matches.Version
return "VSWhere $vswhereVersion"
}
function Get-WinAppDriver {
$winAppDriverVersion = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("C:\Program Files (x86)\Windows Application Driver\WinAppDriver.exe").FileVersion
return "WinAppDriver $winAppDriverVersion"
}
function Get-WixVersion {
$regKey = "HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\*"
$installedApplications = Get-ItemProperty -Path $regKey
return ($installedApplications | Where-Object { $_.BundleCachePath -imatch ".*\\WiX\d*\.exe$" } | Select-Object -First 1).DisplayName
}
function Get-ZstdVersion {
$(zstd --version) -match "v(?<version>\d+\.\d+\.\d+)" | Out-Null
$zstdVersion = $Matches.Version
return "zstd $zstdVersion"
}
function Get-AzureCLIVersion {
$azureCLIVersion = $(az version) | ConvertFrom-Json | Foreach{ $_."azure-cli" }
return "Azure CLI $azureCLIVersion"
}
function Get-AzCopyVersion {
return ($(azcopy --version) -replace "version ")
}
function Get-AzureDevopsExtVersion {
$azureDevExtVersion = (az version | ConvertFrom-Json | ForEach-Object { $_."extensions" })."azure-devops"
return "Azure DevOps CLI extension $azureDevExtVersion"
}
function Get-AWSCLIVersion {
$(aws --version) -match "aws-cli\/(?<version>\d+\.\d+\.\d+)" | Out-Null
$awscliVersion = $Matches.Version
return "AWS CLI $awscliVersion"
}
function Get-AWSSAMVersion {
$(sam --version) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
$awssamVersion = $Matches.Version
return "AWS SAM CLI $awssamVersion"
}
function Get-AWSSessionManagerVersion {
$awsSessionManagerVersion = $(session-manager-plugin --version)
return "AWS Session Manager CLI $awsSessionManagerVersion"
}
function Get-AlibabaCLIVersion {
$alicliVersion = $(aliyun version)
return "Alibaba Cloud CLI $alicliVersion"
}
function Get-CloudFoundryVersion {
$(cf version) -match "(?<version>\d+\.\d+\.\d+)" | Out-Null
$cfVersion = $Matches.Version
return "Cloud Foundry CLI $cfVersion"
}
function Get-HubVersion {
($(hub version) | Select-String -Pattern "hub version") -match "hub version (?<version>\d+\.\d+\.\d+)" | Out-Null
$hubVersion = $Matches.Version
return "Hub CLI $hubVersion"
}
function Get-7zipVersion {
(7z | Out-String) -match "7-Zip (?<version>\d+\.\d+\.?\d*)" | Out-Null
$version = $Matches.Version
return "7zip $version"
}
function Get-GHCVersion {
((ghc --version) | Out-String) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
$ghcVersion = $Matches.Version
return "ghc $ghcVersion"
}
function Get-CabalVersion {
((cabal --version) | Out-String) -match "version (?<version>\d+\.\d+\.\d+\.\d+)" | Out-Null
$cabalVersion = $Matches.Version
return "Cabal $cabalVersion"
}
function Get-StackVersion {
((stack --version --quiet) | Out-String) -match "Version (?<version>\d+\.\d+\.\d+)," | Out-Null
$stackVersion = $Matches.Version
return "Stack $stackVersion"
}
function Get-GoogleCloudSDKVersion {
(gcloud --version) -match "Google Cloud SDK"
}
function Get-ServiceFabricSDKVersion {
$serviceFabricSDKVersion = Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Service Fabric\' -Name FabricVersion
return "Service Fabric SDK $serviceFabricSDKVersion"
}
function Get-NewmanVersion {
return "Newman $(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 "GitHub CLI $ghVersion"
}
function Get-VisualCPPComponents {
$vcpp = Get-CimInstance -ClassName Win32_Product -Filter "Name LIKE 'Microsoft Visual C++%'"
$vcpp | Sort-Object Name, Version | ForEach-Object {
$isMatch = $_.Name -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 = $_.Version
[PSCustomObject]@{
Name = $name
Architecture = $arch
Version = $version
}
}
}
}
function Get-DacFxVersion {
$dacfxversion = & "$env:ProgramFiles\Microsoft SQL Server\160\DAC\bin\sqlpackage.exe" /version
return "DacFx $dacfxversion"
}
function Get-SwigVersion {
(swig -version | Out-String) -match "version (?<version>\d+\.\d+\.\d+)" | Out-Null
$swigVersion = $Matches.Version
return "Swig $swigVersion"
}