@@ -393,11 +393,6 @@ function Get-CurrentBuildKind
393393 }
394394 }
395395
396- # set/reset legacy environment vars for non-script tools (i.e. msbuild.exe)
397- $env: IsAutomatedBuild = $global :CurrentBuildKind -ne [BuildKind ]::LocalBuild
398- $env: IsPullRequestBuild = $global :CurrentBuildKind -eq [BuildKind ]::PullRequestBuild
399- $env: IsReleaseBuild = $global :CurrentBuildKind -eq [BuildKind ]::ReleaseBuild
400-
401396 return $currentBuildKind
402397}
403398
@@ -410,6 +405,20 @@ function Initialize-BuildEnvironment
410405 # Script code should ALWAYS use the global CurrentBuildKind
411406 $global :CurrentBuildKind = Get-CurrentBuildKind
412407
408+ # set/reset legacy environment vars for non-script tools (i.e. msbuild.exe)
409+ $env: IsAutomatedBuild = $global :CurrentBuildKind -ne [BuildKind ]::LocalBuild
410+ $env: IsPullRequestBuild = $global :CurrentBuildKind -eq [BuildKind ]::PullRequestBuild
411+ $env: IsReleaseBuild = $global :CurrentBuildKind -eq [BuildKind ]::ReleaseBuild
412+
413+ switch ($global :CurrentBuildKind )
414+ {
415+ ([BuildKind ]::LocalBuild) { $env: CiBuildName = ' ZZZ' }
416+ ([BuildKind ]::PullRequestBuild) { $env: CiBuildName = ' PRQ' }
417+ ([BuildKind ]::CiBuild) { $env: CiBuildName = ' BLD' }
418+ ([BuildKind ]::ReleaseBuild) { $env: CiBuildName = ' ' }
419+ default { throw " Invalid build kind" }
420+ }
421+
413422 # get the ISO-8601 formatted time stamp of the HEAD commit or the current UTC time for local builds
414423 if (! $env: BuildTime -or $FullInit )
415424 {
@@ -434,11 +443,14 @@ function Initialize-BuildEnvironment
434443 $env: Path = " $env: Path ;$ ( $msbuild.BinPath ) "
435444 }
436445
437- if ($FullInit )
446+ if ($FullInit -or ! $ global :BuildPaths -or ! $ global :BuildInfo )
438447 {
439448 $global :BuildPaths = Get-BuildPaths $PSScriptRoot
440449 $global :BuildInfo = Get-BuildInformation $BuildPaths
450+ }
441451
452+ if ($FullInit )
453+ {
442454 Write-Information ' Build Paths:'
443455 Write-Information ($global :BuildPaths | Format-Table | Out-String )
444456
0 commit comments