Skip to content

Instantly share code, notes, and snippets.

@JanDeDobbeleer
Last active April 7, 2016 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JanDeDobbeleer/6666614e351ffe479fba850777da7334 to your computer and use it in GitHub Desktop.
Save JanDeDobbeleer/6666614e351ffe479fba850777da7334 to your computer and use it in GitHub Desktop.
psake psakefile - Part II
#requires -Version 3
. '.\psakefile-tools.ps1'
Properties {
$solutionFileName = $null
$build_platform = $null
$configuration = $null
}
Task VerifyBuildProperties {
Assert ($solutionFileName -ne $null) 'Solution file name should not be null'
Assert ($build_platform -ne $null) 'Build platform should not be null'
Assert ($configuration -ne $null) 'Configuration should not be null'
}
Task VerifyTestProperties {
# used to test necessary properties before handling a task
# example:
# Assert ($build_platform -ne $null) "Build platform should not be null"
}
Task VerifyVersionProperties -Depends VerifyTestProperties {
# used to test necessary properties before handling a task
# example:
# Assert ($build_platform -ne $null) "Build platform should not be null"
}
# our default task, which is used if no task is specified
Task Default -Depends Build
Task CI -Depends Build, Test, Validate
Task CD -Depends Version, Build
Task Build -Depends VerifyBuildProperties, Clean, RestorePackages {
Write-Host -Object 'Building solution' -ForegroundColor DarkCyan
return Exec {
&('C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe') (Get-SolutionPath -solutionName $solutionFileName) /p:Configuration="$configuration" /p:Platform="$build_platform" /v:q
}
}
Task Clean {
Write-Host -Object 'Cleaning solution' -ForegroundColor DarkCyan
Exec {
&('C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe') (Get-SolutionPath -solutionName $solutionFileName) /p:Configuration="$configuration" /p:Platform="$build_platform" /v:q /t:Clean
}
}
Task Version -Depends VerifyVersionProperties {
# version your app
}
Task RestorePackages {
Write-Host -Object 'Start restoring Nuget packages' -ForegroundColor DarkCyan
$nuget_executable_file_path = $PSScriptRoot + '\NuGet.exe'
$nuget_config_file_path = $PSScriptRoot + '\NuGet.Config'
Exec {
&($nuget_executable_file_path) restore (Get-SolutionPath -solutionName $solutionFileName) -ConfigFile $nuget_config_file_path -NoCache -MSBuildVersion 14
}
}
Task Test -Depends VerifyTestProperties {
# executes unit tests
}
Task Validate {
# executes the WACK
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment