From c3c7fdd253743ce5edcee97da4cec8b006969f83 Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 6 Apr 2020 20:49:49 -0700 Subject: [PATCH 01/16] change build location when in VSTS --- build.psm1 | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/build.psm1 b/build.psm1 index 827654bc2..f1ad22368 100644 --- a/build.psm1 +++ b/build.psm1 @@ -257,7 +257,17 @@ function Start-ScriptAnalyzerBuild if ( -not $script:DotnetExe ) { $script:DotnetExe = Get-DotnetExe } - $buildOutput = & $script:DotnetExe build --framework $framework --configuration "$buildConfiguration" 2>&1 + $dotnetArgs = "build", + "--framework", + $framework, + "--configuration", + "$buildConfiguration" + if ( $env:InVSTS ) { + $dotnetArgs += "--output" + $dotnetArgs += "${PSScriptRoot}\bin\${buildConfiguration}\${framework}" + } + # $buildOutput = & $script:DotnetExe build --framework $framework --configuration "$buildConfiguration" 2>&1 + $buildOutput = & $script:DotnetExe $dotnetArgs 2>&1 if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" } } catch { @@ -271,11 +281,20 @@ function Start-ScriptAnalyzerBuild Publish-File $itemsToCopyCommon $script:destinationDir - $itemsToCopyBinaries = @( - "$projectRoot\Engine\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll", - "$projectRoot\Rules\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" - "$projectRoot\Rules\bin\${buildConfiguration}\${framework}\Microsoft.PowerShell.CrossCompatibility.dll" - ) + if ( $env:InVsts ) { + $itemsToCopyBinaries = @( + "$projectRoot\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll", + "$projectRoot\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" + "$projectRoot\bin\${buildConfiguration}\${framework}\Microsoft.PowerShell.CrossCompatibility.dll" + ) + } + else { + $itemsToCopyBinaries = @( + "$projectRoot\Engine\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll", + "$projectRoot\Rules\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" + "$projectRoot\Rules\bin\${buildConfiguration}\${framework}\Microsoft.PowerShell.CrossCompatibility.dll" + ) + } Publish-File $itemsToCopyBinaries $destinationDirBinaries $settingsFiles = Get-Childitem "$projectRoot\Engine\Settings" | ForEach-Object -MemberName FullName From 272039b9caa1e2a8acdad6b5f560d5c04f40d82a Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 6 Apr 2020 20:59:24 -0700 Subject: [PATCH 02/16] copy newtonsoft assembly from proper location --- build.psm1 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index f1ad22368..f38f20238 100644 --- a/build.psm1 +++ b/build.psm1 @@ -301,7 +301,13 @@ function Start-ScriptAnalyzerBuild Publish-File $settingsFiles (Join-Path -Path $script:destinationDir -ChildPath Settings) if ($framework -eq 'net452') { - Copy-Item -path "$projectRoot\Rules\bin\${buildConfiguration}\${framework}\Newtonsoft.Json.dll" -Destination $destinationDirBinaries + if ( $env:InVSTS ) { + $nsoft = "$projectRoot\bin\${buildConfiguration}\${framework}\Newtonsoft.Json.dll" + } + else { + $nsoft = "$projectRoot\Rules\bin\${buildConfiguration}\${framework}\Newtonsoft.Json.dll" + } + Copy-Item -path $nsoft -Destination $destinationDirBinaries } Pop-Location From 67cc3418f040e5a2746c3d1c497ea671f2c8e80f Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 7 Apr 2020 09:05:31 -0700 Subject: [PATCH 03/16] Add support for verbose output during build --- build.ps1 | 6 ++++-- build.psm1 | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/build.ps1 b/build.ps1 index 94f3cbf4e..a9bbb4ea8 100644 --- a/build.ps1 +++ b/build.ps1 @@ -35,6 +35,7 @@ param( [Parameter(ParameterSetName='Bootstrap')] [switch] $Bootstrap + ) END { @@ -49,15 +50,16 @@ END { $setName = $PSCmdlet.ParameterSetName switch ( $setName ) { "BuildAll" { - Start-ScriptAnalyzerBuild -All -Configuration $Configuration + Start-ScriptAnalyzerBuild -All -Configuration $Configuration -Verbose:$Verbose } "BuildDocumentation" { - Start-ScriptAnalyzerBuild -Documentation + Start-ScriptAnalyzerBuild -Documentation -Verbose:$Verbose } "BuildOne" { $buildArgs = @{ PSVersion = $PSVersion Configuration = $Configuration + Verbose = $Verbose } Start-ScriptAnalyzerBuild @buildArgs } diff --git a/build.psm1 b/build.psm1 index f38f20238..117a23fe9 100644 --- a/build.psm1 +++ b/build.psm1 @@ -170,6 +170,7 @@ function Start-ScriptAnalyzerBuild $documentationFileExists = Test-Path (Join-Path $PSScriptRoot 'out\PSScriptAnalyzer\en-us\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml') if ( $Documentation -or -not $documentationFileExists ) { + Write-Verbose -Verbose:$Verbose -Message "Start-DocumentationBuild" Start-DocumentationBuild } @@ -177,13 +178,14 @@ function Start-ScriptAnalyzerBuild { # Build all the versions of the analyzer foreach($psVersion in 3..7) { - Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion + Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion -Verbose:$Verbose } return } if (-not $profilesCopied) { + Write-Verbose -Verbose:$Verbose -Message "Copy-CompatibilityProfiles" Copy-CompatibilityProfiles # Set the variable in the caller's scope, so this will only happen once Set-Variable -Name profilesCopied -Value $true -Scope 1 @@ -253,7 +255,9 @@ function Start-ScriptAnalyzerBuild # The Rules project has a dependency on the Engine therefore just building the Rules project is enough try { Push-Location $projectRoot/Rules - Write-Progress "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'" + $message = "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'" + Write-Verbose -Verbose:$Verbose -Message "$message" + Write-Progress "$message" if ( -not $script:DotnetExe ) { $script:DotnetExe = Get-DotnetExe } @@ -269,6 +273,7 @@ function Start-ScriptAnalyzerBuild # $buildOutput = & $script:DotnetExe build --framework $framework --configuration "$buildConfiguration" 2>&1 $buildOutput = & $script:DotnetExe $dotnetArgs 2>&1 if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" } + Write-Verbose -Verbose:$Verbose -message "$buildOutput" } catch { Write-Warning $_ From db8bed0021e3eba267b5caed916db986e06715de Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 7 Apr 2020 09:59:25 -0700 Subject: [PATCH 04/16] update verbose behavior incorporate catalog building into module --- build.ps1 | 11 ++++++++--- build.psm1 | 24 ++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/build.ps1 b/build.ps1 index a9bbb4ea8..c63ee50fc 100644 --- a/build.ps1 +++ b/build.ps1 @@ -34,7 +34,12 @@ param( [switch] $InProcess, [Parameter(ParameterSetName='Bootstrap')] - [switch] $Bootstrap + [switch] $Bootstrap, + + [Parameter(ParameterSetName='BuildAll')] + [Parameter(ParameterSetName='BuildOne')] + [switch] $Catalog + ) @@ -50,10 +55,10 @@ END { $setName = $PSCmdlet.ParameterSetName switch ( $setName ) { "BuildAll" { - Start-ScriptAnalyzerBuild -All -Configuration $Configuration -Verbose:$Verbose + Start-ScriptAnalyzerBuild -All -Configuration $Configuration -Verbose:$Verbose -Catalog:$Catalog } "BuildDocumentation" { - Start-ScriptAnalyzerBuild -Documentation -Verbose:$Verbose + Start-ScriptAnalyzerBuild -Documentation -Verbose:$Verbose -Catalog:$Catalog } "BuildOne" { $buildArgs = @{ diff --git a/build.psm1 b/build.psm1 index 117a23fe9..e7e516b95 100644 --- a/build.psm1 +++ b/build.psm1 @@ -114,7 +114,7 @@ function Start-DocumentationBuild { throw "Cannot find markdown documentation folder." } - Import-Module platyPS + Import-Module platyPS -Verbose:$false if ( -not (Test-Path $outputDocsPath)) { $null = New-Item -Type Directory -Path $outputDocsPath -Force } @@ -150,7 +150,9 @@ function Start-ScriptAnalyzerBuild [ValidateSet("Debug", "Release")] [string]$Configuration = "Debug", - [switch]$Documentation + [switch]$Documentation, + + [switch]$Catalog ) BEGIN { @@ -315,6 +317,24 @@ function Start-ScriptAnalyzerBuild Copy-Item -path $nsoft -Destination $destinationDirBinaries } + New-Catalog -Location $script:destinationDir + + Pop-Location + } +} + +function New-Catalog +{ + param ( [Parameter()]$Location ) + if ( ! $IsWindows ) { + Write-Warning "Create catalog only on windows" + return + } + try { + Push-Location $Location + New-FileCatalog -CatalogFilePath PSScriptAnalzyer.cat -Path . + } + finally { Pop-Location } } From 2243b626d226f81bb79930865cc4630f401eba7e Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 7 Apr 2020 13:16:25 -0700 Subject: [PATCH 05/16] better code to handle verbose --- build.ps1 | 20 ++++++++++++++------ build.psm1 | 16 ++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/build.ps1 b/build.ps1 index c63ee50fc..3e22b9f84 100644 --- a/build.ps1 +++ b/build.ps1 @@ -37,16 +37,22 @@ param( [switch] $Bootstrap, [Parameter(ParameterSetName='BuildAll')] - [Parameter(ParameterSetName='BuildOne')] [switch] $Catalog ) +BEGIN { + $verboseWanted = $false + if ( $PSBoundParameters['Verbose'] ) { + $verboseWanted = $PSBoundParameters['Verbose'].ToBool() + } +} + END { - Import-Module -Force (Join-Path $PSScriptRoot build.psm1) + Import-Module -Force (Join-Path $PSScriptRoot build.psm1) -verbose:$false if ( $Clean -or $Clobber ) { - Remove-Build + Remove-Build -verbose:$false if ( $PSCmdlet.ParameterSetName -eq "Clean" ) { return } @@ -55,16 +61,18 @@ END { $setName = $PSCmdlet.ParameterSetName switch ( $setName ) { "BuildAll" { - Start-ScriptAnalyzerBuild -All -Configuration $Configuration -Verbose:$Verbose -Catalog:$Catalog + Start-ScriptAnalyzerBuild -All -Configuration $Configuration -Verbose:$verboseWanted + if ( $Catalog ) { + $catalogFile = New-Catalog + } } "BuildDocumentation" { - Start-ScriptAnalyzerBuild -Documentation -Verbose:$Verbose -Catalog:$Catalog + Start-ScriptAnalyzerBuild -Documentation -Verbose:$Verbose } "BuildOne" { $buildArgs = @{ PSVersion = $PSVersion Configuration = $Configuration - Verbose = $Verbose } Start-ScriptAnalyzerBuild @buildArgs } diff --git a/build.psm1 b/build.psm1 index e7e516b95..1a8fd09cc 100644 --- a/build.psm1 +++ b/build.psm1 @@ -165,6 +165,10 @@ function Start-ScriptAnalyzerBuild $foundVersion = Get-InstalledCLIVersion Write-Warning "No suitable dotnet CLI found, requires version '$requiredVersion' found only '$foundVersion'" } + $verboseWanted = $false + if ( $PSBoundParameters['Verbose'] ) { + $verboseWanted = $PSBoundParameters['Verbose'].ToBool() + } } END { @@ -172,22 +176,22 @@ function Start-ScriptAnalyzerBuild $documentationFileExists = Test-Path (Join-Path $PSScriptRoot 'out\PSScriptAnalyzer\en-us\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml') if ( $Documentation -or -not $documentationFileExists ) { - Write-Verbose -Verbose:$Verbose -Message "Start-DocumentationBuild" - Start-DocumentationBuild + Write-Verbose -Verbose:$verboseWanted -Message "Start-DocumentationBuild" + Start-DocumentationBuild -Verbose:$verboseWanted } if ( $All ) { # Build all the versions of the analyzer foreach($psVersion in 3..7) { - Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion -Verbose:$Verbose + Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion -Verbose:$verboseWanted } return } if (-not $profilesCopied) { - Write-Verbose -Verbose:$Verbose -Message "Copy-CompatibilityProfiles" + Write-Verbose -Verbose:$verboseWanted -Message "Copy-CompatibilityProfiles" Copy-CompatibilityProfiles # Set the variable in the caller's scope, so this will only happen once Set-Variable -Name profilesCopied -Value $true -Scope 1 @@ -258,7 +262,7 @@ function Start-ScriptAnalyzerBuild try { Push-Location $projectRoot/Rules $message = "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'" - Write-Verbose -Verbose:$Verbose -Message "$message" + Write-Verbose -Verbose:$verboseWanted -Message "$message" Write-Progress "$message" if ( -not $script:DotnetExe ) { $script:DotnetExe = Get-DotnetExe @@ -275,7 +279,7 @@ function Start-ScriptAnalyzerBuild # $buildOutput = & $script:DotnetExe build --framework $framework --configuration "$buildConfiguration" 2>&1 $buildOutput = & $script:DotnetExe $dotnetArgs 2>&1 if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" } - Write-Verbose -Verbose:$Verbose -message "$buildOutput" + Write-Verbose -Verbose:$verboseWanted -message "$buildOutput" } catch { Write-Warning $_ From 8ed81713cbd6f4518b71c17db7ccc27ed4012516 Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 8 Apr 2020 09:23:51 -0700 Subject: [PATCH 06/16] file for signing analyzer files --- tools/releaseBuild/AssemblySignConfig.xml | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 tools/releaseBuild/AssemblySignConfig.xml diff --git a/tools/releaseBuild/AssemblySignConfig.xml b/tools/releaseBuild/AssemblySignConfig.xml new file mode 100644 index 000000000..71e19f28e --- /dev/null +++ b/tools/releaseBuild/AssemblySignConfig.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 5ff3bff9f889ee7b9a4b39fb335f811349ac249a Mon Sep 17 00:00:00 2001 From: James Truher Date: Thu, 9 Apr 2020 14:10:12 -0700 Subject: [PATCH 07/16] tweaks to catalog creation --- build.ps1 | 11 ++++++++--- build.psm1 | 5 +++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/build.ps1 b/build.ps1 index 3e22b9f84..8ae36f376 100644 --- a/build.ps1 +++ b/build.ps1 @@ -39,7 +39,6 @@ param( [Parameter(ParameterSetName='BuildAll')] [switch] $Catalog - ) BEGIN { @@ -61,10 +60,16 @@ END { $setName = $PSCmdlet.ParameterSetName switch ( $setName ) { "BuildAll" { - Start-ScriptAnalyzerBuild -All -Configuration $Configuration -Verbose:$verboseWanted + $buildArgs = @{ + All = $true + Configuration = $Configuration + Verbose = $verboseWanted + Catalog = $false + } if ( $Catalog ) { - $catalogFile = New-Catalog + $buildArgs['Catalog'] = $true } + Start-ScriptAnalyzerBuild @buildArgs # -All -Configuration $Configuration -Verbose:$verboseWanted } "BuildDocumentation" { Start-ScriptAnalyzerBuild -Documentation -Verbose:$Verbose diff --git a/build.psm1 b/build.psm1 index 1a8fd09cc..aa17d030d 100644 --- a/build.psm1 +++ b/build.psm1 @@ -186,6 +186,9 @@ function Start-ScriptAnalyzerBuild foreach($psVersion in 3..7) { Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion -Verbose:$verboseWanted } + if ( $Catalog ) { + New-Catalog -Location $script:destinationDir + } return } @@ -321,8 +324,6 @@ function Start-ScriptAnalyzerBuild Copy-Item -path $nsoft -Destination $destinationDirBinaries } - New-Catalog -Location $script:destinationDir - Pop-Location } } From eacda3b915a4e367b901882d803dd9261155cd11 Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 13 Apr 2020 09:33:16 -0700 Subject: [PATCH 08/16] Add suppression of UseCompatibleCommands rule for function that builds file catalog --- build.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/build.psm1 b/build.psm1 index aa17d030d..6499fb440 100644 --- a/build.psm1 +++ b/build.psm1 @@ -330,6 +330,7 @@ function Start-ScriptAnalyzerBuild function New-Catalog { + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', '')] param ( [Parameter()]$Location ) if ( ! $IsWindows ) { Write-Warning "Create catalog only on windows" From c391c7a7c2aeea52b9c9237bc25c7c4bc7b7b1fa Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 13 Apr 2020 12:04:36 -0700 Subject: [PATCH 09/16] Improve message when there are failures in use compatible commands --- Tests/Rules/UseCompatibleCommands.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Rules/UseCompatibleCommands.Tests.ps1 b/Tests/Rules/UseCompatibleCommands.Tests.ps1 index 2e38ba7e3..e2ac6ca68 100644 --- a/Tests/Rules/UseCompatibleCommands.Tests.ps1 +++ b/Tests/Rules/UseCompatibleCommands.Tests.ps1 @@ -400,7 +400,7 @@ Describe 'UseCompatibleCommands' { } $diagnostics = Invoke-ScriptAnalyzer -Path "$PSScriptRoot/../../" -IncludeRule $script:RuleName -Settings $settings - $diagnostics.Count | Should -Be 0 -Because ($diagnostics.RuleName -join ', ') + $diagnostics.Count | Should -Be 0 -Because ($diagnostics.Message -join ', ') } } From dc4653bd7c474d74dcacc0014dc6774cd591f1a1 Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 13 Apr 2020 13:07:48 -0700 Subject: [PATCH 10/16] change logic for whether catalog can be created based on whether new-filecatalog exists rather than IsWindows variable which doesn't exist on PS5 --- build.psm1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.psm1 b/build.psm1 index 6499fb440..9bdaa3457 100644 --- a/build.psm1 +++ b/build.psm1 @@ -332,8 +332,9 @@ function New-Catalog { [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', '')] param ( [Parameter()]$Location ) - if ( ! $IsWindows ) { - Write-Warning "Create catalog only on windows" + $newFileCatalog = Get-Command -ea silentlycontinue New-FileCatalog + if ($null -eq $newFileCatalog) { + Write-Warning "New-FileCatalog not found, not creating catalog" return } try { From 52e58180a75d7f41215027ee7e53d1ee8db52b0d Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 13 Apr 2020 14:55:01 -0700 Subject: [PATCH 11/16] Add catalog signing configuration --- tools/releaseBuild/CatalogSignConfig.xml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 tools/releaseBuild/CatalogSignConfig.xml diff --git a/tools/releaseBuild/CatalogSignConfig.xml b/tools/releaseBuild/CatalogSignConfig.xml new file mode 100644 index 000000000..0f189cfad --- /dev/null +++ b/tools/releaseBuild/CatalogSignConfig.xml @@ -0,0 +1,7 @@ + + + + + + + From 5d5ae336f25846f4dff15eb3dfa82efa11192dff Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 13 Apr 2020 15:00:48 -0700 Subject: [PATCH 12/16] fix typo in catalog name --- build.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index 9bdaa3457..44a4340ce 100644 --- a/build.psm1 +++ b/build.psm1 @@ -339,7 +339,7 @@ function New-Catalog } try { Push-Location $Location - New-FileCatalog -CatalogFilePath PSScriptAnalzyer.cat -Path . + New-FileCatalog -CatalogFilePath PSScriptAnalyzer.cat -Path . } finally { Pop-Location From 2bbd2d570a4067eb3d1f822f4dd7ec3be398b7a7 Mon Sep 17 00:00:00 2001 From: James Truher Date: Mon, 13 Apr 2020 15:29:35 -0700 Subject: [PATCH 13/16] use 400 for signing --- tools/releaseBuild/CatalogSignConfig.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/releaseBuild/CatalogSignConfig.xml b/tools/releaseBuild/CatalogSignConfig.xml index 0f189cfad..73091961b 100644 --- a/tools/releaseBuild/CatalogSignConfig.xml +++ b/tools/releaseBuild/CatalogSignConfig.xml @@ -1,7 +1,6 @@ - - + From 1462e1bd5c7110841ea89841480c86fdf9769094 Mon Sep 17 00:00:00 2001 From: James Truher Date: Fri, 17 Apr 2020 13:43:57 -0700 Subject: [PATCH 14/16] Address PR feedback Remove comment code change logic to use existing environment variable when building in VSTS Remove extraneous suppression of New-FileCatalog --- build.ps1 | 2 +- build.psm1 | 10 ++++------ tools/releaseBuild/AssemblySignConfig.xml | 14 -------------- 3 files changed, 5 insertions(+), 21 deletions(-) diff --git a/build.ps1 b/build.ps1 index 8ae36f376..3cf8cad8e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -69,7 +69,7 @@ END { if ( $Catalog ) { $buildArgs['Catalog'] = $true } - Start-ScriptAnalyzerBuild @buildArgs # -All -Configuration $Configuration -Verbose:$verboseWanted + Start-ScriptAnalyzerBuild @buildArgs } "BuildDocumentation" { Start-ScriptAnalyzerBuild -Documentation -Verbose:$Verbose diff --git a/build.psm1 b/build.psm1 index 44a4340ce..1067840f5 100644 --- a/build.psm1 +++ b/build.psm1 @@ -275,11 +275,10 @@ function Start-ScriptAnalyzerBuild $framework, "--configuration", "$buildConfiguration" - if ( $env:InVSTS ) { + if ( $env:TF_BUILD ) { $dotnetArgs += "--output" $dotnetArgs += "${PSScriptRoot}\bin\${buildConfiguration}\${framework}" } - # $buildOutput = & $script:DotnetExe build --framework $framework --configuration "$buildConfiguration" 2>&1 $buildOutput = & $script:DotnetExe $dotnetArgs 2>&1 if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" } Write-Verbose -Verbose:$verboseWanted -message "$buildOutput" @@ -295,7 +294,7 @@ function Start-ScriptAnalyzerBuild Publish-File $itemsToCopyCommon $script:destinationDir - if ( $env:InVsts ) { + if ( $env:TF_BUILD ) { $itemsToCopyBinaries = @( "$projectRoot\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll", "$projectRoot\bin\${buildConfiguration}\${Framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" @@ -315,7 +314,7 @@ function Start-ScriptAnalyzerBuild Publish-File $settingsFiles (Join-Path -Path $script:destinationDir -ChildPath Settings) if ($framework -eq 'net452') { - if ( $env:InVSTS ) { + if ( $env:TF_BUILD ) { $nsoft = "$projectRoot\bin\${buildConfiguration}\${framework}\Newtonsoft.Json.dll" } else { @@ -330,9 +329,8 @@ function Start-ScriptAnalyzerBuild function New-Catalog { - [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', '')] param ( [Parameter()]$Location ) - $newFileCatalog = Get-Command -ea silentlycontinue New-FileCatalog + $newFileCatalog = Get-Command -ErrorAction SilentlyContinue New-FileCatalog if ($null -eq $newFileCatalog) { Write-Warning "New-FileCatalog not found, not creating catalog" return diff --git a/tools/releaseBuild/AssemblySignConfig.xml b/tools/releaseBuild/AssemblySignConfig.xml index 71e19f28e..2d2738804 100644 --- a/tools/releaseBuild/AssemblySignConfig.xml +++ b/tools/releaseBuild/AssemblySignConfig.xml @@ -40,18 +40,4 @@ - From 2fb32d330b550e7db06bbdea56a1cec3f541815a Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 21 Apr 2020 15:53:36 -0700 Subject: [PATCH 15/16] add the suppression back to the function which creates the filecatalog --- build.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/build.psm1 b/build.psm1 index 1067840f5..17b584c3c 100644 --- a/build.psm1 +++ b/build.psm1 @@ -329,6 +329,7 @@ function Start-ScriptAnalyzerBuild function New-Catalog { + [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseCompatibleCommands', '')] param ( [Parameter()]$Location ) $newFileCatalog = Get-Command -ErrorAction SilentlyContinue New-FileCatalog if ($null -eq $newFileCatalog) { From f04b6a1d1ad919f0624eedff0a8a7a6b6b835f51 Mon Sep 17 00:00:00 2001 From: James Truher Date: Thu, 23 Apr 2020 15:52:47 -0700 Subject: [PATCH 16/16] Create suppression file for CredScan so it does not get triggered. --- tools/releaseBuild/CredScan.Suppressions.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tools/releaseBuild/CredScan.Suppressions.json diff --git a/tools/releaseBuild/CredScan.Suppressions.json b/tools/releaseBuild/CredScan.Suppressions.json new file mode 100644 index 000000000..53b49888f --- /dev/null +++ b/tools/releaseBuild/CredScan.Suppressions.json @@ -0,0 +1,15 @@ +{ + "tool": "Credential Scanner", + "suppressions": [ + { "file": "\\Engine\\Settings\\desktop-4.0-windows.json", + "_justification": "The file contains the list of all parameters of a cmdlet but no passwords are actually present." }, + { "file": "\\Engine\\Settings\\desktop-3.0-windows.json", + "_justification": "The file contains the list of all parameters of a cmdlet but no passwords are actually present." }, + { "file": "\\Engine\\Settings\\desktop-5.1.14393.206-windows.json", + "_justification": "The file contains the list of all parameters of a cmdlet but no passwords are actually present." }, + { "file": "\\Tests\\Engine\\RuleSuppression.tests.ps1", + "_justification": "The parameter password is used in function declaration for test but is not called and no password is present." } + ] +} + +