Unpacking Software Livestream

Join our monthly Unpacking Software livestream to hear about the latest news, chat and opinion on packaging, software deployment and lifecycle management!

Learn More

Chocolatey Product Spotlight

Join the Chocolatey Team on our regular monthly stream where we put a spotlight on the most recent Chocolatey product releases. You'll have a chance to have your questions answered in a live Ask Me Anything format.

Learn More

Chocolatey Coding Livestream

Join us for the Chocolatey Coding Livestream, where members of our team dive into the heart of open source development by coding live on various Chocolatey projects. Tune in to witness real-time coding, ask questions, and gain insights into the world of package management. Don't miss this opportunity to engage with our team and contribute to the future of Chocolatey!

Learn More

Calling All Chocolatiers! Whipping Up Windows Automation with Chocolatey Central Management

Webinar from
Wednesday, 17 January 2024

We are delighted to announce the release of Chocolatey Central Management v0.12.0, featuring seamless Deployment Plan creation, time-saving duplications, insightful Group Details, an upgraded Dashboard, bug fixes, user interface polishing, and refined documentation. As an added bonus we'll have members of our Solutions Engineering team on-hand to dive into some interesting ways you can leverage the new features available!

Watch On-Demand
Chocolatey Community Coffee Break

Join the Chocolatey Team as we discuss all things Community, what we do, how you can get involved and answer your Chocolatey questions.

Watch The Replays
Chocolatey and Intune Overview

Webinar Replay from
Wednesday, 30 March 2022

At Chocolatey Software we strive for simple, and teaching others. Let us teach you just how simple it could be to keep your 3rd party applications updated across your devices, all with Intune!

Watch On-Demand
Chocolatey For Business. In Azure. In One Click.

Livestream from
Thursday, 9 June 2022

Join James and Josh to show you how you can get the Chocolatey For Business recommended infrastructure and workflow, created, in Azure, in around 20 minutes.

Watch On-Demand
The Future of Chocolatey CLI

Livestream from
Thursday, 04 August 2022

Join Paul and Gary to hear more about the plans for the Chocolatey CLI in the not so distant future. We'll talk about some cool new features, long term asks from Customers and Community and how you can get involved!

Watch On-Demand
Hacktoberfest Tuesdays 2022

Livestreams from
October 2022

For Hacktoberfest, Chocolatey ran a livestream every Tuesday! Re-watch Cory, James, Gary, and Rain as they share knowledge on how to contribute to open-source projects such as Chocolatey CLI.

Watch On-Demand

Downloads:

81,487

Downloads of v 4.7.0:

6,708

Last Update:

21 Nov 2017

Package Maintainer(s):

Software Author(s):

  • James Kovacs

Tags:

build powershell

psake

This is not the latest version of psake available.

  • 1
  • 2
  • 3

4.7.0 | Updated: 21 Nov 2017

Downloads:

81,487

Downloads of v 4.7.0:

6,708

Software Author(s):

  • James Kovacs

psake 4.7.0

This is not the latest version of psake available.

  • 1
  • 2
  • 3

Some Checks Have Failed or Are Not Yet Complete

Not All Tests Have Passed


Validation Testing Failed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details
Learn More

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:

NOTE

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

  • 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

3. Copy Your Script

choco upgrade psake -y --source="'INTERNAL REPO URL'" --version="'4.7.0'" [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.7.0'" 
$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.7.0'
    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.7.0'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


cChocoPackageInstaller psake
{
    Name     = "psake"
    Version  = "4.7.0"
    Source   = "INTERNAL REPO URL"
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'psake':
  ensure   => '4.7.0',
  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.

Package Approved

This package was approved by moderator ferventcoder on 24 Nov 2017.

Description

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.


tools\chocolateyInstall.ps1
$nugetPath = $env:ChocolateyInstall
$nugetExePath = Join-Path -Path $nuGetPath -ChildPath 'bin'
$packageBatchFileName = Join-Path -Path $nugetExePath -ChildPath 'psake.bat'

$psakeDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
#$path = ($psakeDir | Split-Path | Join-Path -ChildPath  'psake.cmd')
$path = Join-Path -Path $psakeDir -ChildPath 'psake/psake.cmd'
Write-Host "Adding $packageBatchFileName and pointing to $path"
"@echo off
""$path"" %*" | Out-File $packageBatchFileName -encoding ASCII

Write-Host "PSake is now ready. You can type 'psake' from any command line at any path. Get started by typing 'psake /?'"
tools\chocolateyUninstall.ps1
$nugetPath = $env:ChocolateyInstall
$nugetExePath = Join-Path -Path $nuGetPath -ChildPath 'bin'
$packageBatchFileName = Join-Path -Path $nugetExePath -ChildPath 'psake.bat'

# '[p]sake' is the same as 'psake' but $Error is not polluted
Remove-Module -Name [p]sake -Verbose:$false

Remove-Item -Path $packageBatchFileName -Force -Confirm:$false

Write-Host 'PSake has been uninstalled'
tools\init.ps1
param($installPath, $toolsPath, $package)

$psakeModule = Join-Path -Path $toolsPath -ChildPath 'psake/psake.psd1'
Import-Module -Name $psakeModule
tools\license.txt
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.
tools\psake\en-US\psake.psm1-help.xml.old
 
tools\psake\examples\checkvariables.ps1
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'
}
tools\psake\examples\continueonerror.ps1
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"
}
tools\psake\examples\default.ps1
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
}
tools\psake\examples\formattaskname_scriptblock.ps1
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
}
tools\psake\examples\formattaskname_string.ps1
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
}
tools\psake\examples\msbuild40.ps1
Framework "4.0"
# Framework "4.0x64"

task default -depends ShowMsBuildVersion

task ShowMsBuildVersion {
  msbuild /version
}
tools\psake\examples\nested.ps1
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'
}
tools\psake\examples\nested\nested1.ps1
Properties {
    $x = 100
}

Task default -Depends Nested1CheckX

Task Nested1CheckX{
    Assert ($x -eq 100) '$x was not 100'
}
tools\psake\examples\nested\nested2.ps1
Properties {
    $x = 200
}

Task default -Depends Nested2CheckX

Task Nested2CheckX{
    Assert ($x -eq 200) '$x was not 200'
}
tools\psake\examples\paralleltasks.ps1
Task ParallelTask1 {
    "ParallelTask1"
}

Task ParallelTask2 {
    "ParallelTask2"
}

Task ParallelNested1andNested2 {
    $jobArray = @()
    @("ParallelTask1", "ParallelTask2") | ForEach-Object {
        $jobArray += Start-Job { 
            param($scriptFile, $taskName)
                Invoke-psake $scriptFile -taskList $taskName
            } -ArgumentList $psake.build_script_file.FullName, $_ 
    }
    Wait-Job $jobArray | Receive-Job
}

Task default -depends ParallelNested1andNested2
tools\psake\examples\parameters.ps1
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'}"
}
tools\psake\examples\passingParametersString\build.Release.Version.bat
powershell -Command "& {Import-Module .\..\..\psake.psm1; Invoke-psake .\parameters.ps1 -parameters @{"buildConfiguration"='Release';} }"

Pause
tools\psake\examples\passingParametersString\parameters.ps1
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 ""
}
tools\psake\examples\preandpostaction.ps1
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"
}
tools\psake\examples\preandpostcondition.ps1
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."
}
tools\psake\examples\properties.ps1
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"
}
tools\psake\examples\requiredvariables.ps1
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 `
{
}
tools\psake\examples\tasksetupandteardown.ps1
TaskSetup {
  "Executing task setup"
}

TaskTearDown {
  "Executing task tear down"
}

Task default -depends TaskB

Task TaskA {
  "TaskA executed"
}

Task TaskB -depends TaskA {
  "TaskB executed"
}
tools\psake\private\CleanupEnvironment.ps1
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()
    }
}
tools\psake\private\ConfigureBuildEnvironment.ps1

function ConfigureBuildEnvironment {
    if (!(Get-Variable -Name IsWindows -ErrorAction SilentlyContinue) -or $IsWindows) {
        $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')
            }
            '1.1.0' {
                $versions = @()
            }
            '2.0' {
                $versions = @('v2.0.50727')
            }
            '2.0.0' {
                $versions = @()
            }
            '3.0' {
                $versions = @('v2.0.50727')
            }
            '3.5' {
                $versions = @('v3.5', 'v2.0.50727')
            }
            '4.0' {
                $versions = @('v4.0.30319')
            }
            {($_ -eq '4.5') -or ($_ -eq '4.5.1') -or ($_ -eq '4.5.2')} {
                $versions = @('v4.0.30319')
                $buildToolsVersions = @('15.0', '14.0', '12.0')
            }
            {($_ -eq '4.6') -or ($_ -eq '4.6.1') -or ($_ -eq '4.6.2')} {
                $versions = @('v4.0.30319')
                $buildToolsVersions = @('15.0', '14.0')
            }
            {($_ -eq '4.7') -or ($_ -eq '4.7.1')} {
                $versions = @('v4.0.30319')
                $buildToolsVersions = @('15.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 ($ver -eq "15.0") {
                    if ((Get-Module -Name VSSetup -ListAvailable) -eq $null) {
                        WriteColoredOutput ($msgs.warning_missing_vsssetup_module -f $ver) -foregroundcolor Yellow
                        continue
                    }

                    Import-Module VSSetup

                    # borrowed from nightroman https://github.com/nightroman/Invoke-Build
                    if ($vsInstances = Get-VSSetupInstance) {
                        $vs = @($vsInstances | Select-VSSetupInstance -Version '[15.0,16.0)' -Require Microsoft.Component.MSBuild)
                        if ($vs) {
                            if ($buildToolsKey -eq 'MSBuildToolsPath32') {
                                $frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\15.0\Bin
                            }
                            else {
                                $frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\15.0\Bin\amd64
                            }
                        }

                        $vs = @($vsInstances | Select-VSSetupInstance -Version '[15.0,16.0)' -Product Microsoft.VisualStudio.Product.BuildTools)
                        if ($vs) {
                            if ($buildToolsKey -eq 'MSBuildToolsPath32') {
                                $frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\15.0\Bin
                            }
                            else {
                                $frameworkDirs += Join-Path ($vs[0].InstallationPath) MSBuild\15.0\Bin\amd64
                            }
                        }
                    }
                    else {
                        if (!($root = ${env:ProgramFiles(x86)})) {$root = $env:ProgramFiles}
                        if (Test-Path -LiteralPath "$root\Microsoft Visual Studio\2017") {
                            if ($buildToolsKey -eq 'MSBuildToolsPath32') {
                                $rp = @(Resolve-Path "$root\Microsoft Visual Studio\2017\*\MSBuild\15.0\Bin" -ErrorAction SilentlyContinue)
                            }
                            else {
                                $rp = @(Resolve-Path "$root\Microsoft Visual Studio\2017\*\MSBuild\15.0\Bin\amd64" -ErrorAction SilentlyContinue)
                            }

                            if ($rp) {
                                $frameworkDirs += $rp[-1].ProviderPath
                            }
                        }
                    }
                }
                elseif (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-Object { "$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-Object { 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"
}
tools\psake\private\CreateConfigurationForNewContext.ps1
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
}
tools\psake\private\ExecuteInBuildFileScope.ps1
function ExecuteInBuildFileScope {
    param([string]$buildFile, $module, [scriptblock]$sb)

    # 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

    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
    }

    & $sb $currentContext $module
}
tools\psake\private\Get-DefaultBuildFile.ps1
# Attempt to find the default build file given the config_default of
# buildFileName and legacyBuildFileName.  If neither exist optionally
# return the buildFileName or $null
function Get-DefaultBuildFile {
    param(
        [boolean] $UseDefaultIfNoneExist = $true
    )

    if (test-path $psake.config_default.buildFileName -pathType Leaf) {
        Write-Output $psake.config_default.buildFileName
    } elseif (test-path $psake.config_default.legacyBuildFileName -pathType Leaf) {
        Write-Warning "The default configuration file of default.ps1 is deprecated.  Please use psakefile.ps1"
        Write-Output $psake.config_default.legacyBuildFileName
    } elseif ($UseDefaultIfNoneExist) {
        Write-Output $psake.config_default.buildFileName
    }
}
tools\psake\private\GetCurrentConfigurationOrDefault.ps1
function GetCurrentConfigurationOrDefault() {
    if ($psake.context.count -gt 0) {
        return $psake.context.peek().config
    } else {
        return $psake.config_default
    }
}
tools\psake\private\GetTasksFromContext.ps1
function GetTasksFromContext($currentContext) {

    $docs = $currentContext.tasks.Keys | foreach-object {

        $task = $currentContext.tasks.$_
        new-object PSObject -property @{
            Name = $task.Name;
            Alias = $task.Alias;
            Description = $task.Description;
            DependsOn = $task.DependsOn;
        }
    }

    return $docs
}
tools\psake\private\LoadConfiguration.ps1
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: " + $_
        }
    }
}
tools\psake\private\LoadModules.ps1
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)
                }
            }
        }
        ""
    }
}
tools\psake\private\ResolveError.ps1
# 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)"
    }
}
tools\psake\private\SelectObjectWithDefault.ps1
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 }
    }
}
tools\psake\private\WriteColoredOutput.ps1
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
    }
}
tools\psake\private\WriteDocumentation.ps1
function WriteDocumentation($showDetailed) {

        $currentContext = $psake.context.Peek()

        if ($currentContext.tasks.default) {
            $defaultTaskDependencies = $currentContext.tasks.default.DependsOn
        } else {
            $defaultTaskDependencies = @()
        }

        $docs = GetTasksFromContext $currentContext |
                    Where   {$_.Name -ne 'default'} |
                    ForEach {
                        $isDefault = $null
                        if ($defaultTaskDependencies -contains $_.Name) {
                            $isDefault = $true
                        }
                        return Add-Member -InputObject $_ 'Default' $isDefault -PassThru
                    }

        if ($showDetailed) {
            $docs | Sort-Object 'Name' | format-list -property Name,Alias,Description,@{Label="Depends On";Expression={$_.DependsOn -join ', '}},Default
        } else {
            $docs | Sort-Object 'Name' | format-table -autoSize -wrap -property Name,Alias,@{Label="Depends On";Expression={$_.DependsOn -join ', '}},Default,Description
        }
    }
tools\psake\private\WriteTaskTimeSummary.ps1
function WriteTaskTimeSummary($invokePsakeDuration) {
    if ($psake.context.count -gt 0) {
        $currentContext = $psake.context.Peek()
        if ($currentContext.config.taskNameFormat -is [ScriptBlock]) {
            & $currentContext.config.taskNameFormat "Build Time Report"
        } elseif ($currentContext.config.taskNameFormat -ne "Executing {0}") {
            $currentContext.config.taskNameFormat -f "Build Time Report"
        }
        else {
            "-" * 70
            "Build Time Report"
            "-" * 70
        }
        $list = @()
        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.ToString("hh\:mm\:ss\.fff")
            }
        }
        [Array]::Reverse($list)
        $list += new-object PSObject -property @{
            Name = "Total:";
            Duration = $invokePsakeDuration.ToString("hh\:mm\:ss\.fff")
        }
        # 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 { $_ }
    }
}
tools\psake\psake-config.ps1
<#
-------------------------------------------------------------------
Defaults
-------------------------------------------------------------------
$config.buildFileName="psakefile.ps1"
$config.legacyBuildFileName="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)" }
#>
tools\psake\psake.cmd
@echo off
rem Helper script for those who want to run psake from cmd.exe
rem Example run from cmd.exe:
rem psake "psakefile.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"
tools\psake\psake.ps1
# Helper script for those who want to run psake without importing the module.
# Example run from PowerShell:
# .\psake.ps1 "psakefile.ps1" "BuildHelloWord" "4.0"

# Must match parameter definitions for psake.psm1/invoke-psake
# otherwise named parameter binding fails
[cmdletbinding()]
param(
    [Parameter(Position = 0, Mandatory = $false)]
    [string]$buildFile,

    [Parameter(Position = 1, Mandatory = $false)]
    [string[]]$taskList = @(),

    [Parameter(Position = 2, Mandatory = $false)]
    [string]$framework,

    [Parameter(Position = 3, Mandatory = $false)]
    [switch]$docs = $false,

    [Parameter(Position = 4, Mandatory = $false)]
    [System.Collections.Hashtable]$parameters = @{},

    [Parameter(Position = 5, Mandatory = $false)]
    [System.Collections.Hashtable]$properties = @{},

    [Parameter(Position = 6, Mandatory = $false)]
    [alias("init")]
    [scriptblock]$initialization = {},

    [Parameter(Position = 7, Mandatory = $false)]
    [switch]$nologo = $false,

    [Parameter(Position = 8, Mandatory = $false)]
    [switch]$help = $false,

    [Parameter(Position = 9, Mandatory = $false)]
    [string]$scriptPath,

    [Parameter(Position = 10, Mandatory = $false)]
    [switch]$detailedDocs = $false,

    [Parameter(Position = 11, Mandatory = $false)]
    [switch]$notr = $false
)

# setting $scriptPath here, not as default argument, to support calling as "powershell -File psake.ps1"
if (-not $scriptPath) {
    $scriptPath = $(Split-Path -Path $MyInvocation.MyCommand.path -Parent)
}

# '[p]sake' is the same as 'psake' but $Error is not polluted
Remove-Module -Name [p]sake -Verbose:$false
Import-Module -Name (Join-Path -Path $scriptPath -ChildPath 'psake.psd1') -Verbose:$false
if ($help) {
    Get-Help -Name Invoke-psake -Full
    return
}

if ($buildFile -and (-not (Test-Path -Path $buildFile))) {
    $absoluteBuildFile = (Join-Path -Path $scriptPath -ChildPath $buildFile)
    if (Test-path -Path $absoluteBuildFile) {
        $buildFile = $absoluteBuildFile
    }
}

Invoke-psake $buildFile $taskList $framework $docs $parameters $properties $initialization $nologo $detailedDocs $notr
tools\psake\psake.psd1
@{
    RootModule        = 'psake.psm1'
    ModuleVersion     = '4.7.0'
    GUID              = 'cfb53216-072f-4a46-8975-ff7e6bda05a5'
    Author            = 'James Kovacs'
    Copyright         = 'Copyright (c) 2010-17 James Kovacs, Damian Hickey and Contributors'
    PowerShellVersion = '3.0'
    Description       = 'psake is a build automation tool written in PowerShell.'
    FunctionsToExport = @('Invoke-psake',
                          'Invoke-Task',
                          'Get-PSakeScriptTasks',
                          'Task',
                          'Properties',
                          'Include',
                          'FormatTaskName',
                          'TaskSetup',
                          'TaskTearDown',
                          'Framework',
                          'Assert',
                          'Exec')
    VariablesToExport = 'psake'
    PrivateData = @{
        PSData = @{
            LicenseUri = 'https://github.com/psake/psake/blob/master/license.txt'
            ProjectUri = 'https://github.com/psake/psake'
            Tags     = @('Build', 'Task')
            IconUri  = 'https://raw.githubusercontent.com/psake/graphics/master/png/psake-single-icon-teal-bg-256x256.png'
        }
    }
}
tools\psake\psake.psm1
# 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

if ($PSVersionTable.PSVersion.Major -ge 3)
{
    $script:IgnoreError = 'Ignore'
}
else
{
    $script:IgnoreError = 'SilentlyContinue'
}

# Dot source public/private functions
$public = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'public/*.ps1') -Recurse -ErrorAction Stop)
$private = @(Get-ChildItem -Path (Join-Path -Path $PSScriptRoot -ChildPath 'private/*.ps1') -Recurse -ErrorAction Stop)
foreach ($import in @($public + $private)) {
    try {
        . $import.FullName
    }
    catch {
        throw "Unable to dot source [$($import.FullName)]"
    }
}

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.
    warning_missing_vsssetup_module = Warning: Cannot find build tools version {0} without the module VSSetup. You can install this module with the command: Install-Module VSSetup -Scope CurrentUser
    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 -FileName messages.psd1 -ErrorAction $script:IgnoreError

$scriptDir = Split-Path $MyInvocation.MyCommand.Path
$manifestPath = Join-Path $scriptDir psake.psd1
$manifest = Test-ModuleManifest -Path $manifestPath -WarningAction SilentlyContinue

$script:psake = @{}

$psake.version = $manifest.Version.ToString()
$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 = "psakefile.ps1";
    legacyBuildFileName = "default.ps1";
    framework = "4.0";
    taskNameFormat = "Executing {0}";
    verboseError = $false;
    coloredOutput = $true;
    modules = $null;
    moduleScope = "";
} # contains default configuration, can be overridden 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, Get-PSakeScriptTasks, Task, Properties, Include, FormatTaskName, TaskSetup, TaskTearDown, Framework, Assert, Exec -variable psake
tools\psake\public\Assert.ps1
function Assert {
    <#
        .SYNOPSIS
        Helper function for "Design by Contract" assertion checking.

        .DESCRIPTION
        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.

        .PARAMETER conditionToCheck
        The boolean condition to evaluate

        .PARAMETER failureMessage
        The error message used for the exception if the conditionToCheck parameter is false

        .EXAMPLE
        C:\PS>Assert $false "This always throws an exception"

        Example of an assertion that will always fail.

        .EXAMPLE
        C:\PS>Assert ( ($i % 2) -eq 0 ) "$i is not an even number"

        This exmaple may throw an exception if $i is not an even number

        Note:
        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"
        .LINK
        Exec
        .LINK
        FormatTaskName
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Include
        .LINK
        Invoke-psake
        .LINK
        Properties
        .LINK
        Task
        .LINK
        TaskSetup
        .LINK
        TaskTearDown
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        $conditionToCheck,

        [Parameter(Mandatory = $true)]
        [string]$failureMessage
    )

    if (-not $conditionToCheck) {
        throw ('Assert: {0}' -f $failureMessage)
    }
}
tools\psake\public\Exec.ps1
function Exec {
    <#
        .SYNOPSIS
        Helper function for executing command-line programs.

        .DESCRIPTION
        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.

        .PARAMETER cmd
        The scriptblock to execute. This scriptblock will typically contain the command-line invocation.

        .PARAMETER errorMessage
        The error message to display if the external command returned a non-zero exit code.

        .PARAMETER maxRetries
        The maximum number of times to retry the command before failing.

        .PARAMETER retryTriggerErrorPattern
        If the external command raises an exception, match the exception against this regex to determine if the command can be retried.
        If a match is found, the command will be retried provided [maxRetries] has not been reached.

        .PARAMETER workingDirectory
        The working directory to set before running the external command.

        .EXAMPLE
        exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN command-line client is installed"

        This example calls the svn command-line client.
        .LINK
        Assert
        .LINK
        FormatTaskName
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Include
        .LINK
        Invoke-psake
        .LINK
        Properties
        .LINK
        Task
        .LINK
        TaskSetup
        .LINK
        TaskTearDown
        .LINK
        Properties
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [scriptblock]$cmd,

        [string]$errorMessage = ($msgs.error_bad_command -f $cmd),

        [int]$maxRetries = 0,

        [string]$retryTriggerErrorPattern = $null,

        [string]$workingDirectory = $null
    )

    if ($workingDirectory) {
        Push-Location -Path $workingDirectory
    }

    $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))
        }
        finally {
            if ($workingDirectory) {
                Pop-Location
            }
        }
    }
    while ($true)
}
tools\psake\public\FormatTaskName.ps1
function FormatTaskName {
    <#
        .SYNOPSIS
        This function allows you to change how psake renders the task name during a build.

        .DESCRIPTION
        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.

        .PARAMETER format
        A format string or a scriptblock to execute

        .EXAMPLE
        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"

        -----------
        The script above produces the following output:

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

        Build Succeeded!
        .EXAMPLE
        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"
        }

        -----------
        The above example uses the scriptblock parameter to the FormatTaskName function to render each task name in the color blue.

        Note: the $taskName parameter is arbitrary, it could be named anything.
        .LINK
        Assert
        .LINK
        Exec
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Include
        .LINK
        Invoke-psake
        .LINK
        Properties
        .LINK
        Task
        .LINK
        TaskSetup
        .LINK
        TaskTearDown
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        $format
    )

    $psake.context.Peek().config.taskNameFormat = $format
}
tools\psake\public\Framework.ps1
function Framework {
    <#
    .SYNOPSIS
    Sets the version of the .NET framework you want to use during build.

    .DESCRIPTION
    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.

    .PARAMETER framework
    Version of the .NET framework to use during build.

    .EXAMPLE
    Framework "4.0"

    Task default -depends Compile

    Task Compile -depends Clean {
        msbuild /version
    }

    -----------
    The script above will output detailed version of msbuid v4
    .LINK
    Assert
    .LINK
    Exec
    .LINK
    FormatTaskName
    .LINK
    Get-PSakeScriptTasks
    .LINK
    Include
    .LINK
    Invoke-psake
    .LINK
    Properties
    .LINK
    Task
    .LINK
    TaskSetup
    .LINK
    TaskTearDown
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$framework
    )

    $psake.context.Peek().config.framework = $framework

    ConfigureBuildEnvironment
}
tools\psake\public\Get-PSakeScriptTasks.ps1
function Get-PSakeScriptTasks {
    <#
    .SYNOPSIS
    Returns meta data about all the tasks defined in the provided psake script.

    .DESCRIPTION
    Returns meta data about all the tasks defined in the provided psake script.

    .PARAMETER buildFile
    The path to the psake build script to read the tasks from.

    .EXAMPLE
    PS C:\>Get-PSakeScriptTasks -buildFile '.\build.ps1'

    DependsOn        Alias Name    Description
    ---------        ----- ----    -----------
    {}                     Compile
    {}                     Clean
    {Test}                 Default
    {Clean, Compile}       Test

    Gets the psake tasks contained in the 'build.ps1' file.

    .LINK
    Invoke-psake
    #>
    [CmdletBinding()]
    param(
        [string]$buildFile
    )

    if (-not $buildFile) {
        $buildFile = $psake.config_default.buildFileName
    }

    try {
        ExecuteInBuildFileScope $buildFile $MyInvocation.MyCommand.Module {
            param($currentContext, $module)
            return GetTasksFromContext $currentContext
        }
    } finally {
        CleanupEnvironment
    }
}
tools\psake\public\Include.ps1
function Include {
    <#
        .SYNOPSIS
        Include the functions or code of another powershell script file into the current build script's scope

        .DESCRIPTION
        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.

        .PARAMETER fileNamePathToInclude
        A string containing the path and name of the powershell file to include

        .EXAMPLE
        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 {
        }

        -----------
        The script above includes all the functions and variables defined in the ".\build_utils.ps1" script into the current build script's scope

        Note: You can have more than 1 "Include" function defined in the build script.

        .LINK
        Assert
        .LINK
        Exec
        .LINK
        FormatTaskName
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Invoke-psake
        .LINK
        Properties
        .LINK
        Task
        .LINK
        TaskSetup
        .LINK
        TaskTearDown
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$fileNamePathToInclude
    )

    Assert (test-path $fileNamePathToInclude -pathType Leaf) ($msgs.error_invalid_include_path -f $fileNamePathToInclude)

    $psake.context.Peek().includes.Enqueue((Resolve-Path $fileNamePathToInclude));
}
tools\psake\public\Invoke-psake.ps1
function Invoke-psake {
    <#
        .SYNOPSIS
        Runs a psake build script.

        .DESCRIPTION
        This function runs a psake build script

        .PARAMETER buildFile
        The path to the psake build script to execute

        .PARAMETER taskList
        A comma-separated list of task names to execute

        .PARAMETER framework
        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'

        .PARAMETER docs
        Prints a list of tasks and their descriptions

        .PARAMETER parameters
        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!

        .PARAMETER properties
        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.

        .PARAMETER initialization
        Parameter description

        .PARAMETER nologo
        Do not display the startup banner and copyright message.

        .PARAMETER detailedDocs
        Prints a more descriptive list of tasks and their descriptions.

        .PARAMETER notr
        Do not display the time report.

        .EXAMPLE
        Invoke-psake

        Runs the 'default' task in the '.build.ps1' build script

        .EXAMPLE
        Invoke-psake '.\build.ps1' Tests,Package

        Runs the 'Tests' and 'Package' tasks in the '.build.ps1' build script

        .EXAMPLE
        Invoke-psake Tests

        This example will run the 'Tests' tasks in the 'psakefile.ps1' build script. The 'psakefile.ps1' is assumed to be in the current directory.

        .EXAMPLE
        Invoke-psake 'Tests, Package'

        This example will run the 'Tests' and 'Package' tasks in the 'psakefile.ps1' build script. The 'psakefile.ps1' is assumed to be in the current directory.

        .EXAMPLE
        Invoke-psake .\build.ps1 -docs

        Prints a report of all the tasks and their dependencies and descriptions and then exits

        .EXAMPLE
        Invoke-psake .\parameters.ps1 -parameters @{"p1"="v1";"p2"="v2"}

        Runs the build script called 'parameters.ps1' and passes in parameters 'p1' and 'p2' with values 'v1' and 'v2'

        Here's the .\parameters.ps1 build script:

        properties {
            $my_property = $p1 + $p2
        }

        task default -depends TestParams

        task TestParams {
            Assert ($my_property -ne $null) '$my_property should not be null'
        }

        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".

        .EXAMPLE
        Invoke-psake .\properties.ps1 -properties @{"x"="1";"y"="2"}

        Runs the build script called 'properties.ps1' and passes in parameters 'x' and 'y' with values '1' and '2'

        This feature allows you to override existing properties in your build script.

        Here's the .\properties.ps1 build script:

        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"
        }

        .NOTES
        ---- Exceptions ----

        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.

        ---- $psake variable ----

        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\psakefile.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\psakefile.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; ...

        .LINK
        Assert
        .LINK
        Exec
        .LINK
        FormatTaskName
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Include
        .LINK
        Properties
        .LINK
        Task
        .LINK
        TaskSetup
        .LINK
        TaskTearDown
        .LINK
        Properties
    #>
    [CmdletBinding()]
    param(
        [Parameter(Position = 0, Mandatory = $false)]
        [string]$buildFile,

        [Parameter(Position = 1, Mandatory = $false)]
        [string[]]$taskList = @(),

        [Parameter(Position = 2, Mandatory = $false)]
        [string]$framework,

        [Parameter(Position = 3, Mandatory = $false)]
        [switch]$docs = $false,

        [Parameter(Position = 4, Mandatory = $false)]
        [hashtable]$parameters = @{},

        [Parameter(Position = 5, Mandatory = $false)]
        [hashtable]$properties = @{},

        [Parameter(Position = 6, Mandatory = $false)]
        [alias("init")]
        [scriptblock]$initialization = {},

        [Parameter(Position = 7, Mandatory = $false)]
        [switch]$nologo,

        [Parameter(Position = 8, Mandatory = $false)]
        [switch]$detailedDocs,

        [Parameter(Position = 9, Mandatory = $false)]
        [switch]$notr # disable time report
    )

    try {
        if (-not $nologo) {
            "psake version {0}`nCopyright (c) 2010-2017 James Kovacs & Contributors`n" -f $psake.version
        }
        if (!$buildFile) {
           $buildFile = Get-DefaultBuildFile
        }
        elseif (!(test-path $buildFile -pathType Leaf) -and ((Get-DefaultBuildFile -UseDefaultIfNoneExist $false) -ne $null) ) {
            # If the default 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 = Get-DefaultBuildFile
        }

        ExecuteInBuildFileScope $buildFile $MyInvocation.MyCommand.Module {
            param($currentContext, $module)

            $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()

            if ($docs -or $detailedDocs) {
                WriteDocumentation($detailedDocs)
                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.
            . $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

            $stopwatch.Stop()
            if (-not $notr) {
                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
    }
}
tools\psake\public\Invoke-Task.ps1
function Invoke-Task {
    <#
        .SYNOPSIS
        Executes another task in the current build script.

        .DESCRIPTION
        This is a function that will allow you to invoke a Task from within another Task in the current build script.

        .PARAMETER taskName
        The name of the task to execute.

        .EXAMPLE
        Invoke-Task "Compile"

        This example calls the "Compile" task.

        .LINK
        Assert
        .LINK
        Exec
        .LINK
        FormatTaskName
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Include
        .LINK
        Invoke-psake
        .LINK
        Properties
        .LINK
        Task
        .LINK
        TaskSetup
        .LINK
        TaskTearDown
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [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) {

                $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()

                try {
                    foreach($childTask in $task.DependsOn) {
                        Invoke-Task $childTask
                    }

                    $currentContext.currentTaskName = $taskName

                    try {
                        & $currentContext.taskSetupScriptBlock
                        try {
                            if ($task.PreAction) {
                                & $task.PreAction
                            }

                            if ($currentContext.config.taskNameFormat -is [ScriptBlock]) {
                                $taskHeader = & $currentContext.config.taskNameFormat $taskName
                            } else {
                                $taskHeader = $currentContext.config.taskNameFormat -f $taskName
                            }
                            WriteColoredOutput $taskHeader -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
                        } finally {
                            if ($task.PostAction) {
                                & $task.PostAction
                            }
                        }
                    } finally {
                        & $currentContext.taskTearDownScriptBlock
                    }
                } catch {
                    if ($task.ContinueOnError) {
                        "-"*70
                        WriteColoredOutput ($msgs.continue_on_error -f $taskName,$_) -foregroundcolor Yellow
                        "-"*70
                    }  else {
                        throw $_
                    }
                } finally {
                    $task.Duration = $stopwatch.Elapsed
                }
            } 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)
}
tools\psake\public\Properties.ps1
function Properties {
    <#
        .SYNOPSIS
        Define a scriptblock that contains assignments to variables that will be available to all tasks in the build script

        .DESCRIPTION
        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.

        .PARAMETER properties
        The script block containing all the variable assignment statements

        .EXAMPLE
        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 {
        }

        Note: You can have more than one "Properties" function defined in the build script.

        .LINK
        Assert
        .LINK
        Exec
        .LINK
        FormatTaskName
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Include
        .LINK
        Invoke-psake
        .LINK
        Task
        .LINK
        TaskSetup
        .LINK
        TaskTearDown
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [scriptblock]$properties
    )

    $psake.context.Peek().properties += $properties
}
tools\psake\public\Task.ps1
function Task {
    <#
        .SYNOPSIS
        Defines a build task to be executed by psake

        .DESCRIPTION
        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

        .PARAMETER name
        The name of the task

        .PARAMETER action
        A scriptblock containing the statements to execute for the task.

        .PARAMETER preaction
        A scriptblock to be executed before the 'Action' scriptblock.
        Note: This parameter is ignored if the 'Action' scriptblock is not defined.

        .PARAMETER postaction
        A scriptblock to be executed after the 'Action' scriptblock.
        Note: This parameter is ignored if the 'Action' scriptblock is not defined.

        .PARAMETER precondition
        A scriptblock that is executed to determine if the task is executed or skipped.
        This scriptblock should return $true or $false

        .PARAMETER postcondition
        A scriptblock that is executed to determine if the task completed its job correctly.
        An exception is thrown if the scriptblock returns $false.

        .PARAMETER continueOnError
        If this switch parameter is set then the task will not cause the build to fail when an exception is thrown by the task

        .PARAMETER depends
        An array of task names that this task depends on.
        These tasks will be executed before the current task is executed.

        .PARAMETER requiredVariables
        An array of names of variables that must be set to run this task.

        .PARAMETER description
        A description of the task.

        .PARAMETER alias
        An alternate name for the task.

        .EXAMPLE
        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

        .LINK
        Assert
        .LINK
        Exec
        .LINK
        FormatTaskName
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Include
        .LINK
        Invoke-psake
        .LINK
        Properties
        .LINK
        TaskSetup
        .LINK
        TaskTearDown
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [string]$name = $null,

        [scriptblock]$action = $null,

        [scriptblock]$preaction = $null,

        [scriptblock]$postaction = $null,

        [scriptblock]$precondition = {$true},

        [scriptblock]$postcondition = {$true},

        [switch]$continueOnError,

        [string[]]$depends = @(),

        [string[]]$requiredVariables = @(),

        [string]$description = $null,

        [string]$alias = $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
    }

    $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
    }
}
tools\psake\public\TaskSetup.ps1
function TaskSetup {
    <#
        .SYNOPSIS
        Adds a scriptblock that will be executed before each task

        .DESCRIPTION
        This function will accept a scriptblock that will be executed before each task in the build script.

        .PARAMETER setup
        A scriptblock to execute

        .EXAMPLE
        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"
        }

        The script above produces the following output:

        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

        .LINK
        Assert
        .LINK
        Exec
        .LINK
        FormatTaskName
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Include
        .LINK
        Invoke-psake
        .LINK
        Properties
        .LINK
        Task
        .LINK
        TaskTearDown
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [scriptblock]$setup
    )

    $psake.context.Peek().taskSetupScriptBlock = $setup
}
tools\psake\public\TaskTearDown.ps1

function TaskTearDown {
    <#
        .SYNOPSIS
        Adds a scriptblock to the build that will be executed after each task

        .DESCRIPTION
        This function will accept a scriptblock that will be executed after each task in the build script.

        .PARAMETER teardown
        A scriptblock to execute

        .EXAMPLE
        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"
        }

        The script above produces the following output:

        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

        .LINK
        Assert
        .LINK
        Exec
        .LINK
        FormatTaskName
        .LINK
        Framework
        .LINK
        Get-PSakeScriptTasks
        .LINK
        Include
        .LINK
        Invoke-psake
        .LINK
        Properties
        .LINK
        Task
        .LINK
        TaskSetup
    #>
    [CmdletBinding()]
    param(
        [Parameter(Mandatory = $true)]
        [scriptblock]$teardown
    )

    $psake.context.Peek().taskTearDownScriptBlock = $teardown
}
tools\README.md
Welcome to the psake project
=============================

[![Build status][appveyor-badge]][appveyor-build]
[![Build Status][travis-badge]][travis-build]
[![PowerShell Gallery][psgallery-badge]][psgallery]
[![Chocolatey][chocolatey-badge]][chocolatey]
[![Nuget downloads][nuget-downloads]][nuget]
[![Join the chat at https://gitter.im/psake/psake][gitter-badge]][gitter]

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 existing command-line knowledge.

psake is pronounced sake – as in Japanese rice wine. It does NOT rhyme with make, bake, or rake.

## How to get started

**Step 1:** Download and extract the project

You will need to "unblock" the zip file before extracting - PowerShell by default does not run files downloaded from the Internet.
Just right-click the zip and click on "properties" and click on the "unblock" button.

**Step 2:** CD into the directory where you extracted the project (where the psake.psm1 file is)

> Import-Module .\psake.psm1

If you encounter the following error "Import-Module : ...psake.psm1 cannot be loaded because the execution of scripts is disabled on this system." Please see "get-help about_signing" for more details.

1. Run PowerShell as administrator
2. Set-ExecutionPolicy RemoteSigned

> Get-Help Invoke-psake -Full
> - this will show you help and examples of how to use psake

**Step 3:** Run some examples

> CD .\examples
>
> Invoke-psake
> - This will execute the "default" task in the "psakefile.ps1"
>
> Invoke-psake .\psakefile.ps1 Clean
> - will execute the single task in the psakefile.ps1 script

**Step 4:** Set your PATH variable

If you wish to use the psake command from outside of the install folder, add the folder install directory to your PATH variable.

## Release Notes

You can find all the information about each release of psake in the [releases section](https://github.com/psake/psake/releases).

## How To Contribute, Collaborate, Communicate

If you'd like to get involved with psake, we have discussion groups over at Google: **[psake-dev](http://groups.google.com/group/psake-dev)** **[psake-users](http://groups.google.com/group/psake-users)**

Anyone can fork the main repository and submit patches, as well. And lastly, the [wiki](http://wiki.github.com/psake/psake/) and [issues list](http://github.com/psake/psake/issues) are also open for additions, edits, and discussion.

Also check out the **[psake-contrib](http://github.com/psake/psake-contrib)** project for scripts, modules and functions to help you with a build.

## License

psake is released under the [MIT license](http://www.opensource.org/licenses/MIT).

[appveyor-badge]: https://ci.appveyor.com/api/projects/status/e8b90u1q1ex5hx9m?svg=true
[appveyor-build]: https://ci.appveyor.com/project/psake/psake
[travis-badge]: https://travis-ci.org/psake/psake.svg?branch=master
[travis-build]: https://travis-ci.org/psake/psake
[gitter-badge]: https://badges.gitter.im/Join%20Chat.svg
[gitter]: https://gitter.im/psake/psake?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[psgallery-badge]: https://img.shields.io/powershellgallery/dt/psake.svg
[psgallery]: https://www.powershellgallery.com/packages/psake
[chocolatey-badge]: https://img.shields.io/chocolatey/dt/psake.svg
[chocolatey]: https://chocolatey.org/packages/psake
[nuget-downloads]: https://img.shields.io/nuget/dt/psake.svg
[nuget]: https://www.nuget.org/packages/psake/

Log in or click on link to see number of positives.

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.7.3 15754 Saturday, August 11, 2018 Approved
psake 4.7.2 522 Friday, August 10, 2018 Approved
psake 4.7.1 285 Tuesday, July 24, 2018 Approved
psake 4.7.0 6708 Tuesday, November 21, 2017 Approved
psake 4.6.0 17534 Sunday, March 20, 2016 Approved
psake 4.5.0 1542 Friday, January 15, 2016 Approved
psake 4.4.2 1568 Wednesday, December 9, 2015 Approved
psake 4.4.1 7417 Monday, February 9, 2015 Approved
psake 4.3.2 3039 Wednesday, April 9, 2014 Approved
psake 4.3.1.0 838 Monday, December 23, 2013 Approved
psake 4.3.0.0 538 Saturday, December 7, 2013 Approved

This package has no dependencies.

Discussion for the psake Package

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.
comments powered by Disqus