forked from OctopusDeploy/OctoPack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
130 lines (107 loc) · 3.5 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
## This is the OctoPack build script, written in PSAKE. Run with
##
## Import-Module .\tools\psake\psake.psm1
## Invoke-psake .\build.ps1
##
Framework "4.0"
properties {
$build_number = "3.0.1-alpha"
$configuration = "Release"
$nuget_path = "tools\nuget.exe"
}
task default -depends VerifyProperties, Test, Package
task Clean {
write-host "Clean"
$directories = ".\build"
$directories | ForEach-Object {
Write-Output "Clean directory $_"
Remove-Item $_ -Force -Recurse -ErrorAction Ignore
New-Item -Path $_ -ItemType Directory -Force
}
}
task Versions {
write-host "Apply version stamp"
Generate-Assembly-Info `
-file "source\OctoPack.Tasks\Properties\AssemblyInfo.cs" `
-title "OctoPack Tasks $build_number" `
-description "MSBuild tasks for OctoPack" `
-company "Octopus Deploy Pty. Ltd." `
-product "OctoPack $build_number" `
-clsCompliant false `
-version $build_number `
-copyright "Octopus Deploy Pty. Ltd. 2011 - 2013"
}
task Build -depends Clean, Versions {
write-host "Build"
exec {
msbuild .\source\OctoPack.sln /p:Configuration=$configuration /t:Rebuild
}
}
task Test -depends Build {
write-host "Run unit tests"
}
task Package -depends Build {
write-host "Package"
mkdir .\build\content
mkdir .\build\content\net35
mkdir .\build\content\net40
mkdir .\build\content\netcore45
mkdir .\build\tools
dir -recurse .\source\OctoPack.Tasks\bin\$configuration | copy -destination build\tools -Force
dir -recurse .\source\tools | copy -destination build\tools -Force
Copy-Item .\source\OctoPack.nuspec .\build
Copy-Item .\license.txt .\build
$base = (resolve-path "build")
write-host $base
exec {
& $nuget_path pack build\OctoPack.nuspec -basepath $base -outputdirectory $base -version $build_number -NoPackageAnalysis
}
}
## Helpers
task VerifyProperties {
Assert (![string]::IsNullOrEmpty($build_number)) 'Property build_number was null or empty'
Write-Output "Build number: $build_number"
}
function Generate-Assembly-Info
{
param(
[string]$clsCompliant = "true",
[string]$title,
[string]$description,
[string]$company,
[string]$product,
[string]$copyright,
[string]$version,
[string]$file = $(throw "file is a required parameter.")
)
$asmInfo = "using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: CLSCompliantAttribute($clsCompliant )]
[assembly: ComVisibleAttribute(false)]
[assembly: AssemblyTitleAttribute(""$title"")]
[assembly: AssemblyDescriptionAttribute(""$description"")]
[assembly: AssemblyCompanyAttribute(""$company"")]
[assembly: AssemblyProductAttribute(""$product"")]
[assembly: AssemblyCopyrightAttribute(""$copyright"")]
[assembly: AssemblyVersionAttribute(""3.0.0.0"")]
[assembly: AssemblyInformationalVersionAttribute(""$version"")]
[assembly: AssemblyFileVersionAttribute(""3.0.0.0"")]
[assembly: AssemblyDelaySignAttribute(false)]
"
$dir = [System.IO.Path]::GetDirectoryName($file)
if ([System.IO.Directory]::Exists($dir) -eq $false)
{
Write-Host "Creating directory $dir"
[System.IO.Directory]::CreateDirectory($dir)
}
Write-Host "Generating assembly info file: $file"
Write-Output $asmInfo > $file
}
Import-Module .\tools\psake\teamcity.psm1
TaskSetup {
if ($env:TEAMCITY_VERSION) {
TeamCity-ReportBuildProgress "Running task $($psake.context.Peek().currentTaskName)"
}
}