Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,854 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* -crlf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
How to get started. | ||
|
||
- Download and extract the project | ||
- Open up a PowerShell V2 console window | ||
- CD into the directory where you extracted the project (where the psake.psm1 file is) | ||
> Import-Module .\psake.psm1 | ||
> Get-Help Invoke-psake -Full | ||
- this will show you help and examples of how to use psake | ||
|
||
|
||
> CD .\examples | ||
> Invoke-psake | ||
- This will execute the "default" task in the "default.ps1" | ||
> Invoke-psake .\default.ps1 Clean | ||
- will execute the single task in the default.ps1 script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
Properties { | ||
$x = 1 | ||
$y = 2 | ||
} | ||
|
||
FormatTaskName "[{0}]" | ||
|
||
Task default -Depends Verify | ||
|
||
Task Verify -Description "This task verifies psake's variables" { | ||
|
||
$assertions = @( | ||
((Test-Path 'variable:\psake'), "'psake' variable was not exported from module"), | ||
(($variable:psake.ContainsKey("build_success")), "psake variable does not contain 'build_success'"), | ||
(($variable:psake.ContainsKey("use_exit_on_error")), "psake variable does not contain 'use_exit_on_error'"), | ||
(($variable:psake.ContainsKey("log_error")), "psake variable does not contain 'log_error'"), | ||
(($variable:psake.ContainsKey("version")), "psake variable does not contain 'version'"), | ||
(($variable:psake.ContainsKey("build_script_file")), "psake variable does not contain 'build_script_file'"), | ||
(($variable:psake.ContainsKey("framework_version")), "psake variable does not contain 'framework_version'"), | ||
((!$variable:psake.build_success), 'psake.build_success should be $false'), | ||
((!$variable:psake.use_exit_on_error), 'psake.use_exit_on_error should be $false'), | ||
((!$variable:psake.log_error), 'psake.log_error should be $false'), | ||
((![string]::IsNullOrEmpty($variable:psake.version)), 'psake.version was null or empty'), | ||
(($variable:psake.build_script_file -ne $null), '$psake.build_script_file was null'), | ||
(($variable:psake.build_script_file.Name -eq "checkvariables.ps1"), ("psake variable: {0} was not equal to 'VerifyVariables.ps1'" -f $psake.build_script_file.Name)), | ||
((![string]::IsNullOrEmpty($variable:psake.framework_version)), 'psake variable: $psake.framework_version was null or empty'), | ||
(($variable:context.Peek().tasks.Count -ne 0), 'psake variable: $tasks had length zero'), | ||
(($variable:context.Peek().properties.Count -ne 0), 'psake variable: $properties had length zero'), | ||
(($variable:context.Peek().includes.Count -eq 0), 'psake variable: $includes should have had length zero'), | ||
(($variable:context.Peek().formatTaskNameString -eq "[{0}]"), 'psake variable: $formatTaskNameString was not set correctly'), | ||
(($variable:context.Peek().currentTaskName -eq "Verify"), 'psake variable: $currentTaskName was not set correctly') | ||
) | ||
|
||
foreach ($assertion in $assertions) | ||
{ | ||
Assert ( $assertion[0] ) $assertion[1] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
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' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
properties { | ||
$my_property = $p1 + $p2 | ||
} | ||
|
||
task default -depends TestParams | ||
|
||
task TestParams { | ||
Assert ($my_property -ne $null) '$my_property should not be null' | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/psake/examples/passingParametersString/build.Release.Version.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
powershell -Command "& {Import-Module .\..\..\psake.psm1; Invoke-psake .\parameters.ps1 -parameters @{"buildConfiguration"='Release';} }" | ||
|
||
Pause |
22 changes: 22 additions & 0 deletions
22
packages/psake/examples/passingParametersString/parameters.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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 "" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
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" | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
SakeBottle.jpg | ||
An American produced bottle of Ginjo Sake. | ||
Shawn Clark Lazyeights Photography http://lazyeights.net/cpg/displayimage.php?pos=-122 | ||
This work is licensed under the Creative Commons Attribution 2.5 License (http://creativecommons.org/licenses/by/2.5/). |
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
function runBuilds{ | ||
$buildFiles = ls specs\*.ps1 | ||
$testResults = @() | ||
|
||
#Add a fake build file to the $buildFiles array so that we can verify | ||
#that Invoke-psake fails | ||
$non_existant_buildfile = "" | select Name, FullName | ||
$non_existant_buildfile.Name = "specifying_a_non_existant_buildfile_should_fail.ps1" | ||
$non_existant_buildfile.FullName = "c:\specifying_a_non_existant_buildfile_should_fail.ps1" | ||
$buildFiles += $non_existant_buildfile | ||
|
||
foreach($buildFile in $buildFiles) { | ||
$testResult = "" | select Name, Result | ||
$testResult.Name = $buildFile.Name | ||
|
||
Invoke-psake $buildFile.FullName -Parameters @{'p1'='v1'; 'p2'='v2'} -Properties @{'x'='1'; 'y'='2'} | Out-Null | ||
$testResult.Result = (getResult $buildFile.Name $psake.build_success) | ||
$testResults += $testResult | ||
} | ||
|
||
return $testResults | ||
} | ||
|
||
function getResult([string]$fileName, [bool]$buildSucceeded) { | ||
$shouldSucceed = $null | ||
if ($fileName.EndsWith("_should_pass.ps1")) { | ||
$shouldSucceed = $true | ||
} elseif ($fileName.EndsWith("_should_fail.ps1")) { | ||
$shouldSucceed = $false | ||
} else { | ||
throw "Invalid specification syntax. Specs should end with _should_pass or _should_fail. $fileName" | ||
} | ||
if ($buildSucceeded -eq $shouldSucceed) { | ||
"Passed" | ||
} else { | ||
"Failed" | ||
} | ||
} | ||
|
||
Remove-Module psake -ea SilentlyContinue | ||
|
||
Import-Module .\psake.psm1 | ||
|
||
$results = runBuilds | ||
|
||
Remove-Module psake | ||
|
||
"" | ||
$results | Sort 'Name' | % { if ($_.Result -eq "Passed") { write-host ($_.Name + " (Passed)") -ForeGroundColor 'GREEN'} else { write-host ($_.Name + " (Failed)") -ForeGroundColor 'RED'}} | ||
"" | ||
|
||
$failed = $results | ? { $_.Result -eq "Failed" } | ||
if ($failed) { | ||
write-host "One or more of the build files failed" -ForeGroundColor 'RED' | ||
exit 1 | ||
} else { | ||
write-host "All Builds Passed" -ForeGroundColor 'GREEN' | ||
exit 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Helper script for those who want to run | ||
# psake without importing the module. | ||
import-module .\psake.psm1 | ||
invoke-psake @args | ||
remove-module psake |
Oops, something went wrong.