【发布时间】:2019-11-16 00:57:28
【问题描述】:
我的 VSTS 项目中有一个 PowerShell 模块的提要,我将它用作私人画廊,基于这篇文章: https://roadtoalm.com/2017/05/02/using-vsts-package-management-as-a-private-powershell-gallery/
当我们在机器上运行它时,一切都很好。 我需要这些模块作为发布过程的一部分,所以首要任务是注册这个 repo(如果它不存在),然后下载并安装每个模块的最新版本。 我的脚本的相关部分是:
Install-PackageProvider -Name NuGet -Confirm:$false -RequiredVersion 2.8.5.208
Get-PSRepository | Where-Object {$_.Name -eq "MyPrivateFeed" -or $_.SourceLocation -eq "https://myproject.pkgs.visualstudio.com/_packaging/MyPrivateFeed/nuget/v2"} | Unregister-PSRepository
Register-PSRepository -Name "MyPrivateFeed" -SourceLocation "https://myproject.pkgs.visualstudio.com/_packaging/MyPrivateFeed/nuget/v2" -InstallationPolicy Trusted
$PAT = $(System.AccessToken) | ConvertTo-SecureString -AsPlainText -Force
$VSTSCredentials = New-Object -TypeName PScredential("dummy", $PAT)
Find-Module -Name * -Repository MyPrivateFeed -Credential $VSTSCredentials | Install-Module -Credential $VSTSCredentials
发行版中的 PowerShell 任务失败并显示:
WARNING: Unable to find module repositories.
PackageManagement\Register-PackageSource : The property 'Values' cannot be
found on this object. Verify that the property exists.
At C:\Program
Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4173
char:17
+ ... $null = PackageManagement\Register-PackageSource @PSBoundParamete ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Microsoft.Power...erPackageSource
:RegisterPackageSource) [Register-PackageSource], Exception
+ FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.Pack
ageManagement.Cmdlets.RegisterPackageSource
当我在 ISE/Console 上运行相同的脚本时,它可以在同一台机器上运行(当然,用实际的 PAT 替换令牌) 有人知道这里发生了什么吗?
我尝试将 -PackageManagementProvider NuGet 添加到 Register-PSRepository 但没有帮助
【问题讨论】: