Skip to content

Commit bd34d3f

Browse files
authored
Revert dropping support of Powershell 3 and friends (#2435)
* Revert dropping support of powershell 3 etc. * Update lock and fix reverted change
1 parent 3977039 commit bd34d3f

10 files changed

+608
-415
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ Get-Help ./test.ps1 -Detailed
9494

9595
The Azure Devops Pipeline azure-pipelines.yml file contains the code definition used for builds, unit and integration tests in the CI pipeline.
9696

97-
Within the pipeline, tests are executed against PS7 and PS5.1, on Windows, Linux (Ubuntu) and MacOS.
97+
Within the pipeline, tests are executed against PS7 Core on a strategy matrix of machines, including Ubuntu 16.04, 18.04, macOS Mojave 10.14, Catalina 10.15, Windows Server 2016, 2019. Tests are also executed against PS6.2, PS4, PS3.
9898

9999
## Documentation
100100

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ The example above also has an [annotated and production ready version here](docs
6767

6868
## Installation
6969

70-
Pester runs on Windows, Linux, MacOS and anywhere else thanks to PowerShell. It is compatible with Windows PowerShell 5.1 and PowerShell 7.2 and newer.
70+
Pester runs on Windows, Linux, MacOS and anywhere else thanks to PowerShell. It is compatible with Windows PowerShell 3, 4, 5, 6 and 7.
7171

7272
Pester 3 comes pre-installed with Windows 10, but we recommend updating, by running this PowerShell command _as administrator_:
7373

azure-pipelines.yml

+47
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,50 @@ stages:
126126
failTaskOnFailedTests: true
127127
condition: succeededOrFailed()
128128
timeoutInMinutes: 20
129+
- job:
130+
workspace:
131+
clean: all
132+
strategy:
133+
matrix:
134+
PS3:
135+
agent: 'ps3'
136+
pwsh: false
137+
PS4:
138+
agent: 'ps4'
139+
pwsh: false
140+
PS6_2:
141+
agent: 'ps6'
142+
pwsh: true
143+
pool:
144+
name: Default
145+
demands:
146+
- agent.name -equals $(agent)
147+
steps:
148+
- checkout: none
149+
- task: DownloadPipelineArtifact@2
150+
inputs:
151+
buildType: 'current'
152+
artifactName: 'all'
153+
targetPath: '$(Build.SourcesDirectory)'
154+
- task: PowerShell@2
155+
displayName: 'Test Pester'
156+
inputs:
157+
targetType: 'inline'
158+
pwsh: $(pwsh)
159+
script: |
160+
& ./test.ps1 -CI -PassThru -NoBuild
161+
workingDirectory: '$(Build.SourcesDirectory)'
162+
- task: PublishCodeCoverageResults@1
163+
inputs:
164+
codeCoverageTool: 'JaCoCo'
165+
summaryFileLocation: 'coverage.xml'
166+
pathToSources: 'src/'
167+
failIfCoverageEmpty: false
168+
condition: succeededOrFailed()
169+
- task: PublishTestResults@2
170+
inputs:
171+
testResultsFormat: 'NUnit'
172+
testResultsFiles: 'testResults.xml'
173+
failTaskOnFailedTests: true
174+
condition: succeededOrFailed()
175+
timeoutInMinutes: 20

build.ps1

+6-4
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,10 @@ if ($Clean) {
115115
, ("$PSScriptRoot/src/schemas/NUnit25/*.xsd", "$PSScriptRoot/bin/schemas/NUnit25/")
116116
, ("$PSScriptRoot/src/schemas/NUnit3/*.xsd", "$PSScriptRoot/bin/schemas/NUnit3/")
117117
, ("$PSScriptRoot/src/schemas/JaCoCo/*.dtd", "$PSScriptRoot/bin/schemas/JaCoCo/")
118-
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/net462/Pester.dll", "$PSScriptRoot/bin/bin/net462/")
119-
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/net6.0/Pester.dll", "$PSScriptRoot/bin/bin/net6.0/")
118+
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/net452/Pester.dll", "$PSScriptRoot/bin/bin/net452/")
119+
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/net452/Pester.pdb", "$PSScriptRoot/bin/bin/net452/")
120+
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/netstandard2.0/Pester.dll", "$PSScriptRoot/bin/bin/netstandard2.0/")
121+
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/netstandard2.0/Pester.pdb", "$PSScriptRoot/bin/bin/netstandard2.0/")
120122
)
121123
}
122124

@@ -125,10 +127,10 @@ Copy-Content -Content $content
125127
if ($Clean) {
126128
# update help for New-PesterConfiguration
127129
if ($PSVersionTable.PSVersion.Major -gt 5) {
128-
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/net6.0/Pester.dll")
130+
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/netstandard2.0/Pester.dll")
129131
}
130132
else {
131-
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/net462/Pester.dll")
133+
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/net452/Pester.dll")
132134
}
133135

134136
function Format-NicelyMini ($value) {

publish/release.ps1

+4-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ $files = @(
6060
'Pester.psm1'
6161
'Pester.Format.ps1xml'
6262
'PesterConfiguration.Format.ps1xml'
63-
'bin/net462/Pester.dll'
64-
'bin/net6.0/Pester.dll'
63+
'bin/net452/Pester.dll'
64+
'bin/net452/Pester.pdb'
65+
'bin/netstandard2.0/Pester.dll'
66+
'bin/netstandard2.0/Pester.pdb'
6567
'en-US/about_BeforeEach_AfterEach.help.txt'
6668
'en-US/about_Mocking.help.txt'
6769
'en-US/about_Pester.help.txt'

src/Pester.Types.ps1

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,25 @@ if ($null -ne $configurationType) {
1313
}
1414

1515
if ($PSVersionTable.PSVersion.Major -ge 6) {
16-
$path = "$PSScriptRoot/bin/net6.0/Pester.dll"
16+
$path = "$PSScriptRoot/bin/netstandard2.0/Pester.dll"
1717
# PESTER_BUILD
1818
if ((Get-Variable -Name "PESTER_BUILD" -ValueOnly -ErrorAction Ignore)) {
19-
$path = "$PSScriptRoot/../bin/bin/net6.0/Pester.dll"
19+
$path = "$PSScriptRoot/../bin/bin/netstandard2.0/Pester.dll"
2020
}
2121
else {
22-
$path = "$PSScriptRoot/../bin/bin/net6.0/Pester.dll"
22+
$path = "$PSScriptRoot/../bin/bin/netstandard2.0/Pester.dll"
2323
}
2424
# end PESTER_BUILD
2525
& $SafeCommands['Add-Type'] -Path $path
2626
}
2727
else {
28-
$path = "$PSScriptRoot/bin/net462/Pester.dll"
28+
$path = "$PSScriptRoot/bin/net452/Pester.dll"
2929
# PESTER_BUILD
3030
if ((Get-Variable -Name "PESTER_BUILD" -ValueOnly -ErrorAction Ignore)) {
31-
$path = "$PSScriptRoot/../bin/bin/net462/Pester.dll"
31+
$path = "$PSScriptRoot/../bin/bin/net452/Pester.dll"
3232
}
3333
else {
34-
$path = "$PSScriptRoot/../bin/bin/net462/Pester.dll"
34+
$path = "$PSScriptRoot/../bin/bin/net452/Pester.dll"
3535
}
3636
# end PESTER_BUILD
3737
& $SafeCommands['Add-Type'] -Path $path

src/Pester.psd1

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@{
1+
@{
22

33
# Script module or binary module file associated with this manifest.
44
RootModule = 'Pester.psm1'
@@ -22,7 +22,7 @@
2222
Description = 'Pester provides a framework for running BDD style Tests to execute and validate PowerShell commands inside of PowerShell and offers a powerful set of Mocking Functions that allow tests to mimic and mock the functionality of any command inside of a piece of PowerShell code being tested. Pester tests can execute any command or script that is accessible to a pester test file. This can include functions, Cmdlets, Modules and scripts. Pester can be run in ad hoc style in a console or it can be integrated into the Build scripts of a Continuous Integration system.'
2323

2424
# Minimum version of the Windows PowerShell engine required by this module
25-
PowerShellVersion = '5.1'
25+
PowerShellVersion = '3.0'
2626

2727
# Type files (.ps1xml) to be loaded when importing this module
2828
TypesToProcess = @()

src/csharp/Pester/Pester.csproj

+8-18
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,21 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net6.0;net462</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
55
<LangVersion>latest</LangVersion>
66
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
7-
<DebugType>embedded</DebugType>
87
</PropertyGroup>
98

10-
<!-- PowerShell 7.2.x is the oldest supported PowerShell version. That version is built using net6.0.
11-
But there is a bug in 7.2.0 reference assemblies, up to 7.2.10, where the IExtens.File is missing from the reference assembly:
12-
https://github.com/PowerShell/PowerShell/issues/16408
13-
14-
So we use the version released before 7.2.0 which was 7.1.7. We could probably use 7.2.10 safely as well,
15-
-->
16-
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
17-
<PackageReference Include="System.Management.Automation" Version="7.1.7" />
9+
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
10+
<!-- this version is used specifically to support as old version of PS6 as we can.
11+
issue: https://github.com/pester/Pester/issues/2207 -->
12+
<PackageReference Include="System.Management.Automation" Version="6.0.4" NoWarn="NU1903" />
1813
</ItemGroup>
1914

20-
<!-- Windows PowerShell 5.1 is the only Windows PowerShell that is still in support, and it is built using .NET Framework 4.5.2.
21-
But the oldest still supported OS on which WMF5.1 can be installed, is Windows 10 1607, which comes with .NET Framework 4.6.2. https://learn.microsoft.com/en-us/powershell/scripting/windows-powershell/wmf-overview?view=powershell-7.4#wmf-availability-across-windows-operating-systems
22-
https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/versions-and-dependencies#net-framework-462
23-
.NET 4.6.2 is also the oldest supported version of .NET Framework (https://learn.microsoft.com/en-us/lifecycle/products/microsoft-net-framework)
24-
-->
25-
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
26-
<PackageReference Include="Microsoft.PowerShell.5.1.ReferenceAssemblies" Version="1.0.0" />
15+
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
16+
<PackageReference Include="Microsoft.PowerShell.3.ReferenceAssemblies" Version="1.0.0" />
2717

28-
<!-- To enable build support on unix. -->
18+
<!-- To enable build support on unix-->
2919
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
3020
<PrivateAssets>all</PrivateAssets>
3121
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>

0 commit comments

Comments
 (0)