forked from cosmo0/commandline
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
69 lines (56 loc) · 2.04 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Properties {
$apikey = $null # call nuget.bat with your Nuget API key as parameter
$BIN_PATH = ".\build"
$API_BIN_PATH = Join-Path $BIN_PATH "CommandLine\Release\CommandLine.dll"
$API_DOC_PATH = Join-Path $BIN_PATH "Help\docu"
$NUGET_EXE = ".\.nuget\nuget.exe"
$NUGET_OUTPUT = (Join-Path $BIN_PATH "nuget")
}
Framework "4.0x86"
FormatTaskName "-------- {0} --------"
task default -depends Cleanup-Binaries, Restore-Packages, Build-Solution, Generate-APIDoc
# TODO: update assembly infos from build server ; see https://gist.github.com/toddb/1133511
# cleans up the binaries output folder
task Cleanup-Binaries {
Write-Host "Removing $BIN_PATH"
if (Test-Path $BIN_PATH) {
Remove-Item $BIN_PATH -Force -Recurse
}
}
# restores nuget packages
task Restore-Packages {
Write-Host "Restoring NuGet packages"
& $NUGET_EXE restore CommandLine.sln
}
# builds the solution
task Build-Solution -depends Cleanup-Binaries, Restore-Packages {
Write-Host "Building solution"
Exec {
msbuild "CommandLine.sln" /t:Build /p:Configuration=Release /p:Platform="Any CPU" /p:Warnings=true /v:Normal /nologo /clp:WarningsOnly`;ErrorsOnly`;Summary`;PerformanceSummary
}
}
# generates the API documentation
task Generate-APIDoc -depends Build-Solution {
Write-Host "Generating API docs"
& ".\tools\docu\docu.exe" $API_BIN_PATH --output=$API_DOC_PATH
& ".\tools\doxygen\doxygen.exe" .\Doxyfile
}
# generates a Nuget package
task Generate-Package -depends Build-Solution {
if ($apikey -eq $null -or $apikey -eq "") {
throw New-Object [System.ArgumentException] "If you want to build a Nuget package, please provide your API key as the batch parameter"
} else {
Write-Host "Generating a Nuget package"
& $NUGET_EXE setApiKey $apikey
# Nuget doesn't create the output dir automatically...
if (-not (Test-Path $NUGET_OUTPUT)) {
mkdir $NUGET_OUTPUT | Out-Null
}
# Package the nuget
& $NUGET_EXE Pack ".\nuget\CommandLine.nuspec" -OutputDirectory $NUGET_OUTPUT
# Send the nuget
Get-ChildItem "$NUGET_OUTPUT\*.nupkg" | % {
& $NUGET_EXE Push $_
}
}
}