Load psake-config.ps1 from module directory when there is no one in configdir #55

Closed
wants to merge 30 commits into
from
Commits
+275 −111
Split
View
Binary file not shown.
@@ -1,27 +0,0 @@
-@echo on
-
-:: Assumes robocopy and nuget.exe both on the path
-
-SET DIR=%~dp0%
-SET DESTDIR=%DIR%bin
-
-IF EXIST %DESTDIR% goto deletebin
-
-goto prepare
-
-:deletebin
-rmdir /s /q %DESTDIR%
-if %ERRORLEVEL% NEQ 0 goto errors
-
-:prepare
-robocopy %DIR% %DESTDIR%\tools /E /B /NP /R:0 /W:0 /NJH /NJS /NS /NFL /NDL /XF ".git*" "Nuget*" "*.nupkg" /XD "%DIR%nuget" "%DIR%.git" "%DIR%bin"
-robocopy %DIR%nuget %DESTDIR% /E /B /NP /R:0 /W:0 /NJH /NJS /NS /NFL /NDL
-
-:build
-nuget pack %DESTDIR%\psake.nuspec
-if %ERRORLEVEL% NEQ 0 goto errors
-
-goto :eof
-
-:errors
-EXIT /B %ERRORLEVEL%
@@ -0,0 +1,13 @@
+# Assumes robocopy on the path
+
+$scriptpath = $MyInvocation.MyCommand.Path
+$dir = Split-Path $scriptpath
+$destDir = "$dir\bin"
+if(Test-Path $destDir -PathType container){
+ Remove-Item $destDir -Recurse -Force
+}
+
+robocopy $dir "$destDir\tools" /E /B /NP /R:0 /W:0 /NJH /NJS /NS /NFL /NDL /XF ".git*" "Nuget*" "*.nupkg" /XD "$dir\nuget" "$dir\.git" "$destDir" "$dir\nuget.exe"
+robocopy "$dir\nuget" $destDir /E /B /NP /R:0 /W:0 /NJH /NJS /NS /NFL /NDL
+
+.\nuget pack "$destDir\psake.nuspec"
@@ -51,4 +51,8 @@ Many thanks for contributions to psake are due (in alphabetical order):
* Staxmanade
* lanwin
* smbecker
-* stej
+* stej
+
+## License
+
+psake is released under the [MIT license](http://www.opensource.org/licenses/MIT).
View
@@ -0,0 +1,19 @@
+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.
View
@@ -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.2.0.1</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>
@@ -1,14 +1,19 @@
-$nugetPath = 'C:\NuGet'
-$nugetExePath = Join-Path $nuGetPath 'bin'
-$packageBatchFileName = Join-Path $nugetExePath "psake.bat"
+try {
+ $nugetPath = $env:ChocolateyInstall
+ $nugetExePath = Join-Path $nuGetPath 'bin'
+ $packageBatchFileName = Join-Path $nugetExePath "psake.bat"
-$psakeDir = (Split-Path -parent $MyInvocation.MyCommand.Definition)
-#$path = ($psakeDir | Split-Path | Join-Path -ChildPath 'psake.cmd')
-$path = Join-Path $psakeDir 'psake.cmd'
-Write-Host "Adding $packageBatchFileName and pointing to $path"
-"@echo off
-""$path"" %*" | Out-File $packageBatchFileName -encoding ASCII
+ $psakeDir = (Split-Path -parent $MyInvocation.MyCommand.Definition)
+ #$path = ($psakeDir | Split-Path | Join-Path -ChildPath 'psake.cmd')
+ $path = Join-Path $psakeDir '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 /?'"
-write-host "PSake is now ready. You can type 'psake' from any command line at any path. Get started by typing 'psake /?'"
-Start-Sleep 6
+ Write-ChocolateySuccess 'psake'
+} catch {
+ Write-ChocolateyFailure 'psake' "$($_.Exception.Message)"
+ throw
+}
@@ -40,8 +40,7 @@ function runBuilds()
{
$testResult = "" | select Name, Result
$testResult.Name = $buildFile.Name
-
- invoke-psake $buildFile.FullName -Parameters @{'p1'='v1'; 'p2'='v2'} -Properties @{'x'='1'; 'y'='2'} | Out-Null
+ invoke-psake $buildFile.FullName -Parameters @{'p1'='v1'; 'p2'='v2'} -Properties @{'x'='1'; 'y'='2'} -Initialization { if(!$container) { $container = @{}; } $container.bar = "bar"; $container.baz = "baz"; $bar = 2; $baz = 3 } | Out-Null
$testResult.Result = (getResult $buildFile.Name $psake.build_success)
$testResults += $testResult
if ($testResult.Result -eq "Passed")
View
@@ -3,7 +3,7 @@
Defaults
-------------------------------------------------------------------
$config.buildFileName="default.ps1"
-$config.framework = "3.5"
+$config.framework = "4.0"
$config.taskNameFormat="Executing {0}"
$config.verboseError=$false
$config.coloredOutput = $true
View
@@ -5,7 +5,7 @@ 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
+exit /B %errorlevel%
:help
powershell -NoProfile -ExecutionPolicy Bypass -Command "& '%~dp0\psake.ps1' -help"
View
@@ -18,13 +18,21 @@ param(
[Parameter(Position=5, Mandatory=0)]
[System.Collections.Hashtable]$properties = @{},
[Parameter(Position=6, Mandatory=0)]
- [switch]$nologo = $false,
+ [alias("init")]
+ [scriptblock]$initialization = {},
[Parameter(Position=7, Mandatory=0)]
- [switch]$help = $false,
+ [switch]$nologo = $false,
[Parameter(Position=8, Mandatory=0)]
+ [switch]$help = $false,
+ [Parameter(Position=9, Mandatory=0)]
[string]$scriptPath = $(Split-Path -parent $MyInvocation.MyCommand.path)
)
+$currentThread = [System.Threading.Thread]::CurrentThread
+$invariantCulture = [System.Globalization.CultureInfo]::InvariantCulture
+$currentThread.CurrentCulture = $invariantCulture
+$currentThread.CurrentUICulture = $invariantCulture
+
# '[p]sake' is the same as 'psake' but $Error is not polluted
remove-module [p]sake
import-module (join-path $scriptPath psake.psm1)
@@ -35,9 +43,9 @@ if ($help) {
if (-not(test-path $buildFile)) {
$absoluteBuildFile = (join-path $scriptPath $buildFile)
- if (test-path $absoluteBuildFile) {
+ if (test-path $absoluteBuildFile) {
$buildFile = $absoluteBuildFile
}
}
-invoke-psake $buildFile $taskList $framework $docs $parameters $properties $nologo
+invoke-psake $buildFile $taskList $framework $docs $parameters $properties $initialization $nologo
Oops, something went wrong.