Test-PsakeTask
Contributions are welcome in Psake-repo.
This command was introduced in Psake 5.0 and is not available in earlier versions.
SYNOPSIS
Runs a single task's Action in isolation, without triggering dependencies.
SYNTAX
__AllParameterSets
Test-PsakeTask [[-BuildFile] <string>] [-TaskName] <string> [[-Variables] <hashtable>]
[<CommonParameters>]
DESCRIPTION
Compiles the build file, finds the specified task, and executes only its Action scriptblock with the provided variables. Dependencies are NOT executed.This enables unit-testing individual tasks.
EXAMPLES
EXAMPLE 1
$result = Test-PsakeTask -BuildFile './psakefile.ps1' -TaskName 'Build' -Variables @{
Configuration = 'Debug'
OutputDir = './test-output'
}
$result.Success | Should -BeTrue
This example runs the 'Build' task from 'psakefile.ps1' with two variables injected into the task's scope. The result object contains details about the execution, including success status, duration, and any error messages.
PARAMETERS
-BuildFile
The path to the psake build script. Defaults to 'psakefile.ps1'.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-TaskName
The name of the task to execute.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 1
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Variables
A hashtable of variables to inject into the task's execution scope.
Type: System.Collections.Hashtable
DefaultValue: '@{}'
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 2
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
NOTES
Dependencies, PreAction, and PostAction are skipped — only the task's Action scriptblock is executed.
RELATED LINKS
VERSION
This page was generated using comment-based help in Psake 5.0.4.