mirror of
https://github.com/actions/versions-package-tools.git
synced 2025-12-10 19:50:24 +00:00
Fix win-vs-env.psm1 and pester-extensions.psm1 (#15)
This commit is contained in:
@@ -6,23 +6,28 @@ Pester extension that allows to run command and validate exit code
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
function Get-CommandResult {
|
function Get-CommandResult {
|
||||||
param (
|
Param (
|
||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string] $Command,
|
[string] $Command,
|
||||||
[switch] $Multiline
|
[switch] $Multiline
|
||||||
)
|
)
|
||||||
# Bash trick to suppress and show error output because some commands write to stderr (for example, "python --version")
|
# CMD trick to suppress and show error output because some commands write to stderr (for example, "python --version")
|
||||||
$stdout = & bash -c "$Command 2>&1"
|
If ($IsWindows) {
|
||||||
|
[string[]]$output = & $env:comspec /c "$Command 2>&1"
|
||||||
|
} else {
|
||||||
|
$output = & bash -c "$Command 2>&1"
|
||||||
|
}
|
||||||
$exitCode = $LASTEXITCODE
|
$exitCode = $LASTEXITCODE
|
||||||
|
|
||||||
return @{
|
return @{
|
||||||
Output = If ($Multiline -eq $true) { $stdout } else { [string]$stdout }
|
Output = If ($Multiline -eq $true) { $output } else { [string]$output }
|
||||||
ExitCode = $exitCode
|
ExitCode = $exitCode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShouldReturnZeroExitCode {
|
function ShouldReturnZeroExitCode {
|
||||||
Param(
|
Param(
|
||||||
[String] $ActualValue,
|
[string] $ActualValue,
|
||||||
[switch] $Negate,
|
[switch] $Negate,
|
||||||
[string] $Because # This parameter is unused by we need it to match Pester asserts signature
|
[string] $Because # This parameter is unused by we need it to match Pester asserts signature
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
function Get-VSWhere {
|
function Get-VSWhere {
|
||||||
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe";
|
$vswhere = "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||||
|
|
||||||
if (-not (Test-Path $vswhere )) {
|
if (-not (Test-Path $vswhere )) {
|
||||||
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
|
||||||
@@ -34,9 +34,11 @@ function Invoke-Environment
|
|||||||
}
|
}
|
||||||
|
|
||||||
function Get-VSInstallationPath {
|
function Get-VSInstallationPath {
|
||||||
|
Write-Host "ProgramFiles(x86) - ${env:ProgramFiles(x86)}"
|
||||||
$vswhere = Get-VSWhere
|
$vswhere = Get-VSWhere
|
||||||
|
Write-Host "vswhere - $vswhere"
|
||||||
$installationPath = & $vswhere -prerelease -legacy -latest -property installationPath
|
$installationPath = & $vswhere -prerelease -legacy -latest -property installationPath
|
||||||
|
Write-Host "installationPath - $installationPath"
|
||||||
return $installationPath
|
return $installationPath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user