Skip to content

Commit 44f763d

Browse files
committed
Revert "Revert dropping support of Powershell 3 and friends (#2435)"
This reverts commit bd34d3f.
1 parent a9d0ad0 commit 44f763d

10 files changed

+415
-608
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 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.
97+
Within the pipeline, tests are executed against PS7 and PS5.1, on Windows, Linux (Ubuntu) and MacOS.
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 3, 4, 5, 6 and 7.
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.
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
@@ -127,50 +127,3 @@ stages:
127127
failTaskOnFailedTests: true
128128
condition: succeededOrFailed()
129129
timeoutInMinutes: 20
130-
- job:
131-
workspace:
132-
clean: all
133-
strategy:
134-
matrix:
135-
PS3:
136-
agent: 'ps3'
137-
pwsh: false
138-
PS4:
139-
agent: 'ps4'
140-
pwsh: false
141-
PS6_2:
142-
agent: 'ps6'
143-
pwsh: true
144-
pool:
145-
name: Default
146-
demands:
147-
- agent.name -equals $(agent)
148-
steps:
149-
- checkout: none
150-
- task: DownloadPipelineArtifact@2
151-
inputs:
152-
buildType: 'current'
153-
artifactName: 'all'
154-
targetPath: '$(Build.SourcesDirectory)'
155-
- task: PowerShell@2
156-
displayName: 'Test Pester'
157-
inputs:
158-
targetType: 'inline'
159-
pwsh: $(pwsh)
160-
script: |
161-
& ./test.ps1 -CI -PassThru -NoBuild
162-
workingDirectory: '$(Build.SourcesDirectory)'
163-
- task: PublishCodeCoverageResults@1
164-
inputs:
165-
codeCoverageTool: 'JaCoCo'
166-
summaryFileLocation: 'coverage.xml'
167-
pathToSources: 'src/'
168-
failIfCoverageEmpty: false
169-
condition: succeededOrFailed()
170-
- task: PublishTestResults@2
171-
inputs:
172-
testResultsFormat: 'NUnit'
173-
testResultsFiles: 'testResults.xml'
174-
failTaskOnFailedTests: true
175-
condition: succeededOrFailed()
176-
timeoutInMinutes: 20

build.ps1

+4-6
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,8 @@ 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/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/")
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/")
122120
)
123121
}
124122

@@ -127,10 +125,10 @@ Copy-Content -Content $content
127125
if ($Clean) {
128126
# update help for New-PesterConfiguration
129127
if ($PSVersionTable.PSVersion.Major -gt 5) {
130-
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/netstandard2.0/Pester.dll")
128+
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/net6.0/Pester.dll")
131129
}
132130
else {
133-
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/net452/Pester.dll")
131+
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/net462/Pester.dll")
134132
}
135133

136134
function Format-NicelyMini ($value) {

publish/release.ps1

+2-4
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ $files = @(
6060
'Pester.psm1'
6161
'Pester.Format.ps1xml'
6262
'PesterConfiguration.Format.ps1xml'
63-
'bin/net452/Pester.dll'
64-
'bin/net452/Pester.pdb'
65-
'bin/netstandard2.0/Pester.dll'
66-
'bin/netstandard2.0/Pester.pdb'
63+
'bin/net462/Pester.dll'
64+
'bin/net6.0/Pester.dll'
6765
'en-US/about_BeforeEach_AfterEach.help.txt'
6866
'en-US/about_Mocking.help.txt'
6967
'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/netstandard2.0/Pester.dll"
16+
$path = "$PSScriptRoot/bin/net6.0/Pester.dll"
1717
# PESTER_BUILD
1818
if ((Get-Variable -Name "PESTER_BUILD" -ValueOnly -ErrorAction Ignore)) {
19-
$path = "$PSScriptRoot/../bin/bin/netstandard2.0/Pester.dll"
19+
$path = "$PSScriptRoot/../bin/bin/net6.0/Pester.dll"
2020
}
2121
else {
22-
$path = "$PSScriptRoot/../bin/bin/netstandard2.0/Pester.dll"
22+
$path = "$PSScriptRoot/../bin/bin/net6.0/Pester.dll"
2323
}
2424
# end PESTER_BUILD
2525
& $SafeCommands['Add-Type'] -Path $path
2626
}
2727
else {
28-
$path = "$PSScriptRoot/bin/net452/Pester.dll"
28+
$path = "$PSScriptRoot/bin/net462/Pester.dll"
2929
# PESTER_BUILD
3030
if ((Get-Variable -Name "PESTER_BUILD" -ValueOnly -ErrorAction Ignore)) {
31-
$path = "$PSScriptRoot/../bin/bin/net452/Pester.dll"
31+
$path = "$PSScriptRoot/../bin/bin/net462/Pester.dll"
3232
}
3333
else {
34-
$path = "$PSScriptRoot/../bin/bin/net452/Pester.dll"
34+
$path = "$PSScriptRoot/../bin/bin/net462/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 = '3.0'
25+
PowerShellVersion = '5.1'
2626

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

src/csharp/Pester/Pester.csproj

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

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

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" />
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" />
1318
</ItemGroup>
1419

15-
<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
16-
<PackageReference Include="Microsoft.PowerShell.3.ReferenceAssemblies" Version="1.0.0" />
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" />
1727

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

0 commit comments

Comments
 (0)