0

无法将现有 Powershell 模块的更新发布到我们的 Artifact Store。

在我的脚本中,我注册了我的存储库和包源:

Register-PSRepository -Name ArtifactoryDev -SourceLocation $NuGetDevUrl -PublishLocation $NuGetDevUrl -InstallationPolicy Trusted -Credential $Cred
    Register-PackageSource -Name ArtifactoryDev -ProviderName NuGet -Location $NuGetDevUrl -Trusted -Credential $Cred

然后,我在脚本接近尾声时尝试发布模块以更新 Artifactory 中现有的模块:

    Publish-Module -Path $Module.Path -Repository $RepositoryName -NuGetApiKey "$($ArtifactoryUser):$($ArtifactoryToken)" -Credential $Cred -Force -ErrorAction Stop -Verbose -Debug

我收到以下错误

2019-06-27T12:12:24.2452350Z ##[error]PackageManagement\Get-PackageSource : Unable to find repository 'ArtifactoryDev'. Use Get-PSRepository to see all 
available repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.1.5\PSModule.psm1:9360 char:35
+ ... ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource] 
   , Exception
    + FullyQualifiedErrorId : SourceNotFound,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource

要检查存储库是否存在,我想调用 Get-PackageSource -Name ArtifatoryDe​​v

我可以在结果中看到它:

Name                             ProviderName     IsTrusted  Location
----                             ------------     ---------  --------
ArtifactoryDev                   PowerShellGet    True        http://myremoterepo
4

1 回答 1

1

我在发布功能方面遇到了类似的问题。您是否尝试在发布之前取消注册并重新注册存储库?我发现这可以解决问题。出于某种原因,发布模块在发布之前对 repo 进行匿名调用以检查版本(我认为),如果 repo 是安全的(或不允许匿名身份验证),您可能会收到错误。通过在发布之前取消注册和重新注册存储库,我发现它以某种方式绕过了匿名调用......不知道究竟是为什么。

于 2019-06-28T15:05:57.833 回答