gaelcolas / gaelcolas/Sampler

Private galleries don't register correctly

Open
#430 1 comment 0 reactions 0 assignees View on GitHub
bug good first issue help wanted
Dominant language
PowerShell
Stars
243
Forks
46
Avg merge
1h 41m
Merged PRs (30d)
1

Description

### 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

```text
[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

```text
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

```text
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

```text
Sampler 0.116.5 C:\Users\admindjn\Documents\WindowsPowerShell\Modules\Sampler\0.116.5\Sampler.psd1
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.