This repository has been archived by the owner on Jun 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
/
psiot.build.ps1
64 lines (53 loc) · 2.33 KB
/
psiot.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
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
function NeedsRestore($rootPath) {
# This checks to see if the number of folders under a given
# path (like "src" or "test") is greater than the number of
# obj\project.assets.json files found under that path, implying
# that those folders have not yet been restored.
$projectAssets = (Get-ChildItem "$rootPath\*\obj\project.assets.json")
return ($projectAssets -eq $null) -or ((Get-ChildItem $rootPath).Length -gt $projectAssets.Length)
}
task Restore -If { "Restore" -in $BuildTask -or (NeedsRestore(".\src")) } {
Push-Location $PSScriptRoot\src
exec { dotnet restore }
Pop-Location
}
task Clean Restore, {
Push-Location $PSScriptRoot\src
exec { dotnet clean }
Pop-Location
}
task Build Restore, {
Push-Location $PSScriptRoot\src
exec { dotnet build }
Pop-Location
}
task Test {
Install-Module Pester -Force -Scope CurrentUser
Push-Location $PSScriptRoot\test
$res = Invoke-Pester -OutputFormat NUnitXml -OutputFile TestsResults.xml -PassThru
if ($env:APPVEYOR) {
(New-Object System.Net.WebClient).UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\TestsResults.xml));
}
if ($res.FailedCount -gt 0) { throw "$($res.FailedCount) tests failed."}
Pop-Location
}
task Package Clean, Build, {
if ((Test-Path "$PSScriptRoot\out")) {
Remove-Item -Path $PSScriptRoot\out -Recurse -Force
}
Push-Location "$PSScriptRoot\src\Microsoft.PowerShell.IoT"
dotnet publish
Pop-Location
New-Item -ItemType directory -Path $PSScriptRoot\out
New-Item -ItemType directory -Path $PSScriptRoot\out\Microsoft.PowerShell.IoT
Copy-Item -Path "$PSScriptRoot\src\Microsoft.PowerShell.IoT\Microsoft.PowerShell.IoT.psd1" -Destination "$PSScriptRoot\out\Microsoft.PowerShell.IoT\" -Force
Copy-Item -Path "$PSScriptRoot\src\Microsoft.PowerShell.IoT\bin\Debug\netcoreapp2.0\publish\*" -Destination "$PSScriptRoot\out\Microsoft.PowerShell.IoT\" -Force -Recurse
if ($env:TF_BUILD) {
Import-Module "$PSScriptRoot\tools\vstsBuild.psm1"
Publish-VstsBuildArtifact -ArtifactPath "$PSScriptRoot\out\Microsoft.PowerShell.IoT" -Bucket "Microsoft.PowerShell.IoT"
}
}
# The default task is to run the entire CI build
task . Package