Skip to content

Commit 965eca5

Browse files
authored
Remove conditional compilation for PSv6 and therefore netstandard2.0 for Engine and Rules projects (#1600)
1 parent a0f9822 commit 965eca5

File tree

9 files changed

+25
-59
lines changed

9 files changed

+25
-59
lines changed

Engine/Engine.csproj

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<VersionPrefix>1.19.1</VersionPrefix>
5-
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net452</TargetFrameworks>
5+
<TargetFrameworks>netcoreapp3.1;net452</TargetFrameworks>
66
<AssemblyName>Microsoft.Windows.PowerShell.ScriptAnalyzer</AssemblyName>
77
<AssemblyVersion>1.19.1</AssemblyVersion>
88
<PackageId>Engine</PackageId>
@@ -17,11 +17,11 @@
1717
<DebugType>portable</DebugType>
1818
</PropertyGroup>
1919

20-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netcoreapp3.1' ">
20+
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
2121
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
2222
</PropertyGroup>
2323

24-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netcoreapp3.1' ">
24+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
2525
<Compile Remove="SafeDirectoryCatalog.cs" />
2626
</ItemGroup>
2727

@@ -68,12 +68,6 @@
6868
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
6969
<DefineConstants>$(DefineConstants);PSV7;CORECLR</DefineConstants>
7070
</PropertyGroup>
71-
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
72-
<DefineConstants>$(DefineConstants);PSV6;CORECLR</DefineConstants>
73-
</PropertyGroup>
74-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
75-
<PackageReference Include="System.Management.Automation" Version="6.1.0" />
76-
</ItemGroup>
7771

7872
<ItemGroup Condition="'$(TargetFramework)' == 'net452' AND '$(Configuration)' == 'PSV3Release' AND '$(Configuration)' != 'PSV4Release'">
7973
<PackageReference Include="Microsoft.PowerShell.3.ReferenceAssemblies" Version="1.0.0" />

Engine/PSScriptAnalyzer.psm1

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ $PSModuleRoot = $PSModule.ModuleBase
99

1010
# Import the appropriate nested binary module based on the current PowerShell version
1111
$binaryModuleRoot = $PSModuleRoot
12-
if ($PSVersionTable.PSVersion.Major -eq 7 ) {
13-
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath "PSv$($PSVersionTable.PSVersion.Major)"
14-
}
15-
elseif ($PSVersionTable.PSVersion.Major -eq 6 ) {
12+
[Version] $minimumPowerShellCoreVersion = '7.0.3'
13+
if ($PSVersionTable.PSVersion.Major -ge 6) {
1614
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath "PSv$($PSVersionTable.PSVersion.Major)"
1715
# Minimum PowerShell Core version given by PowerShell Core support itself and
18-
# also the version of NewtonSoft.Json implicitly that PSSA ships with,
19-
# which cannot be higher than the one that PowerShell ships with.
20-
[Version] $minimumPowerShellCoreVersion = '6.2.4'
16+
# the version of Nuget references, such as e.g. Newtonsoft.Json inside PowerShell itself
17+
# or the version of the System.Management.Automation NuGet reference in PSSA.
18+
2119
if ($PSVersionTable.PSVersion -lt $minimumPowerShellCoreVersion) {
2220
throw "Minimum supported version of PSScriptAnalyzer for PowerShell Core is $minimumPowerShellCoreVersion but current version is '$($PSVersionTable.PSVersion)'. Please update PowerShell Core."
2321
}

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Exit
7777
#### Supported PowerShell Versions and Platforms
7878

7979
- Windows PowerShell 3.0 or greater
80-
- PowerShell Core 6.2 or greater on Windows/Linux/macOS
80+
- PowerShell Core 7.0.3 or greater on Windows/Linux/macOS
8181
- Docker (tested only using Docker Desktop on Windows 10 1809)
8282
- 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):
8383

@@ -141,9 +141,9 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c
141141
```powershell
142142
.\build.ps1 -PSVersion 3
143143
```
144-
* PowerShell Core
144+
* PowerShell 7
145145
```powershell
146-
.\build.ps1 -PSVersion 6
146+
.\build.ps1 -PSVersion 7
147147
```
148148
* Rebuild documentation since it gets built automatically only the first time
149149
```powershell

Rules/Rules.csproj

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<VersionPrefix>1.19.1</VersionPrefix>
5-
<TargetFrameworks>netcoreapp3.1;netstandard2.0;net452</TargetFrameworks>
5+
<TargetFrameworks>netcoreapp3.1;net452</TargetFrameworks>
66
<AssemblyName>Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules</AssemblyName>
77
<AssemblyVersion>1.19.1</AssemblyVersion>
88
<PackageId>Rules</PackageId>
@@ -15,6 +15,12 @@
1515
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
1616
</ItemGroup>
1717

18+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
19+
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
20+
<PackageReference Include="Microsoft.Management.Infrastructure" Version="2.0.0" />
21+
<Compile Remove="UseSingularNouns.cs" />
22+
</ItemGroup>
23+
1824
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
1925
<Reference Include="System.ComponentModel.Composition" />
2026
<Reference Include="System.Data.Entity.Design" />
@@ -24,10 +30,6 @@
2430
<DebugType>portable</DebugType>
2531
</PropertyGroup>
2632

27-
<PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
28-
<DefineConstants>$(DefineConstants);CORECLR</DefineConstants>
29-
</PropertyGroup>
30-
3133
<ItemGroup>
3234
<Compile Update="Strings.Designer.cs">
3335
<DesignTime>True</DesignTime>
@@ -42,11 +44,6 @@
4244
<LastGenOutput>Strings.Designer.cs</LastGenOutput>
4345
</EmbeddedResource>
4446
</ItemGroup>
45-
46-
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'netcoreapp3.1'">
47-
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.7.0" />
48-
<Compile Remove="UseSingularNouns.cs" />
49-
</ItemGroup>
5047

5148
<PropertyGroup Condition=" '$(Configuration)' == 'PSV3Release' OR '$(Configuration)' == 'PSV3Debug'">
5249
<DefineConstants>$(DefineConstants);PSV3</DefineConstants>
@@ -60,8 +57,4 @@
6057
<DefineConstants>$(DefineConstants);PSV7;CORECLR</DefineConstants>
6158
</PropertyGroup>
6259

63-
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
64-
<DefineConstants>$(DefineConstants);PSV6;CORECLR</DefineConstants>
65-
</PropertyGroup>
66-
6760
</Project>

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ build_script:
3535
- pwsh: |
3636
if ($env:PowerShellEdition -eq 'PowerShellCore') {
3737
Set-Location $env:APPVEYOR_BUILD_FOLDER
38-
./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 6
39-
./PSCompatibilityCollector/build.ps1 -Configuration "$env:BuildConfiguration" -Framework 'netstandard2.0'
38+
./build.ps1 -Configuration "$env:BuildConfiguration" -PSVersion 7
39+
./PSCompatibilityCollector/build.ps1 -Configuration "$env:BuildConfiguration" -Framework 'netcoreapp3.1'
4040
}
4141
4242
test_script:

build.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ param(
77
[switch]$All,
88

99
[Parameter(ParameterSetName="BuildOne")]
10-
[ValidateRange(3, 7)]
10+
[ValidateSet(3, 4, 5, 7)]
1111
[int]$PSVersion = $PSVersionTable.PSVersion.Major,
1212

1313
[Parameter(ParameterSetName="BuildOne")]

build.psm1

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function Start-ScriptAnalyzerBuild
144144
param (
145145
[switch]$All,
146146

147-
[ValidateRange(3, 7)]
147+
[ValidateSet(3, 4, 5, 7)]
148148
[int]$PSVersion = $PSVersionTable.PSVersion.Major,
149149

150150
[ValidateSet("Debug", "Release")]
@@ -183,7 +183,7 @@ function Start-ScriptAnalyzerBuild
183183
if ( $All )
184184
{
185185
# Build all the versions of the analyzer
186-
foreach($psVersion in 3..7) {
186+
foreach ($psVersion in 3, 4, 5, 7) {
187187
Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion -Verbose:$verboseWanted
188188
}
189189
if ( $Catalog ) {
@@ -200,15 +200,10 @@ function Start-ScriptAnalyzerBuild
200200
Set-Variable -Name profilesCopied -Value $true -Scope 1
201201
}
202202

203+
$framework = 'net452'
203204
if ($PSVersion -eq 7) {
204205
$framework = 'netcoreapp3.1'
205206
}
206-
elseif ($PSVersion -eq 6) {
207-
$framework = 'netstandard2.0'
208-
}
209-
else {
210-
$framework = "net452"
211-
}
212207

213208
# build the appropriate assembly
214209
if ($PSVersion -match "[34]" -and $Framework -ne "net452")
@@ -241,10 +236,6 @@ function Start-ScriptAnalyzerBuild
241236
{
242237
$destinationDirBinaries = "$script:destinationDir"
243238
}
244-
6
245-
{
246-
$destinationDirBinaries = "$script:destinationDir\PSv6"
247-
}
248239
7
249240
{
250241
$destinationDirBinaries = "$script:destinationDir\PSv7"
@@ -256,7 +247,7 @@ function Start-ScriptAnalyzerBuild
256247
}
257248

258249
$buildConfiguration = $Configuration
259-
if ((3, 4, 6, 7) -contains $PSVersion) {
250+
if ((3, 4, 7) -contains $PSVersion) {
260251
$buildConfiguration = "PSV${PSVersion}${Configuration}"
261252
}
262253

tools/releaseBuild/AssemblySignConfig.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\Settings\ScriptingStyle.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\Settings\ScriptingStyle.psd1" />
2121
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\Settings\ScriptSecurity.psd1" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\Settings\ScriptSecurity.psd1" />
2222
</job>
23-
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer PSv6" approvers="vigarg;gstolt">
24-
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" />
25-
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" />
26-
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.PowerShell.CrossCompatibility.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.PowerShell.CrossCompatibility.dll" />
27-
</job>
2823
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer PSv7" approvers="vigarg;gstolt">
2924
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" />
3025
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="400" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" />

tools/releaseBuild/signing.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\Settings\ScriptingStyle.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\Settings\ScriptingStyle.psd1" />
2121
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\Settings\ScriptSecurity.psd1" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\Settings\ScriptSecurity.psd1" />
2222
</job>
23-
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer PSv6" approvers="vigarg;gstolt">
24-
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" />
25-
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" />
26-
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.PowerShell.CrossCompatibility.dll" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv6\Microsoft.PowerShell.CrossCompatibility.dll" />
27-
</job>
2823
<job platform="" configuration="" dest="__OUTPATHROOT__\signed" jobname="PowerShell Script Analyzer PSv7" approvers="vigarg;gstolt">
2924
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.dll" />
3025
<file src="__INPATHROOT__\out\PSScriptAnalyzer\1.19.1\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" signType="Authenticode" dest="__OUTPATHROOT__\PSScriptAnalyzer\1.19.1\PSv7\Microsoft.Windows.PowerShell.ScriptAnalyzer.dll" />

0 commit comments

Comments
 (0)