-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake.ps1
More file actions
141 lines (117 loc) · 3.38 KB
/
make.ps1
File metadata and controls
141 lines (117 loc) · 3.38 KB
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
131
132
133
134
135
136
137
138
139
140
param(
$buildType = "Release"
)
function clean{
# CLEAN
write-host "Cleaning" -foregroundcolor:blue
if(!(Test-Path "$basePath\BuildOutput\"))
{
mkdir "$basePath\BuildOutput\"
}
if(!(Test-Path "$logPath"))
{
mkdir "$logPath"
}
if(!(Test-Path "$basePath\TestOutput\"))
{
mkdir "$basePath\TestOutput\"
}
if(!(Test-Path "$basePath\releases\"))
{
mkdir "$basePath\releases\"
}
remove-item $basePath\BuildOutput\* -recurse
remove-item $basePath\TestOutput\* -recurse
remove-item $logPath\* -recurse
$lastResult = $true
}
function preBuild{
write-host "PreBuild" -foregroundcolor:blue
Try{
# Set assembly VERSION
Get-Content $basePath\src\$projectName\Properties\AssemblyInfo.Template.txt -ErrorAction stop |
Foreach-Object {$_ -replace "//{VERSION}", "[assembly: AssemblyVersion(""$buildVersion"")]"} |
Foreach-Object {$_ -replace "//{FILEVERSION}", "[assembly: AssemblyFileVersion(""$buildVersion"")]"} |
Set-Content $basePath\src\$projectName\Properties\AssemblyInfo.cs
}
Catch{
Write-host "PREBUILD FAILED!" -foregroundcolor:red
exit
}
}
function build{
preBuild
# BUILD
write-host "Building" -foregroundcolor:blue
$msbuild = "c:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe"
$solutionPath = "$basePath\src\$projectName.sln"
Invoke-expression "$msbuild $solutionPath /p:configuration=$buildType /t:Clean /t:Build /verbosity:q /nologo > $logPath\LogBuild.log"
if($? -eq $False){
Write-host "BUILD FAILED!"
exit
}
$content = (Get-Content -Path "$logPath\LogBuild.log")
$failedContent = ($content -match "error")
$failedCount = $failedContent.Count
if($failedCount -gt 0)
{
Write-host "BUILDING FAILED!" -foregroundcolor:red
$lastResult = $false
Foreach ($line in $content)
{
write-host $line -foregroundcolor:red
}
}
if($lastResult -eq $False){
exit
}
}
function nugetPublish{
# DEPLOYING
write-host "Publishing Nuget package" -foregroundcolor:blue
$outputName = ".\releases\$projectName.$fullBuildVersion.nupkg"
nuget push $outputName
}
function nugetPack{
# Packing
write-host "Packing" -foregroundcolor:blue
nuget pack .\src\$projectName\$projectName.csproj -OutputDirectory .\releases > $logPath\LogPacking.log
if($? -eq $False){
Write-host "PACK FAILED!" -foregroundcolor:red
exit
}
}
function zipOutput{
# ZIPPING
write-host "Zipping" -foregroundcolor:blue
$outputName = $projectName+"_V"+$buildVersion+"_BUILD.zip"
zip a -tzip .\releases\$outputName -r .\BuildOutput\*.* > $logPath\LogZipping.log
if($? -eq $False){
Write-host "Zipping FAILED!" -foregroundcolor:red
exit
}
}
$basePath = Get-Location
$logPath = "$basePath\logs"
$buildVersion = Get-Content .\VERSION
$fullBuildVersion = "$buildVersion.0"
$projectName = "locr"
if($buildType -eq "clean"){
clean
exit
}
if($buildType -eq "publish"){
$buildType = "Release"
clean
build
zipOutput
nugetPack
nugetPublish
exit
}
if($buildType -eq "debug"){
$buildType="Debug"
}
clean
build
Write-Host Finished -foregroundcolor:blue