-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathmake.ps1
More file actions
188 lines (161 loc) · 4.84 KB
/
make.ps1
File metadata and controls
188 lines (161 loc) · 4.84 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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
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
if((Test-Path "$basePath\TestResults\"))
{
remove-item $basePath\TestResults -recurse
}
remove-item $logPath\* -recurse
$lastResult = $true
}
function build{
# 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(!$LastExitCode -eq 0){
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
}
}
#vstest.console
function vstest{
# TESTING
write-host "Testing" -foregroundcolor:blue
$trxPath = "$basePath\TestOutput\AllTest.trx"
$resultFile="/resultsfile:$trxPath"
$testDLLs = get-childitem -path "$basePath\TestOutput\*.*" -include "*.Tests.dll"
#write-host "get-childitem -path $basePath\TestOutput\*.* -include *.Tests.dll"
#$arguments = "$testDLLs /Enablecodecoverage"
[Array]$arguments = "$testDLLs "
write-host $vstestPath $arguments
& $vstestPath $arguments > $logPath\LogTest.log
if(!$LastExitCode -eq 10){ # TURNED OFF!!!
Write-host "TESTING FAILED0!" -foregroundcolor:red
$lastResult = $false
}
$content = (Get-Content -Path "$logPath\LogTest.log")
$failedContent = ($content -match "Failed: 0")
$failedCount = $failedContent.Count
if($failedCount -ne 1)
{
Write-host "TESTING FAILED1!" -foregroundcolor:red
$lastResult = $false
}
Foreach ($line in $failedContent)
{
write-host $line -foregroundcolor:blue
}
$failedContent = ($content -match "Not Runnable")
$failedCount = $failedContent.Count
if($failedCount -gt 0)
{
Write-host "TESTING FAILED2!" -foregroundcolor:red
$lastResult = $false
}
Foreach ($line in $failedContent)
{
write-host $line -foregroundcolor:red
}
if($lastResult -eq $False){
exit
}
}
function document{
# DOCUMENTING
Write-Host "Documenting" -foregroundcolor:blue
Invoke-expression "./src/buildoutput/tdg.exe -i '.\src\templates\README.template.md' -o './README.md'"
if($? -eq $False){
Write-host "DOCUMENT FAILED!" -foregroundcolor:red
exit
}
Invoke-expression "./src/buildoutput/tdg.exe -i '.\src\templates\README.template.md' -o '.\src\buildoutput\README.txt'"
if($? -eq $False){
Write-host "DOCUMENT FAILED!" -foregroundcolor:red
exit
}
}
function pack{
# 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 createZip{
# DEPLOYING
write-host "Creating zip" -foregroundcolor:blue
$outputName = $projectName+"_V"+$fullBuildVersion+"_BUILD.zip"
zip a -tzip .\releases\$outputName -r .\src\BuildOutput\*.* >> $logPath\LogDeploy.log
}
function publish{
# DEPLOYING
write-host "Publishing Nuget package" -foregroundcolor:blue
$outputName = ".\releases\$projectName.$fullBuildVersion.nupkg"
nuget push $outputName
}
$basePath = Get-Location
$logPath = "$basePath\logs"
$buildVersion = Get-Content .\VERSION
$fullBuildVersion = "$buildVersion.0"
$projectName = "TestDataGenerator.Core"
$vstestPath = "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
if($buildType -eq "publish"){
$buildType="Release"
clean
build
vstest
pack
publish
exit
}
if($buildType -eq "clean"){
clean
exit
}
else {
clean
build
vstest
pack
}
Write-Host Finished -foregroundcolor:blue