darthal
darthal

Reputation: 543

NuGet Package updates & Package.config remove issue (TF400024)

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:

  1. Open in solution (approx. 18 projects) in VS.NET 2012
  2. Initiate a solution level package update to the latest version via the Package Management Dialog, as described here.
    • The package.config exists and part of the project(s) within said selected solution.
    • Theses packages.configs are NOT checked out of TFS yet.
  3. NuGet package update occurs, select package.config are removed from project and marked as deleted within TFS and references remain in project updated to current version.
  4. Obviously, this means that when I check in the solution and project the packages.config will be removed, making future updates (I believe) painful as above project will fall off NuGet's radar.
  5. 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.
    
    • Interesting, to TFS the file is marked as deleted yet it still resides on my file system?

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

Answers (10)

YUAN ZHANG
YUAN ZHANG

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:

  1. Delete the whole solution folder.
  2. Check out code again.
  3. Right click on the solution, then click "Restore NuGet Packages"

But just make sure the code used to work properly before last time check in.

Upvotes: 0

WilliamK
WilliamK

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:

  1. get a clean workspace
  2. open packages.json
  3. remove the reference to the old NuGet package
  4. install the NuGet most recent version as if it was the first time

This way you don't have to make dirty check-ins.

Upvotes: 0

bth
bth

Reputation: 1

Clearing your nuget cache before updating the packages could solve the problem.

Upvotes: -2

The Furious Bear
The Furious Bear

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

Geovanny López
Geovanny López

Reputation: 11

I had a similar issue and I did the following:

  1. Delete the file from my pc.
  2. Check in the change.

Upvotes: -1

Jeferson Tenorio
Jeferson Tenorio

Reputation: 2180

I had this problem too.

To resolve that:

  1. Open your Source Control Explorer (Team Foundation)
  2. Locate the 'packages' folder of solution
  3. Make Checkin of this folder

After this you will can Install the Nuget packages without receive TF400024 error.

Upvotes: 11

ChrisD
ChrisD

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

RHAD
RHAD

Reputation: 1357

A simple check-in of the code to Visual Studio Online did the trick for me.

Upvotes: 24

Rich
Rich

Reputation: 21

A workaround for us was to check out the entire solution and then update your NuGet packages.

Upvotes: 2

Mateen Ulhaq
Mateen Ulhaq

Reputation: 27201

Try:

  • Unbind all your projects from source control
  • Install the nuget package
  • Rebind all your projects again

Upvotes: 2

Related Questions