Downloads:
85,993
Downloads of v 4.4.1:
7,441
Last Update:
09 Feb 2015
Package Maintainer(s):
Software Author(s):
- James Kovacs
Tags:
build powershell chocolatey- Software Specific:
- Software Site
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
psake
This is not the latest version of psake available.
- 1
- 2
- 3
4.4.1 | Updated: 09 Feb 2015
- Software Specific:
- Software Site
- Package Specific:
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
85,993
Downloads of v 4.4.1:
7,441
Maintainer(s):
Software Author(s):
- James Kovacs
psake 4.4.1
This is not the latest version of psake available.
Legal Disclaimer: Neither this package nor Chocolatey Software, Inc. are affiliated with or endorsed by James Kovacs. The inclusion of James Kovacs trademark(s), if any, upon this webpage is solely to identify James Kovacs goods or services and not for commercial purposes.
- 1
- 2
- 3
Some Checks Have Failed or Are Not Yet Complete
Not All Tests Have Passed
Deployment Method: Individual Install, Upgrade, & Uninstall
To install psake, run the following command from the command line or from PowerShell:
To upgrade psake, run the following command from the command line or from PowerShell:
To uninstall psake, run the following command from the command line or from PowerShell:
Deployment Method:
This applies to both open source and commercial editions of Chocolatey.
1. Enter Your Internal Repository Url
(this should look similar to https://community.chocolatey.org/api/v2/)
2. Setup Your Environment
1. Ensure you are set for organizational deployment
Please see the organizational deployment guide
2. Get the package into your environment
Option 1: Cached Package (Unreliable, Requires Internet - Same As Community)-
Open Source or Commercial:
- Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://community.chocolatey.org/api/v2/. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
- You can also just download the package and push it to a repository Download
-
Open Source
-
Download the package:
Download - Follow manual internalization instructions
-
-
Package Internalizer (C4B)
-
Run: (additional options)
choco download psake --internalize --version=4.4.1 --source=https://community.chocolatey.org/api/v2/
-
For package and dependencies run:
choco push --source="'INTERNAL REPO URL'"
- Automate package internalization
-
Run: (additional options)
3. Copy Your Script
choco upgrade psake -y --source="'INTERNAL REPO URL'" --version="'4.4.1'" [other options]
See options you can pass to upgrade.
See best practices for scripting.
Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.
If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:
choco upgrade psake -y --source="'INTERNAL REPO URL'" --version="'4.4.1'"
$exitCode = $LASTEXITCODE
Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
- name: Install psake
win_chocolatey:
name: psake
version: '4.4.1'
source: INTERNAL REPO URL
state: present
See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.
chocolatey_package 'psake' do
action :install
source 'INTERNAL REPO URL'
version '4.4.1'
end
See docs at https://docs.chef.io/resource_chocolatey_package.html.
cChocoPackageInstaller psake
{
Name = "psake"
Version = "4.4.1"
Source = "INTERNAL REPO URL"
}
Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.
package { 'psake':
ensure => '4.4.1',
provider => 'chocolatey',
source => 'INTERNAL REPO URL',
}
Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.
4. If applicable - Chocolatey configuration/installation
See infrastructure management matrix for Chocolatey configuration elements and examples.
This package was approved by moderator purity on 01 Mar 2015.
psake is a build automation tool written in PowerShell. It avoids the angle-bracket tax associated with executable XML by leveraging the PowerShell syntax in your build scripts. psake has a syntax inspired by rake (aka make in Ruby) and bake (aka make in Boo), but is easier to script because it leverages your existent command-line knowledge. psake is pronounced sake - as in Japanese rice wine. It does NOT rhyme with make, bake, or rake. You can also install with chocolatey (http://nuget.org/List/Packages/chocolatey) and have global psake.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<helpItems schema="maml">
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Invoke-psake</command:name>
<maml:description>
<maml:para>Runs a psake build script.</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb>Invoke</command:verb>
<command:noun>psake</command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>This function runs a psake build script</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>Invoke-psake</command:name>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>buildFile</maml:name>
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>taskList</maml:name>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>framework</maml:name>
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>docs</maml:name>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>parameters</maml:name>
<command:parameterValue required="false" variableLength="false">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>properties</maml:name>
<command:parameterValue required="false" variableLength="false">Hashtable</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>nologo</maml:name>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>buildFile</maml:name>
<maml:description>
<maml:para>The path to the psake build script to execute</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>'default.ps1'</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="1">
<maml:name>taskList</maml:name>
<maml:description>
<maml:para>A comma-separated list of task names to execute</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue />
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="2">
<maml:name>framework</maml:name>
<maml:description>
<maml:para>The version of the .NET framework you want to use during build. You can append x86 or x64 to force a specific framework. If not specified, x86 or x64 will be detected based on the bitness of the PowerShell process.
Possible values: '1.0', '1.1', '2.0', '2.0x86', '2.0x64', '3.0', '3.0x86', '3.0x64', '3.5', '3.5x86', '3.5x64', '4.0', '4.0x86', '4.0x64', '4.5', '4.5x86', '4.5x64', '4.5.1', '4.5.1x86', '4.5.1x64'</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue>'3.5'</dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="3">
<maml:name>docs</maml:name>
<maml:description>
<maml:para>Prints a list of tasks and their descriptions</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue />
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="4">
<maml:name>parameters</maml:name>
<maml:description>
<maml:para>A hashtable containing parameters to be passed into the current build script. These parameters will be processed before the 'Properties' function of the script is processed. This means you can access parameters from within the 'Properties' function!
</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">Hashtable</command:parameterValue>
<dev:type>
<maml:name>Hashtable</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue />
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="5">
<maml:name>properties</maml:name>
<maml:description>
<maml:para>A hashtable containing properties to be passed into the current build script. These properties will override matching properties that are found in the 'Properties' function of the script.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">Hashtable</command:parameterValue>
<dev:type>
<maml:name>Hashtable</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue />
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="6">
<maml:name>nologo</maml:name>
<maml:description>
<maml:para>Do not display the startup banner and copyright message.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue />
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para>---- Exceptions ----</maml:para>
<maml:para>If there is an exception thrown during the running of a build script psake will set the '$psake.build_success' variable to $false. To detect failue outside PowerShell (for example by build server), finish PowerShell process with non-zero exit code when '$psake.build_success' is $false. Calling psake from 'cmd.exe' with 'psake.cmd' will give you that behaviour.</maml:para>
<maml:para></maml:para>
</maml:alert>
<maml:alert>
<maml:para>---- $psake variable ----</maml:para>
<maml:para>When the psake module is loaded a variable called $psake is created which is a hashtable
containing some variables:
$psake.version # contains the current version of psake
$psake.context # holds onto the current state of all variables
$psake.run_by_psake_build_tester # indicates that build is being run by psake-BuildTester
$psake.config_default # contains default configuration
# can be overriden in psake-config.ps1 in directory with psake.psm1 or in directory with current build script
$psake.build_success # indicates that the current build was successful
$psake.build_script_file # contains a System.IO.FileInfo for the current build script
$psake.build_script_dir # contains the fully qualified path to the current build script
You should see the following when you display the contents of the $psake variable right after importing psake
PS projects:\psake> Import-Module .\psake.psm1
PS projects:\psake> $psake
Name Value
---- -----
run_by_psake_build_tester False
version 4.2
build_success False
build_script_file
build_script_dir
config_default @{framework=3.5; ...
context {}
After a build is executed the following $psake values are updated: build_script_file, build_script_dir, build_success
PS projects:\psake> Invoke-psake .\examples\default.ps1
Executing task: Clean
Executed Clean!
Executing task: Compile
Executed Compile!
Executing task: Test
Executed Test!
Build Succeeded!
----------------------------------------------------------------------
Build Time Report
----------------------------------------------------------------------
Name Duration
---- --------
Clean 00:00:00.0798486
Compile 00:00:00.0869948
Test 00:00:00.0958225
Total: 00:00:00.2712414
PS projects:\psake> $psake
Name Value
---- -----
build_script_file YOUR_PATH\examples\default.ps1
run_by_psake_build_tester False
build_script_dir YOUR_PATH\examples
context {}
version 4.2
build_success True
config_default @{framework=3.5; ...
</maml:para>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Invoke-psake</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>Runs the 'default' task in the '.build.ps1' build script</maml:para>
<maml:para />
<maml:para />
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------- EXAMPLE 2 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Invoke-psake '.\build.ps1' Tests,Package</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>Runs the 'Tests' and 'Package' tasks in the '.build.ps1' build script</maml:para>
<maml:para />
<maml:para />
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------- EXAMPLE 3 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Invoke-psake Tests</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>This example will run the 'Tests' tasks in the 'default.ps1' build script. The 'default.ps1' is assumed to be in the current directory.</maml:para>
<maml:para />
<maml:para />
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------- EXAMPLE 4 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Invoke-psake 'Tests, Package'</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>This example will run the 'Tests' and 'Package' tasks in the 'default.ps1' build script. The 'default.ps1' is assumed to be in the current directory.</maml:para>
<maml:para>NOTE: The quotes around the list of tasks to execute is required if you want to execute more than 1 task.</maml:para>
<maml:para />
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------- EXAMPLE 5 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Invoke-psake .\build.ps1 -docs</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>Prints a report of all the tasks and their dependencies and descriptions and then exits</maml:para>
<maml:para />
<maml:para />
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------- EXAMPLE 6 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Invoke-psake .\parameters.ps1 -parameters @{"p1"="v1";"p2"="v2"}</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>Runs the build script called 'parameters.ps1' and passes in parameters 'p1' and 'p2' with values 'v1' and 'v2'</maml:para>
<maml:para>Here's the .\parameters.ps1 build script:</maml:para>
<maml:para />
<maml:para>
properties {
$my_property = $p1 + $p2
}
task default -depends TestParams
task TestParams {
Assert ($my_property -ne $null) '$my_property should not be null'
}</maml:para>
<maml:para />
<maml:para>Notice how you can refer to the parameters that were passed into the script from within the “properties” function. The value of the $p1 variable should be the string “v1” and the value of the $p2 variable should be “v2”.</maml:para>
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------- EXAMPLE 7 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Invoke-psake .\properties.ps1 -properties @{"x"="1";"y"="2"}</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>Runs the build script called 'properties.ps1' and passes in parameters 'x' and 'y' with values '1' and '2'</maml:para>
<maml:para>This feature allows you to over-ride existing properties in your build script.</maml:para>
<maml:para />
<maml:para>Here's the .\properties.ps1 build script</maml:para>
<maml:para>properties {
$x = $null
$y = $null
$z = $null
}
task default -depends TestProperties
task TestProperties {
Assert ($x -ne $null) "x should not be null"
Assert ($y -ne $null) "y should not be null"
Assert ($z -eq $null) "z should be null"
}
</maml:para>
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>FormatTaskName</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>TaskTearDown</command:name>
<maml:description>
<maml:para>Adds a scriptblock to the build that will be executed after each task</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>This function will accept a scriptblock that will be executed after each
task in the build script.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>TaskTearDown</command:name>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>teardown</maml:name>
<command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>teardown</maml:name>
<maml:description>
<maml:para>A scriptblock to execute</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>ScriptBlock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>A sample build script is shown below:
Task default -depends Test
Task Test -depends Compile, Clean {
}
Task Compile -depends Clean {
}
Task Clean {
}
TaskTearDown {
"Running 'TaskTearDown' for task $context.Peek().currentTaskName"
}</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>The script above produces the following output:</maml:para>
<maml:para>Executing task, Clean...
Running 'TaskTearDown' for task Clean
Executing task, Compile...
Running 'TaskTearDown' for task Compile
Executing task, Test...
Running 'TaskTearDown' for task Test
Build Succeeded</maml:para>
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>TaskSetup</command:name>
<maml:description>
<maml:para>Adds a scriptblock that will be executed before each task</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>This function will accept a scriptblock that will be executed before each
task in the build script.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>TaskSetup</command:name>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>setup</maml:name>
<command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>setup</maml:name>
<maml:description>
<maml:para>A scriptblock to execute</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>ScriptBlock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>A sample build script is shown below:
Task default -depends Test
Task Test -depends Compile, Clean {
}
Task Compile -depends Clean {
}
Task Clean {
}
TaskSetup {
"Running 'TaskSetup' for task $context.Peek().currentTaskName"
}</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>The script above produces the following output:</maml:para>
<maml:para>Running 'TaskSetup' for task Clean
Executing task, Clean...
Running 'TaskSetup' for task Compile
Executing task, Compile...
Running 'TaskSetup' for task Test
Executing task, Test...
Build Succeeded</maml:para>
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>FormatTaskName</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Framework</command:name>
<maml:description>
<maml:para>Sets the version of the .NET framework you want to use during build.</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>This function will accept a string containing version of the .NET framework to use during build. Possible values: '1.0', '1.1', '2.0', '2.0x86', '2.0x64', '3.0', '3.0x86', '3.0x64', '3.5', '3.5x86', '3.5x64', '4.0', '4.0x86', '4.0x64', '4.5', '4.5x86', '4.5x64', '4.5.1', '4.5.1x86', '4.5.1x64'. Default is '3.5*', where x86 or x64 will be detected based on the bitness of the PowerShell process.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>Framework</command:name>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>framework</maml:name>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>framework</maml:name>
<maml:description>
<maml:para>Version of the .NET framework to use during build.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">string</command:parameterValue>
<dev:type>
<maml:name>string</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<dev:code>
Framework "4.0"
Task default -depends Compile
Task Compile -depends Clean {
msbuild /version
}</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>The script above will output detailed version of msbuid v4</maml:para>
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>FormatTaskName</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>FormatTaskName</command:name>
<maml:description>
<maml:para>This function allows you to change how psake renders the task name during a build.</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>This function takes either a string which represents a format string (formats using the -f format operator see “help about_operators”) or it can accept a script block that has a single parameter that is the name of the task that will be executed.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>FormatTaskName</command:name>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>format</maml:name>
<command:parameterValue required="true" variableLength="false">String or ScriptBlock</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>format</maml:name>
<maml:description>
<maml:para>A format string or a scriptblock to execute</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String or ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>String or ScriptBlock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>A sample build script that uses a format string is shown below:
Task default -depends TaskA, TaskB, TaskC
FormatTaskName "-------- {0} --------"
Task TaskA {
"TaskA is executing"
}
Task TaskB {
"TaskB is executing"
}
Task TaskC {
"TaskC is executing"
}</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>The script above produces the following output:</maml:para>
<maml:para>-------- TaskA --------
TaskA is executing
-------- TaskB --------
TaskB is executing
-------- TaskC --------
TaskC is executing
Build Succeeded!</maml:para>
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------- EXAMPLE 2 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>A sample build script that uses a ScriptBlock is shown below:
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"
}</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>The preceding example uses the scriptblock parameter to the FormatTaskName function to render each task name in the color blue.</maml:para>
<maml:para>Note: the $taskName parameter is arbitrary it could be named anything</maml:para>
<maml:para />
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Include</command:name>
<maml:description>
<maml:para>Include the functions or code of another powershell script file into the current build script's scope</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>A build script may declare an "includes" function which allows you to define a file containing powershell code to be included and added to the scope of the currently running build script. Code from such file will be executed after code from build script.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>Include</command:name>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>fileNamePathToInclude</maml:name>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>fileNamePathToInclude</maml:name>
<maml:description>
<maml:para>A string containing the path and name of the powershell file to include</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>A sample build script is shown below:
Include ".\build_utils.ps1"
Task default -depends Test
Task Test -depends Compile, Clean {
}
Task Compile -depends Clean {
}
Task Clean {
}</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>The script above includes all the functions and variables defined in the ".\build_utils.ps1" script into the current build script's scope</maml:para>
<maml:para>Note: You can have more than 1 "Include" function defined in the build script</maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>FormatTaskName</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Properties</command:name>
<maml:description>
<maml:para>Define a scriptblock that contains assignments to variables that will be available to all tasks in the build script</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>A build script may declare a "Properies" function which allows you to define variables that will be available to all the "Task" functions in the build script. </maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>Properties</command:name>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>properties</maml:name>
<command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>properties</maml:name>
<maml:description>
<maml:para>The script block containing all the variable assignment statements</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>ScriptBlock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>A sample build script is shown below:
Properties {
$build_dir = "c:\build"
$connection_string = "datasource=localhost;initial catalog=northwind;integrated security=sspi"
}
Task default -depends Test
Task Test -depends Compile, Clean {
}
Task Compile -depends Clean {
}
Task Clean {
}</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>Note: You can have more than 1 "Properties" function defined in the build script</maml:para>
<maml:para></maml:para>
<maml:para></maml:para>
<maml:para></maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>FormatTaskName</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Task</command:name>
<maml:description>
<maml:para>Defines a build task to be executed by psake</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>This function creates a 'task' object that will be used by the psake engine to execute a build task. Note: There must be at least one task called 'default' in the build script</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>Task</command:name>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>Name</maml:name>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>Action</maml:name>
<command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>PreAction</maml:name>
<command:parameterValue required="false" variableLength="false">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>PostAction</maml:name>
<command:parameterValue required="false" variableLength="false">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>Precondition</maml:name>
<command:parameterValue required="false" variableLength="false">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>Postcondition</maml:name>
<command:parameterValue required="false" variableLength="false">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>ContinueOnError</maml:name>
<command:parameterValue required="false" variableLength="false">Boolean</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>Depends</maml:name>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>RequiredVariables</maml:name>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
</command:parameter>
<command:parameter require="false" variableLength="false" globbing="false" pipelineInput="false" postion="0">
<maml:name>Description</maml:name>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>Name</maml:name>
<maml:description>
<maml:para>The name of the task</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>Action</maml:name>
<maml:description>
<maml:para>A scriptblock containing the statements to execute for the task.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>ScriptBlock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>PreAction</maml:name>
<maml:description>
<maml:para>A scriptblock to be executed before the 'Action' scriptblock. Note: This parameter is ignored if the 'Action' scriptblock is not defined.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>ScriptBlock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>PostAction</maml:name>
<maml:description>
<maml:para>A scriptblock to be executed after the 'Action' scriptblock. Note: This parameter is ignored if the 'Action' scriptblock is not defined.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>ScriptBlock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>Precondition</maml:name>
<maml:description>
<maml:para>A scriptblock that is executed to determine if the task is executed or skipped. This scriptblock should return $true or $false</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>ScriptBlock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>Postcondition</maml:name>
<maml:description>
<maml:para>A scriptblock that is executed to determine if the task completed its job correctly. An exception is thrown if the scriptblock returns $false.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>ScriptBlock</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>ContinueOnError</maml:name>
<maml:description>
<maml:para>If this switch parameter is set then the task will not cause the build to fail when an exception is thrown by the task</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">SwitchParameter</command:parameterValue>
<dev:type>
<maml:name>SwitchParameter</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>Depends</maml:name>
<maml:description>
<maml:para>An array of task names that this task depends on. These tasks will be executed before the current task is executed.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>RequiredVariables</maml:name>
<maml:description>
<maml:para>An array of names of variables that must be set to run this task.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String[]</command:parameterValue>
<dev:type>
<maml:name>String[]</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>Description</maml:name>
<maml:description>
<maml:para>A description of the task.</maml:para>
</maml:description>
<command:parameterValue required="false" variableLength="false">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>A sample build script is shown below:
Task default -Depends Test
Task Test -Depends Compile, Clean {
"This is a test"
}
Task Compile -Depends Clean {
"Compile"
}
Task Clean {
"Clean"
}
The 'default' task is required and should not contain an 'Action' parameter.
It uses the 'Depends' parameter to specify that 'Test' is a dependency
The 'Test' task uses the 'Depends' parameter to specify that 'Compile' and 'Clean' are dependencies
The 'Compile' task depends on the 'Clean' task.
Note:
The 'Action' parameter is defaulted to the script block following the 'Clean' task.
An equivalent 'Test' task is shown below:
Task Test -Depends Compile, Clean -Action {
$testMessage
}
The output for the above sample build script is shown below:
Executing task, Clean...
Clean
Executing task, Compile...
Compile
Executing task, Test...
This is a test
Build Succeeded!
----------------------------------------------------------------------
Build Time Report
----------------------------------------------------------------------
Name Duration
---- --------
Clean 00:00:00.0065614
Compile 00:00:00.0133268
Test 00:00:00.0225964
Total: 00:00:00.0782496</dev:code>
<dev:remarks>
<maml:para></maml:para>
<maml:para></maml:para>
<maml:para></maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>FormatTaskName</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Assert</command:name>
<maml:description>
<maml:para>Helper function for "Design by Contract" assertion checking.</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>This is a helper function that makes the code less noisy by eliminating many of the "if" statements that are normally required to verify assumptions in the code.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>Assert</command:name>
<command:parameter require="true" variableLength="true" globbing="false" pipelineInput="false" postion="0">
<maml:name>conditionToCheck</maml:name>
<command:parameterValue required="true" variableLength="false">Boolean</command:parameterValue>
</command:parameter>
<command:parameter require="true" variableLength="true" globbing="false" pipelineInput="false" postion="1">
<maml:name>failureMessage</maml:name>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>conditionToCheck</maml:name>
<maml:description>
<maml:para>The boolean condition to evaluate</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Boolean</command:parameterValue>
<dev:type>
<maml:name>Boolean</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="false (ByValue)" position="1">
<maml:name>failureMessage</maml:name>
<maml:description>
<maml:para>The error message used for the exception if the conditionToCheck parameter is false</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Assert $false "This always throws an exception"</dev:code>
<dev:remarks>
<maml:para></maml:para>
<maml:para></maml:para>
<maml:para></maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
<command:example>
<maml:title>-------------- EXAMPLE 2 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Assert ( ($i % 2) -eq 0 ) "$i is not an even number"</dev:code>
<dev:remarks>
<maml:para>Description</maml:para>
<maml:para>-----------</maml:para>
<maml:para>This exmaple may throw an exception if $i is not an even number</maml:para>
<maml:para></maml:para>
<maml:para>Note:</maml:para>
<maml:para>It might be necessary to wrap the condition with paranthesis to force PS to evaluate the condition
so that a boolean value is calculated and passed into the 'conditionToCheck' parameter.
Example:
Assert 1 -eq 2 "1 doesn't equal 2"
PS will pass 1 into the condtionToCheck variable and PS will look for a parameter called "eq" and
throw an exception with the following message "A parameter cannot be found that matches parameter name 'eq'"
The solution is to wrap the condition in () so that PS will evaluate it first.
Assert (1 -eq 2) "1 doesn't equal 2"
</maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>FormatTaskName</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Exec</command:name>
<maml:description>
<maml:para>Helper function for executing command-line programs.</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode to see if an error occcured. If an error is detected then an exception is thrown. This function allows you to run command-line programs without having to explicitly check fthe $lastexitcode variable.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>Exec</command:name>
<command:parameter require="true" variableLength="true" globbing="false" pipelineInput="false" postion="0">
<maml:name>cmd</maml:name>
<command:parameterValue required="true" variableLength="false">ScriptBlock</command:parameterValue>
</command:parameter>
<command:parameter require="true" variableLength="true" globbing="false" pipelineInput="false" postion="1">
<maml:name>errorMessage</maml:name>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>cmd</maml:name>
<maml:description>
<maml:para>The scriptblock to execute. This scriptblock will typically contain the command-line invocation.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">ScriptBlock</command:parameterValue>
<dev:type>
<maml:name>Boolean</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="false (ByValue)" position="1">
<maml:name>failureMessage</maml:name>
<maml:description>
<maml:para>The error message used for the exception that is thrown.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"</dev:code>
<dev:remarks>
<maml:para>This example calls the svn command-line client.</maml:para>
<maml:para></maml:para>
<maml:para></maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>FormatTaskName</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</command:command>
<command:command xmlns:maml="http://schemas.microsoft.com/maml/2004/10" xmlns:command="http://schemas.microsoft.com/maml/dev/command/2004/10" xmlns:dev="http://schemas.microsoft.com/maml/dev/2004/10">
<command:details>
<command:name>Invoke-Task</command:name>
<maml:description>
<maml:para>Executes another task in the current build script.</maml:para>
</maml:description>
<maml:copyright>
<maml:para />
</maml:copyright>
<command:verb></command:verb>
<command:noun></command:noun>
<dev:version />
</command:details>
<maml:description>
<maml:para>This is a function that will allow you to invoke a Task from within another Task in the current build script.</maml:para>
</maml:description>
<command:syntax>
<command:syntaxItem>
<command:name>Invoke-Task</command:name>
<command:parameter require="true" variableLength="true" globbing="false" pipelineInput="false" postion="0">
<maml:name>taskName</maml:name>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
</command:syntaxItem>
</command:syntax>
<command:parameters>
<command:parameter required="true" variableLength="false" globbing="false" pipelineInput="false (ByValue)" position="0">
<maml:name>taskName</maml:name>
<maml:description>
<maml:para>The name of the task to execute.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">String</command:parameterValue>
<dev:type>
<maml:name>String</maml:name>
<maml:uri />
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para />
</maml:description>
</dev:type>
<maml:description />
</command:inputType>
</command:inputTypes>
<command:returnValues>
<command:returnValue>
<dev:type>
<maml:name>None</maml:name>
<maml:uri />
<maml:description>
<maml:para></maml:para>
</maml:description>
</dev:type>
<maml:description />
</command:returnValue>
</command:returnValues>
<command:terminatingErrors />
<command:nonTerminatingErrors />
<maml:alertSet>
<maml:title></maml:title>
<maml:alert>
<maml:para></maml:para>
</maml:alert>
</maml:alertSet>
<command:examples>
<command:example>
<maml:title>-------------- EXAMPLE 1 --------------</maml:title>
<maml:introduction>
<maml:para>C:\PS></maml:para>
</maml:introduction>
<dev:code>Invoke-Task "Compile"</dev:code>
<dev:remarks>
<maml:para>This example calls the "Compile" task.</maml:para>
<maml:para></maml:para>
<maml:para></maml:para>
</dev:remarks>
<command:commandLines>
<command:commandLine>
<command:commandText />
</command:commandLine>
</command:commandLines>
</command:example>
</command:examples>
<maml:relatedLinks>
<maml:navigationLink>
<maml:linkText>Assert</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Exec</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>FormatTaskName</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Include</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Invoke-psake</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Properties</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Task</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskSetup</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>TaskTearDown</maml:linkText>
<maml:uri />
</maml:navigationLink>
<maml:navigationLink>
<maml:linkText>Framework</maml:linkText>
<maml:uri />
</maml:navigationLink>
</maml:relatedLinks>
</command:command>
</helpItems>
Properties {
$x = 1
$y = 2
}
FormatTaskName "[{0}]"
Task default -Depends Verify
Task Verify -Description "This task verifies psake's variables" {
Assert (Test-Path 'variable:\psake') "psake variable was not exported from module"
Assert ($psake.ContainsKey("version")) "psake variable does not contain 'version'"
Assert ($psake.ContainsKey("context")) "psake variable does not contain 'context'"
Assert ($psake.ContainsKey("build_success")) "psake variable does not contain 'build_success'"
Assert ($psake.ContainsKey("build_script_file")) "psake variable does not contain 'build_script_file'"
Assert ($psake.ContainsKey("build_script_dir")) "psake variable does not contain 'build_script_dir'"
Assert (![string]::IsNullOrEmpty($psake.version)) '$psake.version was null or empty'
Assert ($psake.context -ne $null) '$psake.context was null'
Assert (!$psake.build_success) '$psake.build_success should be $false'
Assert ($psake.build_script_file -ne $null) '$psake.build_script_file was null'
Assert ($psake.build_script_file.Name -eq "checkvariables.ps1") ("psake variable: {0} was not equal to 'checkvariables.ps1'" -f $psake.build_script_file.Name)
Assert (![string]::IsNullOrEmpty($psake.build_script_dir)) '$psake.build_script_dir was null or empty'
Assert ($psake.context.Peek().tasks.Count -ne 0) "psake context variable 'tasks' had length zero"
Assert ($psake.context.Peek().properties.Count -ne 0) "psake context variable 'properties' had length zero"
Assert ($psake.context.Peek().includes.Count -eq 0) "psake context variable 'includes' should have had length zero"
Assert ($psake.context.Peek().config -ne $null) "psake context variable 'config' was null"
Assert ($psake.context.Peek().currentTaskName -eq "Verify") 'psake variable: $currentTaskName was not set correctly'
}
Task default -Depends TaskA
Task TaskA -Depends TaskB {
"Task - A"
}
Task TaskB -Depends TaskC -ContinueOnError {
"Task - B"
throw "I failed on purpose!"
}
Task TaskC {
"Task - C"
}
properties {
$testMessage = 'Executed Test!'
$compileMessage = 'Executed Compile!'
$cleanMessage = 'Executed Clean!'
}
task default -depends Test
task Test -depends Compile, Clean {
$testMessage
}
task Compile -depends Clean {
$compileMessage
}
task Clean {
$cleanMessage
}
task ? -Description "Helper to display task info" {
Write-Documentation
}
properties {
$testMessage = 'Executed Test!'
$compileMessage = 'Executed Compile!'
$cleanMessage = 'Executed Clean!'
}
task default -depends Test
formatTaskName {
param($taskName)
write-host $taskName -foregroundcolor Green
}
task Test -depends Compile, Clean {
$testMessage
}
task Compile -depends Clean {
$compileMessage
}
task Clean {
$cleanMessage
}
properties {
$testMessage = 'Executed Test!'
$compileMessage = 'Executed Compile!'
$cleanMessage = 'Executed Clean!'
}
task default -depends Test
formatTaskName "-------{0}-------"
task Test -depends Compile, Clean {
$testMessage
}
task Compile -depends Clean {
$compileMessage
}
task Clean {
$cleanMessage
}
Framework "4.0"
# Framework "4.0x64"
task default -depends ShowMsBuildVersion
task ShowMsBuildVersion {
msbuild /version
}
Properties {
$x = 1
}
Task default -Depends RunNested1, RunNested2, CheckX
Task RunNested1 {
Invoke-psake .\nested\nested1.ps1
}
Task RunNested2 {
Invoke-psake .\nested\nested2.ps1
}
Task CheckX{
Assert ($x -eq 1) '$x was not 1'
}
Properties {
$x = 100
}
Task default -Depends Nested1CheckX
Task Nested1CheckX{
Assert ($x -eq 100) '$x was not 100'
}
Properties {
$x = 200
}
Task default -Depends Nested2CheckX
Task Nested2CheckX{
Assert ($x -eq 200) '$x was not 200'
}
properties {
$my_property = $p1 + $p2
}
task default -depends TestParams
task TestParams {
Assert ($my_property -ne $null) "`$my_property should not be null. Run with -parameters @{'p1' = 'v1'; 'p2' = 'v2'}"
}
powershell -Command "& {Import-Module .\..\..\psake.psm1; Invoke-psake .\parameters.ps1 -parameters @{"buildConfiguration"='Release';} }"
Pause
properties {
$buildOutputPath = ".\bin\$buildConfiguration"
}
task default -depends DoRelease
task DoRelease {
Assert ("$buildConfiguration" -ne $null) "buildConfiguration should not have been null"
Assert ("$buildConfiguration" -eq 'Release') "buildConfiguration=[$buildConfiguration] should have been 'Release'"
Write-Host ""
Write-Host ""
Write-Host ""
Write-Host -NoNewline "Would build output into path "
Write-Host -NoNewline -ForegroundColor Green "$buildOutputPath"
Write-Host -NoNewline " for build configuration "
Write-Host -ForegroundColor Green "$buildConfiguration"
Write-Host -NoNewline "."
Write-Host ""
Write-Host ""
Write-Host ""
}
task default -depends Test
task Test -depends Compile, Clean -PreAction {"Pre-Test"} -Action {
"Test"
} -PostAction {"Post-Test"}
task Compile -depends Clean {
"Compile"
}
task Clean {
"Clean"
}
properties {
$runTaskA = $false
$taskBSucceded = $true
}
task default -depends TaskC
task TaskA -precondition { $runTaskA -eq $true } {
"TaskA executed"
}
task TaskB -postcondition { $taskBSucceded -eq $true } {
"TaskB executed"
}
task TaskC -depends TaskA,TaskB {
"TaskC executed."
}
properties {
$x = $null
$y = $null
$z = $null
}
task default -depends TestProperties
task TestProperties {
Assert ($x -ne $null) "x should not be null. Run with -properties @{'x' = '1'; 'y' = '2'}"
Assert ($y -ne $null) "y should not be null. Run with -properties @{'x' = '1'; 'y' = '2'}"
Assert ($z -eq $null) "z should be null"
}
properties {
$x = $null
$y = $null
$z = $null
}
task default -depends TestRequiredVariables
# you can put arguments to task in multiple lines using `
task TestRequiredVariables `
-description "This task shows how to make a variable required to run task. Run this script with -properties @{x = 1; y = 2; z = 3}" `
-requiredVariables x, y, z `
{
}
TaskSetup {
"Executing task setup"
}
TaskTearDown {
"Executing task tear down"
}
Task default -depends TaskB
Task TaskA {
"TaskA executed"
}
Task TaskB -depends TaskA {
"TaskB executed"
}
param($installPath, $toolsPath, $package)
$psakeModule = Join-Path $toolsPath psake.psm1
import-module $psakeModule
@"
========================
psake - Automated builds with powershell
========================
"@ | Write-Host
psake
Copyright (c) 2012-13 James Kovacs, Damian Hickey and Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
<#
-------------------------------------------------------------------
Defaults
-------------------------------------------------------------------
$config.buildFileName="default.ps1"
$config.framework = "4.0"
$config.taskNameFormat="Executing {0}"
$config.verboseError=$false
$config.coloredOutput = $true
$config.modules=$null
-------------------------------------------------------------------
Load modules from .\modules folder and from file my_module.psm1
-------------------------------------------------------------------
$config.modules=(".\modules\*.psm1",".\my_module.psm1")
-------------------------------------------------------------------
Use scriptblock for taskNameFormat
-------------------------------------------------------------------
$config.taskNameFormat= { param($taskName) "Executing $taskName at $(get-date)" }
#>
@echo off
rem Helper script for those who want to run psake from cmd.exe
rem Example run from cmd.exe:
rem psake "default.ps1" "BuildHelloWord" "4.0"
if '%1'=='/?' goto help
if '%1'=='-help' goto help
if '%1'=='-h' goto help
powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\psake.ps1' %*; if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }"
exit /B %errorlevel%
:help
powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\psake.ps1' -help"
# Helper script for those who want to run psake without importing the module.
# Example run from PowerShell:
# .\psake.ps1 "default.ps1" "BuildHelloWord" "4.0"
# Must match parameter definitions for psake.psm1/invoke-psake
# otherwise named parameter binding fails
param(
[Parameter(Position=0,Mandatory=0)]
[string]$buildFile,
[Parameter(Position=1,Mandatory=0)]
[string[]]$taskList = @(),
[Parameter(Position=2,Mandatory=0)]
[string]$framework,
[Parameter(Position=3,Mandatory=0)]
[switch]$docs = $false,
[Parameter(Position=4,Mandatory=0)]
[System.Collections.Hashtable]$parameters = @{},
[Parameter(Position=5, Mandatory=0)]
[System.Collections.Hashtable]$properties = @{},
[Parameter(Position=6, Mandatory=0)]
[alias("init")]
[scriptblock]$initialization = {},
[Parameter(Position=7, Mandatory=0)]
[switch]$nologo = $false,
[Parameter(Position=8, Mandatory=0)]
[switch]$help = $false,
[Parameter(Position=9, Mandatory=0)]
[string]$scriptPath,
[Parameter(Position=10,Mandatory=0)]
[switch]$detailedDocs = $false
)
# setting $scriptPath here, not as default argument, to support calling as "powershell -File psake.ps1"
if (!$scriptPath) {
$scriptPath = $(Split-Path -parent $MyInvocation.MyCommand.path)
}
# '[p]sake' is the same as 'psake' but $Error is not polluted
remove-module [p]sake
import-module (join-path $scriptPath psake.psm1)
if ($help) {
Get-Help Invoke-psake -full
return
}
if ($buildFile -and (-not(test-path $buildFile))) {
$absoluteBuildFile = (join-path $scriptPath $buildFile)
if (test-path $absoluteBuildFile) {
$buildFile = $absoluteBuildFile
}
}
Invoke-psake $buildFile $taskList $framework $docs $parameters $properties $initialization $nologo $detailedDocs
# psake
# Copyright (c) 2012 James Kovacs
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#Requires -Version 2.0
#-- Public Module Functions --#
# .ExternalHelp psake.psm1-help.xml
function Invoke-Task
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)] [string]$taskName
)
Assert $taskName ($msgs.error_invalid_task_name)
$taskKey = $taskName.ToLower()
if ($currentContext.aliases.Contains($taskKey)) {
$taskName = $currentContext.aliases.$taskKey.Name
$taskKey = $taskName.ToLower()
}
$currentContext = $psake.context.Peek()
Assert ($currentContext.tasks.Contains($taskKey)) ($msgs.error_task_name_does_not_exist -f $taskName)
if ($currentContext.executedTasks.Contains($taskKey)) { return }
Assert (!$currentContext.callStack.Contains($taskKey)) ($msgs.error_circular_reference -f $taskName)
$currentContext.callStack.Push($taskKey)
$task = $currentContext.tasks.$taskKey
$precondition_is_valid = & $task.Precondition
if (!$precondition_is_valid) {
WriteColoredOutput ($msgs.precondition_was_false -f $taskName) -foregroundcolor Cyan
} else {
if ($taskKey -ne 'default') {
if ($task.PreAction -or $task.PostAction) {
Assert ($task.Action -ne $null) ($msgs.error_missing_action_parameter -f $taskName)
}
if ($task.Action) {
try {
foreach($childTask in $task.DependsOn) {
Invoke-Task $childTask
}
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$currentContext.currentTaskName = $taskName
& $currentContext.taskSetupScriptBlock
if ($task.PreAction) {
& $task.PreAction
}
if ($currentContext.config.taskNameFormat -is [ScriptBlock]) {
& $currentContext.config.taskNameFormat $taskName
} else {
WriteColoredOutput ($currentContext.config.taskNameFormat -f $taskName) -foregroundcolor Cyan
}
foreach ($variable in $task.requiredVariables) {
Assert ((test-path "variable:$variable") -and ((get-variable $variable).Value -ne $null)) ($msgs.required_variable_not_set -f $variable, $taskName)
}
& $task.Action
if ($task.PostAction) {
& $task.PostAction
}
& $currentContext.taskTearDownScriptBlock
$task.Duration = $stopwatch.Elapsed
} catch {
if ($task.ContinueOnError) {
"-"*70
WriteColoredOutput ($msgs.continue_on_error -f $taskName,$_) -foregroundcolor Yellow
"-"*70
$task.Duration = $stopwatch.Elapsed
} else {
throw $_
}
}
} else {
# no action was specified but we still execute all the dependencies
foreach($childTask in $task.DependsOn) {
Invoke-Task $childTask
}
}
} else {
foreach($childTask in $task.DependsOn) {
Invoke-Task $childTask
}
}
Assert (& $task.Postcondition) ($msgs.postcondition_failed -f $taskName)
}
$poppedTaskKey = $currentContext.callStack.Pop()
Assert ($poppedTaskKey -eq $taskKey) ($msgs.error_corrupt_callstack -f $taskKey,$poppedTaskKey)
$currentContext.executedTasks.Push($taskKey)
}
# .ExternalHelp psake.psm1-help.xml
function Exec
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$cmd,
[Parameter(Position=1,Mandatory=0)][string]$errorMessage = ($msgs.error_bad_command -f $cmd),
[Parameter(Position=2,Mandatory=0)][int]$maxRetries = 0,
[Parameter(Position=3,Mandatory=0)][string]$retryTriggerErrorPattern = $null
)
$tryCount = 1
do {
try {
$global:lastexitcode = 0
& $cmd
if ($lastexitcode -ne 0) {
throw ("Exec: " + $errorMessage)
}
break
}
catch [Exception]
{
if ($tryCount -gt $maxRetries) {
throw $_
}
if ($retryTriggerErrorPattern -ne $null) {
$isMatch = [regex]::IsMatch($_.Exception.Message, $retryTriggerErrorPattern)
if ($isMatch -eq $false) {
throw $_
}
}
Write-Host "Try $tryCount failed, retrying again in 1 second..."
$tryCount++
[System.Threading.Thread]::Sleep([System.TimeSpan]::FromSeconds(1))
}
}
while ($true)
}
# .ExternalHelp psake.psm1-help.xml
function Assert
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)]$conditionToCheck,
[Parameter(Position=1,Mandatory=1)]$failureMessage
)
if (!$conditionToCheck) {
throw ("Assert: " + $failureMessage)
}
}
# .ExternalHelp psake.psm1-help.xml
function Task
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][string]$name = $null,
[Parameter(Position=1,Mandatory=0)][scriptblock]$action = $null,
[Parameter(Position=2,Mandatory=0)][scriptblock]$preaction = $null,
[Parameter(Position=3,Mandatory=0)][scriptblock]$postaction = $null,
[Parameter(Position=4,Mandatory=0)][scriptblock]$precondition = {$true},
[Parameter(Position=5,Mandatory=0)][scriptblock]$postcondition = {$true},
[Parameter(Position=6,Mandatory=0)][switch]$continueOnError = $false,
[Parameter(Position=7,Mandatory=0)][string[]]$depends = @(),
[Parameter(Position=8,Mandatory=0)][string[]]$requiredVariables = @(),
[Parameter(Position=9,Mandatory=0)][string]$description = $null,
[Parameter(Position=10,Mandatory=0)][string]$alias = $null,
[Parameter(Position=11,Mandatory=0)][string]$maxRetries = 0,
[Parameter(Position=12,Mandatory=0)][string]$retryTriggerErrorPattern = $null
)
if ($name -eq 'default') {
Assert (!$action) ($msgs.error_default_task_cannot_have_action)
}
$newTask = @{
Name = $name
DependsOn = $depends
PreAction = $preaction
Action = $action
PostAction = $postaction
Precondition = $precondition
Postcondition = $postcondition
ContinueOnError = $continueOnError
Description = $description
Duration = [System.TimeSpan]::Zero
RequiredVariables = $requiredVariables
Alias = $alias
MaxRetries = $maxRetries
RetryTriggerErrorPattern = $retryTriggerErrorPattern
}
$taskKey = $name.ToLower()
$currentContext = $psake.context.Peek()
Assert (!$currentContext.tasks.ContainsKey($taskKey)) ($msgs.error_duplicate_task_name -f $name)
$currentContext.tasks.$taskKey = $newTask
if($alias)
{
$aliasKey = $alias.ToLower()
Assert (!$currentContext.aliases.ContainsKey($aliasKey)) ($msgs.error_duplicate_alias_name -f $alias)
$currentContext.aliases.$aliasKey = $newTask
}
}
# .ExternalHelp psake.psm1-help.xml
function Properties {
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$properties
)
$psake.context.Peek().properties += $properties
}
# .ExternalHelp psake.psm1-help.xml
function Include {
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][string]$fileNamePathToInclude
)
Assert (test-path $fileNamePathToInclude -pathType Leaf) ($msgs.error_invalid_include_path -f $fileNamePathToInclude)
$psake.context.Peek().includes.Enqueue((Resolve-Path $fileNamePathToInclude));
}
# .ExternalHelp psake.psm1-help.xml
function FormatTaskName {
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)]$format
)
$psake.context.Peek().config.taskNameFormat = $format
}
# .ExternalHelp psake.psm1-help.xml
function TaskSetup {
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$setup
)
$psake.context.Peek().taskSetupScriptBlock = $setup
}
# .ExternalHelp psake.psm1-help.xml
function TaskTearDown {
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][scriptblock]$teardown
)
$psake.context.Peek().taskTearDownScriptBlock = $teardown
}
# .ExternalHelp psake.psm1-help.xml
function Framework {
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=1)][string]$framework
)
$psake.context.Peek().config.framework = $framework
ConfigureBuildEnvironment
}
# .ExternalHelp psake.psm1-help.xml
function Invoke-psake {
[CmdletBinding()]
param(
[Parameter(Position = 0, Mandatory = 0)][string] $buildFile,
[Parameter(Position = 1, Mandatory = 0)][string[]] $taskList = @(),
[Parameter(Position = 2, Mandatory = 0)][string] $framework,
[Parameter(Position = 3, Mandatory = 0)][switch] $docs = $false,
[Parameter(Position = 4, Mandatory = 0)][hashtable] $parameters = @{},
[Parameter(Position = 5, Mandatory = 0)][hashtable] $properties = @{},
[Parameter(Position = 6, Mandatory = 0)][alias("init")][scriptblock] $initialization = {},
[Parameter(Position = 7, Mandatory = 0)][switch] $nologo = $false,
[Parameter(Position = 8, Mandatory = 0)][switch] $detailedDocs = $false
)
try {
if (-not $nologo) {
"psake version {0}`nCopyright (c) 2010-2014 James Kovacs & Contributors`n" -f $psake.version
}
if (!$buildFile) {
$buildFile = $psake.config_default.buildFileName
}
elseif (!(test-path $buildFile -pathType Leaf) -and (test-path $psake.config_default.buildFileName -pathType Leaf)) {
# If the $config.buildFileName file exists and the given "buildfile" isn 't found assume that the given
# $buildFile is actually the target Tasks to execute in the $config.buildFileName script.
$taskList = $buildFile.Split(', ')
$buildFile = $psake.config_default.buildFileName
}
# Execute the build file to set up the tasks and defaults
Assert (test-path $buildFile -pathType Leaf) ($msgs.error_build_file_not_found -f $buildFile)
$psake.build_script_file = get-item $buildFile
$psake.build_script_dir = $psake.build_script_file.DirectoryName
$psake.build_success = $false
$psake.context.push(@{
"taskSetupScriptBlock" = {};
"taskTearDownScriptBlock" = {};
"executedTasks" = new-object System.Collections.Stack;
"callStack" = new-object System.Collections.Stack;
"originalEnvPath" = $env:path;
"originalDirectory" = get-location;
"originalErrorActionPreference" = $global:ErrorActionPreference;
"tasks" = @{};
"aliases" = @{};
"properties" = @();
"includes" = new-object System.Collections.Queue;
"config" = CreateConfigurationForNewContext $buildFile $framework
})
LoadConfiguration $psake.build_script_dir
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
set-location $psake.build_script_dir
LoadModules
$frameworkOldValue = $framework
. $psake.build_script_file.FullName
$currentContext = $psake.context.Peek()
if ($framework -ne $frameworkOldValue) {
writecoloredoutput $msgs.warning_deprecated_framework_variable -foregroundcolor Yellow
$currentContext.config.framework = $framework
}
ConfigureBuildEnvironment
while ($currentContext.includes.Count -gt 0) {
$includeFilename = $currentContext.includes.Dequeue()
. $includeFilename
}
if ($docs -or $detailedDocs) {
WriteDocumentation($detailedDocs)
CleanupEnvironment
return
}
foreach ($key in $parameters.keys) {
if (test-path "variable:\$key") {
set-item -path "variable:\$key" -value $parameters.$key -WhatIf:$false -Confirm:$false | out-null
} else {
new-item -path "variable:\$key" -value $parameters.$key -WhatIf:$false -Confirm:$false | out-null
}
}
# The initial dot (.) indicates that variables initialized/modified in the propertyBlock are available in the parent scope.
foreach ($propertyBlock in $currentContext.properties) {
. $propertyBlock
}
foreach ($key in $properties.keys) {
if (test-path "variable:\$key") {
set-item -path "variable:\$key" -value $properties.$key -WhatIf:$false -Confirm:$false | out-null
}
}
# Simple dot sourcing will not work. We have to force the script block into our
# module's scope in order to initialize variables properly.
. $MyInvocation.MyCommand.Module $initialization
# Execute the list of tasks or the default task
if ($taskList) {
foreach ($task in $taskList) {
invoke-task $task
}
} elseif ($currentContext.tasks.default) {
invoke-task default
} else {
throw $msgs.error_no_default_task
}
WriteColoredOutput ("`n" + $msgs.build_success + "`n") -foregroundcolor Green
WriteTaskTimeSummary $stopwatch.Elapsed
$psake.build_success = $true
} catch {
$currentConfig = GetCurrentConfigurationOrDefault
if ($currentConfig.verboseError) {
$error_message = "{0}: An Error Occurred. See Error Details Below: `n" -f (Get-Date)
$error_message += ("-" * 70) + "`n"
$error_message += "Error: {0}`n" -f (ResolveError $_ -Short)
$error_message += ("-" * 70) + "`n"
$error_message += ResolveError $_
$error_message += ("-" * 70) + "`n"
$error_message += "Script Variables" + "`n"
$error_message += ("-" * 70) + "`n"
$error_message += get-variable -scope script | format-table | out-string
} else {
# ($_ | Out-String) gets error messages with source information included.
$error_message = "Error: {0}: `n{1}" -f (Get-Date), (ResolveError $_ -Short)
}
$psake.build_success = $false
# if we are running in a nested scope (i.e. running a psake script from a psake script) then we need to re-throw the exception
# so that the parent script will fail otherwise the parent script will report a successful build
$inNestedScope = ($psake.context.count -gt 1)
if ( $inNestedScope ) {
throw $_
} else {
if (!$psake.run_by_psake_build_tester) {
WriteColoredOutput $error_message -foregroundcolor Red
}
}
} finally {
CleanupEnvironment
}
}
#-- Private Module Functions --#
function WriteColoredOutput {
param(
[string] $message,
[System.ConsoleColor] $foregroundcolor
)
$currentConfig = GetCurrentConfigurationOrDefault
if ($currentConfig.coloredOutput -eq $true) {
if (($Host.UI -ne $null) -and ($Host.UI.RawUI -ne $null) -and ($Host.UI.RawUI.ForegroundColor -ne $null)) {
$previousColor = $Host.UI.RawUI.ForegroundColor
$Host.UI.RawUI.ForegroundColor = $foregroundcolor
}
}
$message
if ($previousColor -ne $null) {
$Host.UI.RawUI.ForegroundColor = $previousColor
}
}
function LoadModules {
$currentConfig = $psake.context.peek().config
if ($currentConfig.modules) {
$scope = $currentConfig.moduleScope
$global = [string]::Equals($scope, "global", [StringComparison]::CurrentCultureIgnoreCase)
$currentConfig.modules | foreach {
resolve-path $_ | foreach {
"Loading module: $_"
$module = import-module $_ -passthru -DisableNameChecking -global:$global
if (!$module) {
throw ($msgs.error_loading_module -f $_.Name)
}
}
}
""
}
}
function LoadConfiguration {
param(
[string] $configdir = $PSScriptRoot
)
$psakeConfigFilePath = (join-path $configdir "psake-config.ps1")
if (test-path $psakeConfigFilePath -pathType Leaf) {
try {
$config = GetCurrentConfigurationOrDefault
. $psakeConfigFilePath
} catch {
throw "Error Loading Configuration from psake-config.ps1: " + $_
}
}
}
function GetCurrentConfigurationOrDefault() {
if ($psake.context.count -gt 0) {
return $psake.context.peek().config
} else {
return $psake.config_default
}
}
function CreateConfigurationForNewContext {
param(
[string] $buildFile,
[string] $framework
)
$previousConfig = GetCurrentConfigurationOrDefault
$config = new-object psobject -property @{
buildFileName = $previousConfig.buildFileName;
framework = $previousConfig.framework;
taskNameFormat = $previousConfig.taskNameFormat;
verboseError = $previousConfig.verboseError;
coloredOutput = $previousConfig.coloredOutput;
modules = $previousConfig.modules;
moduleScope = $previousConfig.moduleScope;
}
if ($framework) {
$config.framework = $framework;
}
if ($buildFile) {
$config.buildFileName = $buildFile;
}
return $config
}
function ConfigureBuildEnvironment {
$framework = $psake.context.peek().config.framework
if ($framework -cmatch '^((?:\d+\.\d+)(?:\.\d+){0,1})(x86|x64){0,1}$') {
$versionPart = $matches[1]
$bitnessPart = $matches[2]
} else {
throw ($msgs.error_invalid_framework -f $framework)
}
$versions = $null
$buildToolsVersions = $null
switch ($versionPart) {
'1.0' {
$versions = @('v1.0.3705')
}
'1.1' {
$versions = @('v1.1.4322')
}
'2.0' {
$versions = @('v2.0.50727')
}
'3.0' {
$versions = @('v2.0.50727')
}
'3.5' {
$versions = @('v3.5', 'v2.0.50727')
}
'4.0' {
$versions = @('v4.0.30319')
}
'4.5.1' {
$versions = @('v4.0.30319')
$buildToolsVersions = @('14.0', '12.0')
}
default {
throw ($msgs.error_unknown_framework -f $versionPart, $framework)
}
}
$bitness = 'Framework'
if ($versionPart -ne '1.0' -and $versionPart -ne '1.1') {
switch ($bitnessPart) {
'x86' {
$bitness = 'Framework'
$buildToolsKey = 'MSBuildToolsPath32'
}
'x64' {
$bitness = 'Framework64'
$buildToolsKey = 'MSBuildToolsPath'
}
{ [string]::IsNullOrEmpty($_) } {
$ptrSize = [System.IntPtr]::Size
switch ($ptrSize) {
4 {
$bitness = 'Framework'
$buildToolsKey = 'MSBuildToolsPath32'
}
8 {
$bitness = 'Framework64'
$buildToolsKey = 'MSBuildToolsPath'
}
default {
throw ($msgs.error_unknown_pointersize -f $ptrSize)
}
}
}
default {
throw ($msgs.error_unknown_bitnesspart -f $bitnessPart, $framework)
}
}
}
$frameworkDirs = @()
if ($buildToolsVersions -ne $null) {
foreach($ver in $buildToolsVersions) {
if (Test-Path "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$ver") {
$frameworkDirs += (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\MSBuild\ToolsVersions\$ver" -Name $buildToolsKey).$buildToolsKey
}
}
}
$frameworkDirs = $frameworkDirs + @($versions | foreach { "$env:windir\Microsoft.NET\$bitness\$_\" })
for ($i = 0; $i -lt $frameworkDirs.Count; $i++) {
$dir = $frameworkDirs[$i]
if ($dir -Match "\$\(Registry:HKEY_LOCAL_MACHINE(.*?)@(.*)\)") {
$key = "HKLM:" + $matches[1]
$name = $matches[2]
$dir = (Get-ItemProperty -Path $key -Name $name).$name
$frameworkDirs[$i] = $dir
}
}
$frameworkDirs | foreach { Assert (test-path $_ -pathType Container) ($msgs.error_no_framework_install_dir_found -f $_)}
$env:path = ($frameworkDirs -join ";") + ";$env:path"
# if any error occurs in a PS function then "stop" processing immediately
# this does not effect any external programs that return a non-zero exit code
$global:ErrorActionPreference = "Stop"
}
function CleanupEnvironment {
if ($psake.context.Count -gt 0) {
$currentContext = $psake.context.Peek()
$env:path = $currentContext.originalEnvPath
Set-Location $currentContext.originalDirectory
$global:ErrorActionPreference = $currentContext.originalErrorActionPreference
[void] $psake.context.Pop()
}
}
function SelectObjectWithDefault
{
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true)]
[PSObject]
$InputObject,
[string]
$Name,
$Value
)
process {
if ($_ -eq $null) { $Value }
elseif ($_ | Get-Member -Name $Name) {
$_.$Name
}
elseif (($_ -is [Hashtable]) -and ($_.Keys -contains $Name)) {
$_.$Name
}
else { $Value }
}
}
# borrowed from Jeffrey Snover http://blogs.msdn.com/powershell/archive/2006/12/07/resolve-error.aspx
# modified to better handle SQL errors
function ResolveError
{
[CmdletBinding()]
param(
[Parameter(ValueFromPipeline=$true)]
$ErrorRecord=$Error[0],
[Switch]
$Short
)
process {
if ($_ -eq $null) { $_ = $ErrorRecord }
$ex = $_.Exception
if (-not $Short) {
$error_message = "`nErrorRecord:{0}ErrorRecord.InvocationInfo:{1}Exception:`n{2}"
$formatted_errorRecord = $_ | format-list * -force | out-string
$formatted_invocationInfo = $_.InvocationInfo | format-list * -force | out-string
$formatted_exception = ''
$i = 0
while ($ex -ne $null) {
$i++
$formatted_exception += ("$i" * 70) + "`n" +
($ex | format-list * -force | out-string) + "`n"
$ex = $ex | SelectObjectWithDefault -Name 'InnerException' -Value $null
}
return $error_message -f $formatted_errorRecord, $formatted_invocationInfo, $formatted_exception
}
$lastException = @()
while ($ex -ne $null) {
$lastMessage = $ex | SelectObjectWithDefault -Name 'Message' -Value ''
$lastException += ($lastMessage -replace "`n", '')
if ($ex -is [Data.SqlClient.SqlException]) {
$lastException += "(Line [$($ex.LineNumber)] " +
"Procedure [$($ex.Procedure)] Class [$($ex.Class)] " +
" Number [$($ex.Number)] State [$($ex.State)] )"
}
$ex = $ex | SelectObjectWithDefault -Name 'InnerException' -Value $null
}
$shortException = $lastException -join ' --> '
$header = $null
$current = $_
$header = (($_.InvocationInfo |
SelectObjectWithDefault -Name 'PositionMessage' -Value '') -replace "`n", ' '),
($_ | SelectObjectWithDefault -Name 'Message' -Value ''),
($_ | SelectObjectWithDefault -Name 'Exception' -Value '') |
? { -not [String]::IsNullOrEmpty($_) } |
Select -First 1
$delimiter = ''
if ((-not [String]::IsNullOrEmpty($header)) -and
(-not [String]::IsNullOrEmpty($shortException)))
{ $delimiter = ' [<<==>>] ' }
return "$($header)$($delimiter)Exception: $($shortException)"
}
}
function WriteDocumentation($showDetailed) {
$currentContext = $psake.context.Peek()
if ($currentContext.tasks.default) {
$defaultTaskDependencies = $currentContext.tasks.default.DependsOn
} else {
$defaultTaskDependencies = @()
}
$docs = $currentContext.tasks.Keys | foreach-object {
if ($_ -eq "default") {
return
}
$task = $currentContext.tasks.$_
new-object PSObject -property @{
Name = $task.Name;
Alias = $task.Alias;
Description = $task.Description;
"Depends On" = $task.DependsOn -join ", "
Default = if ($defaultTaskDependencies -contains $task.Name) { $true }
}
}
if ($showDetailed) {
$docs | sort 'Name' | format-list -property Name,Alias,Description,"Depends On",Default
} else {
$docs | sort 'Name' | format-table -autoSize -wrap -property Name,Alias,"Depends On",Default,Description
}
}
function WriteTaskTimeSummary($invokePsakeDuration) {
if ($psake.context.count -gt 0) {
"-" * 70
"Build Time Report"
"-" * 70
$list = @()
$currentContext = $psake.context.Peek()
while ($currentContext.executedTasks.Count -gt 0) {
$taskKey = $currentContext.executedTasks.Pop()
$task = $currentContext.tasks.$taskKey
if ($taskKey -eq "default") {
continue
}
$list += new-object PSObject -property @{
Name = $task.Name;
Duration = $task.Duration
}
}
[Array]::Reverse($list)
$list += new-object PSObject -property @{
Name = "Total:";
Duration = $invokePsakeDuration
}
# using "out-string | where-object" to filter out the blank line that format-table prepends
$list | format-table -autoSize -property Name,Duration | out-string -stream | where-object { $_ }
}
}
DATA msgs {
convertfrom-stringdata @'
error_invalid_task_name = Task name should not be null or empty string.
error_task_name_does_not_exist = Task {0} does not exist.
error_circular_reference = Circular reference found for task {0}.
error_missing_action_parameter = Action parameter must be specified when using PreAction or PostAction parameters for task {0}.
error_corrupt_callstack = Call stack was corrupt. Expected {0}, but got {1}.
error_invalid_framework = Invalid .NET Framework version, {0} specified.
error_unknown_framework = Unknown .NET Framework version, {0} specified in {1}.
error_unknown_pointersize = Unknown pointer size ({0}) returned from System.IntPtr.
error_unknown_bitnesspart = Unknown .NET Framework bitness, {0}, specified in {1}.
error_no_framework_install_dir_found = No .NET Framework installation directory found at {0}.
error_bad_command = Error executing command {0}.
error_default_task_cannot_have_action = 'default' task cannot specify an action.
error_duplicate_task_name = Task {0} has already been defined.
error_duplicate_alias_name = Alias {0} has already been defined.
error_invalid_include_path = Unable to include {0}. File not found.
error_build_file_not_found = Could not find the build file {0}.
error_no_default_task = 'default' task required.
error_loading_module = Error loading module {0}.
warning_deprecated_framework_variable = Warning: Using global variable $framework to set .NET framework version used is deprecated. Instead use Framework function or configuration file psake-config.ps1.
required_variable_not_set = Variable {0} must be set to run task {1}.
postcondition_failed = Postcondition failed for task {0}.
precondition_was_false = Precondition was false, not executing task {0}.
continue_on_error = Error in task {0}. {1}
build_success = Build Succeeded!
'@
}
import-localizeddata -bindingvariable msgs -erroraction silentlycontinue
$script:psake = @{}
$psake.version = "4.4.1" # contains the current version of psake
$psake.context = new-object system.collections.stack # holds onto the current state of all variables
$psake.run_by_psake_build_tester = $false # indicates that build is being run by psake-BuildTester
$psake.config_default = new-object psobject -property @{
buildFileName = "default.ps1";
framework = "4.0";
taskNameFormat = "Executing {0}";
verboseError = $false;
coloredOutput = $true;
modules = $null;
moduleScope = "";
} # contains default configuration, can be overriden in psake-config.ps1 in directory with psake.psm1 or in directory with current build script
$psake.build_success = $false # indicates that the current build was successful
$psake.build_script_file = $null # contains a System.IO.FileInfo for the current build script
$psake.build_script_dir = "" # contains a string with fully-qualified path to current build script
LoadConfiguration
export-modulemember -function Invoke-psake, Invoke-Task, Task, Properties, Include, FormatTaskName, TaskSetup, TaskTearDown, Framework, Assert, Exec -variable psake
Log in or click on link to see number of positives.
- psake.4.4.1.nupkg (7a1330ed66d1) - ## / 55
In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).
Chocolatey Pro provides runtime protection from possible malware.
Add to Builder | Version | Downloads | Last Updated | Status |
---|---|---|---|---|
psake 4.9.1 | 96 | Monday, October 7, 2024 | Approved | |
psake 4.9.0 | 28671 | Saturday, September 21, 2019 | Approved | |
psake 4.7.3 | 16595 | Saturday, August 11, 2018 | Approved | |
psake 4.7.2 | 551 | Friday, August 10, 2018 | Approved | |
psake 4.7.1 | 305 | Tuesday, July 24, 2018 | Approved | |
psake 4.7.0 | 6747 | Tuesday, November 21, 2017 | Approved | |
psake 4.6.0 | 17560 | Sunday, March 20, 2016 | Approved | |
psake 4.5.0 | 1569 | Friday, January 15, 2016 | Approved | |
psake 4.4.2 | 1593 | Wednesday, December 9, 2015 | Approved | |
psake 4.4.1 | 7441 | Monday, February 9, 2015 | Approved | |
psake 4.3.2 | 3062 | Wednesday, April 9, 2014 | Approved | |
psake 4.3.1.0 | 859 | Monday, December 23, 2013 | Approved | |
psake 4.3.0.0 | 558 | Saturday, December 7, 2013 | Approved |
This package has no dependencies.
Ground Rules:
- This discussion is only about psake and the psake package. If you have feedback for Chocolatey, please contact the Google Group.
- This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
- The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
- Tell us what you love about the package or psake, or tell us what needs improvement.
- Share your experiences with the package, or extra configuration or gotchas that you've found.
- If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.