gaelcolas / Sampler

Module template with build pipeline and examples, including DSC elements.
MIT License
167 stars 42 forks source link

Bootstrap does not work when `AllowPrerelease` is configured #394

Closed raandree closed 1 year ago

raandree commented 1 year ago

Problem description

When having AllowPrerelease set to $true in Resolve-Dependency.psd1, this setting is ignored.

Verbose logs

[pre-build] Starting Build Init
[pre-build] Creating required modules directory C:\BuildWorker1\_work\3\s\output\RequiredModules.
[pre-build] Pre-pending 'C:\BuildWorker1\_work\3\s\output\RequiredModules' folder to PSModulePath
[pre-build] Dependency missing, running './build.ps1 -ResolveDependency -Tasks noop' for you 

[pre-build] Resolving dependencies.
[pre-build] Starting bootstrap process.
VERBOSE: Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\PackageManagement.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.1.7.0\PackageManagement.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\PackageManagement.psd1'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\PackageManagement.format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\PackageManagement.psm1'.
VERBOSE: Exporting cmdlet 'Find-Package'.
VERBOSE: Exporting cmdlet 'Find-PackageProvider'.
VERBOSE: Exporting cmdlet 'Get-Package'.
VERBOSE: Exporting cmdlet 'Get-PackageProvider'.
VERBOSE: Exporting cmdlet 'Get-PackageSource'.
VERBOSE: Exporting cmdlet 'Import-PackageProvider'.
VERBOSE: Exporting cmdlet 'Install-Package'.
VERBOSE: Exporting cmdlet 'Install-PackageProvider'.
VERBOSE: Exporting cmdlet 'Register-PackageSource'.
VERBOSE: Exporting cmdlet 'Save-Package'.
VERBOSE: Exporting cmdlet 'Set-PackageSource'.
VERBOSE: Exporting cmdlet 'Uninstall-Package'.
VERBOSE: Exporting cmdlet 'Unregister-PackageSource'.
VERBOSE: Importing cmdlet 'Find-Package'.
VERBOSE: Importing cmdlet 'Find-PackageProvider'.
VERBOSE: Importing cmdlet 'Get-Package'.
VERBOSE: Importing cmdlet 'Get-PackageProvider'.
VERBOSE: Importing cmdlet 'Get-PackageSource'.
VERBOSE: Importing cmdlet 'Import-PackageProvider'.
VERBOSE: Importing cmdlet 'Install-Package'.
VERBOSE: Importing cmdlet 'Install-PackageProvider'.
VERBOSE: Importing cmdlet 'Register-PackageSource'.
VERBOSE: Importing cmdlet 'Save-Package'.
VERBOSE: Importing cmdlet 'Set-PackageSource'.
VERBOSE: Importing cmdlet 'Uninstall-Package'.
VERBOSE: Importing cmdlet 'Unregister-PackageSource'.
VERBOSE: Importing Bootstrap default parameters from '$PSScriptRoot/Resolve-Dependency.psd1'.
VERBOSE: Setting parameter 'Gallery' to value 'PowerShell'.
VERBOSE: Setting parameter 'AllowPrerelease' to value 'True'.
VERBOSE: Setting parameter 'WithYAML' to value 'True'.
VERBOSE: Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\fullclr\Microsoft.PackageManagement.MetaProvider.PowerShell.dll
VERBOSE: Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\fullclr\Microsoft.PackageManagement.NuGetProvider.dll
VERBOSE: Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\fullclr\Microsoft.PackageManagement.ArchiverProviders.dll
VERBOSE: Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\fullclr\Microsoft.PackageManagement.CoreProviders.dll
VERBOSE: Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\fullclr\Microsoft.PackageManagement.MsuProvider.dll
VERBOSE: Acquiring providers for assembly: C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.8.1\fullclr\Microsoft.PackageManagement.MsiProvider.dll
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.0\PowerShellGet.psd1'.
VERBOSE: Importing function 'Find-Command'.
VERBOSE: Importing function 'Find-DscResource'.
VERBOSE: Importing function 'Find-Module'.
VERBOSE: Importing function 'Find-RoleCapability'.
VERBOSE: Importing function 'Find-Script'.
VERBOSE: Importing function 'Get-InstalledModule'.
VERBOSE: Importing function 'Get-InstalledScript'.
VERBOSE: Importing function 'Get-PSRepository'.
VERBOSE: Importing function 'Install-Module'.
VERBOSE: Importing function 'Install-Script'.
VERBOSE: Importing function 'New-ScriptFileInfo'.
VERBOSE: Importing function 'Publish-Module'.
VERBOSE: Importing function 'Publish-Script'.
VERBOSE: Importing function 'Register-PSRepository'.
VERBOSE: Importing function 'Save-Module'.
VERBOSE: Importing function 'Save-Script'.
VERBOSE: Importing function 'Set-PSRepository'.
VERBOSE: Importing function 'Test-ScriptFileInfo'.
VERBOSE: Importing function 'Uninstall-Module'.
VERBOSE: Importing function 'Uninstall-Script'.
VERBOSE: Importing function 'Unregister-PSRepository'.
VERBOSE: Importing function 'Update-Module'.
VERBOSE: Importing function 'Update-ModuleManifest'.
VERBOSE: Importing function 'Update-Script'.
VERBOSE: Importing function 'Update-ScriptFileInfo'.
VERBOSE: Importing alias 'fimo'.
VERBOSE: Importing alias 'inmo'.
VERBOSE: Importing alias 'pumo'.
VERBOSE: Importing alias 'upmo'.
VERBOSE: Bootstrap: The PowerShellGet version is 1.6.0
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PowerShellGet'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.0\PSModule.psm1:2058 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

How to reproduce

Enable AllowPrerelease and have only a pre-release version of PowerShellGet in the local repository.

Expected behavior

Using the latest version of PowerShellGet as configured even if it is a pre-release.

Current behavior

PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'PowerShellGet'.

Suggested solution

Working on a fix.

Operating system the target node is running

OsName               : Microsoft Windows Server 2022 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value                                                                                                                                                                              
----                           -----                                                                                                                                                                              
PSVersion                      5.1.20348.230                                                                                                                                                                      
PSEdition                      Desktop                                                                                                                                                                            
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                            
BuildVersion                   10.0.20348.230                                                                                                                                                                     
CLRVersion                     4.0.30319.42000                                                                                                                                                                    
WSManStackVersion              3.0                                                                                                                                                                                
PSRemotingProtocolVersion      2.3                                                                                                                                                                                
SerializationVersion           1.1.0.1

Module version used

0.115.0