【问题标题】:Publishing Powershell Modules to VSTS Package Management using Publish-Module使用 Publish-Module 将 Powershell 模块发布到 VSTS 包管理
【发布时间】:2017-12-12 01:05:02
【问题描述】:

我正在尝试将我的 Powershell 模块发布到 VSTS 包管理提要。到目前为止,我有:

$securePass = ConvertTo-SecureString -String $RepositoryPassword -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($RepositoryUsername, $securePass)


Write-Debug "Adding the Repository $RepositoryName"
Register-PSRepository -Name $RepositoryName -SourceLocation $RepositorySourceUri `
                            -PublishLocation $RepositoryPublishUri -Credential $cred `
                          -PackageManagementProvider Nuget -InstallationPolicy Trusted

$PublishParams = @{
    Path = $ModuleFolderPath
    ProjectUri = $ProjectUri
    Tags = $ModuleTags
    Repository = $RepositoryName
    NugetApiKey = $NugetApiKey
}

Publish-Module @PublishParams -Force -Verbose

但是,我收到以下错误:

Publish-PSArtifactUtility:发布模块失败 'Framework.Logging': '发布到 ******** 包管理 喂养 'https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2' 要求将其注册为 NuGet 包源。之后重试 添加此来源
'https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2' 按照指定的说明作为 NuGet 包源 'https://go.microsoft.com/fwlink/?LinkID=698608''。在 C:\程序 文件\WindowsPowerShell\Modules\PowerShellGet\1.1.2.0\PSModule.psm1:1227 字符:17 + 发布-PSArtifactUtility -PSModuleInfo $moduleInfo ` + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~ + 分类信息 : InvalidOperation: (:) [Write-Error], WriteErrorException + 完全限定错误 ID: FailedToPublishTheModule,Publish-PSArtifactUtility

PSRepository 在创建时作为源 Uris 和发布 Uris 传递 https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2。关于我哪里出错的任何指示?

【问题讨论】:

    标签: powershell azure-devops package-managers


    【解决方案1】:

    调用此命令以使用 NuGet.exe 工具添加包源:

    1. 将 Nuget.exe 下载到文件夹中
    2. 打开命令提示符并导航 (CD) 到该文件夹​​

    命令:

    .\nuget.exe sources add -name [sourcename, such as myPSModuleFeed] -source https://[account].pkgs.visualstudio.com/_packaging/[feedname]/nuget/v2 -username test -password [PAT] -storePasswordInClearText
    

    关于个人访问令牌的文章:Authenticate access with personal access tokens for Team Services and TFS

    【讨论】:

    • 谢谢,但是这不会将提要注册为 PSRepository。 VSTS 包管理是否适用于通过 PowerShellGet(发布模块)发布,还是目前通过 Nuget.exe 发布到包管理的唯一方法?
    • @Carl 你不需要更新你的代码,仍然可以使用它。我的意思是您需要将提要添加到 Nuget 源(而不是发布),并且 Publish-Module 对我来说很好。您可以检查 Nuget.config 文件中的来源 (%appdata%\nugget foder)
    • @Carl 工作流程是 1. 调用 Nuget 命令添加源(只需一次) 2. 运行 PowerShell 脚本
    • 谢谢,现在一切似乎都很好 :) 感谢您的帮助。对于未来的参考,我在这里发布了我的完整实现:​​trycatchexfinally.co.uk/posts/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-04
    • 2021-02-13
    • 1970-01-01
    • 2017-10-26
    • 2017-12-29
    • 1970-01-01
    相关资源
    最近更新 更多