Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgrade psake to use the package from NuGet. Now builds should run like:

.\build.ps1 - for the default task
.\build.ps1 Test - for a specific task called Test.
  • Loading branch information...
commit 31f9fad46a62124e6f1c4d9da45f1fe563f998e8 1 parent 015d1c8
@fitzchak fitzchak authored
View
1  .nuget/packages.config
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
+ <package id="psake" version="4.2.0.1" />
<package id="xunit.runners" version="1.9.1" />
</packages>
View
11 build.cmd
@@ -0,0 +1,11 @@
+@echo off
+
+if '%1'=='/?' goto help
+if '%1'=='-help' goto help
+if '%1'=='-h' goto help
+
+powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\build.ps1' %*; if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }"
+goto :eof
+
+:help
+powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\build.ps1' Help"
View
10 build.ps1
@@ -0,0 +1,10 @@
+param($task = "default")
+
+$scriptPath = $MyInvocation.MyCommand.Path
+$scriptDir = Split-Path $scriptPath
+
+get-module psake | remove-module
+
+import-module (Get-ChildItem "$scriptDir\packages\psake.*\tools\psake.psm1" | Select-Object -First 1)
+
+invoke-psake "$scriptDir\default.ps1" $task
View
0  psake_ext.ps1 → build_utils.ps1
File renamed without changes
View
34 default.ps1
@@ -1,3 +1,5 @@
+Include ".\build_utils.ps1"
+
properties {
$base_dir = resolve-path .
$lib_dir = "$base_dir\SharedLibs"
@@ -59,7 +61,6 @@ properties {
$test_prjs = @("Raven.Tests.dll","Raven.Client.VisualBasic.Tests.dll", "Raven.Bundles.Tests.dll" )
}
-include .\psake_ext.ps1
task default -depends Stable,Release
@@ -96,23 +97,6 @@ task Init -depends Verify40, Clean {
New-Item $build_dir -itemType directory -ErrorAction SilentlyContinue | Out-Null
}
-task BeforeCompile {
- $dat = "$base_dir\..\BuildsInfo\RavenDB\Settings.dat"
- $datDest = "$base_dir\Raven.Studio\Settings.dat"
- echo $dat
- if (Test-Path $dat) {
- Copy-Item $dat $datDest -force
- }
- ElseIf ((Test-Path $datDest) -eq $false) {
- New-Item $datDest -type file -force
- }
-}
-
-task AfterCompile {
- #new-item "$base_dir\Raven.Studio\Settings.dat" -type file -force
- remove-item "$build_dir\nlog.config" -force -ErrorAction SilentlyContinue
-}
-
task Compile -depends Init {
$v4_net_version = (ls "$env:windir\Microsoft.NET\Framework\v4.0*").Name
@@ -121,13 +105,23 @@ task Compile -depends Init {
exec { &"$build_dir\Raven.ProjectRewriter.exe" }
try {
- ExecuteTask("BeforeCompile")
+ $dat = "$base_dir\..\BuildsInfo\RavenDB\Settings.dat"
+ $datDest = "$base_dir\Raven.Studio\Settings.dat"
+ echo $dat
+ if (Test-Path $dat) {
+ Copy-Item $dat $datDest -force
+ }
+ ElseIf ((Test-Path $datDest) -eq $false) {
+ New-Item $datDest -type file -force
+ }
+
Write-Host "Compiling with '$global:configuration' configuration" -ForegroundColor Yellow
exec { &"C:\Windows\Microsoft.NET\Framework\$v4_net_version\MSBuild.exe" "$sln_file" /p:OutDir="$buildartifacts_dir\" /p:Configuration=$global:configuration }
} catch {
Throw
} finally {
- ExecuteTask("AfterCompile")
+ #new-item "$base_dir\Raven.Studio\Settings.dat" -type file -force
+ remove-item "$build_dir\nlog.config" -force -ErrorAction SilentlyContinue
}
}
View
313 psake.ps1
@@ -1,313 +0,0 @@
-# psake v0.22
-# Copyright © 2009 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.
-
-param(
- [string]$buildFile = 'default.ps1',
- [string[]]$taskList = @(),
- [string]$framework = '3.5',
- [switch]$debug = $false,
- [switch]$help = $false,
- [switch]$timing = $true,
- [switch]$docs = $false
-)
-
-
-
-if($help) {
-@"
-psake [buildFile] [tasks] [-framework ver] [-debug] [-timing] [-docs]
- where buildFile is the name of the build file, (default: default.ps1)
- tasks is a list of tasks to execute from the build file,
- ver is the .NET Framework version to target - 1.0, 1.1, 2.0, 3.0, or 3.5 (default)
- debug dumps information on the properties, includes, and tasks, as well as more detailed error information.
- timing prints a report showing how long each task took to execute
- docs prints a list of available tasks
-
-psake -help
- Displays this message.
-"@
- return
-}
-
-$global:tasks = @{}
-$global:properties = @()
-$global:includes = New-Object System.Collections.Queue
-$global:psake_version = "0.22"
-$global:psake_buildScript = $buildFile
-$global:psake_frameworkVersion = $framework
-
-$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
-
-function task([string]$name=$null, [scriptblock]$action = $null, [scriptblock]$precondition = $null, [scriptblock]$postcondition = $null, [switch]$continueOnError = $false, [string[]]$depends = @(), [string]$description = $null) {
- if (($name -eq $null) -or ($name.Trim() -eq "")) {
- throw "Error: Task must have a name"
- }
- if($name.ToLower() -eq 'default' -and $action -ne $null) {
- throw "Error: Default task cannot specify an action"
- }
- $newTask = @{
- Name = $name
- DependsOn = $depends
- Action = $action
- Precondition = $precondition
- Postcondition = $postcondition
- ContinueOnError = $continueOnError
- Description = $description
- }
- if($global:tasks.$name -ne $null) { throw "Error: Task, $name, has already been defined." }
- $global:tasks.$name = $newTask
-}
-
-function properties([scriptblock]$propertyBlock) {
- $global:properties += $propertyBlock
-}
-
-function include([string]$include){
- if (!(test-path $include)) { throw "Error: $include not found."}
- $global:includes.Enqueue((Resolve-Path $include));
-}
-
-function AssertNotCircular([string]$name) {
- if($script:callStack.Contains($name)) {
- throw "Error: Circular reference found for task, $name"
- }
-}
-
-function ExecuteTask([string]$name) {
- if($script:executedTasks.Contains($name)) { return }
- AssertNotCircular $name
- $script:callStack.Push($name)
-
- $task = $global:tasks.$name
- foreach($childTask in $task.DependsOn) {
- ExecuteTask $childTask
- }
- if($name -ne 'default') {
- $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
- $precondition = $true
- if($task.Precondition -ne $null) {
- $precondition = (& $task.Precondition)
- }
- "Executing task, $name..."
- if($task.Action -ne $null) {
- if($precondition) {
- trap {
- if ($task.ContinueOnError) {
- "-"*70
- "Error in Task [$name] $_"
- "-"*70
- continue
- } else {
- throw $_
- }
- }
- & $task.Action
- $postcondition = $true
- if($task.Postcondition -ne $null) {
- $postcondition = (& $task.Postcondition)
- }
- if (!$postcondition) {
- throw "Error: Postcondition failed for $name"
- }
- } else {
- "Precondition was false not executing $name"
- }
- }
- $stopwatch.stop()
- $task.Duration = $stopwatch.Elapsed
- }
-
- $poppedTask = $script:callStack.Pop()
- if($poppedTask -ne $name) {
- throw "Error: CallStack was corrupt. Expected $name, but got $poppedTask."
- }
- $script:executedTasks.Push($name)
-}
-
-function Dump-Tasks {
- 'Dumping tasks:'
- foreach($key in $global:tasks.Keys) {
- $task = $global:tasks.$key;
- $task.Name + " depends on " + $task.DependsOn.Length + " other tasks: " + $task.DependsOn;
- }
- "`n"
-}
-
-function Dump-Properties {
- 'Dumping properties:'
- $global:properties
-}
-
-function Dump-Includes {
- 'Dumping includes:'
- $global:includes
-}
-
-function Configure-BuildEnvironment {
- $version = $null
- switch ($framework) {
- '1.0' { $version = 'v1.0.3705' }
- '1.1' { $version = 'v1.1.4322' }
- '2.0' { $version = 'v2.0.50727' }
- '3.0' { $version = 'v2.0.50727' } # .NET 3.0 uses the .NET 2.0 compilers
- '3.5' { $version = 'v3.5' }
- default { throw "Error: Unknown .NET Framework version, $framework" }
- }
- $frameworkDir = "$env:windir\Microsoft.NET\Framework\$version\"
- if(!(test-path $frameworkDir)) {
- throw "Error: No .NET Framework installation directory found at $frameworkDir"
- }
- $env:path = "$frameworkDir;$env:path"
- $global:ErrorActionPreference = "Stop"
-}
-
-function Cleanup-Environment {
- $env:path = $script:originalEnvPath
- Set-Location $script:originalDirectory
- $global:ErrorActionPreference = $originalErrorActionPreference
- remove-variable tasks -scope "global"
- remove-variable properties -scope "global"
- remove-variable includes -scope "global"
- remove-variable psake_* -scope "global"
-}
-
-#borrowed from Jeffrey Snover http://blogs.msdn.com/powershell/archive/2006/12/07/resolve-error.aspx
-function Resolve-Error($ErrorRecord=$Error[0]) {
- $ErrorRecord | Format-List * -Force
- $ErrorRecord.InvocationInfo | Format-List *
- $Exception = $ErrorRecord.Exception
- for ($i = 0; $Exception; $i++, ($Exception = $Exception.InnerException)) {
- "$i" * 70
- $Exception | Format-List * -Force
- }
-}
-
-function Write-Documentation {
- $list = New-Object System.Collections.ArrayList
- foreach($key in $global:tasks.Keys) {
- if($key -eq "default") {
- continue;
- }
- $task = $global:tasks.$key;
- $content = "" | Select-Object Name, Description
- $content.Name = $task.Name
- $content.Description = $task.Description
- $index = $list.Add($content);
- }
-
- $list | Sort 'Name' | Format-Table -Auto
-}
-
-function exec([scriptblock]$command, [string]$errorMsg) {
- & $command
- if ($lastExitCode -ne 0) {
- throw $errorMsg
- }
-}
-
-function Run-Psake {
- trap {
- Cleanup-Environment
- Write-Host -foregroundcolor Red $_
- if($debug) {
- "-" * 80
- "An Error Occurred. See Error Details Below:"
- "-" * 80
- Resolve-Error
- "-" * 80
- }
- exit(1)
- }
-
- $stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
-
- # Execute the build file to set up the tasks and defaults
- if(test-path $buildFile) {
- $buildFile = resolve-path $buildFile
- set-location (split-path $buildFile)
- & $buildFile
- } else {
- throw "Error: Could not find the build file, $buildFile."
- }
-
- if($debug) {
- Dump-Includes
- Dump-Properties
- Dump-Tasks
- }
-
- Configure-BuildEnvironment
-
- # N.B. The initial dot (.) indicates that variables initialized/modified
- # in the propertyBlock are available in the parent scope.
- while ($global:includes.Count -gt 0) {
- $includeBlock = $global:includes.Dequeue();
- . $includeBlock;
- }
- foreach($propertyBlock in $global:properties) {
- . $propertyBlock
- }
-
- if($docs) {
- Write-Documentation
- Cleanup-Environment
- exit(0)
- }
-
- # Execute the list of tasks or the default task
- if($taskList.Length -ne 0) {
- foreach($task in $taskList) {
- ExecuteTask $task
- }
- } elseif ($global:tasks.default -ne $null) {
- ExecuteTask default
- } else {
- throw 'Error: default task required'
- }
-
- $stopwatch.Stop()
-
- if ($timing) {
- "-"*70
- "Build Time Report"
- "-"*70
- $list = @()
- while ($script:executedTasks.Count -gt 0) {
- $name = $script:executedTasks.Pop()
- $task = $global:tasks.$name
- if($name -eq "default") {
- continue;
- }
- $list += "" | Select-Object @{Name="Name";Expression={$name}}, @{Name="Duration";Expression={$task.Duration}}
- }
- [Array]::Reverse($list)
- $list += "" | Select-Object @{Name="Name";Expression={"Total:"}}, @{Name="Duration";Expression={$stopwatch.Elapsed}}
- $list | Format-Table -Auto | Out-String -Stream | ? {$_} # using "Out-String -Stream" to filter out the blank line that Format-Table prepends
- }
-
- # Clear out any global variables
- Cleanup-Environment
-}
-
-Run-Psake
Please sign in to comment.
Something went wrong with that request. Please try again.