Skip to main content

FormatTaskName

This page was generated

Contributions are welcome in Psake-repo.

SYNOPSIS

This function allows you to change how psake renders the task name during a build.

SYNTAX

__AllParameterSets

FormatTaskName [-Format] <Object> [<CommonParameters>]

DESCRIPTION

Useful for adding visual separators or color to task names in the build output. Accepts a -f format string or a scriptblock that receives the task name as its only argument.

EXAMPLES

EXAMPLE 1

Task default -depends TaskA, TaskB, TaskC
FormatTaskName "-------- {0} --------"
Task TaskA {
"TaskA is executing"
}
Task TaskB {
"TaskB is executing"
}
Task TaskC {
"TaskC is executing"
}

A sample build script that uses a format string. The script above produces the following output:

-------- TaskA --------
TaskA is executing
-------- TaskB --------
TaskB is executing
-------- TaskC --------
TaskC is executing

Build Succeeded!

EXAMPLE 2

Task default -depends TaskA, TaskB, TaskC
FormatTaskName {
param($taskName)
write-host "Executing Task: $taskName" -ForegroundColor blue
}
Task TaskA {
"TaskA is executing"
}
Task TaskB {
"TaskB is executing"
}
Task TaskC {
"TaskC is executing"
}

A sample build script that uses a ScriptBlock. The above example uses the scriptblock parameter to the FormatTaskName function to render each task name in the color blue.

Note: the $taskName parameter name is arbitrary, it could be named anything.

PARAMETERS

-Format

A format string or a scriptblock to execute

Type: System.Object
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: true
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

VERSION

This page was generated using comment-based help in Psake 5.0.4.