[Windows] Minor documentation improvements (#6751)

This commit is contained in:
Maxim Lobanov
2022-12-14 19:53:32 +01:00
committed by GitHub
parent 2f83bbaa50
commit 257743a26d
5 changed files with 117 additions and 184 deletions

View File

@@ -1,80 +1,51 @@
function Get-GoMarkdown function Get-ToolcacheGoVersions {
{ $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Go"
$Name = "Go" return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
$ToolInstances = Get-CachedToolInstances -Name $Name -VersionCommand "version"
foreach ($Instance in $ToolInstances)
{
$Version = [System.Version]($Instance.Version -Split(" "))[0]
$Instance."Environment Variable" = "GOROOT_$($Version.major)_$($Version.minor)_X64"
} }
$Content = $ToolInstances | New-MDTable -Columns ([ordered]@{ function Get-ToolcacheNodeVersions {
Version = "left"; $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Node"
Architecture = "left"; return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
"Environment Variable" = "left"
})
return Build-MarkdownElement -Head $Name -Content $Content
} }
function Get-NodeMarkdown function Get-ToolcachePythonVersions {
{ $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Python"
$Name = "Node" return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
$ToolInstances = Get-CachedToolInstances -Name $Name
$Content = $ToolInstances | New-MDTable -Columns ([ordered]@{Version = "left"; Architecture = "left"})
return Build-MarkdownElement -Head $Name -Content $Content
} }
function Get-PythonMarkdown function Get-ToolcacheRubyVersions {
{ $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "Ruby"
$Name = "Python" return Get-ChildItem $toolcachePath -Name | Sort-Object { [Version]$_ }
$ToolInstances = Get-CachedToolInstances -Name $Name -VersionCommand "--version"
$Content = $ToolInstances | New-MDTable -Columns ([ordered]@{Version = "left"; Architecture = "left"})
return Build-MarkdownElement -Head $Name -Content $Content
} }
function Get-RubyMarkdown function Get-ToolcachePyPyVersions {
{ $toolcachePath = Join-Path $env:AGENT_TOOLSDIRECTORY "PyPy"
$Name = "Ruby" Get-ChildItem -Path $toolcachePath -Name | Sort-Object { [Version] $_ } | ForEach-Object {
$ToolInstances = Get-CachedToolInstances -Name $Name -VersionCommand "--version" $pypyRootPath = Join-Path $toolcachePath $_ "x86"
$Content = $ToolInstances | New-MDTable -Columns ([ordered]@{Version = "left"; Architecture = "left"}) [string]$pypyVersionOutput = & "$pypyRootPath\python.exe" -c "import sys;print(sys.version)"
$pypyVersionOutput -match "^([\d\.]+) \(.+\) \[PyPy ([\d\.]+\S*) .+]$" | Out-Null
return Build-MarkdownElement -Head $Name -Content $Content return "{0} [PyPy {1}]" -f $Matches[1], $Matches[2]
}
function Get-PyPyMarkdown
{
$Name = "PyPy"
$ToolInstances = Get-CachedToolInstances -Name $Name
foreach ($Instance in $ToolInstances)
{
$Instance."PyPy Version" = @()
$Instance."Python Version" = $Instance.Version
foreach ($Arch in $Instance.Architecture_Array)
{
$pythonExePath = Join-Path $Instance.Path $Arch | Join-Path -ChildPath "python.exe"
$Instance."PyPy Version" += (& $pythonExePath -c "import sys;print(sys.version.split('\n')[1])").Trim("[]")
} }
} }
$Content = $ToolInstances | New-MDTable -Columns ([ordered]@{ function Build-CachedToolsSection
"Python Version" = "left";
"PyPy Version" = "left"
})
return Build-MarkdownElement -Head $Name -Content $Content
}
function Build-CachedToolsMarkdown
{ {
$markdown = "" $output = ""
$markdown += Get-GoMarkdown
$markdown += Get-NodeMarkdown
$markdown += Get-PythonMarkdown
$markdown += Get-RubyMarkdown
$markdown += Get-PyPyMarkdown
return $markdown $output += New-MDHeader "Go" -Level 4
$output += New-MDList -Lines (Get-ToolcacheGoVersions) -Style Unordered
$output += New-MDHeader "Node.js" -Level 4
$output += New-MDList -Lines (Get-ToolcacheNodeVersions) -Style Unordered
$output += New-MDHeader "Python" -Level 4
$output += New-MDList -Lines (Get-ToolcachePythonVersions) -Style Unordered
$output += New-MDHeader "PyPy" -Level 4
$output += New-MDList -Lines (Get-ToolcachePyPyVersions) -Style Unordered
$output += New-MDHeader "Ruby" -Level 4
$output += New-MDList -Lines (Get-ToolcacheRubyVersions) -Style Unordered
return $output
} }

View File

@@ -5,7 +5,7 @@ function Initialize-RustEnvironment {
} }
function Get-OSName { function Get-OSName {
return (Get-CimInstance -ClassName Win32_OperatingSystem).Caption return (Get-CimInstance -ClassName Win32_OperatingSystem).Caption | Take-Part -Part 1,2,3
} }
function Get-OSVersion { function Get-OSVersion {
@@ -124,7 +124,7 @@ function Get-ChocoVersion {
function Get-VcpkgVersion { function Get-VcpkgVersion {
$commitId = git -C "C:\vcpkg" rev-parse --short HEAD $commitId = git -C "C:\vcpkg" rev-parse --short HEAD
return "Vcpkg (build from master \<$commitId>)" return "Vcpkg (build from commit $commitId)"
} }
function Get-NPMVersion { function Get-NPMVersion {
@@ -190,7 +190,7 @@ function Get-SbtVersion {
function Get-DotnetSdks { function Get-DotnetSdks {
$sdksRawList = dotnet --list-sdks $sdksRawList = dotnet --list-sdks
$sdkVersions = ($sdksRawList | Foreach-Object {$_.Split()[0]}) -join ' ' $sdkVersions = ($sdksRawList | Foreach-Object {$_.Split()[0]}) -join ', '
$sdkPath = $sdksRawList[0].Split(' ', 2)[1] -replace '\[|]' $sdkPath = $sdksRawList[0].Split(' ', 2)[1] -replace '\[|]'
[PSCustomObject]@{ [PSCustomObject]@{
Versions = $sdkVersions Versions = $sdkVersions
@@ -214,7 +214,7 @@ function Get-DotnetRuntimes {
$runtimesRawList = dotnet --list-runtimes $runtimesRawList = dotnet --list-runtimes
$runtimesRawList | Group-Object {$_.Split()[0]} | ForEach-Object { $runtimesRawList | Group-Object {$_.Split()[0]} | ForEach-Object {
$runtimeName = $_.Name $runtimeName = $_.Name
$runtimeVersions = ($_.Group | Foreach-Object {$_.split()[1]}) -join ' ' $runtimeVersions = ($_.Group | Foreach-Object {$_.split()[1]}) -join ', '
$runtimePath = $_.Group[0].Split(' ', 3)[2] -replace '\[|]' $runtimePath = $_.Group[0].Split(' ', 3)[2] -replace '\[|]'
[PSCustomObject]@{ [PSCustomObject]@{
"Runtime" = $runtimeName "Runtime" = $runtimeName
@@ -224,68 +224,61 @@ function Get-DotnetRuntimes {
} }
} }
function Get-DotnetFrameworkTools { function Get-DotnetFrameworkVersions {
$path = "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\*\*\NETFX*" $path = "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\*\*\NETFX * Tools"
Get-ChildItem -Path $path -Directory | Group-Object { $versions = Get-ChildItem -Path $path -Directory | ForEach-Object { $_.Name | Take-Part -Part 1 }
$_.Fullname -Replace " \d+\.\d+(\.\d+)?", " <version>" $versions -join ', '
} | ForEach-Object {
[PSCustomObject]@{
Versions = $_.Group.Name | ForEach-Object { $_.Split(" ")[1] }
Path = $_.Name
}
}
} }
function Get-PowerShellAzureModules { function Get-PowerShellAzureModules {
# Module names [Array] $result = @()
$names = @{ $defaultAzureModuleVersion = "2.1.0"
'az' = 'Az'
'azurerm' = 'AzureRM' [Array] $azInstalledModules = Get-ChildItem -Path "C:\Modules\az_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] }
'azure' = 'Azure' if ($azInstalledModules.Count -gt 0) {
$result += "Az: $($azInstalledModules -join ', ')"
} }
# Get default module version [Array] $azureInstalledModules = Get-ChildItem -Path "C:\Modules\azure_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] } | ForEach-Object { if ($_ -eq $defaultAzureModuleVersion) { "$($_) (Default)" } else { $_ } }
$defaults = @{ if ($azureInstalledModules.Count -gt 0) {
'azurerm' = (Get-Module -Name AzureRM -ListAvailable).Version $result += "Azure: $($azureInstalledModules -join ', ')"
'azure' = (Get-Module -Name Azure -ListAvailable).Version
} }
$modulesPath = "C:\Modules" [Array] $azurermInstalledModules = Get-ChildItem -Path "C:\Modules\azurerm_*" -Directory | ForEach-Object { $_.Name.Split("_")[1] } | ForEach-Object { if ($_ -eq $defaultAzureModuleVersion) { "$($_) (Default)" } else { $_ } }
$modules = Get-ChildItem -Path $modulesPath | Sort-Object Name | Group-Object {$_.Name.Split('_')[0]} if ($azurermInstalledModules.Count -gt 0) {
$modules | ForEach-Object { $result += "AzureRM: $($azurermInstalledModules -join ', ')"
$group = $_.group | Sort-Object {[Version]$_.Name.Split('_')[1].Replace(".zip","")}
$moduleName = $names[$_.Name]
$moduleVersions = $group | ForEach-Object {$_.Name.Split('_')[1]}
$moduleVersions = $moduleVersions -join '<br>'
$modulePath = (($group.FullName).Split("_"))[0] + '_\<version\>'
# set default version
$defaultVersion = $defaults[$_.Name]
if ($defaultVersion) {
$moduleVersions = $moduleVersions.Replace($defaultVersion, "$defaultVersion [Installed]")
} }
[PSCustomObject]@{ [Array] $azCachedModules = Get-ChildItem -Path "C:\Modules\az_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] }
Module = $moduleName if ($azCachedModules.Count -gt 0) {
Version = $moduleVersions $result += "Az (Cached): $($azCachedModules -join ', ')"
Path = $modulePath
} }
[Array] $azureCachedModules = Get-ChildItem -Path "C:\Modules\azure_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] }
if ($azureCachedModules.Count -gt 0) {
$result += "Azure (Cached): $($azureCachedModules -join ', ')"
} }
[Array] $azurermCachedModules = Get-ChildItem -Path "C:\Modules\azurerm_*.zip" -File | ForEach-Object { $_.Name.Split("_")[1] }
if ($azurermCachedModules.Count -gt 0) {
$result += "AzureRM: $($azurermCachedModules -join ', ')"
}
return $result
} }
function Get-PowerShellModules { function Get-PowerShellModules {
$modules = (Get-ToolsetContent).powershellModules.name [Array] $result = @()
$psModules = Get-Module -Name $modules -ListAvailable | Sort-Object Name | Group-Object Name $result += Get-PowerShellAzureModules
$psModules | ForEach-Object {
$moduleName = $_.Name
$moduleVersions = ($_.group.Version | Sort-Object -Unique) -join '<br>'
[PSCustomObject]@{ $result += (Get-ToolsetContent).powershellModules.name | Sort-Object | ForEach-Object {
Module = $moduleName $moduleName = $_
Version = $moduleVersions $moduleVersions = Get-Module -Name $moduleName -ListAvailable | Select-Object -ExpandProperty Version | Sort-Object -Unique
} return "$($moduleName): $($moduleVersions -join ', ')"
} }
return $result
} }
function Get-CachedDockerImages { function Get-CachedDockerImages {
@@ -343,24 +336,14 @@ function Get-PipxVersion {
} }
function Build-PackageManagementEnvironmentTable { function Build-PackageManagementEnvironmentTable {
$envVariables = @( return @(
@{ [PSCustomObject] @{
"Name" = "VCPKG_INSTALLATION_ROOT" "Name" = "VCPKG_INSTALLATION_ROOT"
"Value" = $env:VCPKG_INSTALLATION_ROOT "Value" = $env:VCPKG_INSTALLATION_ROOT
} },
) [PSCustomObject] @{
if (Test-IsWin19) {
$envVariables += @(
@{
"Name" = "CONDA" "Name" = "CONDA"
"Value" = $env:CONDA "Value" = $env:CONDA
} }
) )
} }
return $envVariables | ForEach-Object {
[PSCustomObject] @{
"Name" = $_.Name
"Value" = $_.Value
}
}
}

View File

@@ -26,9 +26,9 @@ $markdown += New-MDList -Style Unordered -Lines @(
"Image Version: $env:IMAGE_VERSION" "Image Version: $env:IMAGE_VERSION"
) )
$markdown += New-MDHeader "Enabled windows optional features" -Level 2 $markdown += New-MDHeader "Windows features" -Level 2
$markdown += New-MDList -Style Unordered -Lines @( $markdown += New-MDList -Style Unordered -Lines @(
"Windows Subsystem for Linux [WSLv1]" "Windows Subsystem for Linux (WSLv1): Enabled"
) )
$markdown += New-MDHeader "Installed Software" -Level 2 $markdown += New-MDHeader "Installed Software" -Level 2
@@ -165,7 +165,7 @@ $markdown += New-MDList -Style Unordered -Lines (@(
) | Sort-Object ) | Sort-Object
) )
$markdown += New-MDHeader "Browsers and webdrivers" -Level 3 $markdown += New-MDHeader "Browsers and Drivers" -Level 3
$markdown += New-MDList -Style Unordered -Lines @( $markdown += New-MDList -Style Unordered -Lines @(
(Get-BrowserVersion -Browser "chrome"), (Get-BrowserVersion -Browser "chrome"),
(Get-SeleniumWebDriverVersion -Driver "chrome"), (Get-SeleniumWebDriverVersion -Driver "chrome"),
@@ -208,7 +208,7 @@ if (Test-IsWin19)
} }
$markdown += New-MDHeader "Cached Tools" -Level 3 $markdown += New-MDHeader "Cached Tools" -Level 3
$markdown += (Build-CachedToolsMarkdown) $markdown += (Build-CachedToolsSection)
$markdown += New-MDHeader "Databases" -Level 3 $markdown += New-MDHeader "Databases" -Level 3
$markdown += Build-DatabasesMarkdown $markdown += Build-DatabasesMarkdown
@@ -241,46 +241,29 @@ $markdown += New-MDNewLine
$markdown += New-MDHeader "Installed Windows SDKs" -Level 4 $markdown += New-MDHeader "Installed Windows SDKs" -Level 4
$sdk = Get-WindowsSDKs $sdk = Get-WindowsSDKs
$markdown += "``Location $($sdk.Path)``"
$markdown += New-MDNewLine $markdown += New-MDNewLine
$markdown += New-MDList -Lines $sdk.Versions -Style Unordered $markdown += New-MDList -Lines $sdk.Versions -Style Unordered
$markdown += New-MDHeader ".NET Core SDK" -Level 3 $markdown += New-MDHeader ".NET Core Tools" -Level 3
$sdk = Get-DotnetSdks $dotnetSdk = Get-DotnetSdks
$markdown += "``Location $($sdk.Path)``" $dotnetFrameworkVersions = Get-DotnetFrameworkVersions
$markdown += New-MDNewLine $dotnetTools = @(
$markdown += New-MDList -Lines $sdk.Versions -Style Unordered ".NET Core SDK: $($dotnetSdk.Versions)",
".NET Framework: $($dotnetFrameworkVersions)"
$markdown += New-MDHeader ".NET Core Runtime" -Level 3 )
Get-DotnetRuntimes | Foreach-Object { $dotnetTools += Get-DotnetRuntimes | ForEach-Object {
$path = $_.Path "$($_.Runtime): $($_.Versions)"
$versions = $_.Versions
$markdown += "``Location: $path``"
$markdown += New-MDNewLine
$markdown += New-MDList -Lines $versions -Style Unordered
} }
$dotnetTools += Get-DotnetTools
$markdown += New-MDList -Style Unordered -Lines $dotnetTools
$markdown += New-MDHeader ".NET Framework" -Level 3
$markdown += "``Type: Developer Pack``"
$markdown += New-MDNewLine
Get-DotnetFrameworkTools | Foreach-Object {
$path = $_.Path
$versions = $_.Versions
$markdown += "``Location: $path``"
$markdown += New-MDNewLine
$markdown += New-MDList -Lines $versions -Style Unordered
}
$markdown += New-MDHeader ".NET tools" -Level 3
$tools = Get-DotnetTools
$markdown += New-MDList -Lines $tools -Style Unordered
# PowerShell Tools # PowerShell Tools
$markdown += New-MDHeader "PowerShell Tools" -Level 3 $markdown += New-MDHeader "PowerShell Tools" -Level 3
$markdown += New-MDList -Lines (Get-PowershellCoreVersion) -Style Unordered $markdown += New-MDList -Lines (Get-PowershellCoreVersion) -Style Unordered
$markdown += New-MDHeader "Azure Powershell Modules" -Level 4 $markdown += New-MDHeader "Powershell Modules" -Level 4
$markdown += Get-PowerShellAzureModules | New-MDTable $markdown += New-MDList -Lines $(Get-PowerShellModules) -Style Unordered
$reportAzPwsh = @' $reportAzPwsh = @'
``` ```
Azure PowerShell module 2.1.0 and AzureRM PowerShell module 2.1.0 are installed Azure PowerShell module 2.1.0 and AzureRM PowerShell module 2.1.0 are installed
@@ -290,9 +273,6 @@ All other versions are saved but not installed.
'@ '@
$markdown += New-MDParagraph -Lines $reportAzPwsh $markdown += New-MDParagraph -Lines $reportAzPwsh
$markdown += New-MDHeader "Powershell Modules" -Level 4
$markdown += Get-PowerShellModules | New-MDTable
$markdown += New-MDNewLine
# Android section # Android section
$markdown += New-MDHeader "Android" -Level 3 $markdown += New-MDHeader "Android" -Level 3

View File

@@ -126,7 +126,7 @@ function Get-MercurialVersion {
function Get-NSISVersion { function Get-NSISVersion {
$nsisVersion = &"c:\Program Files (x86)\NSIS\makensis.exe" "/Version" $nsisVersion = &"c:\Program Files (x86)\NSIS\makensis.exe" "/Version"
return "NSIS $nsisVersion" return "NSIS $($nsisVersion.TrimStart('v'))"
} }
function Get-OpenSSLVersion { function Get-OpenSSLVersion {
@@ -148,7 +148,8 @@ function Get-ParcelVersion {
} }
function Get-PulumiVersion { function Get-PulumiVersion {
return "Pulumi $(pulumi version)" $pulumiVersion = $(pulumi version)
return "Pulumi $($pulumiVersion.TrimStart('v'))"
} }
function Get-SQLPSVersion { function Get-SQLPSVersion {

View File

@@ -1,5 +1,3 @@
Import-Module (Join-Path $PSScriptRoot "..\SoftwareReport\SoftwareReport.Common.psm1") -DisableNameChecking
Describe "Azure Cosmos DB Emulator" { Describe "Azure Cosmos DB Emulator" {
$cosmosDbEmulatorRegKey = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Get-ItemProperty | Where-Object { $_.DisplayName -eq 'Azure Cosmos DB Emulator' } $cosmosDbEmulatorRegKey = Get-ChildItem "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" | Get-ItemProperty | Where-Object { $_.DisplayName -eq 'Azure Cosmos DB Emulator' }
$installDir = $cosmosDbEmulatorRegKey.InstallLocation $installDir = $cosmosDbEmulatorRegKey.InstallLocation
@@ -103,7 +101,7 @@ Describe "GoogleCloudSDK" -Skip:(Test-IsWin22) {
Describe "NET48" { Describe "NET48" {
It "NET48" { It "NET48" {
(Get-DotnetFrameworkTools).Versions | Should -Contain "4.8" Get-ChildItem -Path "${env:ProgramFiles(x86)}\Microsoft SDKs\Windows\*\*\NETFX 4.8 Tools" -Directory | Should -HaveCount 1
} }
} }