Skip to content

Commit f2940d5

Browse files
🪲 [Fix]: Fix Manifest auto calculated conditions (#30)
## Description - Fix Manifest auto calculated conditions ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [x] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent b41509d commit f2940d5

File tree

1 file changed

+12
-18
lines changed

1 file changed

+12
-18
lines changed

scripts/helpers/Build/Build-PSModuleManifest.ps1

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -204,29 +204,23 @@ function Build-PSModuleManifest {
204204
Write-Verbose '[CompatiblePSEditions]'
205205
$capturedPSEdition = $capturedPSEdition | Sort-Object -Unique
206206
if ($capturedPSEdition.count -eq 2) {
207-
throw @"
208-
Conflict detected:
209-
The module requires both 'Desktop' and 'Core' editions.
210-
'Desktop' and 'Core' editions cannot be required at the same time.
211-
"@
207+
throw "Conflict detected: The module requires both 'Desktop' and 'Core' editions." +
208+
"'Desktop' and 'Core' editions cannot be required at the same time."
209+
}
210+
if ($capturedPSEdition.count -eq 0 -and $manifest.PowerShellVersion -gt '5.1') {
211+
Write-Verbose "[CompatiblePSEditions] - Defaulting to 'Core', as no PSEdition was specified and PowerShellVersion > 5.1"
212+
$capturedPSEdition = @('Core')
213+
}
214+
if ($capturedPSEdition.count -eq 0 -and $manifest.PowerShellVersion -lt '6.0') {
215+
Write-Verbose "[CompatiblePSEditions] - Defaulting to 'Desktop', as no PSEdition was specified and PowerShellVersion < 6.0"
216+
$capturedPSEdition = @('Desktop')
212217
}
213218
$manifest.CompatiblePSEditions = $capturedPSEdition.count -eq 0 ? @('Core', 'Desktop') : @($capturedPSEdition)
214219
$manifest.CompatiblePSEditions | ForEach-Object { Write-Verbose "[CompatiblePSEditions] - [$_]" }
215220

216221
if ($manifest.PowerShellVersion -gt '5.1' -and $manifest.CompatiblePSEditions -contains 'Desktop') {
217-
throw @'
218-
Conflict detected:
219-
The module requires PowerShellVersion > 5.1 while CompatiblePSEditions = 'Desktop'
220-
'Desktop' edition is not supported for PowerShellVersion > 5.1
221-
'@
222-
}
223-
224-
if ($manifest.CompatiblePSEditions -contains 'Core' -and $manifest.PowerShellVersion -lt '6.0') {
225-
throw @'
226-
Conflict detected:
227-
The module requires CompatiblePSEditions = 'Core' while PowerShellVersion < 6.0
228-
'Core' edition is not supported for PowerShellVersion < 6.0
229-
'@
222+
throw "Conflict detected: The module requires PowerShellVersion > 5.1 while CompatiblePSEditions = 'Desktop'" +
223+
"'Desktop' edition is not supported for PowerShellVersion > 5.1"
230224
}
231225

232226
Write-Verbose '[PrivateData]'

0 commit comments

Comments
 (0)