-Update build script to run tests against the final assemblies
-Update psake script to latest version
This commit is contained in:
+43
-26
@@ -38,42 +38,34 @@ task Build -depends Clean {
|
|||||||
foreach ($build in $builds)
|
foreach ($build in $builds)
|
||||||
{
|
{
|
||||||
$name = $build.Name
|
$name = $build.Name
|
||||||
|
$finalDir = $build.FinalDir
|
||||||
|
|
||||||
Write-Host -ForegroundColor Green "Building " $name
|
Write-Host -ForegroundColor Green "Building " $name
|
||||||
Write-Host
|
Write-Host
|
||||||
exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$signAssemblies" (GetConstants $build.Constants $signAssemblies) ".\Src\Newtonsoft.Json\$name.csproj" } "Error building $name"
|
exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release /p:OutputPath=bin\Release\$finalDir\ /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$signAssemblies" (GetConstants $build.Constants $signAssemblies) ".\Src\$name.sln" } "Error building $name"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
task Package -depends Build {
|
task Merge -depends Build {
|
||||||
$compileOutputDir = "$sourceDir\Newtonsoft.Json\bin\Release"
|
$binaryDir = "$sourceDir\Newtonsoft.Json\bin\Release\DotNet20"
|
||||||
|
MergeAssembly "$binaryDir\Newtonsoft.Json.Net20.dll" $signKeyPath "$binaryDir\LinqBridge.dll"
|
||||||
Copy-Item -Path $compileOutputDir -Destination $workingDir -recurse
|
del $binaryDir\LinqBridge.dll
|
||||||
|
|
||||||
New-Item -Path $workingDir\Merge -ItemType Directory
|
$binaryDir = "$sourceDir\Newtonsoft.Json.Tests\bin\Release\DotNet20"
|
||||||
|
MergeAssembly "$binaryDir\Newtonsoft.Json.Net20.dll" $signKeyPath "$binaryDir\LinqBridge.dll"
|
||||||
$ilMergeKeyFile = switch($signAssemblies) { $true { "/keyfile:$signKeyPath" } default { "" } }
|
MergeAssembly "$binaryDir\Newtonsoft.Json.Tests.Net20.dll" $signKeyPath "$binaryDir\LinqBridge.dll"
|
||||||
|
del $binaryDir\LinqBridge.dll
|
||||||
exec { .\Tools\ILMerge\ilmerge.exe "/internalize" $ilMergeKeyFile "/out:$workingDir\Merge\Newtonsoft.Json.Net20.dll" "$workingDir\Release\Newtonsoft.Json.Net20.dll" "$workingDir\Release\LinqBridge.dll" } "Error executing ILMerge"
|
}
|
||||||
|
|
||||||
del $workingDir\Release\Newtonsoft.Json.Net20.dll
|
|
||||||
del $workingDir\Release\Newtonsoft.Json.Net20.pdb
|
|
||||||
del $workingDir\Release\LinqBridge.dll
|
|
||||||
|
|
||||||
Copy-Item -Path $workingDir\Merge\Newtonsoft.Json.Net20.dll -Destination $workingDir\Release\
|
|
||||||
Copy-Item -Path $workingDir\Merge\Newtonsoft.Json.Net20.pdb -Destination $workingDir\Release\
|
|
||||||
|
|
||||||
|
task Package -depends Merge {
|
||||||
foreach ($build in $builds)
|
foreach ($build in $builds)
|
||||||
{
|
{
|
||||||
$name = $build.Name
|
$name = $build.TestsName
|
||||||
$finalDir = $build.FinalDir
|
$finalDir = $build.FinalDir
|
||||||
|
|
||||||
New-Item -Path $workingDir\Package\Bin\$finalDir -ItemType Directory
|
Copy-Item -Path "$sourceDir\Newtonsoft.Json\bin\Release\$finalDir" -Destination $workingDir\Package\Bin\$finalDir -recurse
|
||||||
dir $workingDir\Release | where { $_.Name -like "*$name*" -and $_.PSIsContainer -ne $true } | move -Destination $workingDir\Package\Bin\$finalDir\$_
|
|
||||||
}
|
}
|
||||||
|
|
||||||
del $workingDir\Merge -Recurse
|
|
||||||
del $workingDir\Release -Recurse
|
|
||||||
|
|
||||||
if ($buildDocumentation)
|
if ($buildDocumentation)
|
||||||
{
|
{
|
||||||
exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release .\Doc\doc.shfbproj } "Error building documentation. Check that you have Sandcastle, Sandcastle Help File Builder and HTML Help Workshop installed."
|
exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release .\Doc\doc.shfbproj } "Error building documentation. Check that you have Sandcastle, Sandcastle Help File Builder and HTML Help Workshop installed."
|
||||||
@@ -99,12 +91,37 @@ task Test -depends Deploy {
|
|||||||
foreach ($build in $builds)
|
foreach ($build in $builds)
|
||||||
{
|
{
|
||||||
$name = $build.TestsName
|
$name = $build.TestsName
|
||||||
Write-Host -ForegroundColor Green "Building " $name
|
$finalDir = $build.FinalDir
|
||||||
|
|
||||||
|
Write-Host -ForegroundColor Green "Copying test assembly $name to deployed directory"
|
||||||
Write-Host
|
Write-Host
|
||||||
exec { msbuild "/t:Clean;Rebuild" /p:Configuration=Release /p:AssemblyOriginatorKeyFile=$signKeyPath "/p:SignAssembly=$signAssemblies" (GetConstants $build.Constants $signAssemblies) ".\Src\Newtonsoft.Json.Tests\$name.csproj" } "Error executing MSBUILD"
|
robocopy ".\Src\Newtonsoft.Json.Tests\bin\Release\$finalDir" $workingDir\Deployed\Bin\$finalDir /NP /XO /XF LinqBridge.dll
|
||||||
|
|
||||||
|
Copy-Item -Path ".\Src\Newtonsoft.Json.Tests\bin\Release\$finalDir\$name.dll" -Destination $workingDir\Deployed\Bin\$finalDir\
|
||||||
|
|
||||||
Write-Host -ForegroundColor Green "Running tests " $name
|
Write-Host -ForegroundColor Green "Running tests " $name
|
||||||
Write-Host
|
Write-Host
|
||||||
exec { .\Tools\NUnit\nunit-console.exe ".\Src\Newtonsoft.Json.Tests\bin\Release\$name.dll" /xml:$workingDir\$name.xml } "Error running $name tests"
|
exec { .\Tools\NUnit\nunit-console.exe "$workingDir\Deployed\Bin\$finalDir\$name.dll" /xml:$workingDir\$name.xml } "Error running $name tests"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function MergeAssembly($dllPrimaryAssembly, $signKey, [string[]]$mergedAssemlies)
|
||||||
|
{
|
||||||
|
$mergeAssemblyPaths = [String]::Join(" ", $mergedAssemlies)
|
||||||
|
|
||||||
|
$primary = Get-Item $dllPrimaryAssembly
|
||||||
|
$mergedAssemblyName = $primary.Name
|
||||||
|
$temporaryDir = $primary.DirectoryName + "\" + [Guid]::NewGuid().ToString()
|
||||||
|
New-Item $temporaryDir -ItemType Directory
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
exec { .\Tools\ILMerge\ilmerge.exe "/internalize" $ilMergeKeyFile "/out:$temporaryDir\$mergedAssemblyName" $dllPrimaryAssembly $mergeAssemblyPaths } "Error executing ILMerge"
|
||||||
|
Copy-Item -Path $temporaryDir\$mergedAssemblyName -Destination $dllPrimaryAssembly -Force
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Remove-Item $temporaryDir -Recurse -Force
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -270,6 +270,11 @@
|
|||||||
<DependentUpon>LinqToSqlClasses.dbml</DependentUpon>
|
<DependentUpon>LinqToSqlClasses.dbml</DependentUpon>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="bunny_pancake.jpg">
|
||||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
Other similar extension points exist, see Microsoft.Common.targets.
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ namespace Newtonsoft.Json.Tests
|
|||||||
public void SerializeSizeData()
|
public void SerializeSizeData()
|
||||||
{
|
{
|
||||||
Image image = new Image();
|
Image image = new Image();
|
||||||
image.Data = System.IO.File.ReadAllBytes(@"..\..\bunny_pancake.jpg");
|
image.Data = System.IO.File.ReadAllBytes(@"bunny_pancake.jpg");
|
||||||
image.FileName = "bunny_pancake.jpg";
|
image.FileName = "bunny_pancake.jpg";
|
||||||
image.Author = "Hironori Akutagawa";
|
image.Author = "Hironori Akutagawa";
|
||||||
image.Caption = "I have no idea what you are talking about so here's a bunny with a pancake on its head";
|
image.Caption = "I have no idea what you are talking about so here's a bunny with a pancake on its head";
|
||||||
|
|||||||
+80
-61
@@ -21,24 +21,14 @@
|
|||||||
#Requires -Version 2.0
|
#Requires -Version 2.0
|
||||||
|
|
||||||
#-- Private Module Variables (Listed here for quick reference)
|
#-- Private Module Variables (Listed here for quick reference)
|
||||||
[string]$script:originalEnvPath
|
[system.collections.stack]$script:context
|
||||||
[string]$script:originalDirectory
|
|
||||||
[string]$script:formatTaskNameString
|
|
||||||
[string]$script:currentTaskName
|
|
||||||
[hashtable]$script:tasks
|
|
||||||
[array]$script:properties
|
|
||||||
[scriptblock]$script:taskSetupScriptBlock
|
|
||||||
[scriptblock]$script:taskTearDownScriptBlock
|
|
||||||
[system.collections.queue]$script:includes
|
|
||||||
[system.collections.stack]$script:executedTasks
|
|
||||||
[system.collections.stack]$script:callStack
|
|
||||||
|
|
||||||
#-- Public Module Variables -- The psake hashtable variable is initialized in the invoke-psake function
|
#-- Public Module Variables -- The psake hashtable variable is initialized in the invoke-psake function
|
||||||
$script:psake = @{}
|
$script:psake = @{}
|
||||||
$script:psake.use_exit_on_error = $false # determines if psake uses the "exit()" function when an exception occurs
|
$script:psake.use_exit_on_error = $false # determines if psake uses the "exit()" function when an exception occurs
|
||||||
$script:psake.log_error = $false # determines if the exception details are written to a file
|
$script:psake.log_error = $false # determines if the exception details are written to a file
|
||||||
$script:psake.build_success = $false # indicates that the current build was successful
|
$script:psake.build_success = $false # indicates that the current build was successful
|
||||||
$script:psake.version = "2.02" # contains the current version of psake
|
$script:psake.version = "2.02" # contains the current version of psake
|
||||||
$script:psake.build_script_file = $null # contains a System.IO.FileInfo for the current build file
|
$script:psake.build_script_file = $null # contains a System.IO.FileInfo for the current build file
|
||||||
$script:psake.framework_version = "" # contains the framework version # for the current build
|
$script:psake.framework_version = "" # contains the framework version # for the current build
|
||||||
|
|
||||||
@@ -53,18 +43,18 @@ function ExecuteTask
|
|||||||
|
|
||||||
$taskKey = $taskName.Tolower()
|
$taskKey = $taskName.Tolower()
|
||||||
|
|
||||||
Assert ($script:tasks.Contains($taskKey)) "task [$taskName] does not exist"
|
Assert ($script:context.Peek().tasks.Contains($taskKey)) "task [$taskName] does not exist"
|
||||||
|
|
||||||
if ($script:executedTasks.Contains($taskKey))
|
if ($script:context.Peek().executedTasks.Contains($taskKey))
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert (!$script:callStack.Contains($taskKey)) "Error: Circular reference found for task, $taskName"
|
Assert (!$script:context.Peek().callStack.Contains($taskKey)) "Error: Circular reference found for task, $taskName"
|
||||||
|
|
||||||
$script:callStack.Push($taskKey)
|
$script:context.Peek().callStack.Push($taskKey)
|
||||||
|
|
||||||
$task = $script:tasks.$taskKey
|
$task = $script:context.Peek().tasks.$taskKey
|
||||||
|
|
||||||
$taskName = $task.Name
|
$taskName = $task.Name
|
||||||
|
|
||||||
@@ -94,11 +84,11 @@ function ExecuteTask
|
|||||||
ExecuteTask $childTask
|
ExecuteTask $childTask
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:currentTaskName = $taskName
|
$script:context.Peek().currentTaskName = $taskName
|
||||||
|
|
||||||
if ($script:taskSetupScriptBlock -ne $null)
|
if ($script:context.Peek().taskSetupScriptBlock -ne $null)
|
||||||
{
|
{
|
||||||
& $script:taskSetupScriptBlock
|
& $script:context.Peek().taskSetupScriptBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($task.PreAction -ne $null)
|
if ($task.PreAction -ne $null)
|
||||||
@@ -106,7 +96,7 @@ function ExecuteTask
|
|||||||
& $task.PreAction
|
& $task.PreAction
|
||||||
}
|
}
|
||||||
|
|
||||||
$script:formatTaskNameString -f $taskName
|
$script:context.Peek().formatTaskNameString -f $taskName
|
||||||
& $task.Action
|
& $task.Action
|
||||||
|
|
||||||
if ($task.PostAction -ne $null)
|
if ($task.PostAction -ne $null)
|
||||||
@@ -114,9 +104,9 @@ function ExecuteTask
|
|||||||
& $task.PostAction
|
& $task.PostAction
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($script:taskTearDownScriptBlock -ne $null)
|
if ($script:context.Peek().taskTearDownScriptBlock -ne $null)
|
||||||
{
|
{
|
||||||
& $script:taskTearDownScriptBlock
|
& $script:context.Peek().taskTearDownScriptBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -126,7 +116,6 @@ function ExecuteTask
|
|||||||
"-"*70
|
"-"*70
|
||||||
"Error in Task [$taskName] $_"
|
"Error in Task [$taskName] $_"
|
||||||
"-"*70
|
"-"*70
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -159,11 +148,11 @@ function ExecuteTask
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$poppedTaskKey = $script:callStack.Pop()
|
$poppedTaskKey = $script:context.Peek().callStack.Pop()
|
||||||
|
|
||||||
Assert ($poppedTaskKey -eq $taskKey) "Error: CallStack was corrupt. Expected $taskKey, but got $poppedTaskKey."
|
Assert ($poppedTaskKey -eq $taskKey) "Error: CallStack was corrupt. Expected $taskKey, but got $poppedTaskKey."
|
||||||
|
|
||||||
$script:executedTasks.Push($taskKey)
|
$script:context.Peek().executedTasks.Push($taskKey)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Configure-BuildEnvironment
|
function Configure-BuildEnvironment
|
||||||
@@ -190,9 +179,9 @@ function Configure-BuildEnvironment
|
|||||||
|
|
||||||
function Cleanup-Environment
|
function Cleanup-Environment
|
||||||
{
|
{
|
||||||
$env:path = $script:originalEnvPath
|
$env:path = $script:context.Peek().originalEnvPath
|
||||||
Set-Location $script:originalDirectory
|
Set-Location $script:context.Peek().originalDirectory
|
||||||
$global:ErrorActionPreference = $originalErrorActionPreference
|
$global:ErrorActionPreference = $script:context.Peek().originalErrorActionPreference
|
||||||
}
|
}
|
||||||
|
|
||||||
#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
|
||||||
@@ -217,13 +206,13 @@ function Resolve-Error($ErrorRecord=$Error[0])
|
|||||||
function Write-Documentation
|
function Write-Documentation
|
||||||
{
|
{
|
||||||
$list = New-Object System.Collections.ArrayList
|
$list = New-Object System.Collections.ArrayList
|
||||||
foreach($key in $script:tasks.Keys)
|
foreach($key in $script:context.Peek().tasks.Keys)
|
||||||
{
|
{
|
||||||
if($key -eq "default")
|
if($key -eq "default")
|
||||||
{
|
{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
$task = $script:tasks.$key
|
$task = $script:context.Peek().tasks.$key
|
||||||
$content = "" | Select-Object Name, Description
|
$content = "" | Select-Object Name, Description
|
||||||
$content.Name = $task.Name
|
$content.Name = $task.Name
|
||||||
$content.Description = $task.Description
|
$content.Description = $task.Description
|
||||||
@@ -239,10 +228,10 @@ function Write-TaskTimeSummary
|
|||||||
"Build Time Report"
|
"Build Time Report"
|
||||||
"-"*70
|
"-"*70
|
||||||
$list = @()
|
$list = @()
|
||||||
while ($script:executedTasks.Count -gt 0)
|
while ($script:context.Peek().executedTasks.Count -gt 0)
|
||||||
{
|
{
|
||||||
$taskKey = $script:executedTasks.Pop()
|
$taskKey = $script:context.Peek().executedTasks.Pop()
|
||||||
$task = $script:tasks.$taskKey
|
$task = $script:context.Peek().tasks.$taskKey
|
||||||
if($taskKey -eq "default")
|
if($taskKey -eq "default")
|
||||||
{
|
{
|
||||||
continue
|
continue
|
||||||
@@ -524,9 +513,9 @@ Assert
|
|||||||
|
|
||||||
$taskKey = $name.ToLower()
|
$taskKey = $name.ToLower()
|
||||||
|
|
||||||
Assert (!$script:tasks.ContainsKey($taskKey)) "Error: Task, $name, has already been defined."
|
Assert (!$script:context.Peek().tasks.ContainsKey($taskKey)) "Error: Task, $name, has already been defined."
|
||||||
|
|
||||||
$script:tasks.$taskKey = $newTask
|
$script:context.Peek().tasks.$taskKey = $newTask
|
||||||
}
|
}
|
||||||
|
|
||||||
function Properties
|
function Properties
|
||||||
@@ -583,7 +572,7 @@ You can have more than 1 "Properties" function defined in the script
|
|||||||
[Parameter(Position=0,Mandatory=1)]
|
[Parameter(Position=0,Mandatory=1)]
|
||||||
[scriptblock]$properties
|
[scriptblock]$properties
|
||||||
)
|
)
|
||||||
$script:properties += $properties
|
$script:context.Peek().properties += $properties
|
||||||
}
|
}
|
||||||
|
|
||||||
function Include
|
function Include
|
||||||
@@ -640,7 +629,7 @@ You can have more than 1 "Include" function defined in the script
|
|||||||
[string]$fileNamePathToInclude
|
[string]$fileNamePathToInclude
|
||||||
)
|
)
|
||||||
Assert (test-path $fileNamePathToInclude) "Error: Unable to include $fileNamePathToInclude. File not found."
|
Assert (test-path $fileNamePathToInclude) "Error: Unable to include $fileNamePathToInclude. File not found."
|
||||||
$script:includes.Enqueue((Resolve-Path $fileNamePathToInclude));
|
$script:context.Peek().includes.Enqueue((Resolve-Path $fileNamePathToInclude));
|
||||||
}
|
}
|
||||||
|
|
||||||
function FormatTaskName
|
function FormatTaskName
|
||||||
@@ -712,7 +701,7 @@ Assert
|
|||||||
[Parameter(Position=0,Mandatory=1)]
|
[Parameter(Position=0,Mandatory=1)]
|
||||||
[string]$format
|
[string]$format
|
||||||
)
|
)
|
||||||
$script:formatTaskNameString = $format
|
$script:context.Peek().formatTaskNameString = $format
|
||||||
}
|
}
|
||||||
|
|
||||||
function TaskSetup
|
function TaskSetup
|
||||||
@@ -744,7 +733,7 @@ Task Clean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TaskSetup {
|
TaskSetup {
|
||||||
"Running 'TaskSetup' for task $script:currentTaskName"
|
"Running 'TaskSetup' for task $script:context.Peek().currentTaskName"
|
||||||
}
|
}
|
||||||
|
|
||||||
You should get the following output:
|
You should get the following output:
|
||||||
@@ -787,7 +776,7 @@ Assert
|
|||||||
[Parameter(Position=0,Mandatory=1)]
|
[Parameter(Position=0,Mandatory=1)]
|
||||||
[scriptblock]$setup
|
[scriptblock]$setup
|
||||||
)
|
)
|
||||||
$script:taskSetupScriptBlock = $setup
|
$script:context.Peek().taskSetupScriptBlock = $setup
|
||||||
}
|
}
|
||||||
|
|
||||||
function TaskTearDown
|
function TaskTearDown
|
||||||
@@ -819,7 +808,7 @@ Task Clean {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TaskTearDown {
|
TaskTearDown {
|
||||||
"Running 'TaskTearDown' for task $script:currentTaskName"
|
"Running 'TaskTearDown' for task $script:context.Peek().currentTaskName"
|
||||||
}
|
}
|
||||||
|
|
||||||
You should get the following output:
|
You should get the following output:
|
||||||
@@ -861,7 +850,7 @@ Assert
|
|||||||
param(
|
param(
|
||||||
[Parameter(Position=0,Mandatory=1)]
|
[Parameter(Position=0,Mandatory=1)]
|
||||||
[scriptblock]$teardown)
|
[scriptblock]$teardown)
|
||||||
$script:taskTearDownScriptBlock = $teardown
|
$script:context.Peek().taskTearDownScriptBlock = $teardown
|
||||||
}
|
}
|
||||||
|
|
||||||
function Invoke-psake
|
function Invoke-psake
|
||||||
@@ -886,6 +875,9 @@ Default = '3.5'
|
|||||||
|
|
||||||
.PARAMETER Docs
|
.PARAMETER Docs
|
||||||
Prints a list of tasks and their descriptions
|
Prints a list of tasks and their descriptions
|
||||||
|
|
||||||
|
.PARAMETER Parameters
|
||||||
|
A hashtable containing parameters to be passed into the current build script.
|
||||||
|
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
Invoke-psake
|
Invoke-psake
|
||||||
@@ -906,6 +898,11 @@ Runs the 'Tests' and 'Package' tasks in the '.build.ps1' build script
|
|||||||
Invoke-psake '.\build.ps1' -docs
|
Invoke-psake '.\build.ps1' -docs
|
||||||
|
|
||||||
Prints a report of all the tasks and their descriptions and exits
|
Prints a report of all the tasks and their descriptions and 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'
|
||||||
|
|
||||||
.OUTPUTS
|
.OUTPUTS
|
||||||
If there is an exception and '$psake.use_exit_on_error' -eq $true
|
If there is an exception and '$psake.use_exit_on_error' -eq $true
|
||||||
@@ -996,26 +993,35 @@ Assert
|
|||||||
[Parameter(Position=2,Mandatory=0)]
|
[Parameter(Position=2,Mandatory=0)]
|
||||||
[string]$framework = '3.5',
|
[string]$framework = '3.5',
|
||||||
[Parameter(Position=3,Mandatory=0)]
|
[Parameter(Position=3,Mandatory=0)]
|
||||||
[switch]$docs = $false
|
[switch]$docs = $false,
|
||||||
|
[Parameter(Position=4,Mandatory=0)]
|
||||||
|
[System.Collections.Hashtable]$parameters = @{}
|
||||||
)
|
)
|
||||||
|
|
||||||
Begin
|
Begin
|
||||||
{
|
{
|
||||||
$script:psake.build_success = $false
|
|
||||||
$script:psake.framework_version = $framework
|
|
||||||
|
|
||||||
$script:formatTaskNameString = "Executing task: {0}"
|
$script:psake.build_success = $false
|
||||||
$script:taskSetupScriptBlock = $null
|
$script:psake.framework_version = $framework
|
||||||
$script:taskTearDownScriptBlock = $null
|
|
||||||
$script:executedTasks = New-Object System.Collections.Stack
|
|
||||||
$script:callStack = New-Object System.Collections.Stack
|
|
||||||
$script:originalEnvPath = $env:path
|
|
||||||
$script:originalDirectory = Get-Location
|
|
||||||
$originalErrorActionPreference = $global:ErrorActionPreference
|
|
||||||
|
|
||||||
$script:tasks = @{}
|
if ($script:context -eq $null)
|
||||||
$script:properties = @()
|
{
|
||||||
$script:includes = New-Object System.Collections.Queue
|
$script:context = New-Object System.Collections.Stack
|
||||||
|
}
|
||||||
|
|
||||||
|
$script:context.push(@{
|
||||||
|
"formatTaskNameString" = "Executing task: {0}";
|
||||||
|
"taskSetupScriptBlock" = $null;
|
||||||
|
"taskTearDownScriptBlock" = $null;
|
||||||
|
"executedTasks" = New-Object System.Collections.Stack;
|
||||||
|
"callStack" = New-Object System.Collections.Stack;
|
||||||
|
"originalEnvPath" = $env:path;
|
||||||
|
"originalDirectory" = Get-Location;
|
||||||
|
"originalErrorActionPreference" = $global:ErrorActionPreference;
|
||||||
|
"tasks" = @{};
|
||||||
|
"properties" = @();
|
||||||
|
"includes" = New-Object System.Collections.Queue ;
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Process
|
Process
|
||||||
@@ -1042,15 +1048,27 @@ Assert
|
|||||||
|
|
||||||
# N.B. The initial dot (.) indicates that variables initialized/modified
|
# N.B. The initial dot (.) indicates that variables initialized/modified
|
||||||
# in the propertyBlock are available in the parent scope.
|
# in the propertyBlock are available in the parent scope.
|
||||||
while ($script:includes.Count -gt 0)
|
while ($script:context.Peek().includes.Count -gt 0)
|
||||||
{
|
{
|
||||||
$includeBlock = $script:includes.Dequeue()
|
$includeBlock = $script:context.Peek().includes.Dequeue()
|
||||||
. $includeBlock
|
. $includeBlock
|
||||||
}
|
}
|
||||||
foreach($propertyBlock in $script:properties)
|
foreach($propertyBlock in $script:context.Peek().properties)
|
||||||
{
|
{
|
||||||
. $propertyBlock
|
. $propertyBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach($key in $parameters.keys)
|
||||||
|
{
|
||||||
|
if (test-path "variable:\$key")
|
||||||
|
{
|
||||||
|
set-item -path "variable:\$key" -value $parameters.$key
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new-item -path "variable:\$key" -value $parameters.$key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Execute the list of tasks or the default task
|
# Execute the list of tasks or the default task
|
||||||
if($taskList.Length -ne 0)
|
if($taskList.Length -ne 0)
|
||||||
@@ -1060,7 +1078,7 @@ Assert
|
|||||||
ExecuteTask $task
|
ExecuteTask $task
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($script:tasks.default -ne $null)
|
elseif ($script:context.Peek().tasks.default -ne $null)
|
||||||
{
|
{
|
||||||
ExecuteTask default
|
ExecuteTask default
|
||||||
}
|
}
|
||||||
@@ -1108,6 +1126,7 @@ Assert
|
|||||||
{
|
{
|
||||||
# Clear out any global variables
|
# Clear out any global variables
|
||||||
Cleanup-Environment
|
Cleanup-Environment
|
||||||
|
[void]$script:context.Pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user