-
-
Notifications
You must be signed in to change notification settings - Fork 477
Expand file tree
/
Copy pathPester.Types.ps1
More file actions
38 lines (35 loc) · 2.03 KB
/
Copy pathPester.Types.ps1
File metadata and controls
38 lines (35 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# e.g. $minimumVersionRequired = "5.1.0.0" -as [version]
$minimumVersionRequired = $ExecutionContext.SessionState.Module.PrivateData.RequiredAssemblyVersion -as [version]
# Check if the type exists, which means we have a conflict because the assembly is already loaded
$configurationType = 'PesterConfiguration' -as [type]
if ($null -ne $configurationType) {
$loadedVersion = $configurationType.Assembly.GetName().Version
# both use just normal version, without prerelease, we can compare them using the normal [Version] type
if ($loadedVersion -lt $minimumVersionRequired) {
throw [System.InvalidOperationException]"An incompatible version of the Pester.dll assembly is already loaded. The loaded dll version is $loadedVersion, but at least version $minimumVersionRequired is required for this version of Pester to work correctly. This usually happens if you load two versions of Pester into the same PowerShell session, for example after Pester update. To fix this restart your powershell session and load only one version of Pester. It also happens in VSCode if you are developing Pester and load it from non standard location. To solve this in VSCode close all *.Tests.ps1 files, to prevent automatic loading of Pester from PSModulePath, and then restart your session."
}
}
if ($PSVersionTable.PSVersion.Major -ge 7) {
$path = "$PSScriptRoot/bin/net8.0/Pester.dll"
# PESTER_BUILD
if ((Get-Variable -Name "PESTER_BUILD" -ValueOnly -ErrorAction Ignore)) {
$path = "$PSScriptRoot/../bin/bin/net8.0/Pester.dll"
}
else {
$path = "$PSScriptRoot/../bin/bin/net8.0/Pester.dll"
}
# end PESTER_BUILD
& $SafeCommands['Add-Type'] -Path $path
}
else {
$path = "$PSScriptRoot/bin/net462/Pester.dll"
# PESTER_BUILD
if ((Get-Variable -Name "PESTER_BUILD" -ValueOnly -ErrorAction Ignore)) {
$path = "$PSScriptRoot/../bin/bin/net462/Pester.dll"
}
else {
$path = "$PSScriptRoot/../bin/bin/net462/Pester.dll"
}
# end PESTER_BUILD
& $SafeCommands['Add-Type'] -Path $path
}