Reputation: 543
We are having issues with NuGet package updates and TFS source control integration lately. This is causing allot of hassles with our team and making us hesitate in adopting NuGet packages fully.
The issue/bug: instead of updating certain projects "package.config" files, they are being removed from the file system (and marked as deleted within TFS source control) I can't work out why.
The behavior we are seeing is the following:
I notice this and Undo Check-Out & get this error:
TF400024: The change on xxx\packages.config cannot be undone because a file already exists at xxx\packages.config. The file must be deleted from disk for the undo to succeed.
The output provided by Package Manager listed below does not indicate any issues for the project in which the package.config was removed.
Updating 'NugetPackageAssemblyA' from version '1.5.18.0' to '1.5.23.0' in project 'CommonUnitTests'.
Removed reference 'AssemblyAA.dll' from project 'CommonUnitTests'
Removed reference 'AssemblyBB.dll' from project 'CommonUnitTests'
Removed reference 'AssemblyCC.dll' from project 'CommonUnitTests'
Removed reference 'NugetPackageAssemblyA.dll' from project 'CommonUnitTests'
Added file 'packages.config'.
Removed file 'packages.config'
Successfully removed 'NugetPackageAssemblyA 1.5.18.0' from CommonUnitTests.
Added reference 'AssemblyAA' to project 'CommonUnitTests'
Added reference 'AssemblyBB' to project 'CommonUnitTests'
Added reference 'AssemblyCC' to project 'CommonUnitTests'
Added reference 'NugetPackageAssemblyA' to project 'CommonUnitTests'
'packages.config' already exists. Skipping...
Successfully added 'NugetPackageAssemblyA 1.5.23.0' to CommonUnitTests.
DEV. Environment Stats:
Is there anything I'm missing?
Upvotes: 22
Views: 19063
Reputation: 1
If you check out code from TFS, and because the complex relationships between packages you cannot reload one or more nuget(s), here is what I did:
But just make sure the code used to work properly before last time check in.
Upvotes: 0
Reputation: 1772
When you upgrade a package with content files, NuGet uninstall older version, removing the files and causing delete into pending changes. What I did to that avoid was:
This way you don't have to make dirty check-ins.
Upvotes: 0
Reputation: 1
Clearing your nuget cache before updating the packages could solve the problem.
Upvotes: -2
Reputation: 572
I had this same problem. The issue was that I had previously installed and uninstalled the package. Even though I checked the project into TFS after the installation, the package remained in the packages folder in my TFS solution.
In order to resolve, I opened the Source Control Explorer window and located the problem folder as identified in the package installation error message: "The change on \packages[folder][package].nupkg cannot be undone because a file already exists at \packages[folder][package].nupkg. The file must be deleted from disk for the undo to succeed."
I then deleted \packages[folder] and checked in.
After this, my NuGet package installed without issue.
Upvotes: 0
Reputation: 11
I had a similar issue and I did the following:
Upvotes: -1
Reputation: 2180
I had this problem too.
To resolve that:
After this you will can Install the Nuget packages without receive TF400024 error.
Upvotes: 11
Reputation: 129
What's happening here (likely) is that you had a previous version (or the same version) of the .dll as a reference, and at SOME point (whether you did it or VS did it), it removed the reference. While you're not seeing the reference in the folder, the TFS / GIT checkin process is still waiting to "check in" the fact that you've removed it. So if you haven't checked in this fact, VS thinks it's still there, when in reality it's not. You can verify this in the Team Explorer area where you should be able to see the removed .dll (indicated by a line through it).
Kinda stupid, but that's how it goes.
Upvotes: 12
Reputation: 1357
A simple check-in of the code to Visual Studio Online did the trick for me.
Upvotes: 24
Reputation: 21
A workaround for us was to check out the entire solution and then update your NuGet packages.
Upvotes: 2
Reputation: 27201
Try:
Upvotes: 2