0
votes

I have paid licensed NuGet packages retrieved via private NuGet source. It prompts for username and password when trying to search for any packages in visual studio from that source. The application (Xamarin Forms) builds just fine with these licensed packages.

Now Azure DevOps, on the other hand, fails as it's not able to restore nuggets from nuget.org.

After researching, tried 2 options:

Option 1: To use "Service connections" in DevOps to connect to this source with credentials, just like in Visual Studio, and use NuGet restore to select that Service connection. This generates a temp nuget.config file, with it's full content being: <configuration/> and the task fails to locate missing NuGets.

Option 2: To use Artifacts, and push manually from my local machine. I've pushed the project referenced files from their location, but their artifact description has "Trial version" attached at the end. The build still fails with this error:

##[error]The NuGet command failed with exit code(1) and error(NU1101: Unable to find package Infragistics.XF.DV. No packages exist with this id in source(s): 94785e32-5a7b-4923-93b0-abe71c3c1f4c

I assume that it fails in both cases because of the temp nuget.config file is blank. After option 2, the config file gets deleted, so I cant see what's actually inside.

Also note, that this source is extremely slow when browsing using Visual Studio.

Please advise how I could get private packages into DevOps?

EDIT Answer: The Nuget restore task, nuget.config path was blank, as I expected a new one to be auto-generated with similar to answer's content. I added a Nuget.config into the project's source code with 2 feeds and it worked correctly.

Also, you can find your visual studio global Nuget.config at: %AppData%\NuGet.

1

1 Answers

4
votes

Please advise how I could get private packages in to Devops?

Assuming packages your project needs are from two feeds: public nuget.org and another private feed:

For nuget restore task, if we choose Feeds in my Nuget.config in feeds to use, we can configure Credentials for feeds outside this organization/collection there. This is what we need for private feed.

(If you're using yaml pipeline, the related inputs are feedsToUse, nugetConfigPath and externalFeedCredentials)

Following these steps:

1.Create a simple Nuget.Config file in azure devops repos(same branch as your solution):

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="PrivateFeed" value="Url of Your Feed, end with index.json" />
  </packageSources>
</configuration>

Copy content above to the Nuget.Config file and save the change. (Or you can get local Nuget.Config used by Visual Studio and add it into source control)

Note: You should enter the feed url of nuget.org and your private feed in Nuget.Config file.

2.Configure the path to the Nuget.Config file in your azure devops repos in Path to Nuget.config.

3.Create new service connection for private feed if you don't have one:

enter image description here

4.Choose basic Authentication and enter username and password and give the service connection a name, then save.

enter image description here

Now the Azure Devops Service can access your private feed when restoring nuget packages for your project. Hope it helps :)