Skip to content

Commit 5e211f8

Browse files
committed
Add a build
1 parent 1ed8c6f commit 5e211f8

15 files changed

+585
-287
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
output/

Build.build.ps1

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<#
2+
.SYNOPSIS
3+
./project.build.ps1
4+
.EXAMPLE
5+
Invoke-Build
6+
.NOTES
7+
0.5.0 - Parameterize
8+
Add parameters to this script to control the build
9+
#>
10+
[CmdletBinding()]
11+
param(
12+
# dotnet build configuration parameter (Debug or Release)
13+
[ValidateSet('Debug', 'Release')]
14+
[string]$Configuration = 'Release',
15+
16+
# Add the clean task before the default build
17+
[switch]$Clean,
18+
19+
# Collect code coverage when tests are run
20+
[switch]$CollectCoverage
21+
)
22+
$InformationPreference = "Continue"
23+
24+
$BuildTasks = "BuildTasks", "../BuildTasks", "../../BuildTasks" | Convert-Path -ErrorAction Ignore | Select-Object -First 1
25+
26+
## Self-contained build script - can be invoked directly or via Invoke-Build
27+
if ($MyInvocation.ScriptName -notlike '*Invoke-Build.ps1') {
28+
& "$BuildTasks/_Bootstrap.ps1"
29+
30+
Invoke-Build -File $MyInvocation.MyCommand.Path @PSBoundParameters -Result Result
31+
32+
if ($Result.Error) {
33+
$Error[-1].ScriptStackTrace | Out-String
34+
exit 1
35+
}
36+
exit 0
37+
}
38+
39+
## The first task defined is the default task
40+
if ($Clean) {
41+
Add-BuildTask . Clean, Test
42+
} else {
43+
Add-BuildTask . Test
44+
}
45+
46+
## Initialize the build variables, and import shared tasks, including DotNet tasks
47+
. "$BuildTasks/_Initialize.ps1" -PSModuleTasks

ErrorView.psm1

Lines changed: 0 additions & 285 deletions
This file was deleted.

build.psd1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@{
2+
ModuleManifest = ".\Source\ErrorView.psd1"
3+
CopyPaths = 'ErrorView.format.ps1xml'
4+
Prefix = 'prefix.ps1'
5+
# The rest of the paths are relative to the manifest
6+
OutputDirectory = ".."
7+
VersionedOutputDirectory = $true
8+
}

ErrorView.ps1xml renamed to source/ErrorView.format.ps1xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
<ExpressionBinding>
1818
<ScriptBlock>
1919
<![CDATA[
20-
if ($formatter = Get-Command "ConvertTo-$($global:ErrorView -replace "View")ErrorView" -ListImported -ErrorAction Ignore -ParameterName InputObject -ParameterType [System.Management.Automation.ErrorRecord]) {
21-
&@($formatter)[0] $_
20+
if ($formatter = @(Get-Command "ConvertTo-$($ErrorView -replace "View$")ErrorView" -ListImported -ErrorAction Ignore -ParameterName InputObject -ParameterType [System.Management.Automation.ErrorRecord])) {
21+
& ($formatter[0]) -InputObject $_
2222
} else {
2323
ConvertTo-NormalErrorView $_
2424
}
File renamed without changes.

source/prefix.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidGlobalVars', '', Justification = 'ErrorView is all about the ErrorView global variable')]
2+
param(
3+
$global:ErrorView = "Simple"
4+
)
5+
6+
# We need to _overwrite_ the ErrorView
7+
# So -PrependPath, instead of FormatsToProcess
8+
Update-FormatData -PrependPath $PSScriptRoot\ErrorView.format.ps1xml
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
filter ConvertTo-CategoryErrorView {
2+
<#
3+
.SYNOPSIS
4+
Converts an ErrorRecord to a CategoryInfo message string
5+
.DESCRIPTION
6+
The default PowerShell "CategoryView" ErrorView
7+
Copied directly from the PowerShellCore.format.ps1xml
8+
.LINK
9+
https://github.com/PowerShell/PowerShell/blob/c444645b0941d73dc769f0bba6ab70d317bd51a9/src/System.Management.Automation/FormatAndOutput/DefaultFormatters/PowerShellCore_format_ps1xml.cs#L1302
10+
#>
11+
[CmdletBinding()]
12+
param(
13+
# The ErrorRecord to display
14+
[Parameter(ValueFromPipeline)]
15+
[System.Management.Automation.ErrorRecord]
16+
$InputObject
17+
)
18+
$InputObject.CategoryInfo.GetMessage()
19+
}

0 commit comments

Comments
 (0)