0
votes

The package I am trying to restore is both on nuget.org and on a 3rd party myget. The 3rd party is a higher version (pre-release) that I want to use, however it seems to not even try to locate the myget source for this package since it finds the package on nuget.org except not the version I want resulting in the following error message:

##[error]The nuget command failed with exit code(1) and error(Errors in packages.config projects
Unable to find version '2.0.0-dev-00013' of package 'Discord.Addons.Interactive'.
  https://api.nuget.org/v3/index.json: Package 'Discord.Addons.Interactive.2.0.0-dev-00013' is not found on source 'https://api.nuget.org/v3/index.json'.)

The myget is properly configured in my nuget.config, which is in my solution root

<?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="Foxbot" value="https://www.myget.org/F/foxbot-discord-addons/api/v3/index.json" />
  </packageSources>
</configuration>

How would I go about making the nuget restore step respect the myget package source for this package?

2
Hi Perry, how do you configure the nuget restore task in build pipeline? As I know, to make nuget.config work in build pipeline, we should set Nuget.config as our feeds, or it won't work though this file is in Solution directory. (This is something different from restore locally.)LoLance

2 Answers

1
votes

How would I go about making the nuget restore step respect the myget package source for this package?

For nuget restore task, there's one option used to control which feeds to use during package restore.

See feeds to use:

enter image description here

Different from restoring packages locally, the nuget.config file in solution directory(Devops Repos) won't work until we check the Feeds in my Nuget.config option.

So during that process, nuget actually didn't use your nuget.config file for package source, which caused this issue:

enter image description here

Workaround:

Configure the Feeds in my Nuget.config like below to make sure nuget will use your Nuget.config file in Solution directory:

enter image description here

In addition: If you're using yaml format instead of classic format, you should set feedsToUse: 'config' and nugetConfigPath: 'path/NuGet.config'.

0
votes

There is no longer a priority for sources, the fastest one wins.

Packages are expected to be unique on the id and version, scenarios where feeds contain different variations of the same id/version are NOT supported.

The priority ordering caused performance issues, as the calls to the sources were sequential instead of parallel. I would suggest you the following to resolve this issue:

  • avoid having different packages with the same id/version, or to reconcile these issues before hand by using a single feed where this has already been resolved.
  • Add a prefix/suffix in the custom feed source

If still requires the priority , you could so something like below: Have config something like below:

  <packageSources>
        <!-- Internal package source comes before NuGet.org proxy -->   
        <add key="my_private_feed" value="Feed1/" priority="1" />
        <add key="Orgnugetorg" value="https://www.nuget.org/api/v2/" priority="2" />
    </packageSources> 

The **PackageDownloader** needs to be adapted that he waits for the download with the highest priority if package sources have different priorities otherwise fastest wins,

But please be mindful that it would require change in Packagedownloader in your pipeline.

Additional reference:

https://github.com/NuGet/Home/issues/5611

NuGet packageSources priority

Hope it helps.