能否从GitHub Packages公共仓库使用Install-Module安装PowerShell模块?
问题:无法从GitHub Packages的NuGet仓库获取PowerShell模块
背景
我已成功将自研的PowerShell模块发布至GitHub Packages的NuGet仓库,过程参考了多篇PowerShell相关技术文档。
已完成操作
- 注册PSRepository:
Register-PSRepository -Name GitHub -SourceLocation https://nuget.pkg.github.com/beau-witter/index.json -PublishLocation https://nuget.pkg.github.com/beau-witter/index.json -InstallationPolicy Trusted
- 首次执行发布命令成功:
Publish-Module -Path path/to/module -Repository GitHub -NuGetApiKey "<GITHUB_API_KEY>"
- 重复发布同一版本模块时,收到冲突错误,确认首次发布确实成功:
Write-Error: Failed to publish module 'NetworkAnalyzer': 'nuget.exe failed to push Response status code does not indicate success: 409 (Conflict). '
当前问题
执行Find-Module -Repository GitHub -Credential $BuiltCredentialObject时返回空值,无法获取已发布的模块。GitHub官方文档大多围绕.NET项目和dotnet命令展开,关于PowerShell模块的获取步骤描述模糊;相关NuGet社区问题提到GitHub理论上可作为PSRepository供PowerShellGet命令使用,但内容仅涉及发布流程,未说明如何消费已发布的模块。
疑问
是否真的可以从GitHub Packages的NuGet仓库中获取并使用有效的PowerShell模块?
内容的提问来源于stack exchange,提问作者B. Witter
相关产品推荐
相关产品推荐

