This project has moved and is read-only. For the latest updates, please go here.
3
Vote

TFS Build Error "File Contains Corrupted Data" on Nuget Package Restore

description

When adding the HTMLAgilityPack 1.4.9 everything builds and works locally just fine. Once I check in and build on my TFS server I receive the following errors:

"nuget.targets: File Contains corrupted data."

nuget.targets: The command nuget.exe install packages.config - source -RequireConsent -o packages exited with code 1 (I've trimmed out the project name from the messages)

I see someone has the same issue here: https://ajaxcontroltoolkit.codeplex.com/workitem/27733

I have tried uninstalling nuget and reinstalling with no success. The build works just fine on the TFS server until I add HTMLAgilityPack then it fails with this error on multiple developers machines. Any help would be greatly appreciated.

comments

DamienM4194 wrote Sep 17, 2014 at 1:12 PM

There seems to be an issue with 1.4.9, i was able to add 1.4.6 through package manager and everything works fine.

wrote Nov 6, 2014 at 4:48 PM

RobVesse wrote Nov 6, 2014 at 4:56 PM

Have run into same problem, upgrading to 1.4.9 broke my builds both on AppVeyor and my projects TeamCity instance

Downgrading to 1.4.6 resolved the problems

The package file looks to be corrupt because I cannot open it locally in NuGet package explorer and get the same error as on the build servers when attempting to do that

ovidiuolaru wrote Nov 17, 2014 at 1:44 PM

I have the same issue. Any update available? Any workaround? It's getting critical for me.

Thank you.

Ovi

wrote Nov 17, 2014 at 1:45 PM

RobVesse wrote Nov 18, 2014 at 10:17 AM

I tweeted about this and was told (https://twitter.com/htmlagilitypack/status/530420842963140608) that usually this can be down to an outdated NuGet client

If you have a .nuget folder in your solution and are using the now-deprecated MSBuild integrated NuGet package restore then this may be a possible cause of the issues.

I've switched to the newer automated package restore functionality but haven't yet tried upgrading HAP again so don't know if that is the root cause of the issue.

RobVesse wrote Nov 21, 2014 at 12:23 PM

Now had chance to re-upgrade to 1.4.9 and it is now working on multiple different build machines

So to summarise:
  • This is caused by an outdated NuGet client
  • If you use the MSBuild integrated package restore then your project is likely using an old NuGet client even if you have an up to date client installed on the actual build machine
  • See Migrating to Automatic Package Restore for how to switch your project to rely on the system nuget
Note that after switching to automatic package restore you may need to configure your builds to invoke the nuget restore feature as a pre-build step like so otherwise you may fail to compile with missing dependency errors:
nuget restore YourSolution.sln