0
votes

I tried to follow the best practices by using a single feed from the client. So I've setup a Nuget.config file with a single entry to my feed, with a <clear/> tag as stated in the doc.

On the devops server side, I've set up the feed with an Upstream source to the public Nuget Gallery (in order to cache, as this sounded nice in case of public package managers outages.

When I directly use the nuget.exe client on any machine, I can install any nuget.org package in any case. But at build time, when a public package isn't already in my serve's upstream cache, it won't be found by the build agent... (it seems that in this case, the upstreams isn't been used to feed the cache).

Is this normal? Is it limited to already cached packages at build time?

In our develoment team, we are used to add nuget packages through the VS UI (right click project "manage nuget packages"). In this mode, we can not see those upstreams packages, so we toggle the source to nuget directly at dev time.

The solutions that I found could be either:

  • to add a second entry to the Nuget.config to declare nuget.org for build (but we loose the caching capability)
  • to systematically use the command line nuget.exe to install the packages at development time?

What did I miss? Do you have any other ideas/solutions?

EDIT: it seems that it failed due to the following error: enter image description here

BTW: I'm quite new to Azure Devops (using an on premise version "Dev18.M170.6").

1

1 Answers

1
votes

Is this normal? Is it limited to already cached packages at build time?

This is not normal. It is not limited to the cached packages at build time.

For example, I create a new test feed with enable Upstream source to the public Nuget Gallery:

enter image description here

Now only a few packages I tested before are cached, then I add another test package log4net and restore it with my following nuget.config:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <clear />
    <add key="NewFeed" value="https://pkgs.dev.azure.com/<MyOrgName>/_packaging/NewFeed/nuget/v3/index.json" />
  </packageSources>
  
  <config>

</config>

  <packageSourceCredentials>
    <NewFeed>
      <add key="Username" value="XXX" />
      <add key="ClearTextPassword" value="XXX" />
    </NewFeed>
  </packageSourceCredentials>

</configuration>

The nuget restore result:

enter image description here

The feed result:

enter image description here

So, It is not limited to the cached packages at build time. The reason why this method is invalid for you requires specific analysis of your nuget restore task log.

As a reminder, please check if project Build Services have permission to access your feed:

Feed settings->Permissions->...->Allow Project-scoped build:

enter image description here

In our develoment team, we are used to add nuget packages through the VS UI (right click project "manage nuget packages"). In this mode, we can not see those upstreams packages, so we toggle the source to nuget directly at dev time.

You could add the upstream source nuget.org as nuget scource in Visual Studio, which you could dd nuget packages through the VS UI. When you build the pipeline in Azure devops, nuget will restore the package from the custom feed and cache the package from upstream source:

enter image description here