-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.ps1
178 lines (153 loc) · 5.4 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
<#
.SYNOPSIS
Runs a .NET flavoured build process.
.DESCRIPTION
This script was scaffolded using a template from the Endjin.RecommendedPractices.Build PowerShell module.
It uses the InvokeBuild module to orchestrate an opinonated software build process for .NET solutions.
.EXAMPLE
PS C:\> ./build.ps1
Downloads any missing module dependencies (Endjin.RecommendedPractices.Build & InvokeBuild) and executes
the build process.
.PARAMETER Tasks
Optionally override the default task executed as the entry-point of the build.
.PARAMETER Configuration
The build configuration, defaults to 'Release'.
.PARAMETER BuildRepositoryUri
Optional URI that supports pulling MSBuild logic from a web endpoint (e.g. a GitHub blob).
.PARAMETER SourcesDir
The path where the source code to be built is located, defaults to the current working directory.
.PARAMETER CoverageDir
The output path for the test coverage data, if run.
.PARAMETER TestReportTypes
The test report format that should be generated by the test report generator, if run.
.PARAMETER PackagesDir
The output path for any packages produced as part of the build.
.PARAMETER LogLevel
The logging verbosity.
.PARAMETER Clean
When true, the .NET solution will be cleaned and all output/intermediate folders deleted.
.PARAMETER BuildModulePath
The path to import the Endjin.RecommendedPractices.Build module from. This is useful when
testing pre-release versions of the Endjin.RecommendedPractices.Build that are not yet
available in the PowerShell Gallery.
.PARAMETER BuildModuleVersion
The version of the Endjin.RecommendedPractices.Build module to import. This is useful when
testing pre-release versions of the Endjin.RecommendedPractices.Build that are not yet
available in the PowerShell Gallery.
.PARAMETER InvokeBuildModuleVersion
The version of the InvokeBuild module to be used.
#>
[CmdletBinding()]
param (
[Parameter(Position=0)]
[string[]] $Tasks = @("."),
[Parameter()]
[string] $Configuration = "Debug",
[Parameter()]
[string] $BuildRepositoryUri = "",
[Parameter()]
[string] $SourcesDir = $PWD,
[Parameter()]
[string] $CoverageDir = "_codeCoverage",
[Parameter()]
[string] $TestReportTypes = "Cobertura",
[Parameter()]
[string] $PackagesDir = "_packages",
[Parameter()]
[ValidateSet("minimal","normal","detailed")]
[string] $LogLevel = "minimal",
[Parameter()]
[switch] $Clean,
[Parameter()]
[string] $BuildModulePath,
[Parameter()]
[version] $BuildModuleVersion = "1.5.11",
[Parameter()]
[version] $InvokeBuildModuleVersion = "5.10.3"
)
$ErrorActionPreference = $ErrorActionPreference ? $ErrorActionPreference : 'Stop'
$InformationPreference = 'Continue'
$here = Split-Path -Parent $PSCommandPath
#region InvokeBuild setup
if (!(Get-Module -ListAvailable InvokeBuild)) {
Install-Module InvokeBuild -RequiredVersion $InvokeBuildModuleVersion -Scope CurrentUser -Force -Repository PSGallery
}
Import-Module InvokeBuild
# This handles calling the build engine when this file is run like a normal PowerShell script
# (i.e. avoids the need to have another script to setup the InvokeBuild environment and issue the 'Invoke-Build' command )
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
try {
Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundParameters
}
catch {
$_.ScriptStackTrace
throw
}
return
}
#endregion
#region Import shared tasks and initialise build framework
if (!($BuildModulePath)) {
if (!(Get-Module -ListAvailable Endjin.RecommendedPractices.Build | ? { $_.Version -eq $BuildModuleVersion })) {
Write-Information "Installing 'Endjin.RecommendedPractices.Build' module..."
Install-Module Endjin.RecommendedPractices.Build -RequiredVersion $BuildModuleVersion -Scope CurrentUser -Force -Repository PSGallery
}
$BuildModulePath = "Endjin.RecommendedPractices.Build"
}
else {
Write-Information "BuildModulePath: $BuildModulePath"
}
Import-Module $BuildModulePath -RequiredVersion $BuildModuleVersion -Force
# Load the build process & tasks
. Endjin.RecommendedPractices.Build.tasks
#endregion
#
# Build process control options
#
$SkipInit = $false
$SkipVersion = $false
$SkipBuild = $false
$CleanBuild = $Clean
$SkipTest = $false
$SkipTestReport = $false
$SkipAnalysis = $false
$SkipPackage = $false
$SkipPublish = $false
#
# Build process configuration
#
$SolutionToBuild = (Resolve-Path (Join-Path $here ".\Solutions\AzAppConfigToUserSecrets.sln")).Path
$ProjectsToPublish = @(
# "Solutions/MySolution/MyWebSite/MyWebSite.csproj"
)
$NuSpecFilesToPackage = @(
# "Solutions/MySolution/MyProject/MyProject.nuspec"
)
#
# Specify files to exclude from code coverage
# This option is for excluding generated code
# - Use file path or directory path with globbing (e.g dir1/*.cs)
# - Use single or multiple paths (separated by comma) (e.g. **/dir1/class1.cs,**/dir2/*.cs,**/dir3/**/*.cs)
#
$ExcludeFilesFromCodeCoverage = ""
# Synopsis: Build, Test and Package
task . FullBuild
# build extensibility tasks
task RunFirst {}
task PreInit {}
task PostInit {}
task PreVersion {}
task PostVersion {}
task PreBuild {}
task PostBuild {}
task PreTest {}
task PostTest {}
task PreTestReport {}
task PostTestReport {}
task PreAnalysis {}
task PostAnalysis {}
task PrePackage {}
task PostPackage {}
task PrePublish {}
task PostPublish {}
task RunLast {}