@@ -41,6 +41,7 @@ $excludedFiles = @("System.Management.Automation.dll", "JetBrains.Annotations.dl
4141
4242$modulePath = Join-Path $OutputDirectory " PsModule" $ModuleName
4343$isWindowsPowershell = $TargetFramework -like ' net4*'
44+ $isPrerelease = -not [string ]::IsNullOrWhiteSpace($NuGetPreReleaseTag )
4445$moduleAssemblyPath = Join-Path $modulePath ($isWindowsPowershell ? ' desktop' : ' coreclr' )
4546
4647# Prepare the output directory
@@ -59,7 +60,7 @@ Copy-Item -Path (Join-Path $targetDirectory "*") -Destination $moduleAssemblyPat
5960# Prepare the module manifest
6061$config = Get-Content (Join-Path $PSScriptRoot " $ModuleName .psd1" ) - Raw
6162$config = $config.Replace (" ModuleVersion = '0.1'" , " ModuleVersion = '$MajorMinorPatch '" );
62- if (-not [ string ]::IsNullOrWhiteSpace( $NuGetPreReleaseTag ) ) {
63+ if ($isPrerelease ) {
6364 $config = $config.Replace (" # Prerelease = ''" , " Prerelease = '$NuGetPreReleaseTag '" );
6465}
6566Set-Content - Path (Join-Path $modulePath " $ModuleName .psd1" ) - Value $config
@@ -68,17 +69,18 @@ Copy-Item -Path (Join-Path $PSScriptRoot "$ModuleName.psm1") -Destination $modul
6869# This Powershell module requires the module Eryph.ClientRuntime.Configuration.
6970# We download that module first to ensure that it is available. Otherwise,
7071# the import during the test below would fail.
71- $configData = Import-PowerShellDataFile (Join-Path $modulePath " $ModuleName .psd1" )
72- $clientRuntimeVersion = $configData.RequiredModules [0 ].ModuleVersion
73- $clientRuntimeModulePath = Join-Path $OutputDirectory " PsModuleDependencies" " Eryph.ClientRuntime.Configuration"
74- if (-not (Test-Path (Join-Path $clientRuntimeModulePath $clientRuntimeVersion ))) {
75- Save-Module - Path (Join-Path $OutputDirectory " PsModuleDependencies" ) - Name ' Eryph.ClientRuntime.Configuration' - AllowPrerelease - Force
72+ $clientRuntimeModule = Find-Module Eryph.ClientRuntime.Configuration - AllowPrerelease:$isPrerelease
73+ $clientRuntimeVersion = $clientRuntimeModule.Version
74+ $null = New-Item - ItemType Directory - Path (Join-Path $OutputDirectory " PsModuleDependencies" $clientRuntimeVersion ) - ErrorAction SilentlyContinue
75+ $clientRuntimeModulePath = Join-Path $OutputDirectory " PsModuleDependencies" $clientRuntimeVersion " Eryph.ClientRuntime.Configuration"
76+ if (-not (Test-Path $clientRuntimeModulePath )) {
77+ Save-Module - Path (Join-Path $OutputDirectory " PsModuleDependencies" $clientRuntimeVersion ) - Name ' Eryph.ClientRuntime.Configuration' - AllowPrerelease:$isPrerelease
7678}
7779
7880# Verify that all Cmdlets are exposed in the manifest. We must load the modules
7981# in separate Powershell processes to avoid conflicts.
8082$powershell = $isWindowsPowershell ? ' powershell.exe' : ' pwsh.exe'
81- $moduleCmdlets = (& $powershell - Command " Import-Module $clientRuntimeModulePath -RequiredVersion $clientRuntimeVersion ; [array](Import-Module -Scope Local $modulePath -PassThru).ExportedCmdlets.Keys -join ','" ) -split ' ,'
83+ $moduleCmdlets = (& $powershell - Command " Import-Module $clientRuntimeModulePath ; [array](Import-Module -Scope Local $modulePath -PassThru).ExportedCmdlets.Keys -join ','" ) -split ' ,'
8284$assemblyCmdlets = (& $powershell - Command " [array](Import-Module -Scope Local $TargetPath -PassThru).ExportedCmdlets.Keys -join ','" ) -split ' ,'
8385$missingCmdlets = [Linq.Enumerable ]::Except($assemblyCmdlets , $moduleCmdlets )
8486if ($missingCmdlets.Count -gt 0 ) {
0 commit comments