@@ -29,14 +29,14 @@ function Write-PipelineTelemetryError {
29
29
[switch ]$AsOutput ,
30
30
[switch ]$Force )
31
31
32
- $PSBoundParameters.Remove (' Category' ) | Out-Null
32
+ $PSBoundParameters.Remove (' Category' ) | Out-Null
33
33
34
- if ($Force -Or ((Test-Path variable:ci) -And $ci )) {
35
- $Message = " (NETCORE_ENGINEERING_TELEMETRY=$Category ) $Message "
36
- }
37
- $PSBoundParameters.Remove (' Message' ) | Out-Null
38
- $PSBoundParameters.Add (' Message' , $Message )
39
- Write-PipelineTaskError @PSBoundParameters
34
+ if ($Force -Or ((Test-Path variable:ci) -And $ci )) {
35
+ $Message = " (NETCORE_ENGINEERING_TELEMETRY=$Category ) $Message "
36
+ }
37
+ $PSBoundParameters.Remove (' Message' ) | Out-Null
38
+ $PSBoundParameters.Add (' Message' , $Message )
39
+ Write-PipelineTaskError @PSBoundParameters
40
40
}
41
41
42
42
# Specify "-Force" to force pipeline formatted output even if "$ci" is false or not set
@@ -55,8 +55,8 @@ function Write-PipelineTaskError {
55
55
[switch ]$Force
56
56
)
57
57
58
- if (! $Force -And (-Not (Test-Path variable:ci) -Or ! $ci )) {
59
- if ($Type -eq ' error' ) {
58
+ if (! $Force -And (-Not (Test-Path variable:ci) -Or ! $ci )) {
59
+ if ($Type -eq ' error' ) {
60
60
Write-Host $Message - ForegroundColor Red
61
61
return
62
62
}
@@ -66,47 +66,61 @@ function Write-PipelineTaskError {
66
66
}
67
67
}
68
68
69
- if (($Type -ne ' error' ) -and ($Type -ne ' warning' )) {
69
+ if (($Type -ne ' error' ) -and ($Type -ne ' warning' )) {
70
70
Write-Host $Message
71
71
return
72
72
}
73
73
$PSBoundParameters.Remove (' Force' ) | Out-Null
74
- if (-not $PSBoundParameters.ContainsKey (' Type' )) {
74
+ if (-not $PSBoundParameters.ContainsKey (' Type' )) {
75
75
$PSBoundParameters.Add (' Type' , ' error' )
76
76
}
77
77
Write-LogIssue @PSBoundParameters
78
- }
78
+ }
79
79
80
- function Write-PipelineSetVariable {
80
+ function Write-PipelineSetVariable {
81
81
[CmdletBinding ()]
82
82
param (
83
- [Parameter (Mandatory = $true )]
84
- [string ]$Name ,
85
- [string ]$Value ,
86
- [switch ]$Secret ,
87
- [switch ]$AsOutput ,
88
- [bool ]$IsMultiJobVariable = $true )
89
-
90
- if ((Test-Path variable:ci) -And $ci ) {
83
+ [Parameter (Mandatory = $true )]
84
+ [string ]$Name ,
85
+ [string ]$Value ,
86
+ [switch ]$Secret ,
87
+ [switch ]$AsOutput ,
88
+ [bool ]$IsMultiJobVariable = $true )
89
+
90
+ if ((Test-Path variable:ci) -And $ci ) {
91
91
Write-LoggingCommand - Area ' task' - Event ' setvariable' - Data $Value - Properties @ {
92
- ' variable' = $Name
93
- ' isSecret' = $Secret
94
- ' isOutput' = $IsMultiJobVariable
92
+ ' variable' = $Name
93
+ ' isSecret' = $Secret
94
+ ' isOutput' = $IsMultiJobVariable
95
95
} - AsOutput:$AsOutput
96
- }
97
- }
96
+ }
97
+ }
98
98
99
- function Write-PipelinePrependPath {
99
+ function Write-PipelinePrependPath {
100
100
[CmdletBinding ()]
101
101
param (
102
- [Parameter (Mandatory = $true )]
103
- [string ]$Path ,
104
- [switch ]$AsOutput )
102
+ [Parameter (Mandatory = $true )]
103
+ [string ]$Path ,
104
+ [switch ]$AsOutput )
105
105
106
- if ((Test-Path variable:ci) -And $ci ) {
106
+ if ((Test-Path variable:ci) -And $ci ) {
107
107
Write-LoggingCommand - Area ' task' - Event ' prependpath' - Data $Path - AsOutput:$AsOutput
108
- }
109
- }
108
+ }
109
+ }
110
+
111
+ function Write-PipelineSetResult {
112
+ [CmdletBinding ()]
113
+ param (
114
+ [ValidateSet (" Succeeded" , " SucceededWithIssues" , " Failed" , " Cancelled" , " Skipped" )]
115
+ [Parameter (Mandatory = $true )]
116
+ [string ]$Result ,
117
+ [string ]$Message )
118
+ if ((Test-Path variable:ci) -And $ci ) {
119
+ Write-LoggingCommand - Area ' task' - Event ' complete' - Data $Message - Properties @ {
120
+ ' result' = $Result
121
+ }
122
+ }
123
+ }
110
124
111
125
<# #######################################
112
126
# Private functions.
@@ -123,7 +137,8 @@ function Format-LoggingCommandData {
123
137
foreach ($mapping in $script :loggingCommandEscapeMappings ) {
124
138
$Value = $Value.Replace ($mapping.Token , $mapping.Replacement )
125
139
}
126
- } else {
140
+ }
141
+ else {
127
142
for ($i = $script :loggingCommandEscapeMappings.Length - 1 ; $i -ge 0 ; $i -- ) {
128
143
$mapping = $script :loggingCommandEscapeMappings [$i ]
129
144
$Value = $Value.Replace ($mapping.Replacement , $mapping.Token )
@@ -156,7 +171,8 @@ function Format-LoggingCommand {
156
171
if ($first ) {
157
172
$null = $sb.Append (' ' )
158
173
$first = $false
159
- } else {
174
+ }
175
+ else {
160
176
$null = $sb.Append (' ;' )
161
177
}
162
178
@@ -193,7 +209,8 @@ function Write-LoggingCommand {
193
209
$command = Format-LoggingCommand - Area $Area - Event $Event - Data $Data - Properties $Properties
194
210
if ($AsOutput ) {
195
211
$command
196
- } else {
212
+ }
213
+ else {
197
214
Write-Host $command
198
215
}
199
216
}
@@ -212,12 +229,12 @@ function Write-LogIssue {
212
229
[switch ]$AsOutput )
213
230
214
231
$command = Format-LoggingCommand - Area ' task' - Event ' logissue' - Data $Message - Properties @ {
215
- ' type ' = $Type
216
- ' code ' = $ErrCode
217
- ' sourcepath' = $SourcePath
218
- ' linenumber' = $LineNumber
219
- ' columnnumber' = $ColumnNumber
220
- }
232
+ ' type ' = $Type
233
+ ' code ' = $ErrCode
234
+ ' sourcepath' = $SourcePath
235
+ ' linenumber' = $LineNumber
236
+ ' columnnumber' = $ColumnNumber
237
+ }
221
238
if ($AsOutput ) {
222
239
return $command
223
240
}
@@ -229,7 +246,8 @@ function Write-LogIssue {
229
246
$foregroundColor = [System.ConsoleColor ]::Red
230
247
$backgroundColor = [System.ConsoleColor ]::Black
231
248
}
232
- } else {
249
+ }
250
+ else {
233
251
$foregroundColor = $host.PrivateData.WarningForegroundColor
234
252
$backgroundColor = $host.PrivateData.WarningBackgroundColor
235
253
if ($foregroundColor -isnot [System.ConsoleColor ] -or $backgroundColor -isnot [System.ConsoleColor ]) {
0 commit comments