Authenticating with VSTS package feed when publishing DLM package

I've been trying to use the DLM Automation build tasks in VSTS to build and publish a DLM package to a private NuGet package feed, also hosted by VSTS.

My problem is that the only option I get to authenticate using the publish build action is a NuGet API key. This doesn't really help with VSTS because it doesn't really use API keys, it uses PAT tokens instead.

I've tried all sorts of approaches to workaround this, including configuring the copy of nuget.exe in %PATH% to authenticate with the package feed directly (i.e. nuget sources add ... username <pat-user> password <pat-token>), in the hope that the packing task will pick up that executable if/when it goes looking for one - but that hasn't worked either. I suspect it uses an embedded NuGet client?

The stacktrace I get is a fairly standard NuGet 401:
2018-06-12T10:54:40.2011294Z Publishing database package to <REDACTED>.
2018-06-12T10:54:46.5405952Z ##[error]RedGate.DLMAutomation.Shared.Errors.TerminatingException: Cannot publish to NuGet feed. Failed to process request. 'Unauthorized'.
2018-06-12T10:54:46.5407297Z The remote server returned an error: (401) Unauthorized. ---> System.InvalidOperationException: Failed to process request. 'Unauthorized'.
2018-06-12T10:54:46.5407617Z The remote server returned an error: (401) Unauthorized.. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
2018-06-12T10:54:46.5407839Z at System.Net.HttpWebRequest.GetResponse()
2018-06-12T10:54:46.5408014Z at NuGet.RequestHelper.GetResponse()
2018-06-12T10:54:46.5408237Z at NuGet.PackageServer.EnsureSuccessfulResponse(HttpClient client, Nullable`1 expectedStatusCode)
2018-06-12T10:54:46.5414532Z --- End of inner exception stack trace ---
2018-06-12T10:54:46.5414997Z at NuGet.PackageServer.EnsureSuccessfulResponse(HttpClient client, Nullable`1 expectedStatusCode)
2018-06-12T10:54:46.5418175Z at NuGet.PackageServer.PushPackageToServer(String apiKey, Func`1 packageStreamFactory, Int64 packageSize, Int32 timeout, Boolean disableBuffering)
2018-06-12T10:54:46.5419708Z at RedGate.DLMAutomation.Compare.BuildArtifacts.NuGet.PublishToFeed.BuildArtifactPublisher.PublishToNuGet(IBuildArtifact buildArtifact, Uri nugetSource, String apiKey)
2018-06-12T10:54:46.5420258Z --- End of inner exception stack trace ---
2018-06-12T10:54:46.5420458Z at RedGate.DLMAutomation.Compare.BuildArtifacts.NuGet.PublishToFeed.BuildArtifactPublisher.PublishToNuGet(IBuildArtifact buildArtifact, Uri nugetSource, String apiKey)
2018-06-12T10:54:46.5420635Z at RedGate.DLMAutomation.PowerShell.DlmAutomationCommandImpl`1.ProcessRecord()
2018-06-12T10:54:46.5420979Z at RedGate.PowerShell.CommandBase`2.DelegateTo(Action doImplementation)

Would anybody be kind enough to give me some advice on how I can get the DLM package into my VSTS package feed? Is it okay to upload the built .nupkg outside of the official publish task/module? That way I would have the full range of auth options available.

Thanks in advance.
Tagged:

Answers

  • Hello

    It's perfectly fine to upload the NuGet package using any mechanism you wish. You can use `Export-DatabaseBuildArtifact` to export an then publish any way you want.

    As you guessed, we use an embedded client and call just `nuget push`.

    Thanks
    Mikiel Agutu | Software Engineer | Redgate Software
Sign In or Register to comment.