forked from ISeeDEDPpl/Questor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path#Compile#.ps1
423 lines (395 loc) · 19.1 KB
/
#Compile#.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
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
$global:goodbuilds=0
$global:badbuilds=0
$settingsfileloc=".\CompileSettings.xml"
[xml]$compilelocsettings = Get-Content $settingsfileloc
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
#Region Functions
function compilesolution {
param (
$msBuildexEcutable,
$projectFolderName,
$projectSolutionName,
$msBuildOption
)
Write-Host "Staring to build project: " -NoNewline
Write-Host "[$($projectSolutionName)]" -ForegroundColor DarkYellow -BackgroundColor Black
$results=Invoke-Expression "$($msBuildexEcutable) .\$($projectFolderName)\$($projectSolutionName).csproj /p:configuration=$($msBuildOption) /target:Clean';'Build /flp:logfile="".\DebugLogs\$($projectSolutionName)Compile.log"""
if ($LastExitCode -eq 0) {
Write-Host "Build succeeded, 0 Error(s)" -ForegroundColor DarkGreen
write-Host "-----------------------------------------------------------------"
$global:goodbuilds++
}
else {
Write-Host "There were ERRORS while compiling project: " -ForegroundColor Red -NoNewline
Write-Host "[$($projectSolutionName)]" -NoNewline
Write-Host " check log for errors: " -ForegroundColor Red -NoNewline
Write-Host "[DebugLogs\$($projectSolutionName)Errors.log]" -ForegroundColor Yellow
write-Host "-----------------------------------------------------------------"
$global:badbuilds++
}
}
#endregion
#region Settings
#settings
$msbuild=$env:SystemRoot+"\Microsoft.Net\FrameWork\v4.0.30319\msbuild.exe"
$msbuildoption = "Debug"
if ($compilelocsettings.Settings.copyToLocation -ne $null) {
$innerspacedestdir=$compilelocsettings.Settings.copyToLocation
}
else
{
$innerspacedestdir=".NET Programs"
}
#endregion
Write-Host "+====================================================+"
Write-Host "| START |"
Write-Host "+====================================================+"
Write-Host ""
sleep 1
#region Prepare tasks
#Empty Output folder
Write-Host "Removing unnecessary files from .\output\ " -NoNewline
Remove-Item .\output\* -Recurse -Exclude "Caldari L4",*.xml,skillplan.txt
sleep -Milliseconds 300
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
sleep -Milliseconds 500
#empty bin folder
Write-Host "Removing unnecessary files from .\bin\debug\ and .\bin\release\ " -NoNewline
Remove-Item .\bin\debug\* -Recurse -ErrorAction SilentlyContinue -Force | Out-Null
Remove-Item .\bin\release\* -Recurse -ErrorAction SilentlyContinue -Force | Out-Null
sleep -Milliseconds 300
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
sleep -Milliseconds 500
#create DebugLogs folder - if there is one, we will force new one :) we are deleting results anyway :)
Write-Host "Create debug folder .\DebugLogs\ " -NoNewline
New-Item .\DebugLogs\ -Force -ItemType directory | Out-Null
Remove-Item .\DebugLogs\* -Recurse -ErrorAction SilentlyContinue -Force | Out-Null
sleep -Milliseconds 300
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
sleep -Milliseconds 500
#endregion
#maybe we can collect this from XML, but I don't see a way for now
Write-Host ""
Write-Host "Starting to compile" -NoNewline
sleep -Milliseconds 300
Write-Host "." -NoNewline; sleep -Milliseconds 300;Write-Host "." -NoNewline; sleep -Milliseconds 300; Write-Host ".";sleep -Milliseconds 300
Write-Host ""
write-Host "-----------------------------------------------------------------"
compilesolution -msbuildexecutable $msbuild -projectFolderName Questor.Modules -projectSolution Questor.Modules -msbuildoption $msbuildoption
compilesolution -msbuildexecutable $msbuild -projectFolderName Questor -projectSolution Questor -msbuildoption $msbuildoption
compilesolution -msbuildexecutable $msbuild -projectFolderName QuestorLoader -projectSolution QuestorLoader -msbuildoption $msbuildoption
compilesolution -msbuildexecutable $msbuild -projectFolderName ValueDump -projectSolution ValueDump -msbuildoption $msbuildoption
compilesolution -msbuildexecutable $msbuild -projectFolderName QuestorManager -projectSolution QuestorManager -msbuildoption $msbuildoption
compilesolution -msbuildexecutable $msbuild -projectFolderName BUYLPI -projectSolution BUYLPI -msbuildoption $msbuildoption
Write-Host "Copy files to output folder " -NoNewline
if ($msbuildoption -eq "Debug") {
Copy-Item .\bin\$msbuildoption\* -Include *.exe,*.dll,*.pdb -Destination .\output\
}
else {
Copy-Item .\bin\$msbuildoption\* -Include *.exe,*.dll -Destination .\output\
}
sleep -Milliseconds 300
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
sleep -Milliseconds 500
#Summary write-up
Write-Host ""
Write-Host "+====================================================+"
Write-Host "| SUMMARY |"
Write-Host "+====================================================+"
Write-Host "|" -NoNewline
if ($global:badbuilds -gt 0) {
Write-Host "We have encountered $($global:badbuilds) errors while building solutions, please check .\DebugLogs\ !!!" -BackgroundColor Black -ForegroundColor Red -NoNewline
Write-Host "|"
Write-Host "+====================================================+"
Write-Host ""
break
}
if ($global:goodbuilds -gt 0) {
Write-Host "We have successfully compiled $($global:goodbuilds) solutions!" -BackgroundColor Black -ForegroundColor DarkGreen -NoNewline
Write-Host " |"
Write-Host "+====================================================+"
Write-Host ""
}
if ($compilelocsettings.Settings.innerspaceLocation) {
$innerpath=$compilelocsettings.Settings.innerspaceLocation
}
else {
$regInner=Get-ItemProperty "hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\InnerSpace.exe" -ErrorAction SilentlyContinue
$innerpath = $regInner.Path
}
if ($compilelocsettings.Settings.unnattendedCopy -ne $True) {
Write-Host "Do you want files to be copied to production? [ $($innerpath) ]"
Write-Host "[" -ForegroundColor White -NoNewline
Write-Host "Y" -ForegroundColor Yellow -NoNewline
Write-Host "]" -ForegroundColor White -NoNewline
Write-Host "es - Normal Copy [*.dll, *.exe, *.pdb]"
Write-Host "[" -ForegroundColor White -NoNewline
Write-Host "N" -ForegroundColor Yellow -NoNewline
Write-Host "]" -ForegroundColor White -NoNewline
Write-Host "o - do not copy, "
Write-Host "[" -ForegroundColor White -NoNewline
Write-Host "Any key" -ForegroundColor Yellow -NoNewline
Write-Host "]" -ForegroundColor White -NoNewline
Write-Host " means no copy!"
$choice = Read-Host -Prompt "Please select one"
}
else {
Write-Host "You wanted unattended copy, so here we go" -ForegroundColor Yellow -NoNewline
sleep -Milliseconds 400
Write-Host "." -ForegroundColor Yellow -NoNewline; sleep -Milliseconds 400;Write-Host "." -ForegroundColor Yellow -NoNewline; sleep -Milliseconds 400; Write-Host "." -ForegroundColor Yellow;sleep -Milliseconds 400
Write-Host ""
$choice = "Yes"
}
if ($innerpath -eq $null) {
Write-Host "Could not read Innerspace location, please copy manually!!!" -ForegroundColor Red
$choice="N"
}
Write-Host "Found Innerspace path:" -NoNewline
Write-Host " [ " -ForegroundColor White -NoNewline
write-host "$($innerpath)" -NoNewline -ForegroundColor Yellow
Write-Host " ] " -ForegroundColor White -NoNewline
write-host "please check if it is ok?"
sleep 3
switch ($choice)
{
"Y" {
if ((Test-Path "$($innerpath)\$($innerspacedestdir)")-ne $true) {
Write-Host "Creating directory " -NoNewline
Write-Host "[" -NoNewline -ForegroundColor white
write-host "$($innerpath)\$($innerspacedestdir)" -NoNewline -ForegroundColor yellow
Write-Host "]" -NoNewline -ForegroundColor white
write-host "... " -NoNewline
mkdir "$($innerpath)\$($innerspacedestdir)" -Force | Out-Null
sleep -Milliseconds 500
Write-Host "[" -ForegroundColor yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor yellow
}
$iscopied = $false
$i=0
do {
try{
Write-Host "Copy *.exe to production ... " -NoNewline
Copy-Item .\output\*.exe -Destination "$($innerpath)\$($innerspacedestdir)" -Force
sleep -Milliseconds 300
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
$iscopied = $true
}
catch {
$OUTPUT= [System.Windows.Forms.MessageBox]::Show("Encountered problem while copying .exe, questor is probably running." , "Status" , 5)
if ($OUTPUT -eq "RETRY" ) { Write-Host "Retrying copy!!!" -ForegroundColor Yellow}
else {
Write-Host "Skipping copy!!!" -ForegroundColor Red
sleep -Seconds 2
break
}
}
} while ($iscopied -eq $false);
sleep -Milliseconds 500
$iscopied = $false
$i=0
do {
try{
Write-Host "Copy *.dll to production ... " -NoNewline
Copy-Item .\output\*.dll -Destination "$($innerpath)\$($innerspacedestdir)" -Force
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
$iscopied = $true
}
catch {
$OUTPUT= [System.Windows.Forms.MessageBox]::Show("Encountered problem while copying .dll, questor is probably running." , "Status" , 5)
if ($OUTPUT -eq "RETRY" ) { Write-Host "Retrying copy!!!" -ForegroundColor Yellow}
else {
Write-Host "Skipping copy!!!" -ForegroundColor Red
sleep -Seconds 2
break
}
}
} while ($iscopied -eq $false);
sleep -Milliseconds 500
$iscopied = $false
$i=0
do {
try{
Write-Host "Copy *.pdb to production ... " -NoNewline
Copy-Item .\output\*.pdb -Destination "$($innerpath)\$($innerspacedestdir)" -Force
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
$iscopied = $true
}
catch {
$OUTPUT= [System.Windows.Forms.MessageBox]::Show("Encountered problem while copying .pdb, questor is probably running." , "Status" , 5)
if ($OUTPUT -eq "RETRY" ) { Write-Host "Retrying copy!!!" -ForegroundColor Yellow}
else {
Write-Host "Skipping copy!!!" -ForegroundColor Red
sleep -Seconds 2
break
}
}
} while ($iscopied -eq $false);
sleep -Milliseconds 500
Write-Host "Copy missing *.xml files to production ... "
sleep -Milliseconds 500
Get-ChildItem .\output -Filter *.xml | % {
if (!(Test-Path "$($innerpath)\$($innerspacedestdir)\$($_.name)")){
Write-Host "Copying file " -NoNewline
Write-Host "[" -ForegroundColor white -NoNewline
write-host "$($_.name)" -NoNewline -ForegroundColor yellow
Write-Host "]" -ForegroundColor white -NoNewline
Write-Host "... " -NoNewline
Copy-Item .\output\$($_.name) -Destination "$($innerpath)\$($innerspacedestdir)"
sleep -Milliseconds 500
Write-Host "[" -ForegroundColor yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor yellow
}
else {
Write-Host "File " -NoNewline
Write-Host "[" -NoNewline -ForegroundColor white
write-host "$($_.name)" -NoNewline -ForegroundColor yellow
Write-Host "]" -NoNewline -ForegroundColor white
Write-Host " found, skipping ..."
}
}
}
"yes" {
if ((Test-Path "$($innerpath)\$($innerspacedestdir)")-ne $true) {
Write-Host "Creating directory " -NoNewline
Write-Host "[" -NoNewline -ForegroundColor white
write-host "$($innerpath)\$($innerspacedestdir)" -NoNewline -ForegroundColor yellow
Write-Host "]" -NoNewline -ForegroundColor white
write-host "... " -NoNewline
mkdir "$($innerpath)\$($innerspacedestdir)" -Force | Out-Null
sleep -Milliseconds 500
Write-Host "[" -ForegroundColor yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor yellow
}
$iscopied = $false
$i=0
do {
try{
Write-Host "Copy *.exe to production ... " -NoNewline
Copy-Item .\output\*.exe -Destination "$($innerpath)\$($innerspacedestdir)" -Force
sleep -Milliseconds 300
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
$iscopied = $true
}
catch {
$OUTPUT= [System.Windows.Forms.MessageBox]::Show("Encountered problem while copying .exe, questor is probably running." , "Status" , 5)
if ($OUTPUT -eq "RETRY" ) { Write-Host "Retrying copy!!!" -ForegroundColor Yellow}
else {
Write-Host "Skipping copy!!!" -ForegroundColor Red
sleep -Seconds 2
break
}
}
} while ($iscopied -eq $false);
sleep -Milliseconds 500
$iscopied = $false
$i=0
do {
try{
Write-Host "Copy *.dll to production ... " -NoNewline
Copy-Item .\output\*.dll -Destination "$($innerpath)\$($innerspacedestdir)" -Force
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
$iscopied = $true
}
catch {
$OUTPUT= [System.Windows.Forms.MessageBox]::Show("Encountered problem while copying .dll, questor is probably running." , "Status" , 5)
if ($OUTPUT -eq "RETRY" ) { Write-Host "Retrying copy!!!" -ForegroundColor Yellow}
else {
Write-Host "Skipping copy!!!" -ForegroundColor Red
sleep -Seconds 2
break
}
}
} while ($iscopied -eq $false);
sleep -Milliseconds 500
$iscopied = $false
$i=0
do {
try{
Write-Host "Copy *.pdb to prodcution ... " -NoNewline
Copy-Item .\output\*.pdb -Destination "$($innerpath)\$($innerspacedestdir)" -Force
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
$iscopied = $true
}
catch {
$OUTPUT= [System.Windows.Forms.MessageBox]::Show("Encountered problem while copying .pdb, questor is probably running." , "Status" , 5)
if ($OUTPUT -eq "RETRY" ) { Write-Host "Retrying copy!!!" -ForegroundColor Yellow}
else {
Write-Host "Skipping copy!!!" -ForegroundColor Red
sleep -Seconds 2
break
}
}
} while ($iscopied -eq $false);
sleep -Milliseconds 500
Write-Host "Copy missing *.xml files to prodcution ... "
sleep -Milliseconds 500
Get-ChildItem .\output -Filter *.xml | % {
if (!(Test-Path "$($innerpath)\$($innerspacedestdir)\$($_.name)")){
Write-Host "Copying file " -NoNewline
Write-Host "[" -ForegroundColor white -NoNewline
write-host "$($_.name)" -NoNewline -ForegroundColor yellow
Write-Host "]" -ForegroundColor white -NoNewline
Write-Host "... " -NoNewline
Copy-Item .\output\$($_.name) -Destination "$($innerpath)\$($innerspacedestdir)"
sleep -Milliseconds 500
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
}
else {
Write-Host "File " -NoNewline
Write-Host "[" -NoNewline -ForegroundColor white
write-host "$($_.name)" -NoNewline -ForegroundColor yellow
Write-Host "]" -NoNewline -ForegroundColor white
Write-Host " found, skipping ..."
}
}
}
"N" {
Write-Host "Skipping copy ... " -NoNewline
sleep -Milliseconds 500
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
}
"No" {
Write-Host "Skipping copy ... " -NoNewline
sleep -Milliseconds 500
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
}
default {
Write-Host "Skipping copy ... " -NoNewline
sleep -Milliseconds 500
Write-Host "[" -ForegroundColor Yellow -NoNewline
Write-Host " OK " -ForegroundColor Green -NoNewline
Write-Host "]" -ForegroundColor Yellow
}
}
Sleep 4
Write-Host "Bye!"
sleep 2