Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: JamesKovacs/psake
base: 42eb994078
...
head fork: JamesKovacs/psake
compare: f4e8af2774
  • 16 commits
  • 14 files changed
  • 0 commit comments
  • 4 contributors
Commits on Oct 23, 2011
@whut whut Simplified loading modules 98f110b
@whut whut Added note to Include function that code from included file will be e…
…xecuted after code from build script.
2d4e56a
@whut whut Added RequiredVariables argument to Task function
Also unified formatting in Task
5237be1
whut Fixed issue #7 - not using buildFile as taskList in Invoke-Psake, whe…
…n there is folder, not file with name as task

Added -PathType to all test-path invocations
a7aea83
Commits on Nov 04, 2011
whut Fix for issue #23 - psake.cmd should exit with 0 when build succeeded
Also use of -ExecutionPolicy Bypass, which is even less restrictive than -ExecutionPolicy Unrestricted
e17c6dd
whut Use of Cyan foreground color, instead of Blue to make it more visible…
… on darker consoles

Cyan is also commonly recommended, for example in http://blogs.msdn.com/b/abhinaba/archive/2006/01/05/509581.aspx
9d8903c
Commits on Nov 05, 2011
@whut whut Task duration shows duration of task, not of task and it's dependencies
Also added default duration of TimeSpan.Zero (to show in summary 00:00:00 instead of 0)
And added argument to Write-TaskSummary, to make it more readable where $stopwatch variable inside that function came from, and use of where-object instead of its alias ?, to also make it more readable
9f6c11e
whut Warning (yellow colored output) when task failed with -ContinueOnError
Also some small stuff, unified error messages, comment formating, etc
391cf6f
whut Added -help switch to psake.ps1 instead of psake-help.ps1 script
Simplificated psake.cmd because of that (also removed some ifs that detected if help should be displayed, because they for example make it impossible to call task with name "help")
bca24cc
Commits on Feb 10, 2012
@pedroreys pedroreys Adds support to defining an alias to a task.
Example:
  task Task_With_Descriptive_Name -alias twdn {}

By doing that I can now call .\psake.ps1 twdn and have the
Task_With_Descriptive_Name executed
88bb811
@pedroreys pedroreys fixes the task name when using aliases so that the casing is correct 33018d2
Commits on Mar 19, 2012
@idavis idavis fixing case where framework is set using 3 digits (3.0/4.0). The bit …
…substring is empty, not null. This will fix all specs.
4710deb
Commits on Mar 21, 2012
@JamesKovacs Merge pull request #26 from pedroreys/alias
Adds support to defining an alias to a task.
138296d
@JamesKovacs Defaulted psake to .NET 4.0 27cd8a7
@JamesKovacs Switched to semantic versioning ef6ad0a
@JamesKovacs Fixed formatting in .nuspec f4e8af2
View
18 en-US/psake.psm1-help.xml
@@ -1078,7 +1078,7 @@ Task TaskC {
<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.</maml:para>
+ <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>
@@ -1403,6 +1403,10 @@ Task Clean {
<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>
@@ -1506,6 +1510,18 @@ Task Clean {
<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>
View
14 examples/requiredvariables.ps1
@@ -0,0 +1,14 @@
+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 `
+{
+}
View
16 nuget/psake.nuspec
@@ -2,18 +2,14 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>psake</id>
- <version>4.2</version>
+ <version>4.1.0</version>
<authors>James Kovacs</authors>
- <owners>Damian Hickey, Rob Reynolds</owners>
- <projectUrl>https://github.com/JamesKovacs/psake</projectUrl>
+ <owners>James Kovacs, Damian Hickey, Rob Reynolds</owners>
+ <projectUrl>https://github.com/psake/psake</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
- <summary>PSake is a build automation tool written in PowerShell</summary>
- <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.
- </description>
+ <summary>psake is a build automation tool written in PowerShell</summary>
+ <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.</description>
<language>en-US</language>
<tags>build powershell chocolatey</tags>
</metadata>
-</package>
+</package>
View
30 psake-config.ps1
@@ -2,30 +2,20 @@
-------------------------------------------------------------------
Defaults
-------------------------------------------------------------------
-$config.buildFileName="default.ps1";
-$config.framework = "3.5";
-$config.taskNameFormat="Executing {0}";
-$config.verboseError=$false;
-$config.coloredOutput = $true;
-$config.modules=(new-object psobject -property @{ autoload=$false })
+$config.buildFileName="default.ps1"
+$config.framework = "4.0"
+$config.taskNameFormat="Executing {0}"
+$config.verboseError=$false
+$config.coloredOutput = $true
+$config.modules=$null
-------------------------------------------------------------------
-Auto-load modules from .\modules folder
+Load modules from .\modules folder and from file my_module.psm1
-------------------------------------------------------------------
-$config.modules=(new-object psobject -property @{ autoload=$true})
+$config.modules=(".\modules\*.psm1",".\my_module.psm1")
-------------------------------------------------------------------
-Auto-load modules from .\my_modules folder
+Use scriptblock for taskNameFormat
-------------------------------------------------------------------
-$config.modules=(new-object psobject -property @{ autoload=$true; directory=".\my_modules" })
-
--------------------------------------------------------------------
-Explicitly load module(s)
--------------------------------------------------------------------
-$config.modules=(new-object psobject -property @{
- autoload=$false;
- module=(new-object psobject -property @{path="c:\module1dir\module1.ps1"}),
- (new-object psobject -property @{path="c:\module1dir\module2.ps1"})
- })
-}
+$config.taskNameFormat= { param($taskName) "Executing $taskName at $(get-date)" }
#>
View
7 psake-help.ps1
@@ -1,7 +0,0 @@
-# Helper script to return help text.
-
-remove-module psake -ea 'SilentlyContinue'
-$scriptPath = Split-Path -parent $MyInvocation.MyCommand.path
-import-module (join-path $scriptPath psake.psm1)
-Get-Help Invoke-psake -full
-exit $lastexitcode
View
18 psake.cmd
@@ -1,15 +1,11 @@
@echo off
-SET DIR=%~dp0%
-
-if '%1'=='/?' goto usage
-if '%1'=='-?' goto usage
-if '%1'=='?' goto usage
-if '%1'=='/help' goto usage
-if '%1'=='help' goto usage
-
-powershell -NoProfile -ExecutionPolicy unrestricted -Command "& '%DIR%psake.ps1' %*; if ($psake.build_success -eq $false) { exit 1 }"
+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 }"
goto :eof
-:usage
-powershell -NoProfile -ExecutionPolicy unrestricted -Command "& '%DIR%psake-help.ps1'"
+
+:help
+powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\psake.ps1' -help"
View
11 psake.ps1
@@ -18,14 +18,21 @@ param(
[Parameter(Position=5, Mandatory=0)]
[System.Collections.Hashtable]$properties = @{},
[Parameter(Position=6, Mandatory=0)]
- [string]$scriptPath = $(Split-Path -parent $MyInvocation.MyCommand.path),
+ [switch]$nologo = $false,
[Parameter(Position=7, Mandatory=0)]
- [switch]$nologo = $false
+ [switch]$help = $false,
+ [Parameter(Position=8, Mandatory=0)]
+ [string]$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 (-not(test-path $buildFile)) {
$absoluteBuildFile = (join-path $scriptPath $buildFile)
if (test-path $absoluteBuildFile) {
View
202 psake.psm1
@@ -34,31 +34,32 @@ function Invoke-Task
$taskKey = $taskName.ToLower()
+ if ($currentContext.aliases.Contains($taskKey)) {
+ $taskName = $currentContext.aliases.$taskKey.Name
+ $taskKey = $taskName.ToLower()
+ }
+
$currentContext = $psake.context.Peek()
- $tasks = $currentContext.tasks
- $executedTasks = $currentContext.executedTasks
- $callStack = $currentContext.callStack
- Assert ($tasks.Contains($taskKey)) ($msgs.error_task_name_does_not_exist -f $taskName)
+ Assert ($currentContext.tasks.Contains($taskKey)) ($msgs.error_task_name_does_not_exist -f $taskName)
- if ($executedTasks.Contains($taskKey)) { return }
+ if ($currentContext.executedTasks.Contains($taskKey)) { return }
- Assert (!$callStack.Contains($taskKey)) ($msgs.error_circular_reference -f $taskName)
+ Assert (!$currentContext.callStack.Contains($taskKey)) ($msgs.error_circular_reference -f $taskName)
- $callStack.Push($taskKey)
+ $currentContext.callStack.Push($taskKey)
- $task = $tasks.$taskKey
+ $task = $currentContext.tasks.$taskKey
$precondition_is_valid = & $task.Precondition
if (!$precondition_is_valid) {
- Write-ColoredOutput ($msgs.precondition_was_false -f $taskName) -foregroundcolor Blue
+ Write-ColoredOutput ($msgs.precondition_was_false -f $taskName) -foregroundcolor Cyan
} else {
if ($taskKey -ne 'default') {
- $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
if ($task.PreAction -or $task.PostAction) {
- Assert ($task.Action -ne $null) $msgs.error_missing_action_parameter
+ Assert ($task.Action -ne $null) ($msgs.error_missing_action_parameter -f $taskName)
}
if ($task.Action) {
@@ -67,6 +68,7 @@ function Invoke-Task
Invoke-Task $childTask
}
+ $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$currentContext.currentTaskName = $taskName
& $currentContext.taskSetupScriptBlock
@@ -78,7 +80,11 @@ function Invoke-Task
if ($currentContext.config.taskNameFormat -is [ScriptBlock]) {
& $currentContext.config.taskNameFormat $taskName
} else {
- Write-ColoredOutput ($currentContext.config.taskNameFormat -f $taskName) -foregroundcolor Blue
+ Write-ColoredOutput ($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
@@ -88,23 +94,23 @@ function Invoke-Task
}
& $currentContext.taskTearDownScriptBlock
+ $task.Duration = $stopwatch.Elapsed
} catch {
if ($task.ContinueOnError) {
- "-"*70
- $msgs.continue_on_error -f $taskName,$_
"-"*70
+ Write-ColoredOutput ($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
+ # no action was specified but we still execute all the dependencies
foreach($childTask in $task.DependsOn) {
Invoke-Task $childTask
}
}
- $stopwatch.stop()
- $task.Duration = $stopwatch.Elapsed
} else {
foreach($childTask in $task.DependsOn) {
Invoke-Task $childTask
@@ -114,10 +120,10 @@ function Invoke-Task
Assert (& $task.Postcondition) ($msgs.postcondition_failed -f $taskName)
}
- $poppedTaskKey = $callStack.Pop()
+ $poppedTaskKey = $currentContext.callStack.Pop()
Assert ($poppedTaskKey -eq $taskKey) ($msgs.error_corrupt_callstack -f $taskKey,$poppedTaskKey)
- $executedTasks.Push($taskKey)
+ $currentContext.executedTasks.Push($taskKey)
}
# .ExternalHelp psake.psm1-help.xml
@@ -152,17 +158,18 @@ 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]$description = $null
+ [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
)
-
if ($name -eq 'default') {
Assert (!$action) ($msgs.error_default_task_cannot_have_action)
}
@@ -177,16 +184,27 @@ function Task
Postcondition = $postcondition
ContinueOnError = $continueOnError
Description = $description
- Duration = 0
+ Duration = [System.TimeSpan]::Zero
+ RequiredVariables = $requiredVariables
+ Alias = $alias
}
- $taskKey = $name.ToLower()
+ $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
@@ -204,7 +222,7 @@ function Include {
param(
[Parameter(Position=0,Mandatory=1)][string]$fileNamePathToInclude
)
- Assert (test-path $fileNamePathToInclude) ($msgs.error_invalid_include_path -f $fileNamePathToInclude)
+ Assert (test-path $fileNamePathToInclude -pathType Leaf) ($msgs.error_invalid_include_path -f $fileNamePathToInclude)
$psake.context.Peek().includes.Enqueue((Resolve-Path $fileNamePathToInclude));
}
@@ -263,13 +281,13 @@ function Invoke-psake {
# If the default.ps1 file exists and the given "buildfile" isn 't found assume that the given
# $buildFile is actually the target Tasks to execute in the default.ps1 script.
- if ($buildFile -and !(test-path $buildFile) -and (test-path $psake.config_default.buildFileName)) {
+ if ($buildFile -and !(test-path $buildFile -pathType Leaf) -and (test-path $psake.config_default.buildFileName -pathType Leaf)) {
$taskList = $buildFile.Split(', ')
$buildFile = $psake.config_default.buildFileName
}
# Execute the build file to set up the tasks and defaults
- Assert (test-path $buildFile) ($msgs.error_build_file_not_found -f $buildFile)
+ 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
@@ -284,6 +302,7 @@ function Invoke-psake {
"originalDirectory" = get-location;
"originalErrorActionPreference" = $global:ErrorActionPreference;
"tasks" = @{};
+ "aliases" = @{};
"properties" = @();
"includes" = new-object System.Collections.Queue;
"config" = Create-ConfigurationForNewContext $buildFile $framework
@@ -328,8 +347,7 @@ function Invoke-psake {
}
}
- # N.B. The initial dot (.) indicates that variables initialized/modified
- # in the propertyBlock are available in the parent scope.
+ # The initial dot (.) indicates that variables initialized/modified in the propertyBlock are available in the parent scope.
foreach ($propertyBlock in $currentContext.properties) {
. $propertyBlock
}
@@ -351,11 +369,9 @@ function Invoke-psake {
throw $msgs.error_no_default_task
}
- $stopwatch.Stop()
-
Write-ColoredOutput ("`n" + $msgs.build_success + "`n") -foregroundcolor Green
- Write-TaskTimeSummary
+ Write-TaskTimeSummary $stopwatch.Elapsed
$psake.build_success = $true
} catch {
@@ -376,8 +392,8 @@ function Invoke-psake {
$psake.build_success = $false
if (!$psake.run_by_psake_build_tester) {
- #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
+ # 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 $_
@@ -389,7 +405,7 @@ function Invoke-psake {
} finally {
Cleanup-Environment
}
-} #Invoke-psake
+}
#-- Private Module Functions --#
function Write-ColoredOutput {
@@ -414,32 +430,15 @@ function Write-ColoredOutput {
}
function Load-Modules {
- $modules = $null
-
$currentConfig = $psake.context.peek().config
- if ($currentConfig.modules.autoload) {
- if ($currentConfig.modules.directory) {
- Assert (test-path $currentConfig.modules.directory) ($msgs.error_invalid_module_dir -f $currentConfig.modules.directory)
- $modules = get-item(join-path $currentConfig.modules.directory "*.psm1")
- }
- elseif (test-path (join-path $PSScriptRoot "modules")) {
- $modules = get-item (join-path (join-path $PSScriptRoot "modules") "*.psm1")
- }
- } else {
- if ($currentConfig.modules.module) {
- $modules = $currentConfig.modules.module | % {
- Assert (test-path $_.path) ($msgs.error_invalid_module_path -f $_.path);
- get-item $_.path
- }
- }
- }
-
- if ($modules) {
- $modules | % {
- "loading module: $_";
- $module = import-module $_ -passthru;
- if (!$module) {
- throw ($msgs.error_loading_module -f $_.Name)
+ if ($currentConfig.modules) {
+ $currentConfig.modules | foreach {
+ resolve-path $_ | foreach {
+ "Loading module: $_"
+ $module = import-module $_ -passthru
+ if (!$module) {
+ throw ($msgs.error_loading_module -f $_.Name)
+ }
}
}
""
@@ -453,7 +452,7 @@ function Load-Configuration {
$psakeConfigFilePath = (join-path $configdir "psake-config.ps1")
- if (test-path $psakeConfigFilePath) {
+ if (test-path $psakeConfigFilePath -pathType Leaf) {
try {
$config = Get-CurrentConfigurationOrDefault
. $psakeConfigFilePath
@@ -540,7 +539,7 @@ function Configure-BuildEnvironment {
'x64' {
$bitness = 'Framework64'
}
- $null {
+ { [string]::IsNullOrEmpty($_) } {
$ptrSize = [System.IntPtr]::Size
switch ($ptrSize) {
4 {
@@ -561,11 +560,11 @@ function Configure-BuildEnvironment {
}
$frameworkDirs = $versions | foreach { "$env:windir\Microsoft.NET\$bitness\$_\" }
- $frameworkDirs | foreach { Assert (test-path $_) ($msgs.error_no_framework_install_dir_found -f $_)}
+ $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
+ # 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"
}
@@ -579,7 +578,7 @@ function Cleanup-Environment {
}
}
-#borrowed from Jeffrey Snover http://blogs.msdn.com/powershell/archive/2006/12/07/resolve-error.aspx
+# borrowed from Jeffrey Snover http://blogs.msdn.com/powershell/archive/2006/12/07/resolve-error.aspx
function Resolve-Error($ErrorRecord = $Error[0]) {
$error_message = "`nErrorRecord:{0}ErrorRecord.InvocationInfo:{1}Exception:{2}"
$formatted_errorRecord = $ErrorRecord | format-list * -force | out-string
@@ -616,10 +615,10 @@ function Write-Documentation {
"Depends On" = $task.DependsOn -join ", "
Default = if ($defaultTaskDependencies -contains $task.Name) { $true }
}
- } | sort 'Name' | format-table -Auto -Property Name,Description,"Depends On",Default
+ } | sort 'Name' | format-table -autoSize -property Name,Description,"Depends On",Default
}
-function Write-TaskTimeSummary {
+function Write-TaskTimeSummary($invokePsakeDuration) {
"-" * 70
"Build Time Report"
"-" * 70
@@ -639,36 +638,37 @@ function Write-TaskTimeSummary {
[Array]::Reverse($list)
$list += new-object PSObject -property @{
Name = "Total:";
- Duration = $stopwatch.Elapsed
+ Duration = $invokePsakeDuration
}
- $list | format-table -auto -Property Name,Duration | out-string -stream | ? { $_ } #using "Out-String -Stream" to filter out the blank line that Format-Table prepends
+ # 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
- error_corrupt_callstack = CallStack 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_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_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_invalid_module_dir = Unable to load modules from directory: {0}
- error_invalid_module_path = Unable to load module at path: {0}
- 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
- postcondition_failed = Postcondition failed for {0}
- precondition_was_false = Precondition was false not executing {0}
- continue_on_error = Error in Task [{0}] {1}
+ 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!
'@
}
@@ -676,18 +676,16 @@ convertfrom-stringdata @'
import-localizeddata -bindingvariable msgs -erroraction silentlycontinue
$script:psake = @{}
-$psake.version = "4.00" # contains the current version of psake
+$psake.version = "4.1.0" # 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 = "3.5";
+ framework = "4.0";
taskNameFormat = "Executing {0}";
verboseError = $false;
coloredOutput = $true;
- modules = (new-object PSObject -property @{
- autoload = $false
- })
+ modules = $null;
} # 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
View
4 specs/duplicate_alias_should_fail.ps1
@@ -0,0 +1,4 @@
+task default
+task A -alias a {}
+task B -alias b {}
+task C -alias a {}
View
5 specs/task_with_alias_and_dependencies_should_pass.ps1
@@ -0,0 +1,5 @@
+task default -depends Task_With_Alias
+
+task Task_With_Alias -depends Task_Dependency -alias twa {}
+
+task Task_Dependency {}
View
3  specs/task_with_alias_should_pass.ps1
@@ -0,0 +1,3 @@
+task Task_With_Big_Descriptve_Name -alias twbdn {
+ "Doing stuff inside task with alias"
+}
View
10 specs/using_required_when_not_set_should_fail.ps1
@@ -0,0 +1,10 @@
+properties {
+ $x = $null
+ $y = $null
+ $z = $null
+}
+
+task default -depends TestProperties
+
+task TestProperties -requiredVariables z{
+}
View
9 specs/using_required_when_set_should_pass.ps1
@@ -0,0 +1,9 @@
+properties {
+ $x = $null
+ $y = $null
+}
+
+task default -depends TestRequired
+
+task TestRequired -requiredVariables x, y {
+}
View
2  specs/writing_psake_variables_should_pass.ps1
@@ -30,5 +30,5 @@ task Verify -description "This task verifies psake's variables" {
Assert ($config.taskNameFormat -eq "Executing {0}") '$psake.context.peek().config.taskNameFormat not equal to "Executing {0}"'
Assert (!$config.verboseError) '$psake.context.peek().config.verboseError should be $false'
Assert ($config.coloredOutput) '$psake.context.peek().config.coloredOutput should be $false'
- Assert ($config.modules) '$psake.context.peek().config.modules is $null'
+ Assert ($config.modules -eq $null) '$psake.context.peek().config.modules is not $null'
}

No commit comments for this range

Something went wrong with that request. Please try again.