forked from OData/odata.net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
649 lines (569 loc) · 21.2 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
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
# Default to Debug
$Configuration = 'Debug'
# Color
$Success = 'Green'
$Warning = 'Yellow'
$Err = 'Red'
if (($args.Count -eq 0) -or ($args[0] -match 'Nightly'))
{
$TestType = 'Nightly'
$Configuration = 'Release'
}
elseif ($args[0] -match 'Quick' -or ($args[0] -match '-q'))
{
$TestType = "Quick"
}
elseif ($args[0] -match 'Rolling')
{
# Rolling is a legacy options - run all tests.
$TestType = "Nightly"
}
elseif ($args[0] -match 'E2E')
{
# Rolling is a legacy options - run all tests.
$TestType = "Nightly"
}
elseif ($args[0] -match 'DisableSkipStrongName')
{
$TestType = "DisableSkipStrongName"
}
elseif ($args[0] -match 'EnableSkipStrongName')
{
$TestType = "EnableSkipStrongName"
}
elseif ($args[0] -match 'SkipStrongName')
{
# SkipStrongName is a legacy options.
$TestType = "EnableSkipStrongName"
}
else
{
Write-Host 'Please choose Nightly Test or Quick Test!' -ForegroundColor $Err
exit
}
$Build = 'build'
if ($args -contains 'rebuild')
{
$Build = 'rebuild'
}
$PROGRAMFILESX86 = [Environment]::GetFolderPath("ProgramFilesX86")
$env:ENLISTMENT_ROOT = Split-Path -Parent $MyInvocation.MyCommand.Definition
$ENLISTMENT_ROOT = Split-Path -Parent $MyInvocation.MyCommand.Definition
$LOGDIR = $ENLISTMENT_ROOT + "\bin"
# Default to use Visual Studio 2019 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin
$VS14MSBUILD=$PROGRAMFILESX86 + "\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\MSBuild.exe"
$VSTEST = $PROGRAMFILESX86 + "\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"
$FXCOPDIR = $PROGRAMFILESX86 + "\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop"
$SN = $PROGRAMFILESX86 + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\sn.exe"
$SNx64 = $PROGRAMFILESX86 + "\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\sn.exe"
# Use Visual Studio 2017 compiler for .NET Core and .NET Standard. Because VS2017 has different paths for different
# versions, we have to check for each version. Meanwhile, the dotnet CLI is required to run the .NET Core unit tests in this script.
$VS15VERSIONS = "Enterprise",
"Professional",
"Community"
$VS15MSBUILD = $null
ForEach ($version in $VS15VERSIONS)
{
$tempMSBuildPath = ($PROGRAMFILESX86 + "\Microsoft Visual Studio\2017\{0}\MSBuild\15.0\Bin\MSBuild.exe") -f $version
if([System.IO.File]::Exists($tempMSBuildPath))
{
$VS15MSBUILD = $tempMSBuildPath
break
}
}
$DOTNETDIR = "C:\Program Files\dotnet\"
$DOTNETTEST = $null
if ([System.IO.File]::Exists($DOTNETDIR + "dotnet.exe"))
{
$DOTNETTEST = $DOTNETDIR + "dotnet.exe"
}
# Other variables
$FXCOP = $FXCOPDIR + "\FxCopCmd.exe"
$BUILDLOG = $LOGDIR + "\msbuild.log"
$TESTLOG = $LOGDIR + "\mstest.log"
$TESTDIR = $ENLISTMENT_ROOT + "\bin\AnyCPU\$Configuration\Test\Desktop\net452"
$TESTDIRE2E = $ENLISTMENT_ROOT + "\bin\AnyCPU\$Configuration\Test\Desktop\net45"
$NETCORETESTDIR = $ENLISTMENT_ROOT + "\bin\AnyCPU\$Configuration\Test\netcoreapp3.1"
$PRODUCTDIR = $ENLISTMENT_ROOT + "\bin\AnyCPU\$Configuration\Product\net45"
$NUGETEXE = $ENLISTMENT_ROOT + "\sln\.nuget\NuGet.exe"
$NUGETPACK = $ENLISTMENT_ROOT + "\sln\packages"
$XUNITADAPTER = "/TestAdapterPath:" + $NUGETPACK + "\xunit.runner.visualstudio.2.1.0\build\_common"
$ProductDlls = "Microsoft.OData.Client.dll",
"Microsoft.OData.Core.dll",
"Microsoft.OData.Edm.dll",
"Microsoft.OData.Service.Design.T4.dll",
"Microsoft.Spatial.dll"
$XUnitTestDlls = "Microsoft.OData.Core.Tests.dll",
"Microsoft.OData.Edm.Tests.dll",
"Microsoft.Spatial.Tests.dll",
"Microsoft.OData.Client.Tests.dll"
$NetCoreXUnitTestDlls = "Microsoft.OData.Core.Tests.dll",
"Microsoft.OData.Edm.Tests.dll",
"Microsoft.Spatial.Tests.dll"
$TestSupportDlls = "Microsoft.OData.Service.Design.T4.dll",
"Microsoft.OData.Service.dll",
"Microsoft.OData.Service.Test.Common.dll"
$NightlyTestDlls = "microsoft.test.data.services.ddbasics.dll",
"microsoft.odata.client.design.t4.unittests.dll",
"astoriaunittests.tddunittests.dll",
"edmlibtests.dll",
"microsoft.odata.client.tddunittests.dll",
"microsoft.test.taupo.odata.common.tests.dll",
"microsoft.test.taupo.odata.query.tests.dll",
"microsoft.test.taupo.odata.reader.tests.dll",
"microsoft.test.taupo.odata.writer.tests.dll",
"microsoft.test.taupo.odata.scenario.tests.dll",
"astoriaunittests.clientcsharp.dll",
"microsoft.data.namedstream.unittests.dll",
"microsoft.data.serverunittests1.unittests.dll",
"microsoft.data.serverunittests2.unittests.dll",
"regressionunittests.dll",
"microsoft.test.odata.pluggableformat.tests.dll",
"microsoft.data.metadataobjectmodel.unittests.dll",
"astoriaunittests.dll",
"astoriaclientunittests.dll"
# .NET Core tests are different and require the dotnet tool. The tool references the .csproj (VS2017) files instead of dlls
$NetCoreXUnitTestProjs = "\test\FunctionalTests\Microsoft.Spatial.Tests\Microsoft.Spatial.Tests.csproj",
"\test\FunctionalTests\Microsoft.OData.Edm.Tests\Microsoft.OData.Edm.Tests.csproj",
"\test\FunctionalTests\Microsoft.OData.Core.Tests\Microsoft.OData.Core.Tests.csproj",
"\test\FunctionalTests\Microsoft.OData.Client.Tests\Microsoft.OData.Client.Tests.csproj"
$NetCoreE2ETestProjs = "\test\FunctionalTests\Tests\DataServices\ddbasics\Microsoft.Test.Data.Services.DDBasics.csproj",
"\test\FunctionalTests\Tests\DataServices\UnitTests\TDDUnitTests\Microsoft.OData.Service.TDDUnitTests.csproj",
"\test\FunctionalTests\Tests\DataEdmLib\EdmLibTests.csproj",
"\test\FunctionalTests\Tests\DataOData\Tests\OData.Common.Tests\Microsoft.Test.Taupo.OData.Common.Tests.csproj",
"\test\FunctionalTests\Tests\DataOData\Tests\OData.Query.Tests\Microsoft.Test.Taupo.OData.Query.Tests.csproj",
"\test\FunctionalTests\Tests\DataOData\Tests\OData.Reader.Tests\Microsoft.Test.Taupo.OData.Reader.Tests.csproj",
"\test\FunctionalTests\Tests\DataOData\Tests\OData.Writer.Tests\Microsoft.Test.Taupo.OData.Writer.Tests.csproj",
"\test\FunctionalTests\Tests\DataOData\Tests\OData.Scenario.Tests\Microsoft.Test.Taupo.OData.Scenario.Tests.csproj",
"\test\FunctionalTests\Tests\DataServices\UnitTests\NamedStreamTests\Microsoft.Data.NamedStream.UnitTests.csproj",
"\test\FunctionalTests\Tests\DataOData\Tests\OData.PluggableFormat.Tests\Microsoft.Test.OData.PluggableFormat.Tests.csproj",
"\test\FunctionalTests\Tests\DataServices\UnitTests\ServerUnitTests1\Microsoft.Data.ServerUnitTests1.UnitTests.csproj",
"\test\FunctionalTests\Tests\DataServices\UnitTests\ServerUnitTests2\Microsoft.Data.ServerUnitTests2.UnitTests.csproj",
"\test\FunctionalTests\Tests\DataServices\UnitTests\RegressionUnitTests\Microsoft.Data.Web.RegressionUnitTests.csproj",
"\test\FunctionalTests\Tests\DataServices\UnitTests\MetadataObjectModelTests\Microsoft.Data.MetadataObjectModel.UnitTests.csproj",
"\test\FunctionalTests\Tests\DataServices\UnitTests\TDDUnitTests\Microsoft.OData.Service.TDDUnitTests.csproj",
"\test\FunctionalTests\Tests\DataServices\UnitTests\ClientCSharpUnitTests\Microsoft.Data.WebClientCSharp.UnitTests.csproj",
"\test\FunctionalTests\Tests\DataServices\UnitTests\ServerUnitTests\Microsoft.Data.Web.UnitTests.csproj"
$QuickTestSuite = @()
$NightlyTestSuite = @()
ForEach($dll in $XUnitTestDlls)
{
$QuickTestSuite += $TESTDIR + "\" + $dll
$NightlyTestSuite += $TESTDIR + "\" + $dll
}
ForEach($dll in $NightlyTestDlls)
{
$NightlyTestSuite += $TESTDIRE2E + "\" + $dll
}
$E2eTestDlls = @("Microsoft.Test.OData.Tests.Client.dll")
ForEach ($dll in $E2eTestDlls)
{
$NightlyTestSuite += $TESTDIRE2E + "\" + $dll
}
$FxCopRulesOptions = "/rule:$FxCopDir\Rules\DesignRules.dll",
"/rule:$FxCopDir\Rules\NamingRules.dll",
"/rule:$FxCopDir\Rules\PerformanceRules.dll",
"/rule:$FxCopDir\Rules\SecurityRules.dll",
"/rule:$FxCopDir\Rules\GlobalizationRules.dll",
"/dictionary:$ENLISTMENT_ROOT\src\CustomDictionary.xml",
"/ruleid:-Microsoft.Design#CA1006",
"/ruleid:-Microsoft.Design#CA1016",
"/ruleid:-Microsoft.Design#CA1020",
"/ruleid:-Microsoft.Design#CA1021",
"/ruleid:-Microsoft.Design#CA1045",
"/ruleid:-Microsoft.Design#CA2210",
"/ruleid:-Microsoft.Performance#CA1814"
$DataWebRulesOption = "/rule:$TESTDIR\DataWebRules.dll"
Function GetDlls
{
$dlls = @()
ForEach($dll in $ProductDlls)
{
$dlls += $PRODUCTDIR + "\" + $dll
}
ForEach($dll in $XUnitTestDlls)
{
$dlls += $TESTDIR + "\" + $dll
}
ForEach($dll in $NetCoreXUnitTestDlls)
{
$dlls += $NETCORETESTDIR + "\" + $dll
}
ForEach($dll in $TestSupportDlls)
{
$dlls += $TESTDIR + "\" + $dll
}
ForEach($dll in $NightlyTestDlls)
{
$dlls += $TESTDIR + "\" + $dll
}
ForEach($dll in $E2eTestDlls)
{
$dlls += $TESTDIR + "\" + $dll
}
return $dlls
}
Function SkipStrongName
{
$SnLog = $LOGDIR + "\SkipStrongName.log"
Out-File $SnLog
Write-Host 'Skip strong name validations for ODataLib assemblies...'
$dlls = GetDlls
ForEach ($dll in $dlls)
{
& $SN /Vr $dll | Out-File $SnLog -Append
}
ForEach ($dll in $dlls)
{
& $SNx64 /Vr $dll | Out-File $SnLog -Append
}
Write-Host "SkipStrongName Done" -ForegroundColor $Success
}
Function DisableSkipStrongName
{
$SnLog = $LOGDIR + "\DisableSkipStrongName.log"
Out-File $SnLog
Write-Host 'Disable skip strong name validations for ODataLib assemblies...'
$dlls = GetDlls
ForEach ($dll in $dlls)
{
& $SN /Vu $dll | Out-File $SnLog -Append
}
ForEach ($dll in $dlls)
{
& $SNx64 /Vu $dll | Out-File $SnLog -Append
}
Write-Host "DisableSkipStrongName Done" -ForegroundColor $Success
}
Function Cleanup
{
cd $ENLISTMENT_ROOT\tools\Scripts
Write-Host "Dropping stale databases..."
cscript "$ENLISTMENT_ROOT\tools\Scripts\artdbclean.js" //Nologo
cd $ENLISTMENT_ROOT
Write-Host "Clean Done" -ForegroundColor $Success
}
Function CleanBeforeScorch
{
Write-Host 'Stopping TaupoAstoriaRunner as it should no longer be running'
taskkill /F /IM "TaupoAstoriaRunner.exe" 1>$null 2>$null
Write-Host 'Stopping TaupoConsoleRunner as it should no longer be running'
taskkill /F /IM "TaupoConsoleRunner.exe" 1>$null 2>$null
Write-Host 'Stopping VSTest as it should no longer be running'
taskkill /F /IM "vstest.console.exe" 1>$null 2>$null
Write-Host 'Stopping MSbuild as it should no longer be running'
taskkill /F /IM "MSbuild.exe" 1>$null 2>$null
Write-Host 'Stopping code coverage gathering...'
taskkill /f /im VSPerfMon.exe 1>$null 2>$null
Write-Host 'Stopping WinHttpAutoProxySvc as it overflows due to large amount of web calls'
taskkill /F /FI "SERVICES eq WinHttpAutoProxySvc" >$null
net stop w3svc 1>$null 2>$null
Write-Host 'Minimize SQLExpress memory footprint'
net stop "SQL Server (SQLEXPRESS)" 1>$null 2>$null
net start "SQL Server (SQLEXPRESS)" 1>$null 2>$null
Write-Host "Clean Done" -ForegroundColor $Success
}
# Incremental build and rebuild
Function RunBuild ($sln, $vsToolVersion)
{
Write-Host "*** Building $sln ***"
$slnpath = $ENLISTMENT_ROOT + "\sln\$sln"
$Conf = "/p:Configuration=" + "$Configuration"
# Default to VS2015
$MSBUILD = $VS14MSBUILD
if($vsToolVersion -eq '15.0')
{
$MSBUILD=$VS15MSBUILD
}
& $MSBUILD $slnpath /t:$Build /m /nr:false /fl "/p:Platform=Any CPU" $Conf /p:Desktop=true `
/flp:LogFile=$LOGDIR/msbuild.log /flp:Verbosity=Normal 1>$null 2>$null
if($LASTEXITCODE -eq 0)
{
Write-Host "Build $sln SUCCESS" -ForegroundColor $Success
}
else
{
Write-Host "Build $sln FAILED" -ForegroundColor $Err
Write-Host "For more information, please open the following test result files:"
Write-Host "$LOGDIR\msbuild.log"
Cleanup
exit
}
}
Function FailedTestLog ($playlist , $reruncmd , $failedtest1 ,$failedtest2)
{
Write-Output "<Playlist Version=`"1.0`">" | Out-File $playlist
Write-Output "@echo off" | Out-File -Encoding ascii $reruncmd
Write-Output "cd $TESTDIR" | Out-File -Append -Encoding ascii $reruncmd
$rerun = "`"$VSTEST`""
if ($TestType -eq 'Nightly')
{
foreach ($dll in $NightlyTestSuite)
{
$rerun += " $dll"
}
}
else
{
foreach ($dll in $QuickTestSuite)
{
$rerun += " $dll"
}
}
if ($failedtest1.count -gt 0)
{
$rerun += " /Tests:"
}
foreach($case in $failedtest1)
{
$name = $case.split('.')[-1]
$rerun += $name + ","
$output = "<Add Test=`"" + $case + "`" />"
Write-Output $output | Out-File -Append $playlist
}
# build the command only if failed tests exist
if ($failedtest1.count -gt 0)
{
$rerun += " " + $XUNITADAPTER
Write-Output $rerun | Out-File -Append -Encoding ascii $reruncmd
}
$rerun = "`"$VSTEST`""
foreach ($dll in $E2eTestSuite)
{
$rerun += " $dll"
}
if ($failedtest2.count -gt 0)
{
$rerun += " /Tests:"
}
foreach($case in $failedtest2)
{
$name = $case.split('.')[-1]
$rerun += $name + ","
$output = "<Add Test=`"" + $case + "`" />"
Write-Output $output | Out-File -Append $playlist
}
# build the command only if failed tests exist
if ($failedtest2.count -gt 0)
{
Write-Output $rerun | Out-File -Append -Encoding ascii $reruncmd
}
Write-Output "cd $LOGDIR" | Out-File -Append -Encoding ascii $reruncmd
Write-Output "</Playlist>" | Out-File -Append $playlist
Write-Host "There are some test cases failed!" -ForegroundColor $Err
Write-Host "To replay failed tests, please open the following playlist file:" -ForegroundColor $Err
Write-Host $playlist -ForegroundColor $Err
Write-Host "To rerun failed tests, please run the following script:" -ForegroundColor $Err
Write-Host $reruncmd -ForegroundColor $Err
}
Function TestSummary
{
Write-Host 'Collecting test results'
$playlist = "$LOGDIR\FailedTests.playlist"
$reruncmd = "$LOGDIR\rerun.cmd"
if (Test-Path $playlist)
{
rm $playlist
}
if (Test-Path $reruncmd)
{
rm $reruncmd
}
$file = Get-Content -Path $TESTLOG
$pass = 0
$skipped = 0
$fail = 0
$trxfile = New-Object -TypeName System.Collections.ArrayList
$failedtest1 = New-Object -TypeName System.Collections.ArrayList
$failedtest2 = New-Object -TypeName System.Collections.ArrayList
$part = 1
foreach ($line in $file)
{
# Consolidate logic for retrieving number of passed and skipped tests. Failed tests is separate due to the way
# VSTest and DotNet (for .NET Core tests) report results differently.
if ($line -match "^Total tests: .*")
{
# The line is in this format:
# Total tests: 5735. Passed: 5735. Failed: 0. Skipped: 0.
# We want to extract the total passed and total skipped.
# Extract total passed by taking the substring between "Passed: " and "."
# The regex first extracts the string after the hardcoded "Passed: " (i.e. "#. Failed: #. Skipped: #.")
# Then we tokenize by "." and retrieve the first token which is the number for passed.
$pattern = "Passed: (.*)"
$extractedNumber = [regex]::match($line, $pattern).Groups[1].Value.Split(".")[0]
$pass += $extractedNumber
# Extract total skipped by taking the substring between "Skipped: " and "."
# The regex first extracts the string after the hardcoded "Skipped: " (i.e. "#.")
# Then we tokenize by "." and retrieve the first token which is the number for skipped.
$pattern = "Skipped: (.*)"
$extractedNumber = [regex]::match($line, $pattern).Groups[1].Value.Split(".")[0]
$skipped += $extractedNumber
}
elseif ($line -match "^Failed\s+(.*)")
{
$fail = $fail + 1
if ($part -eq 1)
{
[void]$failedtest1.Add($Matches[1])
}
else
{
[void]$failedtest2.Add($Matches[1])
}
}
elseif ($line -match "^Results file: (.*)")
{
[void]$trxfile.Add($Matches[1])
$part = 2
}
}
Write-Host "Test summary:" -ForegroundColor $Success
Write-Host "Passed :`t$pass" -ForegroundColor $Success
if ($skipped -ne 0)
{
Write-Host "Skipped:`t$skipped" -ForegroundColor $Warning
}
$color = $Success
if ($fail -ne 0)
{
$color = $Err
}
Write-Host "Failed :`t$fail" -ForegroundColor $color
Write-Host "---------------" -ForegroundColor $Success
Write-Host "Total :`t$($pass + $fail)" -ForegroundColor $Success
Write-Host "For more information, please open the following test result files:"
foreach ($trx in $trxfile)
{
Write-Host $trx
}
if ($fail -gt 0)
{
FailedTestLog -playlist $playlist -reruncmd $reruncmd -failedtest1 $failedtest1 -failedtest2 $failedtest2
}
else
{
Write-Host "Congratulation! All of the tests passed!" -ForegroundColor $Success
}
}
Function RunTest($title, $testdir, $framework)
{
Write-Host "**********Running $title***********"
if ($framework -eq 'dotnet')
{
foreach($testProj in $testdir)
{
Write-Host "Launching $testProj..."
& $DOTNETTEST "test" ($ENLISTMENT_ROOT + $testProj) "--no-build" >> $TESTLOG
}
}
else
{
& $VSTEST $testdir $XUNITADAPTER >> $TESTLOG
}
if($LASTEXITCODE -ne 0)
{
Write-Host "Run $title FAILED" -ForegroundColor $Err
}
}
Function BuildProcess
{
Write-Host '**********Start To Build The Project*********'
$script:BUILD_START_TIME = Get-Date
if (Test-Path $BUILDLOG)
{
rm $BUILDLOG
}
RunBuild ('OData.sln')
if ($TestType -ne 'Quick')
{
# OData.E2E.sln contains the product code for Net45 framework and a comprehensive list of test projects
RunBuild ('OData.E2E.sln')
# Solutions that contain .NET Core projects require VS2017 for full support. VS2015 supports only .NET Standard.
}
Write-Host "Build Done" -ForegroundColor $Success
$script:BUILD_END_TIME = Get-Date
}
Function TestProcess
{
Write-Host '**********Start To Run The Test*********'
if (Test-Path $TESTLOG)
{
rm $TESTLOG
}
$script:TEST_START_TIME = Get-Date
cd $TESTDIR
if ($TestType -eq 'Nightly')
{
RunTest -title 'NetCoreUnitTests' -testdir $NetCoreXUnitTestProjs -framework 'dotnet'
RunTest -title 'NetCoreE2ETests' -testdir $NetCoreE2ETestProjs -framework 'dotnet'
}
elseif ($TestType -eq 'Quick')
{
Write-Output "==Running Quick Test =="
RunTest -title 'NetCoreUnitTests' -testdir $NetCoreXUnitTestProjs -framework 'dotnet'
}
else
{
Write-Host 'Error : TestType' -ForegroundColor $Err
Cleanup
exit
}
if ($DOTNETTEST)
{
Write-Output "==Running Quick Test =="
RunTest -title 'NetCoreUnitTests' -testdir $NetCoreXUnitTestProjs -framework 'dotnet'
RunTest -title 'NetCoreE2ETests' -testdir $NetCoreE2ETestProjs -framework 'dotnet'
}
else
{
Write-Host 'The dotnet CLI must be installed to run any .NET Core tests.' -ForegroundColor $Warning
}
Write-Host "Test Done" -ForegroundColor $Success
TestSummary
$script:TEST_END_TIME = Get-Date
cd $ENLISTMENT_ROOT
}
Function FxCopProcess
{
Write-Host '**********Start To FxCop*********'
& $FXCOP "/f:$ProductDir\Microsoft.Spatial.dll" "/o:$LOGDIR\SpatialFxCopReport.xml" $DataWebRulesOption `
$FxCopRulesOptions 1>$null 2>$null
& $FXCOP "/f:$ProductDir\Microsoft.OData.Core.dll" "/o:$LOGDIR\CoreFxCopReport.xml" $FxCopRulesOptions 1>$null 2>$null
& $FXCOP "/f:$ProductDir\Microsoft.OData.Edm.dll" "/o:$LOGDIR\EdmFxCopReport.xml" $FxCopRulesOptions 1>$null 2>$null
& $FXCOP "/f:$ProductDir\Microsoft.OData.Client.dll" "/o:$LOGDIR\ClientFxCopReport.xml" $DataWebRulesOption `
$FxCopRulesOptions 1>$null 2>$null
Write-Host "For more information, please open the following test result files:"
Write-Host "$LOGDIR\SpatialFxCopReport.xml"
Write-Host "$LOGDIR\CoreFxCopReport.xml"
Write-Host "$LOGDIR\EdmFxCopReport.xml"
Write-Host "$LOGDIR\ClientFxCopReport.xml"
Write-Host "FxCop Done" -ForegroundColor $Success
}
# Main Process
if (! (Test-Path $LOGDIR))
{
mkdir $LOGDIR 1>$null
}
if ($TestType -eq 'EnableSkipStrongName')
{
CleanBeforeScorch
BuildProcess
SkipStrongName
Exit
}
elseif ($TestType -eq 'DisableSkipStrongName')
{
CleanBeforeScorch
BuildProcess
DisableSkipStrongName
Exit
}
CleanBeforeScorch
BuildProcess
SkipStrongName
TestProcess
Cleanup
$buildTime = New-TimeSpan $script:BUILD_START_TIME -end $script:BUILD_END_TIME
$testTime = New-TimeSpan $script:TEST_START_TIME -end $script:TEST_END_TIME
Write-Host("Build time:`t" + $buildTime)
Write-Host("Test time:`t" + $testTime)