From c485f588c143611e7972e2dea8466fd2b100e398 Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 3 Mar 2020 15:11:27 -0800 Subject: [PATCH 01/12] Changes to break up coreclr build into PS6 and PS7 Since there are language changes in ps7, it seemed reasonable that distinct rules would be created to support these, which are not going to be in ps6 --- Engine/Engine.csproj | 28 +++++++++-- Engine/PSScriptAnalyzer.psd1 | 2 +- Engine/PSScriptAnalyzer.psm1 | 8 ++- Rules/Rules.csproj | 36 +++++++++++-- build.ps1 | 8 +-- build.psm1 | 21 +++++--- tools/releaseBuild/FileCatalogSigning.xml | 2 +- tools/releaseBuild/signing.xml | 61 ++++++++++++----------- 8 files changed, 114 insertions(+), 52 deletions(-) diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index d2afcc430..88c01966e 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -1,8 +1,8 @@  - 1.18.3 - netstandard2.0;net452 + 1.18.4 + netcoreapp3.1;netstandard2.0;net452 Microsoft.Windows.PowerShell.ScriptAnalyzer Engine Microsoft.Windows.PowerShell.ScriptAnalyzer @@ -61,7 +61,29 @@ - + + + + + $(DefineConstants);PSV7;CORECLR + + + $(DefineConstants);PSV6;CORECLR + + + + + + + + + + $(DefineConstants);PSV7;CORECLR + + + $(DefineConstants);PSV6;CORECLR + + diff --git a/Engine/PSScriptAnalyzer.psd1 b/Engine/PSScriptAnalyzer.psd1 index 60c1ed3fa..269f43852 100644 --- a/Engine/PSScriptAnalyzer.psd1 +++ b/Engine/PSScriptAnalyzer.psd1 @@ -11,7 +11,7 @@ Author = 'Microsoft Corporation' RootModule = 'PSScriptAnalyzer.psm1' # Version number of this module. -ModuleVersion = '1.18.3' +ModuleVersion = '1.18.4' # ID used to uniquely identify this module GUID = 'd6245802-193d-4068-a631-8863a4342a18' diff --git a/Engine/PSScriptAnalyzer.psm1 b/Engine/PSScriptAnalyzer.psm1 index 899f98551..1037c4370 100644 --- a/Engine/PSScriptAnalyzer.psm1 +++ b/Engine/PSScriptAnalyzer.psm1 @@ -11,8 +11,12 @@ $PSModuleRoot = $PSModule.ModuleBase $binaryModuleRoot = $PSModuleRoot -if (($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop')) { - $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'coreclr' +# if (($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop')) { +if ($PSVersionTable.PSVersion.Major -eq 7 ) { + $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath "PSv$($PSVersionTable.PSVersion.Major)" +} +elseif ($PSVersionTable.PSVersion.Major -eq 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. diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index 45ebf81d6..418cd0d59 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -1,8 +1,8 @@  - 1.18.3 - netstandard2.0;net452 + 1.18.4 + netcoreapp3.1;netstandard2.0;net452 Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules Rules Microsoft.Windows.PowerShell.ScriptAnalyzer @@ -10,8 +10,8 @@ - - + + @@ -42,7 +42,7 @@ - + @@ -67,4 +67,30 @@ $(DefineConstants);PSV3;PSV4 + + $(DefineConstants);PSV7;CORECLR + + + + + + $(DefineConstants);PSV6;CORECLR + + + + + + + $(DefineConstants);PSV7;CORECLR + + + + + + $(DefineConstants);PSV6;CORECLR + + + + + diff --git a/build.ps1 b/build.ps1 index 14e8a03ee..339ae25f5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -37,10 +37,10 @@ param( [switch] $Bootstrap ) BEGIN { - if ($PSVersion -gt 6) { - # due to netstandard2.0 we do not need to treat PS version 7 differently - $PSVersion = 6 - } + #if ($PSVersion -gt 6) { + # # due to netstandard2.0 we do not need to treat PS version 7 differently + # $PSVersion = 6 + #} } END { diff --git a/build.psm1 b/build.psm1 index 54b5d426b..5a85e3187 100644 --- a/build.psm1 +++ b/build.psm1 @@ -144,9 +144,7 @@ function Start-ScriptAnalyzerBuild param ( [switch]$All, - # Note that 6 should also be chosen for PowerShell7 as both implement netstandard2.0 - # and we do not use features from netstandard2.1 - [ValidateRange(3, 6)] + [ValidateRange(3, 7)] [int]$PSVersion = $PSVersionTable.PSVersion.Major, [ValidateSet("Debug", "Release")] @@ -178,7 +176,7 @@ function Start-ScriptAnalyzerBuild if ( $All ) { # Build all the versions of the analyzer - foreach($psVersion in 3..6) { + foreach($psVersion in 3..7) { Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion } return @@ -191,7 +189,10 @@ function Start-ScriptAnalyzerBuild Set-Variable -Name profilesCopied -Value $true -Scope 1 } - if ($PSVersion -ge 6) { + if ($PSVersion -eq 7) { + $framework = 'netcoreapp3.1' + } + elseif ($PSVersion -eq 6) { $framework = 'netstandard2.0' } else { @@ -199,7 +200,7 @@ function Start-ScriptAnalyzerBuild } # build the appropriate assembly - if ($PSVersion -match "[34]" -and $Framework -eq "core") + if ($PSVersion -match "[34]" -and $Framework -ne "net452") { throw ("ScriptAnalyzer for PS version '{0}' is not applicable to {1} framework" -f $PSVersion,$Framework) } @@ -231,7 +232,11 @@ function Start-ScriptAnalyzerBuild } 6 { - $destinationDirBinaries = "$script:destinationDir\coreclr" + $destinationDirBinaries = "$script:destinationDir\PSv6" + } + 7 + { + $destinationDirBinaries = "$script:destinationDir\PSv7" } default { @@ -240,7 +245,7 @@ function Start-ScriptAnalyzerBuild } $buildConfiguration = $Configuration - if ((3, 4) -contains $PSVersion) { + if ((3, 4, 6, 7) -contains $PSVersion) { $buildConfiguration = "PSV${PSVersion}${Configuration}" } diff --git a/tools/releaseBuild/FileCatalogSigning.xml b/tools/releaseBuild/FileCatalogSigning.xml index 00a95b369..9621e0c66 100644 --- a/tools/releaseBuild/FileCatalogSigning.xml +++ b/tools/releaseBuild/FileCatalogSigning.xml @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - - - + + + From 0ec56c107b9c124c387cf86fd5c4d385cdd81aee Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 3 Mar 2020 15:21:42 -0800 Subject: [PATCH 02/12] move docker file changes from buildfeb2020 branch --- tools/releaseBuild/Image/DockerFile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/releaseBuild/Image/DockerFile b/tools/releaseBuild/Image/DockerFile index 96ad83433..6117ef3bd 100644 --- a/tools/releaseBuild/Image/DockerFile +++ b/tools/releaseBuild/Image/DockerFile @@ -1,7 +1,7 @@ # escape=` #0.3.6 (no powershell 6) # FROM microsoft/windowsservercore -FROM microsoft/dotnet-framework:4.7.1 +FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 LABEL maintainer='PowerShell Team ' LABEL description="This Dockerfile for Windows Server Core with git installed via chocolatey." @@ -14,6 +14,7 @@ COPY dockerInstall.psm1 containerFiles/dockerInstall.psm1 RUN Import-Module PackageManagement; ` Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force; ` Import-Module ./containerFiles/dockerInstall.psm1; ` + [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor [System.Net.SecurityProtocolType]::Tls12; ` Install-ChocolateyPackage -PackageName git -Executable git.exe; ` Install-ChocolateyPackage -PackageName nuget.commandline -Executable nuget.exe -Cleanup; ` Install-Module -Force -Name platyPS -Repository PSGallery; ` @@ -21,12 +22,12 @@ RUN Import-Module PackageManagement; ` C:/dotnet-install.ps1 -Channel Release -Version 2.1.4; ` Add-Path C:/Users/ContainerAdministrator/AppData/Local/Microsoft/dotnet; -RUN Import-Module ./containerFiles/dockerInstall.psm1; ` +#RUN Import-Module ./containerFiles/dockerInstall.psm1; ` # git clone https://Github.com/PowerShell/PSScriptAnalyzer; ` - Install-ChocolateyPackage -PackageName dotnet4.5; +# Install-ChocolateyPackage -PackageName dotnet4.5; -RUN Import-Module ./containerFiles/dockerInstall.psm1; ` - Install-ChocolateyPackage -PackageName netfx-4.5.2-devpack; +#RUN Import-Module ./containerFiles/dockerInstall.psm1; ` +# Install-ChocolateyPackage -PackageName netfx-4.5.2-devpack; COPY buildPSSA.ps1 containerFiles/buildPSSA.ps1 From d9e71388ad86af577a8bc956fff1a9fe04874b92 Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 3 Mar 2020 15:52:43 -0800 Subject: [PATCH 03/12] use final version of 7 sdk --- Engine/Engine.csproj | 4 ++-- Rules/Rules.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index 88c01966e..506b974ed 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -62,7 +62,7 @@ - + $(DefineConstants);PSV7;CORECLR @@ -75,7 +75,7 @@ - + $(DefineConstants);PSV7;CORECLR diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index 418cd0d59..24fb483b2 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -71,7 +71,7 @@ $(DefineConstants);PSV7;CORECLR - + $(DefineConstants);PSV6;CORECLR @@ -84,7 +84,7 @@ $(DefineConstants);PSV7;CORECLR - + $(DefineConstants);PSV6;CORECLR From c15e80900ef1c63efaba8c2e71b37cd0d6b01fe7 Mon Sep 17 00:00:00 2001 From: James Truher Date: Tue, 3 Mar 2020 18:16:15 -0800 Subject: [PATCH 04/12] back to sdk 3.1.101 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 1e85f0e0e..775c52f92 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.102" + "version": "3.1.101" } } From 9a0cb550eb6fa8ce191be3fd6d8b3bd6b8d18c22 Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 4 Mar 2020 10:37:13 -0800 Subject: [PATCH 05/12] back off to 3.1.101 --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 1e85f0e0e..775c52f92 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.102" + "version": "3.1.101" } } From cb178e102ffebecc8d61b0783d9f32479a60ff6d Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 4 Mar 2020 13:41:02 -0800 Subject: [PATCH 06/12] Bring version up to 1.19.0 --- Engine/Engine.csproj | 2 +- Engine/PSScriptAnalyzer.psd1 | 2 +- Rules/Rules.csproj | 2 +- tools/releaseBuild/FileCatalogSigning.xml | 2 +- tools/releaseBuild/signing.xml | 58 +++++++++++------------ 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index 506b974ed..f0a3fe2a0 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -1,7 +1,7 @@  - 1.18.4 + 1.19.0 netcoreapp3.1;netstandard2.0;net452 Microsoft.Windows.PowerShell.ScriptAnalyzer Engine diff --git a/Engine/PSScriptAnalyzer.psd1 b/Engine/PSScriptAnalyzer.psd1 index 269f43852..716464e34 100644 --- a/Engine/PSScriptAnalyzer.psd1 +++ b/Engine/PSScriptAnalyzer.psd1 @@ -11,7 +11,7 @@ Author = 'Microsoft Corporation' RootModule = 'PSScriptAnalyzer.psm1' # Version number of this module. -ModuleVersion = '1.18.4' +ModuleVersion = '1.19.0' # ID used to uniquely identify this module GUID = 'd6245802-193d-4068-a631-8863a4342a18' diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index 24fb483b2..c13e297d7 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -1,7 +1,7 @@  - 1.18.4 + 1.19.0 netcoreapp3.1;netstandard2.0;net452 Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules Rules diff --git a/tools/releaseBuild/FileCatalogSigning.xml b/tools/releaseBuild/FileCatalogSigning.xml index 9621e0c66..6fc649112 100644 --- a/tools/releaseBuild/FileCatalogSigning.xml +++ b/tools/releaseBuild/FileCatalogSigning.xml @@ -2,7 +2,7 @@ - + - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + From c3b2a4cbad0b53f357dc66416b0606923732e7dc Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 11 Mar 2020 13:04:59 -0700 Subject: [PATCH 07/12] bump minimum ps6 to 6.2.4 --- Engine/PSScriptAnalyzer.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/PSScriptAnalyzer.psm1 b/Engine/PSScriptAnalyzer.psm1 index 1037c4370..24c6439b3 100644 --- a/Engine/PSScriptAnalyzer.psm1 +++ b/Engine/PSScriptAnalyzer.psm1 @@ -20,7 +20,7 @@ elseif ($PSVersionTable.PSVersion.Major -eq 6 ) { # 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.1' + [Version] $minimumPowerShellCoreVersion = '6.2.4' 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." } From 255b70d69964a68465b74dde882b3e05ab4ca985 Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 11 Mar 2020 13:16:57 -0700 Subject: [PATCH 08/12] use downlevel newtonsoft library for PS6 --- Rules/Rules.csproj | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index c13e297d7..aadb37e6f 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -8,7 +8,13 @@ Microsoft.Windows.PowerShell.ScriptAnalyzer - + + + + + + + From 147700b2329941c4aa9ed09db7b79628bdfcb21e Mon Sep 17 00:00:00 2001 From: James Truher Date: Wed, 11 Mar 2020 13:18:07 -0700 Subject: [PATCH 09/12] remove commented code in dockerfile --- tools/releaseBuild/Image/DockerFile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tools/releaseBuild/Image/DockerFile b/tools/releaseBuild/Image/DockerFile index 6117ef3bd..771b8c9fb 100644 --- a/tools/releaseBuild/Image/DockerFile +++ b/tools/releaseBuild/Image/DockerFile @@ -22,13 +22,6 @@ RUN Import-Module PackageManagement; ` C:/dotnet-install.ps1 -Channel Release -Version 2.1.4; ` Add-Path C:/Users/ContainerAdministrator/AppData/Local/Microsoft/dotnet; -#RUN Import-Module ./containerFiles/dockerInstall.psm1; ` -# git clone https://Github.com/PowerShell/PSScriptAnalyzer; ` -# Install-ChocolateyPackage -PackageName dotnet4.5; - -#RUN Import-Module ./containerFiles/dockerInstall.psm1; ` -# Install-ChocolateyPackage -PackageName netfx-4.5.2-devpack; - COPY buildPSSA.ps1 containerFiles/buildPSSA.ps1 ENTRYPOINT ["C:\\windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe", "-command"] From 3178e742226b24c388e133fbbdf829b6ea1c3192 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Tue, 31 Mar 2020 09:19:49 -0700 Subject: [PATCH 10/12] Address @bergmeister's comments --- .vscode/settings.json | 4 ++-- Engine/PSScriptAnalyzer.psm1 | 3 --- Rules/Rules.csproj | 21 +++++++++++---------- build.ps1 | 6 ------ 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d5989ce35..d55f534ff 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,7 +8,7 @@ "search.exclude": { "**/node_modules": true, "**/bower_components": true, - "/PSCompatibilityAnalyzer/profiles": true, - "/PSCompatibilityAnalyzer/optional_profiles": true + "/PSCompatibilityCollector/profiles": true, + "/PSCompatibilityCollector/optional_profiles": true } } \ No newline at end of file diff --git a/Engine/PSScriptAnalyzer.psm1 b/Engine/PSScriptAnalyzer.psm1 index 24c6439b3..e98e1c88a 100644 --- a/Engine/PSScriptAnalyzer.psm1 +++ b/Engine/PSScriptAnalyzer.psm1 @@ -9,9 +9,6 @@ $PSModuleRoot = $PSModule.ModuleBase # Import the appropriate nested binary module based on the current PowerShell version $binaryModuleRoot = $PSModuleRoot - - -# if (($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop')) { if ($PSVersionTable.PSVersion.Major -eq 7 ) { $binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath "PSv$($PSVersionTable.PSVersion.Major)" } diff --git a/Rules/Rules.csproj b/Rules/Rules.csproj index aadb37e6f..edc553591 100644 --- a/Rules/Rules.csproj +++ b/Rules/Rules.csproj @@ -8,19 +8,18 @@ Microsoft.Windows.PowerShell.ScriptAnalyzer - + - - + + - - - + + @@ -53,10 +52,6 @@ - - - - $(DefineConstants);PSV3 @@ -76,12 +71,15 @@ $(DefineConstants);PSV7;CORECLR + + $(DefineConstants);PSV6;CORECLR + @@ -89,12 +87,15 @@ $(DefineConstants);PSV7;CORECLR + + $(DefineConstants);PSV6;CORECLR + diff --git a/build.ps1 b/build.ps1 index 339ae25f5..94f3cbf4e 100644 --- a/build.ps1 +++ b/build.ps1 @@ -36,12 +36,6 @@ param( [Parameter(ParameterSetName='Bootstrap')] [switch] $Bootstrap ) -BEGIN { - #if ($PSVersion -gt 6) { - # # due to netstandard2.0 we do not need to treat PS version 7 differently - # $PSVersion = 6 - #} -} END { Import-Module -Force (Join-Path $PSScriptRoot build.psm1) From 64577dd7ab5cac747a63212c770be9f60441f938 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Tue, 31 Mar 2020 12:06:08 -0700 Subject: [PATCH 11/12] Move to SMA reference --- Engine/Engine.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index f0a3fe2a0..9e3d6e4a3 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -62,7 +62,7 @@ - + $(DefineConstants);PSV7;CORECLR @@ -75,7 +75,7 @@ - + $(DefineConstants);PSV7;CORECLR From 94c0ecd65fb4f6f8a6b97da4b29933946fb2e656 Mon Sep 17 00:00:00 2001 From: Robert Holt Date: Tue, 31 Mar 2020 12:25:43 -0700 Subject: [PATCH 12/12] Ensure SafeDirectoryCatalogue is not compiled in netcoreapp3.1 --- Engine/Engine.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/Engine.csproj b/Engine/Engine.csproj index 9e3d6e4a3..5884ff39b 100644 --- a/Engine/Engine.csproj +++ b/Engine/Engine.csproj @@ -20,7 +20,7 @@ $(DefineConstants);CORECLR - +