Reputation: 2282
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?
Upvotes: 1
Views: 1178
Reputation: 28086
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:
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:
Workaround:
Configure the Feeds in my Nuget.config
like below to make sure nuget will use your Nuget.config
file in Solution directory:
In addition: If you're using yaml format instead of classic format, you should set feedsToUse: 'config'
and nugetConfigPath: 'path/NuGet.config'
.
Upvotes: 1
Reputation: 5296
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:
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
Hope it helps.
Upvotes: 0