18
votes

I want a keyboard shortcut to Get Latest Version (Recursive) of the current solution in Visual Studio 2012. We are using TFS.

I've tried to map

File.GetLatestSolutionFiles
File.GetLatestVersion
File.TfsGetLatestVersion

but nothing happens. Any ideas?

As a workaround I've also tried, and failed, to map a keyboard shortcut to:

Tools.shell """c:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\TF.exe""" get $/OUR/REPOSITORY/Main /recursive

This is the command I want a keyboard shortcut to: enter image description here

7
Impossible to answer this accurately when you don't mention what source control you use and how it is integrated with VS.Hans Passant
It won't help you much, but I tested 'File.TfsGetLatestVersion' and CTRL+! as a shortcut with VS 2012 (and VS 2010) and TFS 2010, and it works fine for me. Could it be local to your setup?Simon Mourier
That's the exact setup that we're running! Are you using ReSharper as well? Not that it should matter.Jonas Elfström
I do have R# V5 installed (and the assemblies are loaded in VS adress space), but I leave it the suspended state (you known, when it does not eat the whole memory), but only in VS2010, not in VS2012. PS: don't forget to add the @ when you send comment to someone, I was notified of yours.Simon Mourier

7 Answers

9
votes

Alt-V P Home Alt-F R L

or

Alt-V P Home Menu L (This is how I do it every day)

A shorter solution is by binding one of the commands you listed; How did you try that, exactly?

6
votes

In 2012 you can simply just do "ALT-F R L"

5
votes

The command is TfsGetLatestVersionDynamicSilent. The way that the command works is based on the Solution Explorer.

  1. Set your key binding in Options > Environment > Keyboard. TfsGetLatestVersionDynamicSilent
  2. Select what you want to update in the Solution Explorer. Here, I'm selecting the Solution. Solution
  3. Then, hit your key binding, and voila! Now, you got the latest from TFS for your Solution. All files are up to date.
3
votes
C:\Foo\Bar\Main>tf get . /recursive

from Visual Studio Command Prompt

Full example

Put this in a bat-file:

@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat"
cd /d "C:\Foo\Bar\Main"
tf get . /recursive
pause

Create a shortcut to the .bat-file on your desktop and assign a global key (I have mine mapped to CTRL+ALT+G) to that shortcut. You can assign keys if you right-click the shortcut and choose properties.

2
votes

Mapping the shortcut through Tools -> Options -> Environment -> Keyboard works.

Steps:

  1. Go to Tools menu -> Options.
  2. Expand Environment node. Go to Keyboard section
  3. Type "tfsget" in "Show commands containing:" text box.
  4. Select File.TfsGetLatestVersion from the list of options displayed. enter image description here
  5. Select "Press shortcut keys:" text box and enter your keys combination.
  6. Click Assign button and make sure that the keys combination shows up in "Shortcuts for selected command:" dropdown.
  7. Click Ok button.

To make sure this worked, open Output window (View menu -> Output), clear all messages from it. enter image description here
Open the solution in the Solution Explorer, select the solution, project or the file that you need to get the latest for and key in your combination.

If it worked, you will see the message in the output window: enter image description here

1
votes

Modified off @RickardN's answer

Create a file called GetLatest.bat and put it in your program folder.

The file should contain this:

@echo off
call "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat"
tf get . /recursive
rem require keypress on error, else pause a few seconds
if %errorlevel% neq 0 pause
if %errorlevel% == 0 choice /C X /T 3 /D X > nul

The path to vsdevcmd.bat assumes you are using Visual Studio 2013; change the path depending on your version of Visual Studio. Now go to Tools->External Tools and Add a new command. Call it Get Latest. Set the Command to the path to your .bat file, and set Initial Directory to $(SolutionDir).

You can map the external command to a toolbar button or a shortcut.

0
votes

Using Visual Studio Macros, you can setup this macro

//go to solution explorer
dte.ExecuteCommand("View.SolutionExplorer");

//1 based indexing so item 1 is the first item, which should be you Solution
dte.Windows.Item(1).Activate();

//perform get on the activated item (which is the solution)
dte.ExecuteCommand("File.TfsGetLatestVersion");

Then you just bind that macro to something like cntrl+alt+shift+G

If you are not using Visual Studio Macros i highly recommend them: Macros For Visual Studio 13/15/17