-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.ps1
76 lines (61 loc) · 2.47 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
param (
[string]$targetFrameworks = "all",
[string]$configuration = "FAKE_XRM_EASY_9",
[string]$packTests = ""
)
$localPackagesFolder = '../local-packages'
Write-Host "Checking if local packages folder '$($localPackagesFolder)' exists..."
$packagesFolderExists = Test-Path $localPackagesFolder -PathType Container
if(!($packagesFolderExists))
{
New-Item $localPackagesFolder -ItemType Directory
}
Write-Host "Deleting previous dependencies..." -ForegroundColor Yellow
$restoredPackagesFolder = './packages'
$restoredPackagesFolderExists = Test-Path $restoredPackagesFolder -PathType Container
if($restoredPackagesFolderExists)
{
Get-ChildItem -Path $restoredPackagesFolder -Include fakexrmeasy.* -Directory -Recurse -Force | Remove-Item -Recurse -Force
}
else
{
New-Item $restoredPackagesFolder -ItemType Directory
}
Write-Host " -> Cleaning..." -ForegroundColor Yellow
./clean.ps1 -folderPath "./src/FakeXrmEasy.CodeActivities/bin"
./clean.ps1 -folderPath "./src/FakeXrmEasy.CodeActivities/obj"
./clean.ps1 -folderPath "./tests/FakeXrmEasy.CodeActivities.Tests/bin"
./clean.ps1 -folderPath "./tests/FakeXrmEasy.CodeActivities.Tests/obj"
if($targetFrameworks -eq "all")
{
dotnet restore --no-cache --force --force-evaluate /p:Configuration=$configuration /p:PackTests=$packTests --packages $restoredPackagesFolder
}
else {
dotnet restore --no-cache --force --force-evaluate /p:Configuration=$configuration /p:PackTests=$packTests /p:TargetFrameworks=$targetFrameworks --packages $restoredPackagesFolder
}
if(!($LASTEXITCODE -eq 0)) {
throw "Error restoring packages"
}
if($targetFrameworks -eq "all")
{
dotnet build --configuration $configuration --no-restore /p:PackTests=$packTests
}
else
{
dotnet build --configuration $configuration --no-restore --framework $targetFrameworks /p:PackTests=$packTests
}
if(!($LASTEXITCODE -eq 0)) {
throw "Error during build step"
}
if($targetFrameworks -eq "all")
{
dotnet test --configuration $configuration --no-build --verbosity normal /p:PackTests=$packTests --collect:"XPlat code coverage" --settings tests/.runsettings --results-directory ./coverage
}
else
{
dotnet test --configuration $configuration --no-build --framework $targetFrameworks --verbosity normal /p:PackTests=$packTests --collect:"XPlat code coverage" --settings tests/.runsettings --results-directory ./coverage
}
if(!($LASTEXITCODE -eq 0)) {
throw "Error during test step"
}
Write-Host "*** Build Succeeded :) **** " -ForegroundColor Green