Skip to content

🪲 [Fix]: Install built modules into their real manifest version folder#19

Merged
Marius Storhaug (MariusStorhaug) merged 6 commits into
mainfrom
fix/install-real-module-version
Jul 8, 2026
Merged

🪲 [Fix]: Install built modules into their real manifest version folder#19
Marius Storhaug (MariusStorhaug) merged 6 commits into
mainfrom
fix/install-real-module-version

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Jul 8, 2026

Copy link
Copy Markdown
Member

What

Install-PSModule copied the built module into a hard-coded .../<name>/999.0.0 folder and then Import-Moduled it. That only worked while the build pipeline stamped the 999.0.0 placeholder into every manifest. Now that Process-PSModule#326 resolves and stamps the real version at build time, the folder name (999.0.0) no longer matches the manifest ModuleVersion, so PowerShell rejects the module ("does not have a valid module manifest file") and Import-Module fails.

Change

Read the manifest ModuleVersion and install into the matching version folder. Fall back to 999.0.0 only when the manifest is unstamped (a build that opted out of version resolution), preserving the previous behaviour for that case.

Import the freshly installed manifest path with -Force -Global so a preloaded placeholder version does not keep command resolution pinned to 999.0.0.

Validation

Added tests/Install-PSModule.Tests.ps1 and wired it into Action-Test. The regression test covers real-version installation, absence of the 999.0.0 folder for stamped manifests, replacement of a preloaded 999.0.0 command, and rejection of malformed ModuleVersion values.

Local validation passed:

  • pwsh -NoProfile -File ./tests/Install-PSModule.Tests.ps1
  • Invoke-ScriptAnalyzer -Path . -Recurse -Settings .github/linters/.powershell-psscriptanalyzer.psd1
  • action-shaped run: ./src/main.ps1, Get-Module -Name Helpers -ListAvailable, then the regression script

Part of the Process-PSModule#326 "test what you ship" refactor (test-harness version-awareness). Consumed by Test-PSModule, Document-PSModule, and the Process-PSModule Test-Module job.

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.
Copilot AI review requested due to automatic review settings July 8, 2026 00:58
Marius Storhaug (MariusStorhaug) added a commit to PSModule/Process-PSModule that referenced this pull request Jul 8, 2026
…lpers to PR#19 branch

Fix the hard-coded Import-Module -RequiredVersion 999.0.0 in the Pester Prescript to use the resolved module version. Temporarily pin Install-PSModuleHelpers to the fix/install-real-module-version branch (PSModule/Install-PSModuleHelpers#19) to validate end-to-end; will repin to the released tag before merge.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates Install-PSModule to install built PowerShell modules into a versioned folder matching the module manifest’s ModuleVersion, fixing import failures now that builds stamp the real version instead of the 999.0.0 placeholder.

Changes:

  • Read ModuleVersion from the module manifest and use it as the version folder name.
  • Fall back to 999.0.0 only when the manifest version is missing/unstamped.
Comments suppressed due to low confidence (1)

src/Helpers/Helpers.psm1:329

  • Import-Module -Name $moduleName can import a different installed version if multiple versions of the module exist in $env:PSModulePath. Previously the hard-coded 999.0.0 made the installed copy win as the highest version; now that you install to the real version folder, it’s safer to import by the manifest path (or require the version) to ensure the freshly-copied module is the one that gets loaded.
    Copy-Item -Path "$Path/*" -Destination $codePath -Recurse -Force
    Write-Host '::group::Importing module'
    Import-Module -Name $moduleName -Verbose
    Write-Host '::endgroup::'
    if ($PassThru) {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Helpers/Helpers.psm1 Outdated
…ifest path

Addresses review feedback: build the install path with Join-Path (cross-platform separators) and import the just-installed module by its manifest path so it is not shadowed by another version already on PSModulePath.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/Helpers/Helpers.psm1 Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 01:07
Add -Force so the just-installed copy replaces any already-loaded version of the same module, guaranteeing the correct version is used by downstream tests.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/Helpers/Helpers.psm1 Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 01:10
Join-Path -AdditionalChildPath is PowerShell 6+ only; nested Join-Path calls keep the same behavior while remaining compatible with Windows PowerShell 5.1.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/Helpers/Helpers.psm1 Outdated
Copilot AI review requested due to automatic review settings July 8, 2026 01:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/Helpers/Helpers.psm1 Outdated
Parse ModuleVersion as [version] and fail fast on a malformed value so a crafted manifest cannot inject path separators/traversal into the install path. Empty/unstamped manifests still fall back to the 999.0.0 placeholder.
Copilot AI review requested due to automatic review settings July 8, 2026 01:16

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 8, 2026 10:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@MariusStorhaug Marius Storhaug (MariusStorhaug) merged commit 68e8ca7 into main Jul 8, 2026
19 checks passed
@MariusStorhaug Marius Storhaug (MariusStorhaug) deleted the fix/install-real-module-version branch July 8, 2026 12:17
Marius Storhaug (MariusStorhaug) added a commit to PSModule/Test-PSModule that referenced this pull request Jul 8, 2026
Built modules whose manifests carry a real, resolved version can now be
tested by `Test-PSModule`. Previously the action installed the built
module under the historical `999.0.0` placeholder folder, so module
tests failed once the build flow started stamping manifests with the
version that will actually be shipped.

## Fixed: Built modules with resolved versions can be tested

`Test-PSModule` now installs and validates built module outputs whose
manifest `ModuleVersion` has already been resolved to the real build
version. The module is installed under a matching version folder before
module tests run, so PowerShell accepts the manifest and Pester
validates the artifact from the expected path.

This is delivered by bumping the pinned
`PSModule/Install-PSModuleHelpers` to `v1.0.8`, which installs built
modules at their real version instead of the `999.0.0` placeholder.

## Technical Details

- `action.yml`: `PSModule/Install-PSModuleHelpers` pin bumped `v1.0.7`
-> `v1.0.8` (the release from
[PSModule/Install-PSModuleHelpers#19](PSModule/Install-PSModuleHelpers#19)).
- `src/tests/Module/PSModule/PSModule.Tests.ps1`: new test asserting the
installed version folder matches the manifest `ModuleVersion`, guarding
against a regression to the `999.0.0` behavior.
- `tests/outputTestRepo/outputs/module/PSModuleTest/PSModuleTest.psd1`:
fixture `ModuleVersion` updated `999.0.0` -> `3.0.11` to model the
current build output.
- The branch is merged up to date with `main`, which already carries the
`actions/checkout` v7.0.0, `super-linter` v8.7.0, and
`PSModule/Invoke-Pester` v4.2.6 pins, so this PR no longer changes
those.
Marius Storhaug (MariusStorhaug) added a commit to PSModule/Document-PSModule that referenced this pull request Jul 9, 2026
PR PSModule/Install-PSModuleHelpers#19 is merged and released as v1.0.8. Replace the TEMP branch pin with the released v1.0.8 commit SHA.
Marius Storhaug (MariusStorhaug) added a commit to PSModule/Document-PSModule that referenced this pull request Jul 9, 2026
…PSModuleHelpers) (#52)

## What

`Document-PSModule` installs the built module (via `Install-PSModule`
from `Install-PSModuleHelpers`) before generating docs. That helper used
to copy the module into a hard-coded `999.0.0` folder, which breaks now
that
[Process-PSModule#326](PSModule/Process-PSModule#326)
stamps the real version at build time (folder no longer matches the
manifest, so `Import-Module` fails and `Build-Docs` breaks).

## Change

Bump the `Install-PSModuleHelpers` pin to the version that installs into
a folder matching the manifest `ModuleVersion`
([PSModule/Install-PSModuleHelpers#19](PSModule/Install-PSModuleHelpers#19)).

> **Pinned to the released tag:**
[PSModule/Install-PSModuleHelpers#19](PSModule/Install-PSModuleHelpers#19)
is merged and released, so this now pins
[`v1.0.8`](https://github.com/PSModule/Install-PSModuleHelpers/releases/tag/v1.0.8).

Part of the
[Process-PSModule#326](PSModule/Process-PSModule#326)
refactor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants