I am currently working with 2 different TFS servers. When running the tfs commands in Visual Studio Command Prompt, how is it determined which TFS server to work with. For example, the "tf status" requires a TFS server parameter indicating which server to run the command against. But, for other commands, like delete for example, how does it know which server to perform the operation against?
Thanks in advance.
In general, the command line tools (tf.exe, tfpt.exe) automatically determine the server based upon the workspace that the current directory is mapped to.
If you are running the command in a directory that is not mapped in any workspace, then you will need to explictly specify the server. Some commands require a workspace (e.g. tf edit) and you will not be able to run them without a local folder workspace mapping.
To explicitly specify a server:
For the Visual Studio 2008 tools, you
can use
/server:http://tfsserver:8080/
For the Visual Studio 2010 tools, you
use
/collection:http://tfsserver:8080/tfs/Collection/
/collection also applied to other commands like witadmin.exe
Generally speaking, the TFS command-line commands will work with the workspace that the relevant files are in. So, if you are deleting a file using tf delete, TFS will use the workspace data. It doesn't actually perform the delete on the server until you check in, but when you do, TFS will use the server associated with the workspace.
It works by looking in the current location and then determining if there is a workspace active in that location, if there it uses that one. Otherwise you have to tell it by pointing at the server or local source locations.
Related
I use VS Community as a Developer and have spun up my own TFS Server in the past. I have been using Ubuntu more frequently and decided to try out VS Code. I started up Code and installed the Visual Studio Team Services Extension which is what I thought would be what I needed. I've read/tried online that you first have to open up a Solution which then redirects you to sign in to the web portion of their TFS/Teams which is not where my code resides. I was also not able to find the equivalent of the Team Explorer in Windows and the Plug Icon that asks you for a connection.
So my question is, how do you connect to your TFS Server and get your Projects in VS Code for Ubuntu, if possible?
UPDATE: I have gotten closer trying the following but do not have a complete solution. These steps will at least get you closer to connecting to your server.
Run Java -Version to ensure you have at least Java8 if not, run sudo apt-get install default-jre
Next download https://github.com/Microsoft/team-explorer-everywhere/releases/download/v14.114.0/TEE-CLC-14.114.0.zip
Run the command at your download location /../extract TEE-CLC-14.114.0.zip
Run this command to accept the EULA /../TEE-CLC-14.114.0/tf eula
Run this command to connect to TFS (assuming yours is the same as default) /../TEE-CLC-14.114.0/tf workspaces -collection:http://[SERVER IP HERE]:8080/tfs/defaultcollection
Sign in using AD or your Login
Run this command so you do not have to supply creds export TF_AUTO_SAVE_CREDENTIALS=1
Open VS Code > File > Preferences > Settings
On the right side is the user settings add the following "tfvc.location": "/../TEE-CLC-14.114.0/tf" and Save
Restart Code and that's all I have thus far
Below is a short list of steps to get up-and-running with TFVC support:
Install the Team Services extension for Visual Studio Code.
Team Foundation Server requires your domain credentials.
Ensure you have a TF command line client installed (either TF.exe or
the TEE CLC).
Set the tfvc.location VS Code setting to the full path of your TF
command line client.
Open a folder containing a Local TFVC Workspace and sign in when
prompted.
Set the SCM Provider to TFVC.
So your next step is opening either the root folder or a sub-folder of the TFVC repository. Detailed step you can refer to the documentation below:
https://github.com/Microsoft/vsts-vscode/blob/master/TFVC_README.md#quick-start
Also, you could check the video below which shows you how to set up the TFVC support on Windows and demonstrates much of the functionality available for Team Foundation Version Control. The features shown in this video apply equally well to the TFVC support on macOS and Linux:
https://www.youtube.com/watch?v=6IzJ2UPGmoQ&feature=youtu.be
I'm using MS Team Foundation Server 2012 with a server workspace, and the local files are on a Linux server (accessed via Samba). Accessing TFS from Visual Studio 2017.
When I check in foo.txt, TFS successfully sets foo.txt to read only as expected (r-xr--r--). But TFS does NOT set the permissions for the directory in which foo.txt is stored. Thus although I can't modify foo.txt, I still have write permissions to the directory it's in, so I can delete foo.txt or rename it or over-write it.
Is there a way I can tell TFS to manage the permissions of the directory a file is stored in (in addition to the file itself)? So that I would NOT be able to delete/rename/overwrite a file (outside of Visual Studio) without first checking it out of TFS? I'd be happy if when I checked out a file, the directory it is stored in became writeable(u+w), and when all files in the directory are checked in, the directory becomes readonly again (ugo-w).
As a side note I thought this might be a complexity of my having the files stored on a Linux box. But I tried it with a local file stored on my Win 7 PC, and got the same result. TFS will set the read-only file attribute. But even with read-only attribute set, I can still delete / overwrite / rename a file. I suppose because I'm an administrator of my PC (the security tab of the file properties shows I have full control).
So I think it's a generic TFS question. Since TFS uses the read-only attribute to prevent files from being modified outside of TFS without being checked out, is there a good way for TFS to prevent them from being deleted / overwritten / renamed outside of TFS?
Without that, I think I'm at risk of my local files accidentally becoming out of synch with the repository, and that doesn't seem like a good thing.
Just as you said local workspace is more appropriate for your situation.
And this is also available with TFS 2012.
A local workspace caches the unmodified version of each of your files to enable you to edit, compare, and do other things without being connected to the server. Just like work offline. Besides when you add or delete files outside of Visual Studio, the program automatically detects these changes.
Even though you have permission of the directory in which foo.txt is stored, such as delete foo.txt, you still can't be able to check in TFS source contol without sufficient permissions. And if you accidentally delete the file, also easy to restore locally, just get your files again.
Moreover, if you are an administrator, you can specify which type of workspace Visual Studio creates for your team members by default: Local or Server.
Take a look this excellent blog: Server workspaces vs. local workspaces which helps you clearly understand differences between the two.
I use a server workspace for my Visual Studio / TFS setup because our project far exceeds the 100,000 file recommended limit for local workspaces.
One of the drawbacks of a server workspace is that Visual Studio cannot automatically detect changes to files in the workspace if these changes have been made outside of Visual Studio.
If I believe there may be undetected changes lurking in my workspace, how can I tell Visual Studio to actively/explicitly check the integrity of the workspace. I.E. I need a "get" operation that assumes that zero pending changes may actually be incorrect.
There is a PowerTools command tfpt online which looks for files which have had their read-only attribute removed (if you were messing with them on the train home for example) but I guess you might have new files and need something like detected changes in local workspaces.
If you go into Source Control explorer you can right click your folder, select compare and then play around with what you need to compare the server to your local copy (file types, new files, different files etc)
TFPT Online:
http://blogs.msdn.com/b/buckh/archive/2005/11/16/power-toy-tfpt-exe.aspx
If you are using TFS 2013+ and Visual Studio 2013+ then you can use the "tf reconcile" command to analyse the differences.
https://msdn.microsoft.com/en-us/library/bb385984.aspx
The power tools "tfpt online" command has been depricated for some time.
Using the TFS tools in VS2010, I had added a CodePlex server. I had mapped a project on there to a local path, say C:\MyProject Later, we moved the project to a dedicated TFS server, so I added a new TFS server, and deleted the CodePlex one. This in turn removed the "workspace" for it.
However, now if I try to map a project in the second TFS server to C:\MyProject, I get the error:
The path C:\MyProject is already mapped in workspace MY-MACHINE;SND\myCodeplexUserName [https://tfs.codeplex.com/tfs/tfs32]
If I go to File | Source Control | Workspaces... in VS, that CodePlex workspace is not listed (since I had deleted the TFS server reference)
Does anyone know of another way to remove the existing mappings?
Use the command line utility tf with the workspace and workspaces commands. You may also find the workfold command useful.
Open a Visual Studio Command Prompt and type:
tf help workspace
I had to do this the other day to delete all the workspaces for a collection that was moved to a different server. In my case, the command was tf workspace /delete /collection:<url>. Use tf workspaces to display all your current workspaces.
i have used TF.exe (Team Foundation Client) to checkout files from outside with the following command.
http://blogs.msdn.com/b/noahc/archive/2007/01/22/real-tfs-command-line-help.aspx
tf checkout $project/filename
but, i need to checkout from outside when TFS server is also not reachable. In visual studio, it prompts us to work offline and then later on, it sync automatically with the changes into server when it goes online. How do i acheive the same from tf.exe or any other way to do it.
PS: i do have real requirement of editing some files which is not belongs solution files which gets modified from outside of visual studio. as of now,i am using tf checkout method to checkout the file from outside. but, this require connection TFS server all the time.
You can't do this with the command-line tools, because the offline mode is a feature of Visual Studio, not of TFS.
The tools always work directly with the TFS, so it must be online and reachable at that time.
Amendment regarding your P.S.: What Visual Studio does in Offline mode is just setting the local files to writable and "remembering" with which files it did that. Then, on going online again, it checks for any changes in the meantime. If there were any, it starts a merge process, if there weren't, it checks out the file without getting it.
There's no reason why you couldn't do this same process by hand, it's just more comfortable through VS.
BTW: Why not have a Solution for this "dangling files"? Just create an emtpy solution and add them as Solution Items. This way you can use the VS offline mode.