简体   繁体   中英

Publishing Powershell Modules to VSTS Package Management using Publish-Module

I am trying to publish my Powershell modules to a VSTS Package Management feed. 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. 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

The PSRepository is passed https://xxx.pkgs.visualstudio.com/_packaging/PowershellModules/nuget/v2 as both the source and publish Uris when it is created. Any pointers as to where I am going wrong?

Calling this command to add package source with NuGet.exe tool:

  1. Download Nuget.exe to a folder
  2. Open Command Prompt and navigate (CD) to that folder

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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