Skip to content

Instantly share code, notes, and snippets.

@skalinets
Last active December 18, 2015 11:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skalinets/5775878 to your computer and use it in GitHub Desktop.
Save skalinets/5775878 to your computer and use it in GitHub Desktop.
my psake default.ps1 initial template
Framework "4.0"
# Framework "4.0x64"
properties {
$solutionDir = "..\src"
$buildConfiguration = 'RELEASE'
$packages = join-path $solutionDir "packages"
}
task default -depends run-unit-tests
function Get-Solutions (){
ls (join-path $solutionDir "*.sln") | %{ $_.FullName}
}
function Run-MsBuild ($a) {
Get-Solutions | %{ exec { msbuild $_ /NoLogo /m /p:Configuration=$buildConfiguration /v:m $a}}
}
function Restore-SolutionNugets() {
if (!(test-path $packages)) { mkdir $packages }
pushd $packages
exec {..\.nuget\nuget install ..\.nuget\packages.config}
popd
}
task clean {
Run-MsBuild '/t:Clean'
}
task compile -depends clean {
Restore-SolutionNugets
Run-MsBuild '/t:Build'
}
function testDlls($pattern) {
return ls "$SolutionDir\*\bin\$buildConfiguration" -rec `
| where { $_.Name.EndsWith(".dll") } `
| where { $_.Name.Contains("Tests") } `
| where { (Test-Path ((split-path $_.FullName) + $pattern)) -eq $True } `
| % { $_.FullName }
}
task run-unit-tests -depends compile -description "xUnit unit tests" {
$xunitDlls = testDlls "\xunit.dll"
$xunit = @(ls $solutionDir -Include "xunit.console.clr4.exe" -Recurse)[0].FullName
exec{ & $xunit $xunitDlls /noshadow }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment