Force TFS to detect changes - tfs

Seems like this should be something very simple, but I can't find how to do this...
I made a changes to several files spread within a repo by using a script that I wrote. Problem is TFS in its infinite wisdom does not think the files have changed. Aside from manually finding each file and clicking "checkout for editing" is there any way to tell TFS to just rescan everything and detect changes?

A Folder Compare (File->Source Control->Compare...) should do the trick. Select the top folder from where to start comparison, and select to compare with Latest Version. The result hould show files that are changed, and whether they are checked out or not.

TFS has a "Reconcile" command for this. See https://stackoverflow.com/a/22860674/932282 for a complete answer.

Local Workspace
You need to work with a local Workspace. Here's how to manage workspaces:
visualstudio.com: "Create and work with workspaces".
When adding or editing the workspace you click Advanced >> . Then you set Location: to Local.
Now when your script or anything else changes files outside Visual Studio, your workspace detects the changes automatically.
It also detects adds or deletes but you have to include them to your Pending Changes manually with the link under Excluded Changes
BUT BE CAREFUL. When adds or deletes get detected and you add them to your Pending Changes, the files aren't automatically included to your project. So you maybe check them in to TFS, but they aren't listed under the Solution Explorer.
Matt Burke has a fix for that problem:
mattburkdev.com: "Automatically Include All Files in Folder in Visual Studio"
To edit the Project file you rightclick your project, chosse Unload Project, then rightclick on it again and choose Edit. After you edited the project files save and close it. Then rightclick and chose Load Project.
But with that you also need to be careful, because the Project only searches for new files in these folders to include, when you load the project and not while you have the project open. So when some files get added outside Visual Studio, you just reload the project.
Server Workspace
But if you have to stick to a Server Workspace for some reason i got another trick for you:
FIRST:
Check out all Files that maybe have pending changes (better check out many files). Then go to Team Explorer -> Pending Changes and choose all files you just checked out. Then choose "undo changes". After this you get a message "Confirm Undo Checkout". This message ONLY pops up for the files, which actually HAVE changed! Press "NO" for each files or "No to All".
FINALLY: Under pending changes all files get removed from the list except the ones which have pending changes.
I hope I could help someone and you didn't have to search for this solution as long as I had to ^^

If any of your changes occured when you were offline, you can go to File > Source Control > Go Online, and all files will be checked for modification.

If none of the above work, you can also try to rebind your projects by going to File -> Source Control -> Advanced -> Change Source Control.

In Visual Studio 2015:
Source Control -> Advances -> Refresh Status

I had this problem a while age when i moved project from one pc to another.
the solution was to remove temporary files that TFS had created in solution folder.
Delete .vs and hidden $tf folder.
If no luck,on your local PC copy your solution folder to another, remove all files inside solution, get latest version from TFS server ,then from the copied folder just grab neccessary and edited files and put them back to solution folder (this will overwrite some files).
After all don't forget to check project mappings and if everything seems correct try right clicking on solution and 'Add to source control' option.

Dtsx file dropped in TFS folder was not being recognized.
On your Visual Studio (2015) home screen, click on the Team Foundation Server link. Make navigate to the correct branch.
On the window on the left side of the screen, navigate to the folder that contains your file. Expand the folder.
To the right of the folder you will see three dots. Click on those and then click on “ + Add File(s)”.
Choose “Upload Existing Files”. Then you can drag and drop your .dtsx files into the window and then click Okay.
Finally, you’ll have to do a ‘Fetch’ to add the files there. Then you need to do a ‘Pull’. Lastly, you can commit the change to remote branch.

Related

How to make TFS detect changes in folders outside solution?

I'm making an angular webapp for a C# solution and I have to use TFS.
I set my workspace as local (as described here) and added the angular folder from Source Control Explorer.
Now all existing files are marked with the [add] tag and I can check-in them, but I can't understand why added or removed files are not detected as pending changes.
What am I missing?
They're under "Excluded" changes. You'll see a marker that says "Detected: X adds" or "Y removes". You can click it to promote them to tracked changes. It assumes that stuff that's being added or removed outside of Visual Studio isn't intended to be in source control, so it doesn't start tracking until you tell it that you want them to be tracked.
This may not be the perfect solution you're looking for, but I ran into an almost identical issue. This is how I solved it,
1) Open Solution Explorer in Visual Studio
2) Find your Project ( Angular Project )
3) Right click on it, and click Compare changes.
4) In compare options see View Options and check the following:
Show items that exist only in source path
Show items that exist only in target path
Show items that are different
5) Then find all the files that are in your local mapping that are missing from your server version, right click on them and click "Add file". You should be able to do this for entire folders / groups of files using shift + click .
6) Once you've added all your missing files, make sure they're being tracked in Team Explorer -> Pending changes, then check in your files.
I haven't figured out how to get Visual Studio to track these files automatically as I believe it requires a solution file like in normal C# projects to track them, but I could be wrong.

Why do all my files have a red check next to them when I "check out latest" for the first time from TFS?

I'm going into TFS and creating a mapping to a local folder, then I right click on the folder I want to check out and click on "Get Latest Version". After I have pulled down all the files I open up the solution in VS and in the Solution Explorer window I see all the files (including the solution and project files) have red check boxes next to them. So now it looks like they all need to be checked in because I have made edits! This is not true, I'm checking these fiels out for the first time and haven't made any changes yet.
How do I check out the folder without it looking like there are already edits that need to be checked in? (no red check next to each file)
I had a similar problem (red checks next to everything in the Solution Explorer window). I resolved it by selecting the solution in the Solution Explorer, and then selecting from the menu bar: File > Source Control > Refresh Status. This removed all my red checks.
In Team Explorer (in Visual Studio): Tools | Options | Source Control | Visual Studio Team Foundation Server and select Show Deleted Items...
Then in source control explorer you'll see the items greyed out. You can right click on them and Undelete. (This option will only be available if they, after the undelete, will be included in your current workspace).
The red check marks indicate that there has been a change to the file. Many of these answers for previous versions of Visual Studio seem correct. I use Visual Studio 2017 and using GitHub.
If you have several files with the red check mark:
Right click project
Go to Source Control,
Select Commit,
{Follow standard commit procedure}
Enter your commit message,
Sync,
Push.
If there is just one file or you want to commit the files individually:
Right click each file
Select Commit,
{Follow standard commit procedure}
Enter your commit message,
Sync,
Push.
Right click project
Right click file
Identify Version Control Item Status in Solution Explorer
Checked out
Represents an item for which the current user has a pending change in their current workspace, and the item is not exclusively locked.
For me, the red X's were appearing because I had moved the files from a Feature branch to an Archived branch (After a successful merge into the main branch).
I tried File > Source Control > Refresh Status however this didn't help.
I didn't want to go messing with cache files.
I found this answer:
Go to Tools/Options/Source Control/Visaul Studio Team Foundation Server. Check if there is a check mark next to "Show deleted items in the Source Control Explorer".
I had to right click the particular folder and selected the "Source control" ->"undo pending changes" option.
Just spent 4 hours trying to rectify this and none of the solutions above worked for me, not even unmapping and re-mapping the solution.
In case anyone still has this problem, try removing your workspace and re-adding it.
Below are the instructions for removing and re-adding a workspace in Visual Studio 2019, but it should be similar for any other version as well:
Go to Team Explorer, scroll down and under Solutions you will see
Workspace: "Name of your workspace"
Click on the arrow next to it and select Manage Workspaces
A dialog box containing your workspace will open. Click Edit to see
the paths for Source Control Folder and Local Folder. Make a note of
them as it will be useful for re-adding the workspace. Close the Edit
Workspace window, select the Workspace and press Remove
Once it is removed, select Add then enter the paths that you noted
earlier. Press OK to confirm and it should re-add your workspace
without the check marks.
In Visual studio 2019, I have unloaded the project and I have reloaded the project. Then it went.
Working solution tested. It turned out very easy. Pending Add + sign or Pending Edit red check sign statuses on projects (below screenshot) of solution are git's statuses, this is very normal, and they will be disappeared after you "git add ." and "git commit -m 'messages'". Done!
After banging my head against a brick wall for 4 hours, it turned out I didn't want to delete the folders and files in the Source Control Explorer with the red X alongside them I had previously deleted, but merely toggle the Show/Hide Deleted Items button so it made them all disappear:
Highlight the adulterating red-crossed folder/file, and click the 2nd icon from the left in Source Controller menu that looks like an 'Xx'. For me, that's all I wanted to do. My offending files had actually been physically deleted from everywhere except from the documentary evidence that they had once been in the Source Controller. That sorted it for me.

TFS checkin error - could not find file

When checking in my project I get the error:
Could not find file 'C\blah blah blah'.
I have a feeling this might be a file from an old project I deleted.
I have tried deleting my TFS connection and workspaces.
This will happen when TFS has some changes staged that no longer exist on the file system. For instance, if you add some files in Visual Studio (which adds them to the changes list), delete them directly from the file system, then attempt to check in the changes, it will complain that it could not find the file(s).
To remove these changes from the list, you can open Source Control Explorer (View > Other Windows > Source Control Explorer) and either Delete the nonexistent files or right-click on the offending files and Undo Pending Changes.
You can also undo these specific changes from the Pending Changes panel in Team Explorer.
Create an empty file to replace the missing file and complete your check-in. After you have checked in the file correctly delete the file that is not needed.
Go to the project that has file 'blah blah blah', you should see the file has an error mark indicating it does not exist. Right click the file > Delete. That should take care of the problem.
I had a similar problem. I had forgotten I was tinkering with adding publish profiles for publish. TFS felt it needed to check that in, even though the output wasn't there. I simply right clicked on the App.Publish folder in Team Explorer inside of visual studio and chose to exclude. Checked everything back in with no problem.
I encountered the same error:
but my issue was a bit different. I was changing a couple of folder names and when committing I didn't add the new folders to the repo:
git add folderName
solved the issue for me.

Latest value = "Not Downloaded"

I have several projects in TFS which visually appear in the directory hierarchy as grayed out. When I browse within the projects in Visual Studio 2010/Source Control/TFS 2010, I notice that all of their contents have a Latest value of "Not downloaded". Normally, I have only seen Latest values of "Yes" or "No".
I have tried all of the varieties of "Get latest" that I know, but I am always alerted that "All files are up to date".
If I try to "Check out for edit", I am not allowed.
When I observe the properties of these grayed out files, they always say Workspace Version = "Not applicable".
How do I fix TFS so that I can download and check out the projects again? My suspicion is that my workspace is messed up, but I do not know what to do to restore/reconfigure it.
I was able to remap the directory to fix my issue. To do this, I
selected (right-clicked) the branch that included all of my code, and selected "Remove Mapping..."
renamed the folder I was mapped to within TFS (you can delete it as well, but I renamed just to keep it during this experimental process)
created a new folder with the original name of the branch I was mapped to in the beginning, and
selected (right-clicked) the branch that included all of my code, and selected "Map to Local Folder".
This process forces a complete re-download of the entire branch. Luckily for me, my branch was only 2GB, so I was able to re-download in about 5-10 minutes.
The reason for getting "All files are up to date" - is that the information on the TFS server and the files on your disk is out of sync. If you delete the files on your disk with file explorer - the TFS server still thinks you have the file on disk. To re-sync you have to force an update like this:
Check the two checkbox on this dialog - and click Get:
It happened to me as well when I added and existing project as a reference to another project.
When I added the project reference I had a pop-up message that told me that the current project already exists at the source control but at a different location then the relative path of the current project.
by a mistake I choose the wrong option which lead to the unnecessary mapping.
In order to solve this issue I've removed the mapping from the workspace.
only after removing the mapping i could get the latest project.
I solved it by following this - remove the work space and then tfs prompted me to download everything again.
https://msdn.microsoft.com/en-us/library/ms181386(v=vs.100).aspx
It sounds like the folders / files in TFS are not mapped to a local drive in your workspace.
In Source Control Explorer, select the "Workspace:" dropdown, then select "Workspaces".
Choose your current workspace form the list that appears, then hit "Edit". Check that the TFS folder $/blah is mapped to a local folder c:\tfs\blah
You should now be able to get latest, check out etc.
I had some weirdness with this after :
updating to TFS2017
updating to VS2017
trying to change my TFS URL to https (gave up and reverted back to http)
So somewhere along the line this broke my workspace such that all my projects were showing as unbound. I was able to do a get latest again. This should not overwrite any files you have changed providing they are writable, but if you have any doubt whatsoever then backup your local workspace before doing get latest. It will ask you to resolve conflicts - so make sure to select 'keep local copy'.
In my case, when the branch was deleted: Right click + Check in, helped.

Manually update files

Scenario:
A solution is checked into TFS. Changes are made to an offline/disconnected/unbound copy of the solution, which becomes "the latest" version. I want to update the repo with this disconnected copy's files.
How do I get TFS to look at all the files and determine which ones have changed, so it can check only those in?
If this were SVN, I would just plop the files on top of the existing working copy, and it would just work.
Do you have another copy of the solution that is bound to TFS? If not, you'll need one. You have two options:
Take the solution "offline" by right-clicking on the solution node and click "Go Offline". You can then copy your changed solution on top of the bound solution. When you load the solution again, right-click the solution again and choose Go Online. This will scan the disk and determine what has changed.
You other options is to run "tf edit" recursively on a bound solution, copy your changed solution on top of the bound one and then run "tfpt uu". "uu" stands for undo unchanged and it will undo changes to the files that are not different.
I cant think of any elegant way off hand but your best option would be to know what files were changed or added offline and connect them to the TFS version while removing the old TFS files.
To do this simply right click all of the old files and either delete them or exclude them from the project then move the new files into their physical folders and replace them with the updated version. If files were added then add them in the correct folders. Finally make sure all files are view-able in the solution explorer by clicking "show all files". Finally, right click the files you changed and select include in project for each.
This way you will have replaced only the files that were changed and won't have to check in the entire solution to TFS making it very unclear what files were changed with your check-in.

Resources