From 965eca5c1f19056f9a57c6fa5e255dbabc4dc979 Mon Sep 17 00:00:00 2001 From: "Christoph Bergmeister [MVP]" Date: Tue, 10 Nov 2020 17:34:44 +0000 Subject: [PATCH] Remove conditional compilation for PSv6 and therefore netstandard2.0 for Engine and Rules projects (#1600) --- Engine/Engine.csproj | 12 +++--------- Engine/PSScriptAnalyzer.psm1 | 12 +++++------- README.md | 6 +++--- Rules/Rules.csproj | 21 +++++++-------------- appveyor.yml | 4 ++-- build.ps1 | 2 +- build.psm1 | 17 ++++------------- tools/releaseBuild/AssemblySignConfig.xml | 5 ----- tools/releaseBuild/signing.xml | 5 ----- 9 files changed, 25 insertions(+), 59 deletions(-) diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index 111224745..64a07032e 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -2,7 +2,7 @@ 1.19.1 - netcoreapp3.1;netstandard2.0;net452 + netcoreapp3.1;net452 Microsoft.Windows.PowerShell.ScriptAnalyzer 1.19.1 Engine @@ -17,11 +17,11 @@ portable - + $(DefineConstants);CORECLR - + @@ -68,12 +68,6 @@ $(DefineConstants);PSV7;CORECLR - - $(DefineConstants);PSV6;CORECLR - - - - diff --git a/Engine/PSScriptAnalyzer.psm1 b/Engine/PSScriptAnalyzer.psm1 index e98e1c88a..5d10735b5 100644 --- a/Engine/PSScriptAnalyzer.psm1 +++ b/Engine/PSScriptAnalyzer.psm1 @@ -9,15 +9,13 @@ $PSModuleRoot = $PSModule.ModuleBase # Import the appropriate nested binary module based on the current PowerShell version $binaryModuleRoot = $PSModuleRoot -if ($PSVersionTable.PSVersion.Major -eq 7 ) { - $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath "PSv$($PSVersionTable.PSVersion.Major)" -} -elseif ($PSVersionTable.PSVersion.Major -eq 6 ) { +[Version] $minimumPowerShellCoreVersion = '7.0.3' +if ($PSVersionTable.PSVersion.Major -ge 6) { $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath "PSv$($PSVersionTable.PSVersion.Major)" # Minimum PowerShell Core version given by PowerShell Core support itself and - # also the version of NewtonSoft.Json implicitly that PSSA ships with, - # which cannot be higher than the one that PowerShell ships with. - [Version] $minimumPowerShellCoreVersion = '6.2.4' + # the version of Nuget references, such as e.g. Newtonsoft.Json inside PowerShell itself + # or the version of the System.Management.Automation NuGet reference in PSSA. + if ($PSVersionTable.PSVersion -lt $minimumPowerShellCoreVersion) { throw "Minimum supported version of PSScriptAnalyzer for PowerShell Core is $minimumPowerShellCoreVersion but current version is '$($PSVersionTable.PSVersion)'. Please update PowerShell Core." } diff --git a/README.md b/README.md index a35d55177..bc8c8905f 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ Exit #### Supported PowerShell Versions and Platforms - Windows PowerShell 3.0 or greater -- PowerShell Core 6.2 or greater on Windows/Linux/macOS +- PowerShell Core 7.0.3 or greater on Windows/Linux/macOS - Docker (tested only using Docker Desktop on Windows 10 1809) - PowerShell 6 Windows Image tags from [mcr.microsoft.com/powershell](https://hub.docker.com/r/microsoft/powershell). Example (1 warning gets produced by `Save-Module` but can be ignored): @@ -141,9 +141,9 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c ```powershell .\build.ps1 -PSVersion 3 ``` - * PowerShell Core + * PowerShell 7 ```powershell - .\build.ps1 -PSVersion 6 + .\build.ps1 -PSVersion 7 ``` * Rebuild documentation since it gets built automatically only the first time ```powershell diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index 6d2bcbc88..2fcf8f225 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -2,7 +2,7 @@ 1.19.1 - netcoreapp3.1;netstandard2.0;net452 + netcoreapp3.1;net452 Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules 1.19.1 Rules @@ -15,6 +15,12 @@ + + + + + + @@ -24,10 +30,6 @@ portable - - $(DefineConstants);CORECLR - - True @@ -42,11 +44,6 @@ Strings.Designer.cs - - - - - $(DefineConstants);PSV3 @@ -60,8 +57,4 @@ $(DefineConstants);PSV7;CORECLR - - $(DefineConstants);PSV6;CORECLR - - diff --git a/appveyor.yml b/appveyor.yml index 884efd718..84f29a49f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,8 +35,8 @@ build_script: - pwsh: | if ($env:PowerShellEdition -eq 'PowerShellCore') { Set-Location $env:APPVEYOR_BUILD_FOLDER - ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 6 - ./PSCompatibilityCollector/build.ps1 -Configuration "$env:BuildConfiguration" -Framework 'netstandard2.0' + ./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 7 + ./PSCompatibilityCollector/build.ps1 -Configuration "$env:BuildConfiguration" -Framework 'netcoreapp3.1' } test_script: diff --git a/build.ps1 b/build.ps1 index 3cf8cad8e..1f4687b84 100644 --- a/build.ps1 +++ b/build.ps1 @@ -7,7 +7,7 @@ param( [switch]$All, [Parameter(ParameterSetName="BuildOne")] - [ValidateRange(3, 7)] + [ValidateSet(3, 4, 5, 7)] [int]$PSVersion = $PSVersionTable.PSVersion.Major, [Parameter(ParameterSetName="BuildOne")] diff --git a/build.psm1 b/build.psm1 index 3056abb6b..8a61674ee 100644 --- a/build.psm1 +++ b/build.psm1 @@ -144,7 +144,7 @@ function Start-ScriptAnalyzerBuild param ( [switch]$All, - [ValidateRange(3, 7)] + [ValidateSet(3, 4, 5, 7)] [int]$PSVersion = $PSVersionTable.PSVersion.Major, [ValidateSet("Debug", "Release")] @@ -183,7 +183,7 @@ function Start-ScriptAnalyzerBuild if ( $All ) { # Build all the versions of the analyzer - foreach($psVersion in 3..7) { + foreach ($psVersion in 3, 4, 5, 7) { Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion -Verbose:$verboseWanted } if ( $Catalog ) { @@ -200,15 +200,10 @@ function Start-ScriptAnalyzerBuild Set-Variable -Name profilesCopied -Value $true -Scope 1 } + $framework = 'net452' if ($PSVersion -eq 7) { $framework = 'netcoreapp3.1' } - elseif ($PSVersion -eq 6) { - $framework = 'netstandard2.0' - } - else { - $framework = "net452" - } # build the appropriate assembly if ($PSVersion -match "[34]" -and $Framework -ne "net452") @@ -241,10 +236,6 @@ function Start-ScriptAnalyzerBuild { $destinationDirBinaries = "$script:destinationDir" } - 6 - { - $destinationDirBinaries = "$script:destinationDir\PSv6" - } 7 { $destinationDirBinaries = "$script:destinationDir\PSv7" @@ -256,7 +247,7 @@ function Start-ScriptAnalyzerBuild } $buildConfiguration = $Configuration - if ((3, 4, 6, 7) -contains $PSVersion) { + if ((3, 4, 7) -contains $PSVersion) { $buildConfiguration = "PSV${PSVersion}${Configuration}" } diff --git a/tools/releaseBuild/AssemblySignConfig.xml b/tools/releaseBuild/AssemblySignConfig.xml index cd5678d30..a3f2e3f1c 100644 --- a/tools/releaseBuild/AssemblySignConfig.xml +++ b/tools/releaseBuild/AssemblySignConfig.xml @@ -20,11 +20,6 @@ - - - - - diff --git a/tools/releaseBuild/signing.xml b/tools/releaseBuild/signing.xml index 4a224b8a5..c6d35f47e 100644 --- a/tools/releaseBuild/signing.xml +++ b/tools/releaseBuild/signing.xml @@ -20,11 +20,6 @@ - - - - -