Fody/FodyAddinSamples

NuGet Package Restore failure

Closed this issue · 2 comments

When I clone this repository and perform a NuGet Package Restore in Visual Studio 2017 I get the following two errors:

NuGet Package restore failed for project CommanderSample: Unable to find version '0.8.1.2' of package 'Commander.Fody'.
NuGet Package restore failed for project DependencyInjection\NinjectSample: Unable to find version '1.0.0' of package 'Ninject.Fody'.

I initially got this problem in Visual Studio 2017 but not in Visual Studio 2015. After successfully restoring in 2015 it then worked in 2017. After poking around for a bit I realized that 2017 was configured to only use https://api.nuget.org/v3/index.json while 2015 will also use https://www.nuget.org/api/v2/curated-feeds/microsoftdotnet/, a v2 NuGet feed. Commander.Fody and Ninject.Fody can be restored through the v2 NuGet API but not the v3 NuGet API. Once they were in my local NuGet cache at %UserProfile%\.nuget\packages 2017 wouldn't need to download them.

After clearing Fody-related packages from my package cache a few times and poking around some more it looks like these packages can be installed just fine using the v3 NuGet API. For example, when running Install-Package Commander.Fody, NuGet will call https://api.nuget.org/v3/registration1-gz/commander.fody/index.json which successfully contains JSON containing the URL https://api.nuget.org/packages/commander.fody.0.8.1.2.nupkg. The package can then be successfully downloaded using that URL.

The problem is that for any existing project with Commander.Fody in its packages.config that needs to do a Package Restore, NuGet will call https://api.nuget.org/v3-flatcontainer/commander.fody/0.8.1.2/commander.fody.0.8.1.2.nupkg. This returns a 404 instead of the .nupkg file.

For these two packages, the v3 NuGet API endpoint to get a list of the versions also returns a 404. For example, you can successfully see versions for ArraySlice.Fody from https://api.nuget.org/v3-flatcontainer/arrayslice.fody/index.json. However https://api.nuget.org/v3-flatcontainer/commander.fody/index.json is a 404.

Is there anything unusual about the .nuspec files for Commander.Fody and Ninject.Fody that would cause this behavior? Or is this a problem entirely on NuGet.org's end?

The workaround is to add https://www.nuget.org/api/v2 as a NuGet package source. It'll use that successfully after the v3 source fails. The v2 API will redirect to the working .nupkg URL that the v3 API returns when initially installing:

  • https://www.nuget.org/api/v2/package/Commander.Fody/0.8.1.2
  • https://www.nuget.org/api/v2/package/Ninject.Fody/1.0.0

this looks like a nuget index corruption. best option is to raise it with the nuget guys. for the short period i will remove the projects from the solution

I contacted them. For reference, it's a known issue and tracked by this existing issue. It looks like multiple versions of several Fody packages have this problem.