How to connect to source control server using TF command line utility - visual-studio-2010

I'm trying to run a commands using Tf Command-Line Utility I'm getting errors when trying to connect to TFS server. I'm not sure what tf tool is expecting as far as parameters.
It tells me to connect to workspaces by running tf /collection:TeamProjectCollectionUrl'
To get the TeamProjectCollectionUrl I went into Visual Studio Team Explorer, looked at properties of a project and copied URL property. The url starts with vstfs://

You want to use the standard HTTP or HTTPS URL to specify your project collection. (This is the same URL that's shown in the connection dialog in Visual Studio.) For example:
http://tfs.contoso.com:8080/tfs/DefaultCollection
TFS installs on port 8080 by default, and (beginning in TFS 2010), the name of your project collection is the suffix.
Alternately, you shouldn't need to specify the project collection - if you run the tf resolve command from one of your working folders, it will determine the server information automatically. That is, if you have the workspace mapping:
$/Project/Source -> C:\Work\Source
If your current working directory is C:\Work\Source and run the tf command line client, it should locate your TFS workspace automatically.

1- Add "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE" path into Environment variable path.
2 - Create a batch file (simply copy and modify the below commands and save into file with ext .bat)
CLS
tf get $/Project/Source /recursive /force
Pause
exit
3- Copy .bat file and place into your local Mapped folder and run.

Related

Finding files that are not checked into repo

Is there an easy way to find files that are not checked into my repository in my Visual Studio project?
In the past, there's been times when I get my code base from the repo only to realize that some files -- for some reason -- had not been checked into the repository.
I recently got a new laptop and downloaded the code for my app onto my new machine. I'm now getting an error when I run the app on the new laptop but on the old one it runs perfectly fine. My first thought was that there were configuration differences between two machines so I downloaded the code into a new folder on the old machine and started having the same error that I'm having on the new laptop. If I run the app from the original folder on the old machine, it runs fine.
This makes me think that I may have some differences in the code between what's on the repo and the original folder. As a result, if I get the code from the repo, I have the error. If I try to check in the code from the original folder on the old laptop, Visual Studio tells me that there's nothing to check in.
So, is there an easy way for me to see if there's any file that is not checked into the repo on my old laptop?
BTW, I'm running Visual Studio 2019 -- with the latest updates/patches -- and my repo is on Azure DevOps and uses TFVC.
Running tf vc status /format:detailed /recursive from a Visual Studio Developer Commandline in your workspace root should give you a good overview of files not checked in and files with pending changes.
C:\Users\JesseHouwing\source\Workspaces\xxx>tf vc status /format:detailed /recursive
-----------------------------------------------------------------------------------------------------------------------
Detected Changes:
-----------------------------------------------------------------------------------------------------------------------
$/xxx/test.txt
User : Jesse Houwing
Date : zaterdag 27 juli 2019 21:20:00
Lock : none
Change : add
Workspace : SHARKIE
Local item : [SHARKIE] C:\Users\JesseHouwing\Source\Workspaces\xxx\test.txt
0 change(s), 1 detected change(s)
It should auto-detect files unless you specify the /nodetectchanges flag.
Or, if your .tfignore file is well specified, you can run tf vc add * /recursive to automatically create a pending change for all files that are currently not under version control. If needed, edit your tfignore file before running the add command. Add /noignore to bypass the ignore file, but that may add bin and obj and packages folders as well, be careful.
tf.exe is hidden deep in the bowels of Visual Studio, easiest way to get access to it is to use the Developer Command Prompt:
My installation has put it here:
C:\Users\JesseHouwing\source\Workspaces\xxx>where tf
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\TF.exe

In TFS, is it possible to create local workspace from a script?

MS' pages talk about using the command-line tf.exe to create a local workspace prior to calling tf get but describe that even from the command-line, a TFS dialog box will be shown.
One of our build scripts, as we move from VSS to TFS, gets a repo into a working copy prior to building. It would be preferable if this script can be run on a 'clean' PC and it automatically creates the local workspaces, or can somehow get a copy without using a workspace (we really need something closer to svn export as no changes are being made). But a dialog box requires we manually set up each machine with local workspaces first.
Is what I want possible?
If you look at the full help tf help workspace, you see:
tf workspace /new [/noprompt] [/template:workspacename[;workspaceowner]]
[/computer:computername] [/comment:("comment"|#commentfile)]
[workspacename[;workspaceowner]]
[/collection:TeamProjectCollectionUrl]
[/permission:(Private|PublicLimited|Public)]
[/login:username,[password]]
As you can see, you can specify /noprompt and all of the parameters that the prompt would collect.
For setting the working folder, you'd use tf workfold:
tf workfold /map serverfolder localfolder
[/collection:TeamProjectCollectionUrl]
[/workspace:workspacename]
[/login:username,[password]]

Customize install-log location in Visual studio setup projects

The SetUp projects from Visual Studio will have their installation logs under temp folder with the name format like " %temp%\ .log "
Can I have some customization done here, so that these installation logs will go to a specific folder ?
You can change the location that MSI logs are written to by invoking MSIEXEC with the /L <logfilepath> argument. If you cannot change the command line arguments (such as if the MSI is invoked by a setup executable), edit the registry to change the default log location.

Visual Studio post-build copy failing (but works on the command line)

In VS 2010, I have a post-build event copying project assemblies into a common .dll folder. The .dll folder is mapped by a virtual drive (R:).
On running, I get the following: The command "copy /y "C:\CommonDLLs\Utilities.dll" "R:\"" exited with code 1.
The thing is, when I run copy /y "C:\CommonDLLs\Utilities.dll" "R:\" at the command prompt, it works correctly. I'm running VS as an admin, so I should have permissions to execute the command. Other people using the same code from source control are having no problems, but I'm stumped as to what to fix to get the copy to work correctly. Anyone have any suggestions?
EDIT: more information
The R drive is mapped/created/populated initially by a .bat script that I run as an admin as well. if I update my scripts to run to the location the R drive points to, everything runs ok, so I think this might be a drive mapping issue. The thing is, I(as a local admin) have full control over both the folder and the drive mapping.
I would guess that the virtual drive does not exist under the Admin account and as such cannot be found.
Either don't run VS as Admin, or set up the virtual drive in an command prompt running as Admin.

Delete TFS branch without downloading it

I am trying to delete a branch that has not been downloaded into my workspace via following command.
tf delete /lock:checkout /recursive $/TfsServerName/TfsFolder/Branch
I get following error message:
No matching items found in $/TfsServerName/TfsFolder/Branch in your workspace.
Is there a way to delete a TFS branch without actually downloading it?
you can do a non-recurisve get of only the folder with the "tf get" command. I am not aware that you can delete it when you don't have a local copy of the folder.
Make sure the folder above the branch is mapped to the filesystem, then:
Open up Visual Studio's "Developer Command Prompt"
cd (change directory) into the folder above the branch
and run the following:
tf get .
tf delete /recursive branch-folder
tf checkin
This will do a non-recursive get, mark the whole branch/folder for deletion, then prompt you to enter a message and check in the change.
Should work with VS2012-2015 & TFS 2010 to current. Also tested with Visual Studio Team Services hosted TFS (as of 25th Feb 2016)
With VS2012 / TFS server 2010, the delete command needs /recursive
In the Source Control Explorer you can get the latest version of a branch then cancel it as soon as it starts downloading. That will un-ghost the branch allowing you to delete it through the interface. You'll also have to delete the few files that were downloaded to your local work space. It's a total hack but it's really quick and easy.
In the Source Control Explorer, if you simply map the branch to a local path and hit OK, it will enable the "delete dropdown".

Resources