"The item already exists" when adding trying to add files to TFS - visual-studio-2013

I am having problems adding files to TFS Online. Here are the steps I made to get up to this point:
Created a project in TFS "SomeProject_Classic"
Mapped it to a path in my computer C:\SomeProject\classic
Pushed all files from from WITHIN the \classic folder to this project
Deleted the project in TFS
Recreated a new project in TFS with the same name ("SomeProject_Classic")
Mapped it to a path on my computer C:\SomeProject
I try to add the classic folder (not only the files in it like step 3, but the entire folder itself)
On this last step, it gives me the error "The item $/SomeProject_Classic/classic/somefile.txt already exists".
Basically, I think it is having a problem thinking that I have already added these files because I created a project with the same name in TFS and never "checked those files out for deletion" before deleting the project.. I feel like I need to clear a cache or TFS memory or something. Any advice?

Clean the Cache folder on client computer. The folder path is: C:\Users\username\AppData\Local\Microsoft\Team Foundation\6.0\Cache.
Use the tf destroy command to destroy, or permanently delete, version-controlled files from Team Foundation version control. Check:https://msdn.microsoft.com/en-us/library/bb386005(v=vs.100).aspx

This was somewhat related to Cece's answer in that even though it was deleted on the server, my local computer still thought the file were in the uploaded workspace.
What I did was create a temp folder TempRepo on my desktop and moved the files from the "classic" folder to it. I mapped my workspace to this TempRepo folder. Then I was able to "add existing files" to the workspace and push my files from this temp folder to Visual Studio Online.
When I was done, I just mapped the workspace back to the original folder and performed a "Get" operation. Now I have all the files uploaded onto TFS and the correct workspace set.

I just changed the file name. Fixed it.

Just do "Undo Pending changes" and delete the files and check-in again...problem will be fixed..

Related

Visual Studio shows Local Path but folder not mapped

I'm using Visual Studio 2012 and TFS, and I needed to move my folders on my local machine which was mapped to a different directory. When remapping, I was having problems where the folder mappings were getting messed up badly as you could see in "Source Control Explorer" in Visual Studio.
As part of my attempts to fix it (after hours of trying), I removed all folders from the Workspace and removed all folder mapping from the root with recursive checked so nothing would be mapped and no local folders in workspace. However a few subfolders in TFS still show their Local Path setting when viewed in "Source Control Explorer".
To make matters worse, when I try to "Map to Local Drive" in order to remove the setting, it says "The server folder is not mapped". So it says it's not mapped but shows that it's mapped.
I've tried remapping the root again with recursive checked and the prior local path settings stay the same and the Workspace only shows the "root" as mapped.
As a side note, I do have multiple servers that I have to connect to in case that matters.
I'm unable to remove mapping on the folder, what do I do? Does anybody have any ideas?
I was able to get it to work.
The way I did it was by removing all mappings in the root as the original question stated, but for those folders that maintained local paths, I just mapped to a valid directory where I wanted them to be instead of the old path.
While doing this Visual Studio crashed (i'm sure that never happens). I then restarted Visual Studio and then went back to the previous folders with the recently changed mappings and then removed mappings. When I did this, it removed the mappings and said "not mapped". I did this for all the the folders that were messed up.
After all folders were un-mapped, I mapped the root to where I wanted with recursive checked and the problem folders from before were mapped to the new directory.
I think the key was that I had to remove the mappings at the root and then remap the folders and then un-map them again. Throw in a little "designed" crash by Microsoft's Visual Studio (sarcasm intended) and it worked. Thanks for those that provided help.
There is a remove mapping option if you right click on the project and go to advanced.
Have you tried using Team Foundation Sidekicks to view your mappings? You can find all the working folders in your workspace and delete them.
If that doesn't help, try creating a new workspace.

TFS - Latest field still showing "Yes" after deleting local files

In TFS Source Control Explorer my items are marked "Yes" in Latest field even though I have deleted all my local files. Is there a way to reevaluate that column so it shows "Not Downloaded" again?
Here is the solution if you want to delete your files from your local file system (using Windows Explorer for example) and change the column “Latest” in the Source Control Explorer from “Yes” to “Not downloaded”.
Go to “Get Specific Version…” on the files and select Changeset 1.
Changeset 1 is a special changeset on your TFS instance. If you do a get for changeset 1 on any actual files then they will not exist at that point in time on the system so will be deleted locally and the server will know this.
Link with the info: Removing source control files from your local file system
You should change the scope of your workspace to reflect what you do want locally.
You can also use the Cloak option to prevent sub folders.
https://msdn.microsoft.com/en-us/library/ms181378.aspx#mappings
You should never delete files locally when using a server workspace. If you use a local workspace TFS will lend delete those files from source.
Source Control Explorer reflects actions you performed to TFS instead of local file system. Please treat them separately. Visual Studio tries to keep them in sync, but it doesn't prevent you from deleting files directly.
Use tf get <files> /Force to re-get files you just deleted.

Can't delete project folders created by Visual Studio 2010

I created a Visual Studio 2010 project that I want to remove completely and that includes all project folders.
I'm logged in as the administrator.
I tried to delete the folders in the file explorer, but only get a message telling me I need to have administrator permission to delete it.
Visual Studio seems to have put a lock on the project folders that an administrator account can't access.
I know I have rights to create and remove folders on my own because I created a test folder and deleted it without any issues.
Do you know a work-around for this?
Solved:
Here are the steps I took:
Navigate into one of the folders inside the one to remove. If it can't be deleted, navigate into a sub folder.
Delete it.
After the sub folder are removed, I was able to get rid of the main solution folder.
I have not tried this yet for deleting, but I recently found how to turn on the hidden Administrator account. I'm assuming it would let me delete the files.
There is a process (VBCSCompiler.exe) in Windows Task Manager to every solution you have started it.
to delete the solution directory you have to kill this process (VBCSCompiler.exe) then delete the directory.
Try to exit from Visual Studio first
Go to task manager and find all visual studio programs and end the tasks.
Then delete the folder.
I was able to delete the folder only after deleting all of the files in all the sub folders first.
Very strange though. It seems Visual Studio somehow locks it even after a reboot but it does not lock the individual files. For example I had to remove all the files in 1 particular folder. Once they were deleted it allowed me to delete the folder itself.
Well, at least I know how to handle it the next time.
I had the same problem. None of the suggestions I found on the internet worked (ownership, permissions, etc.) I had all this anyway as I am administrator on my PC and the dialogue box said I must get permission from myself to delete it!
In the end I renamed the folder 1st, then deleted it. It worked. I tried to verify this, but subsequent folders that I created with VS didn't give the same problem.
This is a major annoyance. I'm tempted to write a DOS batch shell script that drills down and removes files from the bottom of the project hierarchy on up. But I've a job with deadlines.
I just cut and pasted the project folder to my c:\temp folder to get it out of my sight!
I added a new item like user control. Then excluded the folder from project. Closed VS 2010. Then went to the project folder and deleted the files/usercontrol.ascx. Finally deleted the folder. Now opened the VS solution from my local drive itself and did not use view start page-link to open the solution.
None of the answers worked for me.
Only after i ended the process devenv.exe via Task Manager, it allowed me to delete .vs folder.
In my case, none of these solutions worked.
For those who run their application with Docker support, make sure you stop the container first with:
docker stop your_container_id
or
docker rm -f your_container_id
and then you can delete the project folder. However, in some cases, you may have to quit Docker temporarily to delete the folder.
I deleted the .vs folder and then the other folders at the same level. That allowed me to delete the main folder.
For me, it came down to the /bin/roslyn/ folder. If this is the case for you, end all instance of VBCSCompiler.exe in the Task Manager.
Can not delete \bin\roslyn\VBCSCompiler.exe - Access is denied
I have experienced same problem with visual studio 2022 multiple time and every time this solution works.
If you don't want to do anything then wait for 1 min and try again to delete that folder after closing visual studio.
I think windows takes some time to automatically clean up resources in Project folder used by visualstudio.

Deleting a folder in TFS

I created a folder in a TFS Project under workspace "CPortalWS". I deleted the workspace, but now I would like to delete the folder in the project and the delete option is not available.
I've tried to create a new workspace mapped to the project but I still don't get the option to delete.
Is this a bug in TFS? How can I delete the folder?
Any help would be appreciated.
Deleting a folder in TFS is a little strange.
You have to:
Create a Workspace
Get the latest source for the folder (to your local machine)
Inside Source Explorer, delete the folder
Check in your changes (this is the step that deletes the folder in Source Control)
only note that delete is not an actual delete.
the folders/files are still there and kept in Version Control, for example for Undelete scenarios.
You can see them and avail the undelete function if you go to "Tools > Options > Source Control > Visual Studio Team Foundation Server" and check "Show deleted items in the Source Control Explorer" and then right-click on one of the deleted folders.
so, if you want real delete, where the folder/files actually go away you need to use the Destroy Command which is only available from the command line, see link below
http://msdn.microsoft.com/en-us/library/bb386005.aspx
When you delete in TFS, it does not remove it from TFS. It maintains a copy of the deleted files, even when you check in the deletion. This can cause some issues.
To permanently delete from TFS, you need to issue a tfs destroy command.
To do this:
Open a Visual Studio Command Prompt.
Issue the following command: tf destroy $/SourceLocation/Folder. Where $/SourceLocation/Folder is the Source location of the deleted folder in TFS.
Please note: This command will also delete the file(s) from disk.
I had a similar issue, where I had 1 folder which despite being deleted from Hard drive, was still showing as in Source Control (with a green + by the folder). It also showed me the content but if I tried to open any, an error message informed me the file wasn't there.
Clicking on any folder didn't show the delete button. I then realised that selecting a file did! If you don't have a file, create a text file and add it to the folder you want to delete (via Source Control). Click this file, note the delete shows. Select a folder and note that the delete disappears but only after half a second. This small delay is actually usable.
I clicked the file, so the delete button is enabled and hovered the mouse above the delete button. Using the keyboard, I did a CTRL + A and as soon as all files and folders were selected I clicked left mouse button. And it worked! Everything was removed, including (and this is the odd thing) the parent folder.
Create a Workspace; and get latest on the base folder; Dont forget to cloak the relevant folders. If you are going to delete the subfolders then cloak all and get latest on the base folder. So you save a lot of time in pulling files.

The project file has been moved renamed or is not on your computer

I get this error when I try to load a VS 2008 project from TFS source control:
The project file has been moved, renamed or is not on your computer
After I click OK the project says "unavailable".
What is the problem? How do I resolve this? I never had this problem before. Some blogs said to delete the .suo file but I can't locate the .suo file. I deleted the entire project on my local computer so that the next time it opens it will create a new one, but I still get same error.
What typically helps to fix it is deleting the Solution User Options aka "SUO".
VS up to 2013
In the older VS it is stored as a "hidden" SolutionName.suo in the same folder as the main .sln file.
VS2015 or later
In VS2015 the same data was moved to a "hidden" .vs folder under the same folder as the main .sln file.
I just ran into this issue using VS 2013 after renaming a project. Stanley's answer guided me to the solution:
Close VS - delete .suo file - start VS again.
Delete the .suo file in a special way.
Don't have the solution open when you delete the hidden .suo file.
Restart VisualStudio.
Open solution and Add project without error message.
TFS works like most source control packages: It remembers what it has put on your computer so that when you "Get Latest" it only has to get the chnages since your last "Get" instead of having to get absolutely everything.
This has one caveat: If you delete or rename the local files on your disk, TFS won't know that you have done this, and it will still think they are where it left them.
If you then "Get Latest" it will not bother to update the missing files.
You are then likely to get all kinds of "missing file" errors, from TFS and any other tools that look for the files.
To get around it, you need to:
If you think you might have any changes in there that you don't want to lose, copy the source folder on your PC as a back up just in case!
Right click on the project (in Solution Explorer) or folder (in Source Control)
Choose "Get Specific Version" from the context menu
Choose to get the "Latest Version" and tick the option that says (something like) "force get of files already in your workspace", which tells TFS to forget about what it "knows" and get all the files again anyway.
If you have any locally-changed (writable) files, then be careful. There is a second option that will overwrite these, losing your changes. But you have the backup, so you should be safe. It's generally better to tick this option as well to make sure that all your source code is completely up to date. (But obviously only if you don't mind losing any local changes!)
When you OK, this will forcibly get all the files in the project to your local drive, and should correct the problem.
Easiest option worked out for me is:
Right click the project & Remove the "not loaded" or "unavailable" project
Right click the solution & Add "Existing Project"
Though it's well known VS defect, definately we can handle it!
Open the solution file in edit mode
Modify the relative path to match the modified/moved physical path ..
SccProjectUniqueName1 = Source\\Order\\Order.csproj
SccProjectName1 = Order.ApplicationService
SccLocalPath1 = Order.ApplicationService
Also, makesure of correct relative path for the referring project(s)
Project("{asdasd-301F-11D3-BF4B-asdasd}") = "Order",
"Source\Order\Order.csproj", "{E25641BC-C990-40E2-8876-08AE8728F763}"
EndProject
Try opening the .csproj or .vbproj instead of the .sln. What has probably happened is the .sln (solution) file has a absolute file reference (instead of a relative path) to the compoenent project(s). You may need to re-create the .sln, or hand-edit it.
In my case, deleting the .suo file was insufficient. I discovered that my workspace configuration had an error. I discovered and resolved the problem with these steps:
In Team Explorer, "Manage Workspaces..."
Click "Edit..."
Correct the value under "Local Folder"
Finally, delete the affected .suo files per the accepted answer.
I found it easiest to create a new Solution sln file.
Clear out your workspace mappings (File -> Source Control -> Workspaces). Edit the workspace and either clear out all the mappings (more repercussion) or find the one that's associated to this server path. Then open Source Control Explorer and remap. Double click the SLN in Source Control explorer and it should get latest. Not entirely sure what has happened or what state you managed to get into, but with this should get you moving again.
I ran into this issue and was able to resolve it by obtaining the .rptproj files from a co-worker and copying them into my local directory. The project was then able to re-load.
I spent a lot of time for trying solve this problem. I did these steps : rename project, rename namespaces, rename project folder, edit .sln file, edit hidden .suo file. Project loaded but it was unrecognizable for TFS! Finally I found this guide.
If you're using Resharper and TFVC is your version control, follow these steps :
Right-click the project in Solution Explorer, select Rename, and enter the new name
Right-click the project again and select Properties. Change the "Assembly name" and "Default namespace" on the Application tab.
Right-click the project again and select Refactor -> Adjust Namespaces. Accept the changes.
Change the AssemblyTitle and AssemblyProduct in Properties/AssemblyInfo.cs
Delete bin and obj directories in Windows Explorer
Open the Source Control Explorer and rename the project's directory. This will close the solution. Let it be closed.
Open the SLN file (with a text editor such as Notepad++) and change the path to the project (there should be multiple places).
Open the Solution again. Clean and Rebuild the project.
Right click on the unavailable project and edit the project file ... chances are, you will find a hardcoded file path or a virtual one that does not match where you checked the project out to.
Kindness,
Dan
Solution for this
Again rename the project folder
Set specific version & force get in TFS
remove read only & hidden option in the latest folder (not the rename one)
Now you can open the project without any issues
Sometimes, even though you changed .sln and .csproj path, and manually rename, you might forget to check the folder name that contains the project.
It happened to me too. Apparently the csproj files were not checked in when I had created them in my old computer, and so when I downloaded the project from TFS in my new computer, the files were not there.
After checking them in using my old computer and getting them from TFS in the new computer, I succeeded in reloading the project.
In my case, because I modified .csproj file, it changed to .csproj.user .
I remove .user from the end of the file.

Resources