0

I am trying to do the Nuke.Build push to Azure DevOps internal feed. If I do it within Azure Pipelines, and add a step to publish the nuget, it will give me a step like this:

For the classic:

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet push'
  inputs:
    command: push
    publishVstsFeed: 'faeeeeee-eeee-eeee-eeee-c48a92cb3804/2a06fd96-0000-0000-0000-643ff5710000'

for the yaml:

  - task: NuGetCommand@2
    inputs:
      command: 'push'
      packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
      nuGetFeedType: 'internal'
      publishVstsFeed: 'faeeeeee-eeee-eeee-eeee-c48a92cb3804/2a06fd96-0000-0000-0000-643ff5710000'

In both cases it relies on the internal variable or token that is used to publish to the internal NuGet Feed.

Now, when I do it from Nuke, I have the Publish step like this:

Target Publish => _ => _
    .DependsOn(Pack)
    .Executes(() =>
    {
        DotNetTasks.DotNetNuGetPush(x => x
        .SetApiKey("????")
        .SetSource("https://pkgs.dev.azure.com/company/project/_packaging/feed/nuget/v3/index.json")
        .SetTargetPath(PackagesDirectory));
    });

I get from that:

error: Response status code does not indicate success: 401 (Unauthorized).

So the API Key is needed.

Where do I get the ApiKey from? There got to be a way of importing the secret from the pipeline, so I could use it from the Publish step in Nuke.Build (besides the PAT way) in a non-interactive way?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
tridy
  • 1,166
  • 1
  • 12
  • 21
  • So far I have not figured out how to do that. For now I am using secret variables in the pipeline, in yaml I use `variables` to import the secrets and then use `parameter.json` file in Nuke to import these variables. After that, I use `DotNetTasks.DotNetNuGetAddSource` with PAT to add the source to the nuget settings, and then I am able to Push the *.nupkg file to the feed. I wish it were possible to do that with the internal identity/account since everything is within Azure DevOps, but no luck with that. – tridy Jul 17 '23 at 14:00

0 Answers0