VSO NuGet Publisher Build Step Fails

后端 未结 3 1246
长发绾君心
长发绾君心 2021-01-01 00:33

I am using Visual Studio Online - Package Manager Preview, along with the new build system. The package manager preview adds a number of build steps, including a \"NuGet Pub

相关标签:
3条回答
  • 2021-01-01 00:47

    The in-box NuGet Publish task has two options: "external" feeds and "internal" feeds. External feeds are intended for 3rd party services like NuGet.org, Artifactory, and expect a service connection with an API key.

    Internal feeds are those hosted by Team Services. Instead of a service connection, you add the URL of the feed's NuGet endpoint. The build system relies on the Project Collection Build Service (for collection-scoped build definitions) or Project Build Service (for "this project"-scoped build defs) being a Reader or Contributor to the feed. Docs for all that are available here.

    0 讨论(0)
  • 2021-01-01 00:56

    UPDATE: It is all fixed now so you can use the standard packaging steps in vNext and they work like a charm.

    For the time being, I am substituting the NuGet Publisher step with a PowerShell build step.

    This slots into the build after the "NuGet Packager" step and allows me to specify all of the credentials by setting up a package source before pusing the package.

    $feedUrl = "https://example.pkgs.visualstudio.com/DefaultCollection/_packaging/Example/nuget/v3/index.json"
    
    $packagePath =  $ENV:BUILD_REPOSITORY_LOCALPATH + "\YourOrg.YourComponent." + $ENV:BUILD_BUILDNUMBER + ".nupkg"
    
    Write-Host "Adding package Source"
    $addSourceCommand = $ENV:BUILD_REPOSITORY_LOCALPATH + "\nuget sources add -name ""Example"" -source " + $feedUrl + " -username ""your.username"" -password ""yourpassword"""
    Invoke-Expression -Command $addSourceCommand
    
    Write-Host "Pushing package to NuGet"
    $pushCommand =  $ENV:BUILD_REPOSITORY_LOCALPATH + "\nuget push $packagePath -Source " + $feedUrl + " -ApiKey Example"
    Invoke-Expression -Command $pushCommand
    
    0 讨论(0)
  • 2021-01-01 01:07

    I landed here because I'm researching/configuring an internal deploy -- where I'm running my own NuGet Server (nuget.server, as opposed to visual studio online). The error was the same (or has similar text):

    Object reference not set to an instance of an object

    My solution, it turned out, was that the URL wasn't right. The correct version is: http://server-name/NuGet/api/v2/package

    For completeness, I had: http://server-name/NuGet/ which was wrong.

    0 讨论(0)
提交回复
热议问题