据我所知a PowerShell repository is a NuGet repository ...
GitHub 刚刚发布了他们的 package registry ,我的公司目前用于 npm,但也有一个用于 NuGet 的端点。
我可以使用我的 GitHub 凭据访问 NuGet 端点 ( https://nuget.pkg.github.com/mycompany/index.json ),它返回一个有效的 json:
{
"version": "3.0.0-beta.1",
"resources": [
{
"@id": "https://nuget.pkg.github.com/mycompany/download",
"@type": "PackageBaseAddress/3.0.0",
"comment": "Get package content (.nupkg)."
},
{
"@id": "https://nuget.pkg.github.com/mycompany/query",
"@type": "SearchQueryService",
"comment": "Filter and search for packages by keyword."
},
{
"@id": "https://nuget.pkg.github.com/mycompany/query",
"@type": "SearchQueryService/3.0.0-beta",
"comment": "Filter and search for packages by keyword."
},
{
"@id": "https://nuget.pkg.github.com/mycompany/query",
"@type": "SearchQueryService/3.0.0-rc",
"comment": "Filter and search for packages by keyword."
},
{
"@id": "https://nuget.pkg.github.com/mycompany",
"@type": "PackagePublish/2.0.0",
"comment": "Push and delete (or unlist) packages."
},
{
"@id": "https://nuget.pkg.github.com/mycompany",
"@type": "RegistrationsBaseUrl",
"comment": "Get package metadata."
},
{
"@id": "https://nuget.pkg.github.com/mycompany",
"@type": "RegistrationsBaseUrl/3.0.0-beta",
"comment": "Get package metadata."
},
{
"@id": "https://nuget.pkg.github.com/mycompany",
"@type": "RegistrationsBaseUrl/3.0.0-rc",
"comment": "Get package metadata."
}
]
}
我一直在尝试使用它在我的本地机器上将其设置为存储库(在理想情况下,我会在我的 CI/CD 上推送模块并将它们提供给
Install-Module
使用 GitHub 作为存储库的人):PS C:> $gitHubCredential = Get-Credential
PS C:> (iwr https://nuget.pkg.github.com/mycompany/index.json -Credential $gitHubCredential).StatusCode
200
PS C:> Register-PSRepository -Name GitHub -SourceLocation https://nuget.pkg.github.com/mycompany -PublishLocation https://nuget.pkg.github.com/mycompany -Credential $gitHubCredential
Register-PSRepository : The specified Uri 'https://nuget.pkg.github.com/mycompany' for parameter 'SourceLocation' is
an invalid Web Uri. Please ensure that it meets the Web Uri requirements.
At line:1 char:1
+ Register-PSRepository -Name GitHub -SourceLocation https://nuget.pkg. ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (https://nuget.pkg.github.com/mycompany:String) [Register-PSRepository
], ArgumentException
+ FullyQualifiedErrorId : InvalidWebUri,Register-PSRepository
我在尝试一些不可能的事情吗?
最佳答案
我自己已经研究了几天了。 these docs 中第 3 步的注意事项是 PowerShell 不支持 v3 的 NuGet 提要/API。据我所知,GitHub 包注册表仅支持 NuGet 提要/API 的 v3,因此我担心目前无法实现。
关于powershell - 使用 GitHub 包注册表作为 PowerShell 包存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60008539/