Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

Commit 93868d8

Browse files
Force-reload the freshly-installed module on import
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.
1 parent 22e7c03 commit 93868d8

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/Helpers/Helpers.psm1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,10 @@ function Install-PSModule {
324324
$codePath = New-Item -Path (Join-Path -Path $PSModulePath -ChildPath $moduleName -AdditionalChildPath $moduleVersion) -ItemType Directory -Force | Select-Object -ExpandProperty FullName
325325
Copy-Item -Path "$Path/*" -Destination $codePath -Recurse -Force
326326
Write-Host '::group::Importing module'
327-
# Import the freshly-installed copy explicitly by its manifest path so it is not shadowed
328-
# by another version of the same module that may already be on $env:PSModulePath.
329-
Import-Module -Name (Join-Path -Path $codePath -ChildPath "$moduleName.psd1") -Verbose
327+
# Import the freshly-installed copy explicitly by its manifest path (with -Force) so it is
328+
# not shadowed by another version of the same module that may already be loaded or present
329+
# on $env:PSModulePath.
330+
Import-Module -Name (Join-Path -Path $codePath -ChildPath "$moduleName.psd1") -Force -Verbose
330331
Write-Host '::endgroup::'
331332
if ($PassThru) {
332333
return $codePath

0 commit comments

Comments
 (0)