Skip to content

Commit e849068

Browse files
Drop v3 and v4 support from build (#2081)
Co-authored-by: Christoph Bergmeister <c.bergmeister@gmail.com>
1 parent 73455be commit e849068

File tree

7 files changed

+13
-65
lines changed

7 files changed

+13
-65
lines changed

Directory.Packages.props

+1-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
<!-- Newtonsoft.Json brings in an old version of CSharp. So, we are forcing a newer version. -->
44
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
55
<PackageVersion Include="Microsoft.Management.Infrastructure" Version="3.0.0" />
6-
<PackageVersion Include="Microsoft.PowerShell.3.ReferenceAssemblies" Version="1.0.0" />
7-
<PackageVersion Include="Microsoft.PowerShell.4.ReferenceAssemblies" Version="1.0.0" />
86
<PackageVersion Include="Microsoft.PowerShell.5.ReferenceAssemblies" Version="1.1.0" />
97
<PackageVersion Include="Microsoft.Win32.Registry" Version="5.0.0" />
108
<!-- The version of Newtonsoft.Json needs to be newer than the version in the oldest supported version of PowerShell 7: https://github.com/PowerShell/PowerShell/blob/v7.2.17/src/System.Management.Automation/System.Management.Automation.csproj#L15 -->
119
<PackageVersion Include="Newtonsoft.Json" Version="13.0.3" />
1210
<PackageVersion Include="Pluralize.NET" Version="1.0.2" />
13-
<PackageVersion Include="PowerShellStandard.Library" Version="3.0.0-preview-02" />
11+
<PackageVersion Include="PowerShellStandard.Library" Version="5.1.1" />
1412
<PackageVersion Include="System.Management.Automation" Version="7.4.7" />
1513
<PackageVersion Include="System.Reflection.TypeExtensions" Version="4.7.0" />
1614
</ItemGroup>

Engine/Engine.csproj

+1-25
Original file line numberDiff line numberDiff line change
@@ -75,33 +75,9 @@
7575
<PropertyGroup Condition="'$(TargetFramework)' == 'net8'">
7676
<DefineConstants>$(DefineConstants);PSV7;CORECLR</DefineConstants>
7777
</PropertyGroup>
78-
79-
<ItemGroup Condition="'$(TargetFramework)' == 'net462' AND '$(Configuration)' == 'PSV3Release' AND '$(Configuration)' != 'PSV4Release'">
80-
<PackageReference Include="Microsoft.PowerShell.3.ReferenceAssemblies" />
81-
</ItemGroup>
82-
83-
<ItemGroup Condition="'$(TargetFramework)' == 'net462' AND '$(Configuration)' == 'PSV4Release'">
84-
<PackageReference Include="Microsoft.PowerShell.4.ReferenceAssemblies" />
85-
</ItemGroup>
8678

87-
<ItemGroup Condition="'$(TargetFramework)' == 'net462' AND '$(Configuration)' != 'PSV3Release'">
79+
<ItemGroup Condition="'$(TargetFramework)' == 'net462' ">
8880
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" />
8981
</ItemGroup>
90-
91-
<PropertyGroup Condition=" '$(Configuration)' == 'PSV3Release' ">
92-
<DefineConstants>$(DefineConstants);PSV3</DefineConstants>
93-
</PropertyGroup>
94-
95-
<PropertyGroup Condition=" '$(Configuration)' == 'PSV4Release' ">
96-
<DefineConstants>$(DefineConstants);PSV3;PSV4</DefineConstants>
97-
</PropertyGroup>
98-
99-
<PropertyGroup Condition=" '$(Configuration)' == 'PSV3Debug' ">
100-
<DefineConstants>$(DefineConstants);PSV3</DefineConstants>
101-
</PropertyGroup>
102-
103-
<PropertyGroup Condition=" '$(Configuration)' == 'PSV4Debug' ">
104-
<DefineConstants>$(DefineConstants);PSV3;PSV4</DefineConstants>
105-
</PropertyGroup>
10682

10783
</Project>

Engine/PSScriptAnalyzer.psd1

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ GUID = 'd6245802-193d-4068-a631-8863a4342a18'
2020
CompanyName = 'Microsoft Corporation'
2121

2222
# Copyright statement for this module
23-
Copyright = '(c) Microsoft Corporation 2016. All rights reserved.'
23+
Copyright = '(c) Microsoft Corporation 2025. All rights reserved.'
2424

2525
# Description of the functionality provided by this module
2626
Description = 'PSScriptAnalyzer provides script analysis and checks for potential code defects in the scripts by applying a group of built-in or customized rules on the scripts being analyzed.'
2727

2828
# Minimum version of the Windows PowerShell engine required by this module
29-
PowerShellVersion = '3.0'
29+
PowerShellVersion = '5.1'
3030

3131
# Name of the Windows PowerShell host required by this module
3232
# PowerShellHostName = ''

PSCompatibilityCollector/Microsoft.PowerShell.CrossCompatibility/Microsoft.PowerShell.CrossCompatibility.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
2121
<PackageReference Include="Newtonsoft.Json" />
22-
<PackageReference Include="Microsoft.PowerShell.3.ReferenceAssemblies" />
22+
<PackageReference Include="Microsoft.PowerShell.5.ReferenceAssemblies" />
2323
<PackageReference Include="Microsoft.Management.Infrastructure" VersionOverride="1.0.0" />
2424
</ItemGroup>
2525

README.md

+4-16
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ To install **PSScriptAnalyzer** from source code:
7373
### Requirements
7474

7575
- [Latest .NET 8.0 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)
76-
* If building for Windows PowerShell versions, then the .NET Framework 4.6.2 [targeting pack](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net462) (also referred to as developer/targeting pack) need to be installed. This is only possible on Windows.
77-
* Optionally but recommended for development: [Visual Studio 2017/2019](https://www.visualstudio.com/downloads)
76+
- If building for Windows PowerShell versions, then the .NET Framework 4.6.2 [targeting pack](https://dotnet.microsoft.com/en-us/download/dotnet-framework/net462) (also referred to as developer/targeting pack) need to be installed. This is only possible on Windows.
77+
- Optional but recommended for development: [Visual Studio 2022](https://www.visualstudio.com/downloads)
78+
- Or [Visual Studio Code](https://code.visualstudio.com/download)
7879
- [Pester v5 PowerShell module, available on PowerShell Gallery](https://github.com/pester/Pester)
7980
- [PlatyPS PowerShell module, available on PowerShell Gallery](https://github.com/PowerShell/platyPS/releases)
80-
- Optionally but recommended for development: [Visual Studio](https://www.visualstudio.com/downloads)
8181

8282
### Steps
8383

@@ -110,18 +110,6 @@ To install **PSScriptAnalyzer** from source code:
110110
.\build.ps1 -PSVersion 5
111111
```
112112
113-
- Windows PowerShell version 4.0
114-
115-
```powershell
116-
.\build.ps1 -PSVersion 4
117-
```
118-
119-
- Windows PowerShell version 3.0
120-
121-
```powershell
122-
.\build.ps1 -PSVersion 3
123-
```
124-
125113
- PowerShell 7
126114
127115
```powershell
@@ -134,7 +122,7 @@ To install **PSScriptAnalyzer** from source code:
134122
.\build.ps1 -Documentation
135123
```
136124

137-
- Build all versions (PowerShell v3, v4, v5, and v6) and documentation
125+
- Build all versions (PowerShell v5 and v7) and documentation
138126

139127
```powershell
140128
.\build.ps1 -All

build.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ param(
77
[switch]$All,
88

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

1313
[Parameter(ParameterSetName="BuildOne")]

build.psm1

+3-17
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function Start-ScriptAnalyzerBuild
8888
param (
8989
[switch]$All,
9090

91-
[ValidateSet(3, 4, 5, 7)]
91+
[ValidateSet(5, 7)]
9292
[int]$PSVersion = $PSVersionTable.PSVersion.Major,
9393

9494
[ValidateSet("Debug", "Release")]
@@ -124,7 +124,7 @@ function Start-ScriptAnalyzerBuild
124124
if ( $All )
125125
{
126126
# Build all the versions of the analyzer
127-
foreach ($psVersion in 3, 4, 5, 7) {
127+
foreach ($psVersion in 5, 7) {
128128
Write-Verbose -Verbose -Message "Configuration: $Configuration PSVersion: $psVersion"
129129
Start-ScriptAnalyzerBuild -Configuration $Configuration -PSVersion $psVersion -Verbose:$verboseWanted
130130
}
@@ -147,12 +147,6 @@ function Start-ScriptAnalyzerBuild
147147
$framework = 'net8'
148148
}
149149

150-
# build the appropriate assembly
151-
if ($PSVersion -match "[34]" -and $Framework -ne "net462")
152-
{
153-
throw ("ScriptAnalyzer for PS version '{0}' is not applicable to {1} framework" -f $PSVersion,$Framework)
154-
}
155-
156150
Push-Location -Path $projectRoot
157151
if (-not (Test-Path "$projectRoot/global.json"))
158152
{
@@ -176,14 +170,6 @@ function Start-ScriptAnalyzerBuild
176170

177171
switch ($PSVersion)
178172
{
179-
3
180-
{
181-
$destinationDirBinaries = "$script:destinationDir\PSv3"
182-
}
183-
4
184-
{
185-
$destinationDirBinaries = "$script:destinationDir\PSv4"
186-
}
187173
5
188174
{
189175
$destinationDirBinaries = "$script:destinationDir"
@@ -199,7 +185,7 @@ function Start-ScriptAnalyzerBuild
199185
}
200186

201187
$buildConfiguration = $Configuration
202-
if ((3, 4, 7) -contains $PSVersion) {
188+
if ($PSVersion -eq 7) {
203189
$buildConfiguration = "PSV${PSVersion}${Configuration}"
204190
}
205191

0 commit comments

Comments
 (0)