简体   繁体   English

使用Publish-Module将Powershell模块发布到VSTS包管理

[英]Publishing Powershell Modules to VSTS Package Management using Publish-Module

I am trying to publish my Powershell modules to a VSTS Package Management feed. 我正在尝试将我的Powershell模块发布到VSTS包管理源。 So far I have: 到目前为止,我有:

$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

However, I get the following error: 但是,我收到以下错误:

Publish-PSArtifactUtility : Failed to publish module 'Framework.Logging': 'Publishing to a ******** package management feed ' https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2 ' requires it to be registered as a NuGet package source. Publish-PSArtifactUtility:无法发布模块'Framework.Logging':'发布到********包管理订阅源' https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2 '要求将其注册为NuGet包源。 Retry after adding this source 添加此源后重试
' https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2 ' as NuGet package source by following the instructions specified at ' https://go.microsoft.com/fwlink/?LinkID=698608 ''. https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2 ”作为按照下列指定的指令NuGet包源' https://go.microsoft.com/fwlink/?LinkID=698608 ‘’ 。 At C:\\Program Files\\WindowsPowerShell\\Modules\\PowerShellGet\\1.1.2.0\\PSModule.psm1:1227 char:17 + Publish-PSArtifactUtility -PSModuleInfo $moduleInfo ` + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException + FullyQualifiedErrorId : FailedToPublishTheModule,Publish-PSArtifactUtility 在C:\\ Program Files \\ WindowsPowerShell \\ Modules \\ PowerShellGet \\ 1.1.2.0 \\ PSModule.psm1:1227 char:17 + Publish-PSArtifactUtility -PSModuleInfo $ moduleInfo` + ~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidOperation :( :) [Write-Error ],WriteErrorException + FullyQualifiedErrorId:FailedToPublishTheModule,Publish-PSArtifactUtility

The PSRepository is passed https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2 as both the source and publish Uris when it is created. PSRepository在创建时通过https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2作为源和发布Uris。 Any pointers as to where I am going wrong? 关于我哪里出错的任何指示?

Calling this command to add package source with NuGet.exe tool: 调用此命令以使用NuGet.exe工具添加包源:

  1. Download Nuget.exe to a folder 将Nuget.exe下载到一个文件夹
  2. Open Command Prompt and navigate (CD) to that folder 打开命令提示符并导航(CD)到该文件夹

command: 命令:

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

Article about Personal Access token: Authenticate access with personal access tokens for Team Services and TFS 有关个人访问令牌的文章: 使用个人访问令牌验证对Team Services和TFS的访问权限

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM