Test-BuildEnvironment
Contributions are welcome in Psake-repo.
This command was introduced in Psake 5.0 and is not available in earlier versions.
SYNOPSIS
Tests whether the .NET framework required by a build is available on the current machine.
SYNTAX
Framework (Default)
Test-BuildEnvironment [[-Framework] <string>] [<CommonParameters>]
BuildFile
Test-BuildEnvironment -BuildFile <string> [<CommonParameters>]
DESCRIPTION
Resolves the MSBuild and .NET runtime directories for the specified framework version and checks that every required directory exists. Returns $true if the environment is ready, $false otherwise.
The framework to check is determined in order of precedence: 1. The -Framework parameter, if supplied. 2. The framework declared in -BuildFile, if supplied. 3. The active psake build context (if one is on the stack). 4. The psake default framework (4.7.2).
This is useful in Pester specs to skip tests that require a framework toolchain that is not installed:
It 'compiles with MSBuild 4.8' { if (-not (Test-BuildEnvironment -Framework '4.8')) { Set-ItResult -Skipped -Because 'Framework 4.8 not available' }
...
rest of test }
It 'uses the project framework' { if (-not (Test-BuildEnvironment -BuildFile './psakefile.ps1')) { Set-ItResult -Skipped -Because 'Required framework not available' }
...
rest of test }
EXAMPLES
EXAMPLE 1
Test-BuildEnvironment -Framework '4.8'
Returns $true when MSBuild 17.0 or 16.0 and the v4.0.30319 runtime directory are both present.
EXAMPLE 2
Test-BuildEnvironment -BuildFile './psakefile.ps1'
Loads the build file, reads its Framework setting, and returns $true if that framework is installed.
EXAMPLE 3
if (-not (Test-BuildEnvironment)) {
Write-Warning "Build environment not ready for current framework"
}
Tests the framework configured in the active psake context.
PARAMETERS
-BuildFile
Path to a psake build script. The framework declared in that file is read and tested. Ignored when -Framework is also supplied.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: BuildFile
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Framework
The .NET framework version string to test (e.g. '4.8', '3.5', '4.7.2x64'). Takes precedence over -BuildFile and the active context.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Framework
Position: 0
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
INPUTS
OUTPUTS
[bool]
{{ Fill in the Description }}
System.Boolean
{{ Fill in the Description }}
NOTES
RELATED LINKS
VERSION
This page was generated using comment-based help in Psake 5.0.3.