TFS Check In History - tfs

I am trying to find out the most recent branch/merge for my project (I'm migrating to a new server and want to define a starting changeset). Is there a way for me to either query the repository database or the command line tools to find out the most recent branch/merge?

You can find the history of a current folder by using the history command.
Lets assume your entire project resides in a directory called 'project'. Using the below command will give you a list of all the changesets that impacted that directory or any of its children.
tf history project /r

Related

TFS Server checkin error - could not find file - Server Related and Command Line

This relates to question,
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.
The Solution was:
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.
Follow up Question:
So my question is,
how do I conduct the equivalent of this in the TFS Server? It continuously happens multiple times on our team.
This works on a person's desktop, but whats the equivalent commandline in the TFS server, and can I incorporate this in my build steps?
You delete files from TFS in the wrong way. the TFS server doesn't know your local file system, if you deleted a file from your local folder the file still exists on TFS.
This is the reason for the issues and errors. if a developer wants to delete a file and he deleted the file from the local folder and then got the error Could not find file and to solve it he does "Undo pending changes" so the file still exists on TFS and when another developer see the file in his system he also deleted it locally and he also will get the error in the check-in.
So, if a developer wants to delete a file from TFS he needs to right-click on the file and "Delete" and "check-in". if he already deleted it locally he can do the "delete nonexistent files" and "check-in". now each developer when he does "Get latest" not will get the file.
You can also delete files with a tf.exe command line in the delete command:
tf delete [/lock:(none|checkin|checkout)] [/recursive] [/login:username,[password]] itemspec
During the build, you can add a command line/Power Shell task and run the tf.exe.
You can undo another person's changes from the commandline using:
tf vc undo /workspace:workspacename;owner $/project/path/to/file
You can get this information by calling:
tf vc status $/project/path/to/file /user:*
This allows you to remove pending changes from the server, though it won't cause the files to be reverted on the workstation of the developer in question.
Both commands offer a /recursive option to undo multiple files under a specific path at once.
If you're using Visual Studio 2015 or earlier, then you can use the TFS Power Tools to add a "Find by status" option to the Visual Studio Source Control Explorer. This has unfortunately not made it into Visual Studio 2017 and there are no TFS Power Tools for Visual Studio 2017.
The TFS Sidekicks offer a Status Sidekick screen, which allows you to query all files currently checked out for edit in server workspaces and allow you to undo them centrally.
Preventing the issue altogether
To prevent the issue altogether you have a few options. You can switch to Local workspaces, instead of server workspaces. Those auto-detect local changes and don't register changes on the TFS server itself. Read more about local workspaces.
You can perform the deletes from the tf vc command line instead of using other tools to delete files and folders, for example:
tf vc delete $/project/path/to/file
The delete command also has a /recursive option. Using this command will not only update your local folder, but will also update the server workspace.

Update all local workspaces with changes to a folder in my project collection

I have a folder with name "OutputBinaries" inside my project collection. I have local workspaces mapped to this folder on multiple machines. I want to automatically update all these local workspaces whenever there are any modification to "OutputBinaries" folder.
I know tf get command can help if it is specific to a particular machine or a particular workspace. But how this can be accomplished with workspaces on different machines
We are on the latest TFS version
Firstly, as Daniel mentioned above:
"Binary outputs should not be stored in source control. If they are
dependencies for applications, you should either manage them as NuGet
packages or include them as project references."
For you specific question, we can only run the tf get command in particular workspace on the specific machine.
To update all local workspaces you can try to create a batch script with tf get command. Then run it periodically on each machine. You can set that with Windows Task Scheduler, see How to schedule a Batch File to run automatically in Windows for details.
Also this thread for your reference : Run a task every x-minutes with Windows Task Scheduler

TFS: How do I get a list of managed files in my enlistment?

In tfs, how do I get a list of files in my working directory that are being managed by tfs? I don't care if I've checked them out or not (if I did, tf status would be the obvious choice). I just care whether or not tfs is tracking changes for them or not.
I want to use this like I use hg locate for Mercurial. I want to search through all the files that are not temporary files or build products of some kind, things that are part of the base source code, for something that shows up in the build products, but I don't know where it comes from.
Try to use LocalVersions command. (The newly be added file won’t be list)
You could use tf workflod command. Which could displays information about the mappings between your workspace folders and the folders on the server for Team Foundation version control.
The following command displays the working folder mappings for the workspace in the current directory:
C:\projects>tf workfold
If you want to list the working folder mappings for a different workspace, you can specify the /workspace:workspacename parameter.
C:\>tf workfold /workspace:My_Other_Workspace
Required Permissions
To use the workfold command, you must be the owner of the specified or implied workspace or have the global Administer workspaces permission set to Allow.

TFS is not recognizing a manually downloaded file in the project when I try to get it

Here is the use-case. There is a very large file in the TFS branch, let's say it is 50GB. When I try to get this specific file with a command line similar to this:
tf get $/Branch/very-large-file.dat
The operation fails because the required time for the download is larger than the time a VPN would stay connected and of-course TFS is behind a VPN. This is why I have download the file manually using a different approach. Problem is that once the file is in place in my local directory and I check which files need to be updated with the following command:
tf get $/Branch/ /recursive /preview
I see that the very-large-file.dat will be downloaded from TFS. And if I go again with:
tf get $/Branch/very-large-file.dat
This will just create the partial file in the directory and start downloading the file from scratch.
Is there a way to update the local version table on the server, so that TFS knows that I have the file locally without having to download it?
In TFS 2012 lcoal workspaces were added, in which case TFS will recognize the file and will compare it to the server version. In 2010 and earlier, the server will keep a list of files on your workspace stored on the server at all times, which will say that you didn't download the file. The server workspace is also cached on your client. I don't know of a way to tell TFS from the commandline or another simple way the file is up to date.
As a workaround you could 'cloak' the large file to tell TFS you don't want to download it at all.

TFS shelveset migration from one branch to another

I have to migrate the shelveset created in one branch say "development" to another say "release".
so that I can directly merge the shelveset then to release which was created for development branch.
the command I have used is:
tfpt unshelve "shelveset name" /migrate /source:"$...development" /target:"$...Release"
it is showing this error:
unable to determine the workspace
Your location from where you launch the command must be from within your workspace.
E.g. c:\workspaces\project\development if that's where your source is located.
I guess you question is: How can I get the job done without this error occurring?.
In that case, make sure both branches are mapped to your local system and a latest version of your source code in you did a get-latest-version.
That should prevent the error from happening, because the paths then both contain information about the workspace used for the mapping.
I ran into the same issue today.
After checking the items below I got it working:
Have only one Powertools installed.
Run the command from a Developer Command Prompt
Run the command from the folder that is mapped to your target workspace.
I had to uninstall v. 2010 so only v. 2012 remained. The version numbers doesn't seem to reference your TFS version.
To check if you are at the correct folder, you can run tf workspace.
In the window that pops up find the workspace that you want to target and check in column Local Folder. Make sure you are in that folder.
I spent good amount of time to get this done and I had few issues to overcome and one of these in fact was
unable to determine the workspace
This particular issue was solved by running the command from source branch root folder. This is contrary to some answers here and on SO in general where they say to use "target" branch - no, use "source":
cd [your !!source!! branch root]
tfpt unshelve /migrate /source:"$/MyCollection/Development/Maint1.1" /target:"$/MyCollection/Development/Maint1.2" "myShelveset;UserName"
Second issue appeared after this. Seem that it couldn't connect to TFS server. what I realized, I have multiple VS installed and connected to different TFS servers. I was using VS12 and I had workspace and server connection. But I didn't realize that same connection needs to be replicated in VS13 for TFPT2013 to work. It connects to same server and workspace.
I also tried doing it using TFPT2015 but I installed it and it didn't install TFPT.exe hence it was useless. So I tried from TFPT2013 to TFS2015 and it worked for this particular command. I wonder, why not, if VS12/13 works fine against TFS2015?
To summarize
Use CMD or DevCMD - doesn't matter
run from source branch root folder
verify Team Explorer Server connection
TF Power Tools 2013 work against TFS v15, at least migrate option works
My first answer explains how to have this done properly using TFPT. In this answer, I want to explain how to do it without TFPT.
Every developer should have multiple workspaces. Because we work on multiple issues simultaneously and we don't want to mix it up. so, you work on one issue in WS1 and another issue in WS2. So, if you unshelve your shelveset in a different workspace, this will do that as well. Because your shelveset can't point to 2 different locations in the same workspace. But in different workspace it will unshelve to a location mapped in that workspace.
I ran into the same problem as Boris Callens. I had installed the TF Power Tools for VS2012 and VS2013. When runing the tfpt.exe command in command promt I always had the error message "unable to determine the workspace". This is because I was using the VS 2012 power tools with TFS 2013. So I had to change the Path to the Power Tools in the System Environment Variable "TFSPowerToolDir" to point to the Power Tools for VS2013.
You can find the version number running: tfpt.exe /?
TF Power Tools version

Resources