Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private galleries don't register correctly #430

Open
cohdjn opened this issue Jun 14, 2023 · 1 comment
Open

Private galleries don't register correctly #430

cohdjn opened this issue Jun 14, 2023 · 1 comment
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community.

Comments

@cohdjn
Copy link

cohdjn commented Jun 14, 2023

Problem description

When modifying Resolve-Dependency.psd1 to use a private internal gallery, build.ps1 throws errors because the arguments presented to Register-PSRepository in the splat are wrong.

This is the original splat:

    RegisterGallery = @{
        Name = 'PSProdRepo'
        GallerySourceLocation = 'https://obfuscated.local/nuget/PSProdRepo'
        GalleryPublishLocation = 'https://obfuscated.local/nuget/PSProdRepo'
        GalleryScriptSourceLocation = 'https://obfuscated.local/nuget/PSProdRepo'
        GalleryScriptPublishLocation = 'https://obfuscated.local/nuget/PSProdRepo'
        InstallationPolicy = 'Trusted'
    }

The corrected splat:

    RegisterGallery = @{
        Name = 'PSProdRepo'
        SourceLocation = 'https://obfuscated.local/nuget/PSProdRepo'
        PublishLocation = 'https://obfuscated.local/nuget/PSProdRepo'
        ScriptSourceLocation = 'https://obfuscated.local/nuget/PSProdRepo'
        ScriptPublishLocation = 'https://obfuscated.local/nuget/PSProdRepo'
        InstallationPolicy = 'Trusted'
    }

Verbose logs

[pre-build] Starting Build Init
[pre-build] Dependency missing, running './build.ps1 -ResolveDependency -Tasks noop' for you 

[pre-build] Resolving dependencies.
[pre-build] Starting bootstrap process.
Register-PSRepository : A parameter cannot be found that matches parameter name 'GalleryPublishLocation'.
At C:\PSCodeGallery\Modules\Prod\Snmp\Resolve-Dependency.ps1:263 char:31
+         Register-PSRepository @RegisterGallery
+                               ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Register-PSRepository], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Register-PSRepository
 
PackageManagement\Get-PackageSource : Unable to find repository 'PSProdRepo'. Use Get-PSRepository to see all available 
repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.4.1\PSModule.psm1:9531 char:35
+ ... ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource], Exception   
    + FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource

How to reproduce

Uncomment the splat in Resolve-Dependency.psd1 and provide valid arguments but leave the keys as originally coded.

Expected behavior

It should have registered my internal repo.

Current behavior

The build process dies when registering the internal repository.

Suggested solution

Correct the keys in the splat, though I suspect it may not be that simple depending on the varied versions of Powershell.

Operating system the target node is running

sName               : Microsoft Windows 10 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

PSVersion                      5.1.19041.2364
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.2364
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module version used

Sampler 0.116.5 C:\Users\admindjn\Documents\WindowsPowerShell\Modules\Sampler\0.116.5\Sampler.psd1
@gaelcolas
Copy link
Owner

True! Thanks for spotting, that's a mistake from many years ago...
I'd love a PR :)

@johlju johlju added bug The issue is a bug. help wanted The issue is up for grabs for anyone in the community. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub labels Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue is a bug. good first issue The issue should be easier to fix and can be taken up by a beginner to learn to contribute on GitHub help wanted The issue is up for grabs for anyone in the community.
Projects
None yet
Development

No branches or pull requests

3 participants