-
Notifications
You must be signed in to change notification settings - Fork 96
/
build.ps1
93 lines (73 loc) · 2.46 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
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "")]
[CmdletBinding(DefaultParameterSetName="build")]
param (
[Parameter(ParameterSetName="build")]
[switch]
$Clean,
[Parameter(ParameterSetName="build")]
[switch]
$Build,
[Parameter(ParameterSetName="publish")]
[switch]
$Publish,
[Parameter(ParameterSetName="publish")]
[switch]
$Signed,
[ValidateSet("Debug", "Release")]
[string] $BuildConfiguration = "Debug",
[ValidateSet("netstandard2.0", "net472")]
[string] $BuildFramework = "net472"
)
Import-Module -Name "$PSScriptRoot/buildtools.psd1" -Force
$config = Get-BuildConfiguration -ConfigPath $PSScriptRoot
$script:ModuleName = $config.ModuleName
$script:FormatFileName = $config.FormatFileName
$script:SrcPath = $config.SourcePath
$script:OutDirectory = $config.BuildOutputPath
$script:SignedDirectory = $config.SignedOutputPath
$script:TestPath = $config.TestPath
$script:ModuleRoot = $PSScriptRoot
$script:Culture = $config.Culture
$script:BuildConfiguration = $BuildConfiguration
$script:BuildFramework = $BuildFramework
if ($env:TF_BUILD) {
$vstsCommandString = "vso[task.setvariable variable=BUILD_OUTPUT_PATH]$OutDirectory"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
$vstsCommandString = "vso[task.setvariable variable=SIGNED_OUTPUT_PATH]$SignedDirectory"
Write-Host ("sending " + $vstsCommandString)
Write-Host "##$vstsCommandString"
}
. $PSScriptRoot/doBuild.ps1
if ($Clean) {
if (Test-Path $OutDirectory) {
Remove-Item -Path $OutDirectory -Force -Recurse -ErrorAction Stop -Verbose
}
if (Test-Path "${SrcPath}/code/bin")
{
Remove-Item -Path "${SrcPath}/code/bin" -Recurse -Force -ErrorAction Stop -Verbose
}
if (Test-Path "${SrcPath}/code/obj")
{
Remove-Item -Path "${SrcPath}/code/obj" -Recurse -Force -ErrorAction Stop -Verbose
}
}
if (-not (Test-Path $OutDirectory))
{
$script:OutModule = New-Item -ItemType Directory -Path (Join-Path $OutDirectory $ModuleName)
}
else
{
$script:OutModule = Join-Path $OutDirectory $ModuleName
}
if ($Build.IsPresent -or $PsCmdlet.ParameterSetName -eq "Build")
{
$sb = (Get-Item Function:DoBuild).ScriptBlock
Invoke-ModuleBuild -BuildScript $sb
}
if ($Publish.IsPresent)
{
Publish-ModulePackage -Signed:$Signed.IsPresent
}