8

I'm aware of Build.PublishSelection as a shortcut to pull up the publish project window (and publish the entire project), but I would like to bind something to publish just the current file I'm editing. You can right click the file in solution explorer and publish it, but I have to do this 200+ times a day and those seconds add up.

Any hotkey command to do this or other possible workaround?

jtubre
  • 669
  • 1
  • 8
  • 13

3 Answers3

7

In Visual Studio Enterprise 2017 this is the shortcut sequence (basically a path to the publish menu item):

  1. Alt+B - opens the "Build" menu
  2. H - selects: "Publish your_solution_name", selects the "Publish" button
  3. Enter - confirms
ellockie
  • 3,730
  • 6
  • 42
  • 44
  • 2
    just fyi, my favorite way to publish is, right click on the toolbar and enable Web One Click Publish toolbar. Then you get one button to click to do it. Also, this used to be able to be bound to a key in vs2010 and earlier. – rocketsarefast Feb 04 '21 at 15:34
  • @rocketsarefast, but how to assign a shortcut for that action? – Aviw Feb 13 '21 at 23:22
  • @Aviw, i cant assign a keyboard shortcut to the toolbar button unfortunately, but at least its just one mouse click. Not great but better than nothing. – rocketsarefast Nov 02 '21 at 19:02
5

Visual Studio 2022: Alt + B, H and hit Enter.

Visual Studio 2019: Alt + B, H and hit Enter.

Visual Studio 2017: Alt + ', Alt + P and hit Enter.

Creating a shortcut (works in any version): Go to Tools > Options > Environment > Keyboard, look for Build.PublishSelection, in Press shortcut keys type e.g. Alt + P and click on Assign.

Luis Hernandez
  • 453
  • 5
  • 8
3

For Visual Studio 2015:

Alt + ¨, Alt + P will publish the currently selected file(s).

The ¨ key is the one just left of the enter key.

Jim Aho
  • 9,932
  • 15
  • 56
  • 87