1
votes

I have a private package on Azure DevOps which I consume by an API project.

For that I have in this API project the following:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="nuget" value="https://api.nuget.org/v3/index.json" />
    <add key="mypack" value="https://pkgs.dev.azure.com/org/_packaging/mypack/nuget/v3/index.json" />
  </packageSources>
  <packageSourceCredentials>
    <mypack>
      <add key="Username" value="EmailUserInDevOps" />
      <add key="ClearTextPassword" value="TokenFromDevOps" />
    </mypack>
  </packageSourceCredentials>
</configuration>

It works fine on my development machine ...

But I also want to build the API project using DevOps.

For that I connect DevOps to a Github repository where the API project is.

But in this repository I do not have the Nuget.config file.

I don't have it there to not expose my Password to mypack feed.

How can I solve this?

1

1 Answers

2
votes

Add a NuGet restore step to your build and point it to the artifacts feed.

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    command: 'restore'
    restoreSolution: '$(Build.SourcesDirectory)/WhateverProject.sln'
    feedsToUse: 'select'
    vstsFeed: 'feed guid'
    includeNuGetOrg: true

Additional authentication should not be necessary, as it's running in the context of a service that is already authenticated to your artifacts feed.