-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.ps1
56 lines (44 loc) · 1.56 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
#Requires -Version 7.0
using namespace System.IO
<#
Local build script to perform build and test validation
#>
param(
[ValidateSet('Debug', 'Release')]
[String]$Configuration = 'Debug',
[String]$ArtifactsPath = (Join-Path $PSScriptRoot '.artifacts'),
[Switch]$ServeDocs = $false,
[Switch]$Resources
)
. ([Path]::Combine($PSScriptRoot, 'build', 'scripts', 'Utils.ps1'))
$docsProject = [Path]::Combine($PSScriptRoot, 'src', 'SimpleVersion.Docs')
$ErrorActionPreference = 'Stop'
# Resources
if ($Resources) {
exec dotnet msbuild /t:ResourceGen
return
}
# Clean
Remove-Item $ArtifactsPath -Recurse -Force -ErrorAction Ignore
# Restore Tools
dotnet tool restore
# Version
$versionDetails = exec dotnet simpleversion
$version = ($versionDetails | ConvertFrom-Json).Formats.Semver2
if ($env:TF_BUILD) { Write-Output "##vso[build.updatebuildnumber]$version" }
# Default Args
$dotnetArgs = @('--configuration', $Configuration, "/p:Version=$version")
# Build
exec dotnet build $dotnetArgs
# Docs
exec dotnet publish $docsProject $dotnetArgs -o "${ArtifactsPath}/docs" /p:ServeDocs=$ServeDocs
if ($ServeDocs) {
return
}
# Test
$testArtifacts = Join-Path $ArtifactsPath 'tests'
exec dotnet test $dotnetArgs --results-directory $testArtifacts --no-build
exec dotnet reportgenerator "-reports:$(Join-Path $testArtifacts '**/*.cobertura.xml')" "-targetDir:$(Join-Path $testArtifacts 'CoverageReport')" "-reporttypes:HtmlInline_AzurePipelines"
# Pack
$distArtifacts = Join-Path $ArtifactsPath 'dist'
exec dotnet pack $dotnetArgs --output $distArtifacts --no-build