How to determine folder vs branch with tf command? - tfs

I have this example where FolderA had sub FolderB and they were both folders, until I branched FolderB to FolderB-branch. Then both sub folder turned into branches.
How can I use tf command to determine what is folder and what is branch?
tf dir /r and tf dir /r /folders show the same info.
How can I use tf command to distinguish what is what?
TFS 11, Visual Studio 2012.

There is a way do this, using tf branches command. When using it, TFS returns 2 responses:
when item is a Folder:
Item FolderA is not used in any branch view
when item is a Branch, it lists branch tree, like:
../FolderB
>> ../FolderB-branch
Now we can parse the output and assign if item is a Folder or a Branch.
Of course, the command tf branches need to be run in parent folder or with full parameters like /collection and others, if required.

Related

How to know the current changeset id TFS Visual Studio

I have this workspace on this machine that is not updated for some days. I want to know the latest changeset Id that exists on this machine.
Let's say the latest changeset that is checked-in is 8400. I want to somehow find the current changeset id of the workspace on this machine, that might be say for example 8329.
Yeah, the tf history command can achieve that.
For your convenience, you can simply copy below strings and save as a cmd/bat file, then run it directly to get the latest changeset ID under the specific directory within the local workspace. (In your scenario you need to enter the root path of your workspace)
ECHO OFF
SET "VSDir=C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer" :: For VS 2017
:: For VS 2015: SET "VSDir=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE"
CD %VSDir%
SET /p LocalPath=Enter LocalPath:
ECHO.
tf history %LocalPath% /r /noprompt /stopafter:1 /version:W
ECHO.
PAUSE
Besides, you can also use the Version Control client API to achieve that.
For more information please refer to: How to determine the latest changeset in your workspace
You may use tf history command. Go to root workspace folder and:
tf history . /recursive /noprompt /stopafter:1 /version:W

Let Jenkins build from multiple TFS repositories

I have a problem with Jenkins building my source code. I'm using a lib repo and a repo for my code. I want Jenkins to build the project if anything in one of the repos changes.
Does anyone has some pointer how to solve this? I managed to get it working in the case that everything is in only one repo, but I want to separate the lib and the project code.
Unfortunately,the TFS pluging for Jenkins currently does not support checking out the sources from multiple locations.
However, as a work around you could use the command line to create any sort of workspace that you like, and even copy a template workspace that you have lying around.
To achieved this use both TF and the powershell Snapin Microsoft.TeamFoundation.PowerShell.
Basically the workflow is as follows :
Get-TFsWorkspace (Powershell : To check for the workspace)
TF Workspace /new (To Create a workspace)
TF Workfold /unmap (use this to remove the default $/ mapping which is
made during workspace creation)
TF Workfold /map (To map specific locations, ie $/Repo/project)
TF Scorch (to remove any artifacts if there are any)
TF Get (To get the code)
More details please refer this answer in a similar question.

Copy source files to other TFS

We have a TeamCity/Octopus setup that runs great for several projects.
A new client wants access to the source code during development. Is it possible to copy code from our TFS to an other TFS using TeamCity? It does not need to be real-time. Daily copies are OK.
Not sure if we should use TeamCity for this or if there are possibilities within TFS itself.
You could setup a daily build schedule and use the TFS command line utilities to transfer the files to another server. You'll probably get all kinds of sync issues along the way, unless you always take your own solution as the current situation.
Look at tf.exe, especially the workspace, workfold commands and add, delete, and optionally destroy. Complete the job with a tf checkin.
Process as follows:
Create a workspace on your source TFS server (or use the built-in workspace features in team city): tf workspace /new
Map the folders you want to share: tf workfold /map
Get the files to the machine that's doing the transfer: tf get /recursive
Create a workspace on your target TFS server: tf workspace /new
Map the folders you want to share to tf workfold /map to a new folder that's not mapped to the source TFS server.
WS2 delete the files in the target folder: tf delete * /recursive
WS2 Check in to make sure you won't get any conflict remotely: tf checkin /recursive
WS1 -> WS2 Copy the files from the first workspace to the second: xcopy
WS2 Add all files: tf add * /recursive
WS2 Checkin all files tf checkin * /recursive
WS2 & WS2 Delete the workspace: tf workspace /delete
(Optional) Delete the files in the folders of the deleted workspaces on disk.
PS: if you move to git, this all becomes a lot easier, since the distributed nature of git is kind of meant for scenarios like these.

How to track the branched history through tf command?

I know this can be achieved through IDE from this link How to Branch and keep the branch history with TFS 2013
However, I want to achieve this by tf command. I have tried tf history, not the wanted result.
You may need to use tf branchs command instead of tf history command which displays the history of a branch for a specified file or folder.
tf branches itemspec [/version:versionspec] [/collection:TeamProjectCollectionUrl] [/login:username,[password]]
More detail info, please refer to the link from MSDN: Branches Command

TFS: How to find untracked files in a TFS workspace?

Is there any easy way to list all untracked files in a TFS workspace, like what "git status" reports in the "untracked files" section, or the output of the following command:
git ls-files --other --exclude-standard
TFS PowerTools works for me! I also find I can get the same result with the following command:
tfpt treeclean /noprompt /preview /recursive
TFS PowerTools can do that
http://msdn.microsoft.com/en-us/tfs2008/bb980963.aspx
After installing it, from the command line try:
tfpt online
In Visual Studio IDE, in Source Control Explorer, right click on a folder an choose "Compare". This will allow you to compare local folder with your source control folder. There are various options there as well like ability to show or hide items that exist only on one side, exclude files by extensions, etc

Resources