gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 01:07:49 25 4
gpt4 key购买 nike

我正在尝试将我的 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 : 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. 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''. 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



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

最佳答案

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

  • 将 Nuget.exe 下载到文件夹
  • 打开命令提示符并导航 (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

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

    关于powershell - 使用 Publish-Module 将 Powershell 模块发布到 VSTS 包管理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44975744/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com