Skip to content

Commit

Permalink
b#48614111: Add "break on error" setting to the top of powershell scr…
Browse files Browse the repository at this point in the history
…ipts in WASDK (#4529)

* 48614111: draft 1

* 48614111: use 'Set-StrictMode -Version 1.0' in Generate-TerminalVelocityFeatures.ps1

* 48614111: upcated Generate-TerminalVelocityFeatures.ps1

* 48614111: cleaned away unintended blank lines

* 48614111: add workaround to CopyFilesToStagingDir.ps1

* 48614111: moved workaround in CopyFilesToStagingDir.ps1 to BuildAll.ps1
  • Loading branch information
alexlamtest committed Jul 3, 2024
1 parent f753170 commit 517707a
Show file tree
Hide file tree
Showing 24 changed files with 67 additions and 2 deletions.
6 changes: 6 additions & 0 deletions BuildAll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Param(
[switch]$Clean = $false
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

$env:Build_SourcesDirectory = (Split-Path $MyInvocation.MyCommand.Path)
$buildOverridePath = "build\override"
$BasePath = "BuildOutput/FullNuget"
Expand Down Expand Up @@ -288,7 +291,10 @@ Try {
{
foreach($platformToRun in $platform.Split(","))
{
# TODO: $windowsAppSdkBinariesPath may not be defined. Remove the temp downgrade to 1.0 once this issue has been fixed (b#52130179).
Set-StrictMode -Version 1.0
.\build\CopyFilesToStagingDir.ps1 -BuildOutputDir 'BuildOutput' -OverrideDir "$buildOverridePath" -PublishDir "$windowsAppSdkBinariesPath" -NugetDir "$BasePath" -Platform $PlatformToRun -Configuration $ConfigurationToRun
Set-StrictMode -Version 3.0
if ($lastexitcode -ne 0)
{
write-host "ERROR: msCopyFilesToStagingDir.ps1 FAILED."
Expand Down
1 change: 1 addition & 0 deletions TestAll.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ param(
$StartTime = Get-Date
$lastexitcode = 0
Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

function Get-Tests
{
Expand Down
3 changes: 3 additions & 0 deletions build/CopyFilesToStagingDir.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Param(
[switch]$PublishAppxFiles=$false
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

$FullBuildOutput = "$($BuildOutputDir)\$($Configuration)\$($Platform)"
$FullPublishDir = "$($PublishDir)\$($Configuration)\$($Platform)"

Expand Down
3 changes: 3 additions & 0 deletions build/NuSpecs/build-nupkg.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Param(
# Version is read from the VERSION file.
#

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

$scriptDirectory = $script:MyInvocation.MyCommand.Path | Split-Path -Parent

pushd $scriptDirectory
Expand Down
3 changes: 3 additions & 0 deletions build/ShouldSkipPRBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ function AllChangedFilesAreSkippable
return $allFilesAreSkippable
}

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

$shouldSkipBuild = $false

if($env:BUILD_REASON -eq "PullRequest")
Expand Down
1 change: 1 addition & 0 deletions build/StripSymbols.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[parameter(mandatory)][string] $OutputDirectory
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"
function Get-Is64Bit
{
Expand Down
3 changes: 3 additions & 0 deletions build/scripts/ConvertVersionDetailsToPackageConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Param(
[string]$packageConfigPath = ""
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

[xml]$buildConfig = Get-Content -Path $versionDetailsPath

$packagesText =
Expand Down
2 changes: 2 additions & 0 deletions build/scripts/Install-WindowsSdkISO.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
param([Parameter(Mandatory=$true, Position=0)]
[string]$buildNumber)

Set-StrictMode -Version 3.0

# Ensure the error action preference is set to the default for PowerShell3, 'Stop'
$ErrorActionPreference = 'Stop'

Expand Down
3 changes: 1 addition & 2 deletions build/scripts/windows-sdk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ param(
[string]$SdkVersion = $null
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"



function Install-EXE
{
Param
Expand Down
3 changes: 3 additions & 0 deletions dev/MRTCore/build/DownloadDotNetCoreSdk.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ param(
[switch]$skipLKG
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

$dotnetInstallScript = "$env:TEMP\dotnet-install.ps1"

$repoInstallDir = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\.dotnet")
Expand Down
3 changes: 3 additions & 0 deletions dev/MRTCore/build/Initialize-InstallMSBuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ param(

Import-Module -Name $PSScriptRoot\MSBuildFunctions.psm1 -DisableNameChecking

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

# Check if the VS cmd prompt is a valid one
$msbuildUpToDate = Test-MSBuild (Join-Path $env:VSINSTALLDIR "MSBuild\Current\Bin\msbuild.exe")
if (-not $msbuildUpToDate)
Expand Down
3 changes: 3 additions & 0 deletions eng/common/Scripts/ConvertVersionDetailsToPackageConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Param(
[string]$packageConfigPath = ""
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

[xml]$buildConfig = Get-Content -Path $versionDetailsPath

$packagesText =
Expand Down
1 change: 1 addition & 0 deletions eng/common/Scripts/GetLKGCompilerPackageInfoIfNeeded.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ param
[String] $SourceDirectory
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"

# If $env:LkgVcToolsName and $env:LkgVcToolsVersion are not fully specified, try to retrieve the defaults from WindowsAppSDK-GlobalVariables.yml.
Expand Down
3 changes: 3 additions & 0 deletions eng/common/Scripts/MaestroGetRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Param(
[string]$queryParameters
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

$headers = @{
Authorization="Bearer $token"
}
Expand Down
3 changes: 3 additions & 0 deletions eng/common/Scripts/MaestroHelpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,6 @@ function IsMaestroFriendlyAzureDevOpUri([string]$buildRepositoryUri)
}
return $false
}

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'
3 changes: 3 additions & 0 deletions eng/common/Scripts/MaestroPostRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Param(
[string]$queryParameters = ''
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

$headers = @{
Authorization="Bearer $token"
}
Expand Down
3 changes: 3 additions & 0 deletions eng/common/Scripts/PublishPublicSymbols.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ Param(
[switch] $preProductionEnviroment
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

$ProjectName = 'WindowsAppSDK'

$endPoint = "https://symbolrequestprod.trafficmanager.net/projects/$ProjectName/requests"
Expand Down
1 change: 1 addition & 0 deletions eng/common/Scripts/StripSymbols.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ param(
[parameter(mandatory)][string] $OutputDirectory
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = "Stop"
function Get-IsAmd64Bit
{
Expand Down
3 changes: 3 additions & 0 deletions eng/common/Scripts/UpdateVersionDetailsConfig.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Param(
[string]$dependencyVersion
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

Write-Host $dependencyName
Write-Host $dependencyVersion

Expand Down
3 changes: 3 additions & 0 deletions eng/common/VersionInfo/GenerateVersionInfo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ Param(
[int]$ProductMinor
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

# Don't output file with Bom
$utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False

Expand Down
3 changes: 3 additions & 0 deletions tools/GenerateDynamicDependencyOverrides.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function Convert-Guid
return $guid
}

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

if (-not(Test-Path -Path $Path -PathType Container))
{
Write-Host "Creating $Path..."
Expand Down
3 changes: 3 additions & 0 deletions tools/GeneratePushNotificationsOverrides.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ function Convert-Guid
return $guid
}

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

if (-not(Test-Path -Path $Path -PathType Container))
{
Write-Host "Creating $Path..."
Expand Down
6 changes: 6 additions & 0 deletions tools/TerminalVelocity/Generate-TerminalVelocityFeatures.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Param(
[string]$Namespace
)

Set-StrictMode -Version 3.0

# Make sure Channel has the exact spelling even if the parameter had different case
foreach ($c in "Experimental", "Preview", "Stable", "WindowsInbox")
{
Expand Down Expand Up @@ -93,6 +95,9 @@ Class Feature
{
$this.Name = $entry.name
$this.State = ConvertTo-FeatureState $entry.state

# TODO: Remove the temp workaround of downgrading to StrictModel 1.0 once b#52128443 is fixed.
Set-StrictMode -Version 1.0
$this.Id = $entry.id
$this.ChannelTokenStates = [System.Collections.Generic.Dictionary[string, State]]::new()
$this.DisabledReleaseToken = $Null -Ne $entry.alwaysDisabledReleaseTokens
Expand All @@ -107,6 +112,7 @@ Class Feature
{
$this.ChannelTokenStates[$b] = [State]::AlwaysEnabled
}
Set-StrictMode -Version 3.0
}

[string] PreprocessorName([string]$namespace)
Expand Down
3 changes: 3 additions & 0 deletions tools/VerifyCopyrightHeaders.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ Param(
[switch]$Fix = $false
)

Set-StrictMode -Version 3.0
$ErrorActionPreference = 'Stop'

$copyrightHeaderText = (
"Copyright (c) Microsoft Corporation and Contributors.",
"Licensed under the MIT License."
Expand Down

0 comments on commit 517707a

Please sign in to comment.