Skip to content

Commit b06dec0

Browse files
Install built module into its manifest version folder
Install-PSModule copied the built module into a hard-coded 999.0.0 folder, so Import-Module failed once the manifest carried a real (non-placeholder) version. Read the manifest ModuleVersion and install into the matching version folder, falling back to 999.0.0 only when the manifest is unstamped.
1 parent dd52e57 commit b06dec0

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Helpers/Helpers.psm1

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,15 @@ function Install-PSModule {
313313
Write-Host '::group::Resolving dependencies'
314314
Resolve-PSModuleDependency -ManifestFilePath $manifestFilePath
315315
Write-Host '::endgroup::'
316+
# Install into a version folder that matches the manifest's ModuleVersion so PowerShell
317+
# accepts the module. Fall back to the 999.0.0 placeholder only when the manifest is
318+
# unstamped (e.g. a build that opted out of version resolution).
319+
$moduleVersion = (Import-PowerShellDataFile -Path $manifestFilePath).ModuleVersion
320+
if ([string]::IsNullOrWhiteSpace($moduleVersion)) {
321+
$moduleVersion = '999.0.0'
322+
}
316323
$PSModulePath = $env:PSModulePath -split [System.IO.Path]::PathSeparator | Select-Object -First 1
317-
$codePath = New-Item -Path "$PSModulePath/$moduleName/999.0.0" -ItemType Directory -Force | Select-Object -ExpandProperty FullName
324+
$codePath = New-Item -Path "$PSModulePath/$moduleName/$moduleVersion" -ItemType Directory -Force | Select-Object -ExpandProperty FullName
318325
Copy-Item -Path "$Path/*" -Destination $codePath -Recurse -Force
319326
Write-Host '::group::Importing module'
320327
Import-Module -Name $moduleName -Verbose

0 commit comments

Comments
 (0)