From 6f97d1a49e51076d414084adb1354c12a12bdddf Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 23 Oct 2018 22:55:48 +0100 Subject: [PATCH 01/13] simplify build scripts even more and upgrade platyPS in Appveyor --- README.md | 14 ++++----- build.ps1 | 9 ++---- build.psm1 | 70 ++++++++++++++------------------------------- tools/appveyor.psm1 | 5 ++-- 4 files changed, 34 insertions(+), 64 deletions(-) diff --git a/README.md b/README.md index 849f556c6..f76aea8c4 100644 --- a/README.md +++ b/README.md @@ -123,31 +123,31 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c * Building You can either build using the `Visual Studio` solution `PSScriptAnalyzer.sln` or build using `PowerShell` specifically for your platform as follows: - * The default build is for PowerShell Core + * The default build is for the currently used version of PowerShell ```powershell .\build.ps1 ``` * Windows PowerShell version 5.0 ```powershell - .\build.ps1 -Framework full -PSVersion 5 -Configuration Release + .\build.ps1 -PSVersion 5 -Configuration Release ``` * Windows PowerShell version 4.0 ```powershell - .\build.ps1 -Framework full -PSVersion 4 -Configuration Release + .\build.ps1 -PSVersion 4 -Configuration Release ``` * Windows PowerShell version 3.0 ```powershell - .\build.ps1 -Framework full -PSVersion 3 -Configuration Release + .\build.ps1 -PSVersion 3 -Configuration Release ``` * PowerShell Core ```powershell - .\buildCoreClr.ps1 -Framework core -Configuration Release -Build + .\buildCoreClr.ps1 -Configuration Release -Build ``` -* Build documentation +* Build documentation (required for using the module) ```powershell .\build.ps1 -Documentation ``` -* Build all versions (PowerShell v3, v4, v5, and Core) and documentation +* Build all versions (PowerShell v3, v4, v5, and v6) and documentation ```powershell .\build.ps1 -All ``` diff --git a/build.ps1 b/build.ps1 index e0e0712cd..a7b0e1cf5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -7,12 +7,8 @@ param( [switch]$All, [Parameter(ParameterSetName="BuildOne")] - [ValidateSet("full", "core")] - [string]$Framework = "core", - - [Parameter(ParameterSetName="BuildOne")] - [ValidateSet("3","4","5")] - [string]$PSVersion = "5", + [ValidateRange(3, 6)] + [int]$PSVersion = $PSVersionTable.PSVersion.Major, [Parameter(ParameterSetName="BuildOne")] [Parameter(ParameterSetName="BuildAll")] @@ -55,7 +51,6 @@ END { } "BuildOne" { $buildArgs = @{ - Framework = $Framework PSVersion = $PSVersion Configuration = $Configuration } diff --git a/build.psm1 b/build.psm1 index 5473a0da7..7ce2acc8f 100644 --- a/build.psm1 +++ b/build.psm1 @@ -93,14 +93,10 @@ function Start-DocumentationBuild $docsPath = Join-Path $projectRoot docs $markdownDocsPath = Join-Path $docsPath markdown $outputDocsPath = Join-Path $destinationDir en-US - $requiredVersionOfplatyPS = 0.9 - #$modInfo = new-object Microsoft.PowerShell.Commands.ModuleSpecification -ArgumentList @{ ModuleName = "platyps"; ModuleVersion = $requiredVersionOfplatyPS} - #if ( $null -eq (Get-Module -ListAvailable -FullyQualifiedName $modInfo)) if ( $null -eq (Get-Module -ListAvailable platyPS)) { Write-Verbose -verbose "platyPS not found, installing" Install-Module -Force -Name platyPS -Scope CurrentUser - # throw "Cannot find required minimum version $requiredVersionOfplatyPS of platyPS. Install via 'Install-Module platyPS'" } if (-not (Test-Path $markdownDocsPath)) { @@ -122,12 +118,8 @@ function Start-ScriptAnalyzerBuild [switch]$All, [Parameter(ParameterSetName="BuildOne")] - [ValidateSet("full", "core")] - [string]$Framework = "core", - - [Parameter(ParameterSetName="BuildOne")] - [ValidateSet("3","4","5")] - [string]$PSVersion = "5", + [ValidateRange(3, 6)] + [int]$PSVersion = $PSVersionTable.PSVersion.Major, [Parameter(ParameterSetName="BuildOne")] [Parameter(ParameterSetName="BuildAll")] @@ -138,19 +130,13 @@ function Start-ScriptAnalyzerBuild [switch]$Documentation ) - BEGIN { - if ( $PSVersion -match "[34]" -and $Framework -eq "core" ) { - throw "Script Analyzer for PowerShell 3/4 cannot be built for framework 'core'" - } - } END { if ( $All ) { # Build all the versions of the analyzer - Start-ScriptAnalyzerBuild -Framework full -Configuration $Configuration -PSVersion "3" - Start-ScriptAnalyzerBuild -Framework full -Configuration $Configuration -PSVersion "4" - Start-ScriptAnalyzerBuild -Framework full -Configuration $Configuration -PSVersion "5" - Start-ScriptAnalyzerBuild -Framework core -Configuration $Configuration -PSVersion "5" + foreach($psVersion in 3..6) { + Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion + } Start-ScriptAnalyzerBuild -Documentation return } @@ -161,22 +147,12 @@ function Start-ScriptAnalyzerBuild return } - Push-Location -Path $projectRoot - - if ( $framework -eq "core" ) { - $frameworkName = "netstandard2.0" - } - else { - $frameworkName = "net451" + $framework = 'net451' + if ($PSVersion -ge 6) { + $framework = 'netstandard2.0' } - # build the appropriate assembly - if ($PSVersion -match "[34]" -and $Framework -eq "core") - { - throw ("ScriptAnalyzer for PS version '{0}' is not applicable to {1} framework" -f $PSVersion,$Framework) - } - - #Write-Progress "Building ScriptAnalyzer" + Push-Location -Path $projectRoot if (-not (Test-Path "$projectRoot/global.json")) { throw "Not in solution root" @@ -191,51 +167,49 @@ function Start-ScriptAnalyzerBuild $destinationDir = "$projectRoot\out\PSScriptAnalyzer" # this is normalizing case as well as selecting the proper location - if ( $Framework -eq "core" ) { - $destinationDirBinaries = "$destinationDir\coreclr" - } - elseif ($PSVersion -eq '3') { + if ($PSVersion -eq '3') { $destinationDirBinaries = "$destinationDir\PSv3" } elseif ($PSVersion -eq '4') { $destinationDirBinaries = "$destinationDir\PSv4" } - else { + elseif ($PSVersion -eq '5') { $destinationDirBinaries = $destinationDir } + else { + $destinationDirBinaries = "$destinationDir\coreclr" + } # build the analyzer - #Write-Progress "Building for framework $Framework, configuration $Configuration" # The Rules project has a dependency on the Engine therefore just building the Rules project is enough $config = "PSV${PSVersion}${Configuration}" try { Push-Location $projectRoot/Rules - Write-Progress "Building ScriptAnalyzer '$framework' version '${PSVersion}' configuration '${Configuration}'" - $buildOutput = dotnet build Rules.csproj --framework $frameworkName --configuration "${config}" + Write-Progress "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$config'" + $buildOutput = dotnet build --framework $framework --configuration "${config}" if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" } } catch { - Write-Error "Failure to build $framework ${config}" + Write-Error "Failure to build for PSVersion '$PSVersion' using framework '$framework' and configuration '$config'" return } finally { Pop-Location } - #Write-Progress "Copying files to $destinationDir" Publish-File $itemsToCopyCommon $destinationDir $itemsToCopyBinaries = @( - "$projectRoot\Engine\bin\${config}\${frameworkName}\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll", - "$projectRoot\Rules\bin\${config}\${frameworkName}\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" + "$projectRoot\Engine\bin\${config}\${framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll", + "$projectRoot\Rules\bin\${config}\${framework}\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" ) Publish-File $itemsToCopyBinaries $destinationDirBinaries Publish-File $settingsFiles (Join-Path -Path $destinationDir -ChildPath Settings) # copy newtonsoft dll if net451 framework - if ($Framework -eq "full") { - Copy-Item -path "$projectRoot\Rules\bin\${config}\${frameworkName}\Newtonsoft.Json.dll" -Destination $destinationDirBinaries + if ($framework -eq "full") { + Copy-Item -path "$projectRoot\Rules\bin\${config}\${framework}\Newtonsoft.Json.dll" -Destination $destinationDirBinaries } Pop-Location @@ -256,7 +230,7 @@ function Test-ScriptAnalyzer try { $savedModulePath = $env:PSModulePath $env:PSModulePath = "${testModulePath}{0}${env:PSModulePath}" -f [System.IO.Path]::PathSeparator - $scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe") + $scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe,Summary") if ( $InProcess ) { & $scriptBlock } diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index cc8e15f81..7773b02ee 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -20,14 +20,15 @@ function Invoke-AppVeyorInstall { } } + $platyPSVersion = '0.12.0' if ($null -eq (Get-Module -ListAvailable PowershellGet)) { # WMF 4 image build Write-Verbose -Verbose "Installing platyPS via nuget" - nuget install platyPS -Version 0.9.0 -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion + nuget install platyPS -Version $platyPSVersion -source https://www.powershellgallery.com/api/v2 -outputDirectory "$Env:ProgramFiles\WindowsPowerShell\Modules\." -ExcludeVersion } else { Write-Verbose -Verbose "Installing platyPS via Install-Module" - Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion '0.9.0' + Install-Module -Name platyPS -Force -Scope CurrentUser -RequiredVersion $platyPSVersion } # the legacy WMF4 image only has the old preview SDKs of dotnet From 749138b704e7ecc134e9715f9899ac016fe46bf0 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 23 Oct 2018 23:06:46 +0100 Subject: [PATCH 02/13] add check for minimum version of platyps --- build.psm1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.psm1 b/build.psm1 index 7ce2acc8f..aeabfcf94 100644 --- a/build.psm1 +++ b/build.psm1 @@ -93,9 +93,9 @@ function Start-DocumentationBuild $docsPath = Join-Path $projectRoot docs $markdownDocsPath = Join-Path $docsPath markdown $outputDocsPath = Join-Path $destinationDir en-US - if ( $null -eq (Get-Module -ListAvailable platyPS)) + if ( $null -eq (Get-Module -ListAvailable platyPS) -or ((Get-Module -ListAvailable platyPS | Select-Object -First 1).Version -lt [version]0.12)) { - Write-Verbose -verbose "platyPS not found, installing" + Write-Verbose -verbose "platyPS module not found or below required version of 0.12, installing the latest version." Install-Module -Force -Name platyPS -Scope CurrentUser } if (-not (Test-Path $markdownDocsPath)) From 863b48b1f61aed29bd615d2cbee5e0da9b871a21 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 23 Oct 2018 23:13:10 +0100 Subject: [PATCH 03/13] fix ci and remove other leftovers --- README.md | 8 ++++---- Utils/ReleaseMaker.psm1 | 6 +----- appveyor.yml | 6 +++--- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f76aea8c4..10c159b32 100644 --- a/README.md +++ b/README.md @@ -129,19 +129,19 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c ``` * Windows PowerShell version 5.0 ```powershell - .\build.ps1 -PSVersion 5 -Configuration Release + .\build.ps1 -PSVersion 5 ``` * Windows PowerShell version 4.0 ```powershell - .\build.ps1 -PSVersion 4 -Configuration Release + .\build.ps1 -PSVersion 4 ``` * Windows PowerShell version 3.0 ```powershell - .\build.ps1 -PSVersion 3 -Configuration Release + .\build.ps1 -PSVersion 3 ``` * PowerShell Core ```powershell - .\buildCoreClr.ps1 -Configuration Release -Build + .\build.ps1 -PSVersion 6 ``` * Build documentation (required for using the module) ```powershell diff --git a/Utils/ReleaseMaker.psm1 b/Utils/ReleaseMaker.psm1 index 68868664a..8f2553839 100644 --- a/Utils/ReleaseMaker.psm1 +++ b/Utils/ReleaseMaker.psm1 @@ -93,11 +93,7 @@ function New-ReleaseBuild try { if ( test-path out ) { remove-item out/ -recurse -force } - .\buildCoreClr.ps1 -Framework net451 -Configuration PSV3Release -Build - .\buildCoreClr.ps1 -Framework net451 -Configuration PSV4Release -Build - .\buildCoreClr.ps1 -Framework net451 -Configuration Release -Build - .\buildCoreClr.ps1 -Framework netstandard2.0 -Configuration Release -Build - .\build.ps1 -BuildDocs + .\build.ps1 -All -Configuration Release } finally { diff --git a/appveyor.yml b/appveyor.yml index 49ed21b69..c831803d0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -36,15 +36,15 @@ build_script: Set-Location $env:APPVEYOR_BUILD_FOLDER ./build.ps1 -Documentation if ( $env:PSVersion -eq "4" ) { # On WMF4: Also build for v3 to check it builds at least since we do not have a WMF3 image - ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 3 -Framework full + ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 3 } - ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion "$env:PSVersion" -Framework full + ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion "$env:PSVersion" } - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { Set-Location $env:APPVEYOR_BUILD_FOLDER ./build.ps1 -Documentation - ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 5 -Framework core + ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 5 } test_script: From 95b4042521246accd3a0d9820df0e04cddfc614f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 23 Oct 2018 23:17:19 +0100 Subject: [PATCH 04/13] fix appveyor core build --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index c831803d0..5a82f912f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -44,7 +44,7 @@ build_script: if ($env:PowerShellEdition -eq 'PowerShellCore') { Set-Location $env:APPVEYOR_BUILD_FOLDER ./build.ps1 -Documentation - ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 5 + ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 6 } test_script: From 2c0326b00d5c614d1804b4ce56568e832100e066 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 23 Oct 2018 23:36:06 +0100 Subject: [PATCH 05/13] fix wmf4 build by including the newtonsoft dll --- build.psm1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/build.psm1 b/build.psm1 index aeabfcf94..ad633f2fd 100644 --- a/build.psm1 +++ b/build.psm1 @@ -207,8 +207,7 @@ function Start-ScriptAnalyzerBuild Publish-File $settingsFiles (Join-Path -Path $destinationDir -ChildPath Settings) - # copy newtonsoft dll if net451 framework - if ($framework -eq "full") { + if ($framework -eq net451) { Copy-Item -path "$projectRoot\Rules\bin\${config}\${framework}\Newtonsoft.Json.dll" -Destination $destinationDirBinaries } From 7d78b1a77974309423c54c8960782cbafd2f163f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 23 Oct 2018 23:45:40 +0100 Subject: [PATCH 06/13] fix syntax --- build.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index ad633f2fd..4e4e968a9 100644 --- a/build.psm1 +++ b/build.psm1 @@ -207,7 +207,7 @@ function Start-ScriptAnalyzerBuild Publish-File $settingsFiles (Join-Path -Path $destinationDir -ChildPath Settings) - if ($framework -eq net451) { + if ($framework -eq 'net451') { Copy-Item -path "$projectRoot\Rules\bin\${config}\${framework}\Newtonsoft.Json.dll" -Destination $destinationDirBinaries } From 3be79c7e81fdbb4dc811b7bab493c5250efefd4e Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 23 Oct 2018 23:47:17 +0100 Subject: [PATCH 07/13] trigger ci From 43113acabda779e95c8f00a674c130b60a80d75f Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 23 Oct 2018 23:51:31 +0100 Subject: [PATCH 08/13] trigger ci From 7517b5a6daa0d5c579abdb3e72d5d407605f9f12 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Wed, 19 Dec 2018 21:38:09 +0000 Subject: [PATCH 09/13] address PR comments --- build.psm1 | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/build.psm1 b/build.psm1 index 4e4e968a9..8da4c1e1c 100644 --- a/build.psm1 +++ b/build.psm1 @@ -93,7 +93,8 @@ function Start-DocumentationBuild $docsPath = Join-Path $projectRoot docs $markdownDocsPath = Join-Path $docsPath markdown $outputDocsPath = Join-Path $destinationDir en-US - if ( $null -eq (Get-Module -ListAvailable platyPS) -or ((Get-Module -ListAvailable platyPS | Select-Object -First 1).Version -lt [version]0.12)) + $platyPS = Get-Module -ListAvailable platyPS + if ($null -eq $platyPS -or ($platyPS | Sort-Object Version -Descending | Select-Object -First 1).Version -lt [version]0.12) { Write-Verbose -verbose "platyPS module not found or below required version of 0.12, installing the latest version." Install-Module -Force -Name platyPS -Scope CurrentUser @@ -166,27 +167,38 @@ function Start-ScriptAnalyzerBuild $settingsFiles = Get-Childitem "$projectRoot\Engine\Settings" | ForEach-Object -MemberName FullName $destinationDir = "$projectRoot\out\PSScriptAnalyzer" - # this is normalizing case as well as selecting the proper location - if ($PSVersion -eq '3') { - $destinationDirBinaries = "$destinationDir\PSv3" - } - elseif ($PSVersion -eq '4') { - $destinationDirBinaries = "$destinationDir\PSv4" - } - elseif ($PSVersion -eq '5') { - $destinationDirBinaries = $destinationDir - } - else { - $destinationDirBinaries = "$destinationDir\coreclr" + switch ($PSVersion) + { + 3 + { + $destinationDirBinaries = "$destinationDir\PSv3" + } + 4 + { + $destinationDirBinaries = "$destinationDir\PSv4" + } + 5 + { + $destinationDirBinaries = "$destinationDir" + } + 6 + { + $destinationDirBinaries = "$destinationDir\coreclr" + } + default + { + throw "Unsupported PSVersion: '$PSVersion'" + } } - # build the analyzer - # The Rules project has a dependency on the Engine therefore just building the Rules project is enough $config = "PSV${PSVersion}${Configuration}" + + # Build ScriptAnalyzer + # 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 '$config'" - $buildOutput = dotnet build --framework $framework --configuration "${config}" + Write-Progress "Building ScriptAnalyzer for PSVersion '$PSVersion' using framework '$framework' and configuration '$Configuration'" + $buildOutput = dotnet build --framework $framework --configuration "$config" if ( $LASTEXITCODE -ne 0 ) { throw "$buildOutput" } } catch { From c595fcc99c1ee5b42c538ae1be7c787692e954af Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Wed, 19 Dec 2018 22:09:09 +0000 Subject: [PATCH 10/13] build docs automatically the first time to simplify build process and save time on rebuild and get rid of unnecessary low level parameter sets --- README.md | 3 +-- appveyor.yml | 2 -- build.ps1 | 6 ++++-- build.psm1 | 11 +++-------- 4 files changed, 8 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 10c159b32..9198ade4b 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,7 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c ```powershell .\build.ps1 -PSVersion 6 ``` -* Build documentation (required for using the module) +* Rebuild documentation since it gets built automatically only the first time ```powershell .\build.ps1 -Documentation ``` @@ -166,7 +166,6 @@ For adding/removing resource strings in the `*.resx` files, it is recommended to Pester-based ScriptAnalyzer Tests are located in `path/to/PSScriptAnalyzer/Tests` folder. * Ensure [Pester 4.3.1](https://www.powershellgallery.com/packages/Pester/4.3.1) or higher is installed -* Ensure that the documentation has been built (`./build.ps1 -Documentation`) * In the root folder of your local repository, run: ``` PowerShell ./build -Test diff --git a/appveyor.yml b/appveyor.yml index e61713cad..0e3ec08d6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -24,7 +24,6 @@ build_script: - ps: | if ( $env:PowerShellEdition -eq 'WindowsPowerShell' ) { Set-Location $env:APPVEYOR_BUILD_FOLDER - ./build.ps1 -Documentation if ( $env:PSVersion -eq "4" ) { # On WMF4: Also build for v3 to check it builds at least since we do not have a WMF3 image ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 3 } @@ -33,7 +32,6 @@ build_script: - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { Set-Location $env:APPVEYOR_BUILD_FOLDER - ./build.ps1 -Documentation ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 6 } diff --git a/build.ps1 b/build.ps1 index a7b0e1cf5..2473146e2 100644 --- a/build.ps1 +++ b/build.ps1 @@ -15,7 +15,9 @@ param( [ValidateSet("Debug", "Release")] [string]$Configuration = "Debug", - [Parameter(ParameterSetName="BuildDoc")] + # For building documentation only + # or re-building it since docs gets built automatically only the first time + [Parameter(ParameterSetName="BuildDocumentation")] [switch]$Documentation, [Parameter(ParameterSetName='BuildAll')] @@ -46,7 +48,7 @@ END { "BuildAll" { Start-ScriptAnalyzerBuild -All -Configuration $Configuration } - "BuildDoc" { + "BuildDocumentation" { Start-ScriptAnalyzerBuild -Documentation } "BuildOne" { diff --git a/build.psm1 b/build.psm1 index 8da4c1e1c..1772cb023 100644 --- a/build.psm1 +++ b/build.psm1 @@ -115,19 +115,14 @@ function Start-ScriptAnalyzerBuild { [CmdletBinding(DefaultParameterSetName="BuildOne")] param ( - [Parameter(ParameterSetName="BuildAll")] [switch]$All, - [Parameter(ParameterSetName="BuildOne")] [ValidateRange(3, 6)] [int]$PSVersion = $PSVersionTable.PSVersion.Major, - [Parameter(ParameterSetName="BuildOne")] - [Parameter(ParameterSetName="BuildAll")] [ValidateSet("Debug", "Release")] [string]$Configuration = "Debug", - [Parameter(ParameterSetName="BuildDoc")] [switch]$Documentation ) @@ -138,14 +133,14 @@ function Start-ScriptAnalyzerBuild foreach($psVersion in 3..6) { Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion } - Start-ScriptAnalyzerBuild -Documentation return } - if ( $Documentation ) + $documentationFileExists = Test-Path (Join-Path $PSScriptRoot 'out\PSScriptAnalyzer\en-us\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll-Help.xml') + # Build docs either when -Documentation switch is being specified or the first time in a clean repo + if ( $Documentation -or -not $documentationFileExists ) { Start-DocumentationBuild - return } $framework = 'net451' From 3e532314067b20e1e24692c4c4984be7a397765d Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 15 Jan 2019 07:27:29 +0000 Subject: [PATCH 11/13] revert accidentally checked in file --- Engine/Helper.cs | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Engine/Helper.cs b/Engine/Helper.cs index 93239344a..b093d9c0f 100644 --- a/Engine/Helper.cs +++ b/Engine/Helper.cs @@ -11,7 +11,6 @@ using System.Linq; using System.Management.Automation; using System.Management.Automation.Language; -using System.Management.Automation.Runspaces; namespace Microsoft.Windows.PowerShell.ScriptAnalyzer { @@ -144,20 +143,6 @@ public void Initialize() if (commandInfoCache == null) { commandInfoCache = new Dictionary(); - - using (var ps = System.Management.Automation.PowerShell.Create()) - { - var psCommand = ps.AddCommand("Get-Command") - .AddParameter("All"); - - var commandInfos = psCommand.Invoke(); - foreach(var commandInfo in commandInfos) - { - var key = new CommandLookupKey(commandInfo.Name, commandInfo.CommandType); - commandInfoCache.Add(key, commandInfo); - } - } - } IEnumerable aliases = this.invokeCommand.GetCommands("*", CommandTypes.Alias, true); @@ -665,6 +650,7 @@ public bool PositionalParameterUsed(CommandAst cmdAst, bool moreThanTwoPositiona return moreThanTwoPositional ? argumentsWithoutProcedingParameters > 2 : argumentsWithoutProcedingParameters > 0; } + /// /// Get a CommandInfo object of the given command name /// From ac11bf5dece0f34a0cb0654dbb4cea4b250f1612 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Tue, 15 Jan 2019 22:29:06 +0000 Subject: [PATCH 12/13] fix merge/integration problem when merging from upstream --- build.psm1 | 1 - 1 file changed, 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index a01138e87..6a19f7aef 100644 --- a/build.psm1 +++ b/build.psm1 @@ -143,7 +143,6 @@ function Start-ScriptAnalyzerBuild Start-DocumentationBuild } - $framework = 'net451' if ($PSVersion -ge 6) { $framework = 'netstandard2.0' } From fa1c18adee259de0acd132e23cb613f0ab4c38c3 Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Wed, 16 Jan 2019 07:18:19 +0000 Subject: [PATCH 13/13] Fix another merge problem due to variable rename --- build.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.psm1 b/build.psm1 index 6a19f7aef..f9f216554 100644 --- a/build.psm1 +++ b/build.psm1 @@ -147,7 +147,7 @@ function Start-ScriptAnalyzerBuild $framework = 'netstandard2.0' } else { - $frameworkName = "net452" + $framework = "net452" } Push-Location -Path $projectRoot