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

这一生的挚爱 提交于 2019-11-30 14:37:34

问题


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 pacakage.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 :

  • Nuget Package manager : version 2.2.40116.9051
  • Visual Studio 2012 : version 11.051106.01 Update 1

Is there anything I'm missing ???? Thanks


回答1:


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




回答2:


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.




回答3:


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.




回答4:


Try:

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



回答5:


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




回答6:


All:

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.

Thanks,

-Yuan Z




回答7:


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.




回答8:


I had a similar issue and I did the following:

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



回答9:


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



来源:https://stackoverflow.com/questions/15441609/nuget-package-updates-package-config-remove-issue-tf400024

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!