Skip to content

Commit f245c22

Browse files
committed
Enhance PublishToPSGallery script with repository verification and detailed logging
1 parent ea6e272 commit f245c22

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

.azuredevops/scripts/PublishToPSGallery.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,25 @@ try {
2929
# Publish to PowerShell Gallery
3030
# Ensure the default repository is registered, PSGallery
3131
if (-not (Get-PSRepository -Name 'PSGallery' -ErrorAction SilentlyContinue)) {
32+
Write-Host "PSGallery repository not found. Registering..."
3233
Register-PSRepository -Default
3334
}
34-
Publish-Module -Path $ModulePath -NuGetApiKey $ApiKey -SkipAutomaticTags
35+
36+
# Verify PSGallery is properly configured
37+
$psGallery = Get-PSRepository -Name 'PSGallery' -ErrorAction Stop
38+
Write-Host "PSGallery repository found:"
39+
Write-Host " SourceLocation: $($psGallery.SourceLocation)"
40+
Write-Host " PublishLocation: $($psGallery.PublishLocation)"
41+
Write-Host " InstallationPolicy: $($psGallery.InstallationPolicy)"
42+
43+
# Publish to PowerShell Gallery with explicit repository name
44+
Write-Host "Publishing module from: $ModulePath"
45+
Publish-Module -Path $ModulePath -NuGetApiKey $ApiKey -Repository 'PSGallery' -SkipAutomaticTags -Verbose
3546

3647
Write-Host "Successfully published to PowerShell Gallery"
3748
}
3849
catch {
3950
Write-Host "##vso[task.logissue type=error]Error publishing to PowerShell Gallery. Error was $($_.Exception.Message)"
51+
Write-Host "##vso[task.logissue type=error]Full error details: $($_.Exception | Format-List * -Force | Out-String)"
4052
exit 1
4153
}

0 commit comments

Comments
 (0)