Skip to content

Commit

Permalink
Drop support of PowerShell 3, 4, 6.2, and unsupported 7 (#2432)
Browse files Browse the repository at this point in the history
* Drop support of PowerShell 3, 4, 6.2, and 7.1

* Use embedded pdbs
  • Loading branch information
nohwnd authored Apr 7, 2024
1 parent 90cc57d commit 6466ee0
Show file tree
Hide file tree
Showing 11 changed files with 449 additions and 423 deletions.
11 changes: 3 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,9 @@ Get-Help ./build.ps1 -Detailed

Pester has a C# Solution which requires .NET Framework SDKs and Developer Packs in order to compile. The targeted frameworks can be found in `src\csharp\Pester\Pester.csproj`.

### Install .NET Core 6.0 SDK
### Install .NET 8.0 SDK

[Download Link](https://dotnet.microsoft.com/download/dotnet-core/6.0)

### .Net Framework 4.5 Developer Pack

[Download Link](https://dotnet.microsoft.com/download/dotnet-framework/net452)
<https://aka.ms/msbuild/developerpacks>
[Download Link](https://dotnet.microsoft.com/en-us/download/dotnet/8.0)

## Running Tests

Expand Down Expand Up @@ -99,7 +94,7 @@ Get-Help ./test.ps1 -Detailed

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

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.
Within the pipeline, tests are executed against PS7 and PS5.1, on Windows, Linux (Ubuntu) and MacOS.

## Documentation

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ The example above also has an [annotated and production ready version here](docs

## Installation

Pester runs on Windows, Linux, MacOS and anywhere else thanks to PowerShell. It is compatible with Windows PowerShell 3, 4, 5, 6 and 7.
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.

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

Expand Down
47 changes: 0 additions & 47 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,50 +127,3 @@ stages:
failTaskOnFailedTests: true
condition: succeededOrFailed()
timeoutInMinutes: 20
- job:
workspace:
clean: all
strategy:
matrix:
PS3:
agent: 'ps3'
pwsh: false
PS4:
agent: 'ps4'
pwsh: false
PS6_2:
agent: 'ps6'
pwsh: true
pool:
name: Default
demands:
- agent.name -equals $(agent)
steps:
- checkout: none
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'all'
targetPath: '$(Build.SourcesDirectory)'
- task: PowerShell@2
displayName: 'Test Pester'
inputs:
targetType: 'inline'
pwsh: $(pwsh)
script: |
& ./test.ps1 -CI -PassThru -NoBuild
workingDirectory: '$(Build.SourcesDirectory)'
- task: PublishCodeCoverageResults@1
inputs:
codeCoverageTool: 'JaCoCo'
summaryFileLocation: 'coverage.xml'
pathToSources: 'src/'
failIfCoverageEmpty: false
condition: succeededOrFailed()
- task: PublishTestResults@2
inputs:
testResultsFormat: 'NUnit'
testResultsFiles: 'testResults.xml'
failTaskOnFailedTests: true
condition: succeededOrFailed()
timeoutInMinutes: 20
10 changes: 4 additions & 6 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,8 @@ if ($Clean) {
, ("$PSScriptRoot/src/schemas/NUnit25/*.xsd", "$PSScriptRoot/bin/schemas/NUnit25/")
, ("$PSScriptRoot/src/schemas/NUnit3/*.xsd", "$PSScriptRoot/bin/schemas/NUnit3/")
, ("$PSScriptRoot/src/schemas/JaCoCo/*.dtd", "$PSScriptRoot/bin/schemas/JaCoCo/")
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/net452/Pester.dll", "$PSScriptRoot/bin/bin/net452/")
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/net452/Pester.pdb", "$PSScriptRoot/bin/bin/net452/")
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/netstandard2.0/Pester.dll", "$PSScriptRoot/bin/bin/netstandard2.0/")
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/netstandard2.0/Pester.pdb", "$PSScriptRoot/bin/bin/netstandard2.0/")
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/net462/Pester.dll", "$PSScriptRoot/bin/bin/net462/")
, ("$PSScriptRoot/src/csharp/Pester/bin/$Configuration/net6.0/Pester.dll", "$PSScriptRoot/bin/bin/net6.0/")
)
}

Expand All @@ -127,10 +125,10 @@ Copy-Content -Content $content
if ($Clean) {
# update help for New-PesterConfiguration
if ($PSVersionTable.PSVersion.Major -gt 5) {
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/netstandard2.0/Pester.dll")
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/net6.0/Pester.dll")
}
else {
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/net452/Pester.dll")
$null = [Reflection.Assembly]::LoadFrom("$PSScriptRoot/bin/bin/net462/Pester.dll")
}

function Format-NicelyMini ($value) {
Expand Down
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"rollForward": "latestFeature",
"version": "8.0.100"
}
}
6 changes: 2 additions & 4 deletions publish/release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,8 @@ $files = @(
'Pester.psm1'
'Pester.Format.ps1xml'
'PesterConfiguration.Format.ps1xml'
'bin/net452/Pester.dll'
'bin/net452/Pester.pdb'
'bin/netstandard2.0/Pester.dll'
'bin/netstandard2.0/Pester.pdb'
'bin/net462/Pester.dll'
'bin/net6.0/Pester.dll'
'en-US/about_BeforeEach_AfterEach.help.txt'
'en-US/about_Mocking.help.txt'
'en-US/about_Pester.help.txt'
Expand Down
12 changes: 6 additions & 6 deletions src/Pester.Types.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ if ($null -ne $configurationType) {
}

if ($PSVersionTable.PSVersion.Major -ge 6) {
$path = "$PSScriptRoot/bin/netstandard2.0/Pester.dll"
$path = "$PSScriptRoot/bin/net6.0/Pester.dll"
# PESTER_BUILD
if ((Get-Variable -Name "PESTER_BUILD" -ValueOnly -ErrorAction Ignore)) {
$path = "$PSScriptRoot/../bin/bin/netstandard2.0/Pester.dll"
$path = "$PSScriptRoot/../bin/bin/net6.0/Pester.dll"
}
else {
$path = "$PSScriptRoot/../bin/bin/netstandard2.0/Pester.dll"
$path = "$PSScriptRoot/../bin/bin/net6.0/Pester.dll"
}
# end PESTER_BUILD
& $SafeCommands['Add-Type'] -Path $path
}
else {
$path = "$PSScriptRoot/bin/net452/Pester.dll"
$path = "$PSScriptRoot/bin/net462/Pester.dll"
# PESTER_BUILD
if ((Get-Variable -Name "PESTER_BUILD" -ValueOnly -ErrorAction Ignore)) {
$path = "$PSScriptRoot/../bin/bin/net452/Pester.dll"
$path = "$PSScriptRoot/../bin/bin/net462/Pester.dll"
}
else {
$path = "$PSScriptRoot/../bin/bin/net452/Pester.dll"
$path = "$PSScriptRoot/../bin/bin/net462/Pester.dll"
}
# end PESTER_BUILD
& $SafeCommands['Add-Type'] -Path $path
Expand Down
8 changes: 4 additions & 4 deletions src/Pester.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
RootModule = 'Pester.psm1'

# Version number of this module.
ModuleVersion = '5.5.0'
ModuleVersion = '5.6.0'

# ID used to uniquely identify this module
GUID = 'a699dea5-2c73-4616-a270-1f7abb777e71'
Expand All @@ -22,7 +22,7 @@
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.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '3.0'
PowerShellVersion = '5.1'

# Type files (.ps1xml) to be loaded when importing this module
TypesToProcess = @()
Expand Down Expand Up @@ -116,14 +116,14 @@
LicenseUri = "https://www.apache.org/licenses/LICENSE-2.0.html"

# Release notes for this particular version of the module
ReleaseNotes = 'https://github.com/pester/Pester/releases/tag/5.5.0'
ReleaseNotes = 'https://github.com/pester/Pester/releases/tag/5.6.0'

# Prerelease string of this module
Prerelease = ''
}

# Minimum assembly version required
RequiredAssemblyVersion = '5.5.0'
RequiredAssemblyVersion = '5.6.0'
}

# HelpInfo URI of this module
Expand Down
26 changes: 18 additions & 8 deletions src/csharp/Pester/Pester.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net452</TargetFrameworks>
<TargetFrameworks>net6.0;net462</TargetFrameworks>
<LangVersion>latest</LangVersion>
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
<DebugType>embedded</DebugType>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<!-- this version is used specifically to support as old version of PS6 as we can.
issue: https://github.com/pester/Pester/issues/2207 -->
<PackageReference Include="System.Management.Automation" Version="6.0.4" />
<!-- PowerShell 7.2.x is the oldest supported PowerShell version. That version is built using net6.0.
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:
https://github.com/PowerShell/PowerShell/issues/16408
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,
-->
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageReference Include="System.Management.Automation" Version="7.1.7" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net452'">
<PackageReference Include="Microsoft.PowerShell.3.ReferenceAssemblies" Version="1.0.0" />
<!-- Windows PowerShell 5.1 is the only Windows PowerShell that is still in support, and it is built using .NET Framework 4.5.2.
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
https://learn.microsoft.com/en-us/dotnet/framework/migration-guide/versions-and-dependencies#net-framework-462
.NET 4.6.2 is also the oldest supported version of .NET Framework (https://learn.microsoft.com/en-us/lifecycle/products/microsoft-net-framework)
-->
<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="Microsoft.PowerShell.5.1.ReferenceAssemblies" Version="1.0.0" />

<!-- To enable build support on unix-->
<!-- To enable build support on unix. -->
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
Loading

0 comments on commit 6466ee0

Please sign in to comment.