@@ -29,14 +29,14 @@ function Write-PipelineTelemetryError {
2929 [switch ]$AsOutput ,
3030 [switch ]$Force )
3131
32- $PSBoundParameters.Remove (' Category' ) | Out-Null
32+ $PSBoundParameters.Remove (' Category' ) | Out-Null
3333
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
4040}
4141
4242# Specify "-Force" to force pipeline formatted output even if "$ci" is false or not set
@@ -55,8 +55,8 @@ function Write-PipelineTaskError {
5555 [switch ]$Force
5656 )
5757
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' ) {
6060 Write-Host $Message - ForegroundColor Red
6161 return
6262 }
@@ -66,47 +66,61 @@ function Write-PipelineTaskError {
6666 }
6767 }
6868
69- if (($Type -ne ' error' ) -and ($Type -ne ' warning' )) {
69+ if (($Type -ne ' error' ) -and ($Type -ne ' warning' )) {
7070 Write-Host $Message
7171 return
7272 }
7373 $PSBoundParameters.Remove (' Force' ) | Out-Null
74- if (-not $PSBoundParameters.ContainsKey (' Type' )) {
74+ if (-not $PSBoundParameters.ContainsKey (' Type' )) {
7575 $PSBoundParameters.Add (' Type' , ' error' )
7676 }
7777 Write-LogIssue @PSBoundParameters
78- }
78+ }
7979
80- function Write-PipelineSetVariable {
80+ function Write-PipelineSetVariable {
8181 [CmdletBinding ()]
8282 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 ) {
9191 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
9595 } - AsOutput:$AsOutput
96- }
97- }
96+ }
97+ }
9898
99- function Write-PipelinePrependPath {
99+ function Write-PipelinePrependPath {
100100 [CmdletBinding ()]
101101 param (
102- [Parameter (Mandatory = $true )]
103- [string ]$Path ,
104- [switch ]$AsOutput )
102+ [Parameter (Mandatory = $true )]
103+ [string ]$Path ,
104+ [switch ]$AsOutput )
105105
106- if ((Test-Path variable:ci) -And $ci ) {
106+ if ((Test-Path variable:ci) -And $ci ) {
107107 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+ }
110124
111125<# #######################################
112126# Private functions.
@@ -123,7 +137,8 @@ function Format-LoggingCommandData {
123137 foreach ($mapping in $script :loggingCommandEscapeMappings ) {
124138 $Value = $Value.Replace ($mapping.Token , $mapping.Replacement )
125139 }
126- } else {
140+ }
141+ else {
127142 for ($i = $script :loggingCommandEscapeMappings.Length - 1 ; $i -ge 0 ; $i -- ) {
128143 $mapping = $script :loggingCommandEscapeMappings [$i ]
129144 $Value = $Value.Replace ($mapping.Replacement , $mapping.Token )
@@ -156,7 +171,8 @@ function Format-LoggingCommand {
156171 if ($first ) {
157172 $null = $sb.Append (' ' )
158173 $first = $false
159- } else {
174+ }
175+ else {
160176 $null = $sb.Append (' ;' )
161177 }
162178
@@ -193,7 +209,8 @@ function Write-LoggingCommand {
193209 $command = Format-LoggingCommand - Area $Area - Event $Event - Data $Data - Properties $Properties
194210 if ($AsOutput ) {
195211 $command
196- } else {
212+ }
213+ else {
197214 Write-Host $command
198215 }
199216}
@@ -212,12 +229,12 @@ function Write-LogIssue {
212229 [switch ]$AsOutput )
213230
214231 $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+ }
221238 if ($AsOutput ) {
222239 return $command
223240 }
@@ -229,7 +246,8 @@ function Write-LogIssue {
229246 $foregroundColor = [System.ConsoleColor ]::Red
230247 $backgroundColor = [System.ConsoleColor ]::Black
231248 }
232- } else {
249+ }
250+ else {
233251 $foregroundColor = $host.PrivateData.WarningForegroundColor
234252 $backgroundColor = $host.PrivateData.WarningBackgroundColor
235253 if ($foregroundColor -isnot [System.ConsoleColor ] -or $backgroundColor -isnot [System.ConsoleColor ]) {
0 commit comments