Does a keyboard short cut exist in Visual Studio 2010 to debug the current project? - visual-studio

I have a solution with 36 projects.
When I'm working on one of the projects I'd like to be able to debug it without having to right click the project then select 'debug' then select 'start new instance'.
Thank you.

You could add in the Options dialog under Environment->Keyboard "ClassViewContextMenus.ClassViewProject.Debug.Startnewinstance" as a shortcut.
This starts debugging on the current project.
(maybe this changed a bit for 2010)
source: http://www.sharpdevel.com/2009/09/visual-studio-debug-start-new-instance.html

One thing that you could do is to right click your Solution, go to Properties. Select 'Startup Project' and choose 'Current selection'. After this, the project that you click will be set as startup project. You can debug the project that you want by clicking it and pressing F5 (or whatever key you have for start debugging).

Steps to add keyboard shortcut to debug the present project instead of the solution:
Open VisualStudio2010 > Tools>Options>Environment>Keyboard
Show commands containing "StartNewInstance"
and you will see: "ClassViewContextMenus.ClassViewProject.Debug.StartNewInstance"
Enter your choice into "Press shortcut keys" (for example Alt-F5)
Click the Assign button
OK
Away you go.

In Visual Studio 2017, the keyboard shortcut to start debugging is:
F5

Related

How to make visual studio project into exe file and give UI

I have a code which detects the FACES from the image file (C++ file). I am using Visual Studio-2010 and OpenCV-2.4.10 for this project.
Now I want to create an EXE file and I want to give User Interface which will ask the user to upload an image and produces the Output image back on to the User Interface.
So how can I do this.
Please help me in this regards.
Thankz in advance.
To build a solution that's open in Visual Studio and selected in Solution Explorer, you can:
On the menu bar, choose Build, Build Solution.
Or, in Solution Explorer, open the shortcut menu for the solution and then choose Build Solution.
Or, press F7. (This is the default keyboard shortcut for the C/C++ development settings.)
Or, in the Command Window (on the menu bar, choose View, Other Windows, Command Window), enter Build.BuildSolution.
Or, in the Quick Launch box, enter build build solution.
To build a project that's selected in Solution Explorer, you can:
On the menu bar, choose Build, Build .
Or, in Solution Explorer, open the shortcut menu for the project and then choose Build.
Or, in the Command Window (on the menu bar, choose View, Other Windows, Command Window), enter Build.BuildOnlyProject.
Or, in the Quick Launch box, enter build project only build only .
You can then navigate to the build location, either /debug or /release depending on the option you have chosen, you will find your .exe there
You need to use Publish from right-clicked project in Solution Explorer

How to run debug on a project selected in Solution Explorer with a key combo?

Is there a way to bind a shortcut that will run a project that is currently selected in the Solution Explorer (that is not the startup project of the current solution) in Visual Studio 2010?
I couldn't find any actions related to Solution Explorer specifically in Options > Environment > Keyboard section.
Find this msdn doc http://msdn.microsoft.com/en-us/library/aa301747(v=vs.71).aspx, it already explains quite clearly. If you have any more doubt, we can discuss it further.
Update:
I've done this on my computer with Visual studio 2010.
After seeing this dialog, choose an action from the drop down lists under the Show commands containing, in your case, choose Debug.Run. Then choose global in the Use new shortcut in list, and in the Press shortcut keys your customized shortcut key, for example Alt+r, press Assign. Press OK.
After all the settings, I press Alt + r, my selected project compiles and runs, just the same as the menu Debug->Run.
Hope I've made myself clear for your solution.

Visual Studio - Attach to process shortcut

When I want to debug I have to do Debug->Attach to Process -> Look for a process in the list -> Attach.
I was wondering if I can create some kind of a shortcut to do this for me?
The shortcut is Ctrl+Alt+P in Visual Studio 2005 and above.
The easiest way to do this is to write a macro which finds the DTE.LocalProcess you wan to target and automatically attach. For example
Public Sub AttachShortcut()
For Each proc In DTE.Debugger.LocalProcesses
If proc.Name = "what you're looking for" Then
proc.Attach()
Exit Sub
End IF
Next
End Sub
Note: This Stack Overflow Question is related and has a sample you may find useful
Attaching to a child process automatically in Visual Studio during Debugging
To enable the 'Attach to Process' toolbar button in Visual Studio 2013, 2015, 2017, 2019, and 2022
Right-click on any toolbar and click 'customize...'
Click the 'commands' tab
Click the 'Toolbar' radio button
Select the toolbar where you want your button to appear from the dropdown
Click the 'Add Command...' button
Select 'Debug' from the categories list on the left
Select 'Attach to Process' from the commands list on the right, and click ok. The button will appear on your selected toolbar.
Optionally, use the 'Move Up' and 'Move Down' buttons on the right to move your new button to your desired location within the toolbar. I keep mine just after the Debug button.
You can use the Alt key shortcut ALT+D,P to launch the "Attach to Process" window via Debug menu.
Once there, you can use your keyboard to search the list of Available Processes (e.g. type "w3wp" if you want to attach to an IIS app pool)
Writing a macro is one option, however it cannot deduct which process to attach to by itself.
Another nice solution is to map the "Attach to process" command to a shortcut key:
(Tools -> Options -> Environment -> Keyboard, type attach, like i did in this example, and select a shortcut key):
This answer should work for Visual Studio 2010.
I like having buttons to do this on my debug toolbar
https://gist.github.com/1406827
The gist contains a method for attaching to IIS (w3wp.exe) or ASP (aspnet_wp.exe) and also nunit (nunit-agent.exe). Instructions are included on how to add the macros to your debug toolbar.
For Visual Studio 2017, 2019, there is a ReAttach extension available. Very handy.
I use this built in "Shortcut"
ALT+D, P, W, ENTER
this opens the debug menu, selects attach to process, scrolls down to w3wp.exe and attaches.
It's long but should work in multiple visual studio versions with no setup required, with or without resharper and it works when running multiple IIS processes as you can choose which process to attach to.
Addins are probably a better way to do this now. I use one called "Attach to anything". You can find them in Visual Studio 2012. Go to "Tools" -> "Extensions and updates", search for "attach", and install "attach to anything".
Also see:
Automate "Attach to Process" in Visual Studio 2012
Alt+Shift+P to reattach the last attached process.
It works for me in Visual Studio 2017.
Personally I prefer to use Debugger.Launch() as suggested here
in this thread, because it doesn't need for references to the DTE (that's IDE-specific and must be explicitly referenced into the project to be used)
VS extensions
Debug Attach Manager
ReAttach
Resurrect
More: Search the VS Marketplace for "attach"
Keyboard
The attach to process shortcut is Ctrl+Alt+P in Visual Studio 2005 and above. You can then press the first letter of the process name you want, e.g. w for w3wp.exe and it'll jump to that, then Enter to attach.
You can use the Alt key shortcut ALT+D,P to launch the "Attach to Process" window via Debug menu.
Code
Add System.Diagnostics.Debugger.Launch() to your code
Current release is VS2015 at time of writing.
Go ahead and edit/extend this answer :-)

How to locate a file in Solution Explorer in Visual Studio 2010?

I have a huge solution with multiple projects. Sometime I need to navigate to a file in Solution Explorer. Using the VS 2010 'Navigate To' feature I can open any file by name in Visual Studio 2010 but I want to be able to select the file in Solution Explorer as well?
There's an option to track the active (open and viewed) item in the solution explorer. If the file is in view, the file in the solution explorer will be selected.
Tools->Options->Projects and Solutions->Track Active Item in Solution Explorer
VS2012 added a new command called SolutionExplorer.SyncWithActiveDocument. The default shortcut for c# is Ctrl+[,S
This command will navigate to the active file in the Solution Explorer.
Also, it seems that you need to have the "Track Active Item in Solution Explorer" option turned off.
With ReSharper installed Shift+Alt+L will find the current file in Solution Explorer in Visual Studio 2008+.
I found the track option to be a little annoying.
I prefer to use DPack. It contain "Locate In Solution Explorer" operation, plus many other features (some are less powerful in VS2010, like their browsers), and it's free.
Note that ReSharper also have the locate feature that works batter than DPack's (in some cases, DPack's locate won't work if the file is collapsed behind folders), but you don't want to buy ReSharper only for this feature.
Brian Schmitt has a great Locate File in Solution Explorer – Visual Studio Macro post for this. The macro is extremely simple and quick. Basically it toggles the setting
Tools->Options->Projects and Solutions->Track Active Item in Solution Explorer
so that the current file ends up selected in the Solution Explorer but, because it is not left on, you don't get irritated by Solution Explorer nodes being expanded for all the files you access.
Public Sub LocateFileInSolutionExplorer()
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand("View.TrackActivityinSolutionExplorer")
DTE.ExecuteCommand("View.SolutionExplorer")
End Sub
Bind a Keyboard ShortCut to this custom macro to effectively create what should be a built-in Visual Studio feature.
If you have ReSharper and want to add "Locate in Solution Explorer" to the tab's context menu:
Go to Tools -> Customize -> Commands -> Context Menu
Select "Other Context Menus | Easy MDI Document Window".
Click "Add Command".
Choose "Resharper" -> "ReSharper_LocateInSolutionOrAssemblyExplorer" (in VS2019, the category name was changed to "Extensions")
"OK" -> "Close"
Now, when right click on any tab and you'll see a new option: Locate in Solution Explorer.
UPDATE:
Following the comment from #jeremy-paskali, you can set a keyboard shortcut for this command:
Go to Tools -> Customize -> "Keyboard..."
Search for "ReSharper.ReSharper_LocateInSolutionOrAssemblyExplorer" in the "Show commands containing" field and select it.
Review the currently assigned shortcuts in the drop down below.
Make any changes, if needed.
"OK" -> "Close"
Visual Studio 2012 has a new shortcut Ctrl [, S. Yes you have to type Ctrl [ and then release and then immediately type S (or click the little sync icon at the top of Solution Explored). It will synchronize to the item.
Of course you can change the shortcut. I think I'll try Alt+L for locate.
If you want to change the shortcut, it's command name under Options\Environment\Keyboard is SolutionExplorer.SyncWithActiveDocument.
Usually this is more useful than always tracking, which in older versions always was a disaster because it would track 100 items in a row and then be jumping all over the place...
I know its little too late, but hope it helps someone else. The best option now is to install Microsoft Visual Studio add on called - Productivity Power Tools.
http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef
With this comes "Solution Navigator" (alternative to Solution Explorer, with a lot of benefits) - which then you can use to filter the files to only show "Open". You can even filter files to show "Edited" and "Unsaved".
In the event you want to only track the current file through a
keyboard shortcut - the activity is
"View.TrackActivityinSolutionExplorer" (assign keys here -> Tools -
Options - Environment - Keyboard)
Credit (James' comment)
This worked for me
There are several build-in ways you can accomplish this nowadays:
Configure VS to track the active item in Solution Explorer: This can be accomplished by selecting "Track active item in Solution
Explorer" at
Tools > Settings > Projects and Solutions > General
Use "Sync with active document": This can be accomplished in 2 ways.
Firing the SolutionExplorer.SyncWithActiveDocument command by using the default key combination CTRL+]+S
CTRL+)+S if you happen to be using an AZERTY keyboard like me.
By using the "Sync with active document" button on top of the Solution Explorer. The button looks like 2 apposing arrows on top of each other.
If you're version is older then VS2019 Version 16.10.2 then this button looks like this:
From VS2019 Version 16.10.2 onwards this button will look like this:
And yet again Microsoft has changed the button icon in more recent versions of VS 2022:
In Visual Studio 2010 you can turn on the "Track Active Item in Solution Explorer" option. This will mean whenever you switch between documents the new document gets selected in Solution Explorer. This can be irritating if your solution has lots of folders, because as you move around files in your solution all the folders will be left open.
Visual Studio 2012 introduced the new "Sync with Active Document" feature. Three is a button for it at the top of Solution Explorer, or you can use the shortcut Ctrl + [, S.
This is actually built in to visual studio without the need for ReSharper (which I love BTW).
http://blogs.msdn.com/b/zainnab/archive/2010/03/29/track-active-item-in-solution-explorer-vstipproj0011.aspx
If you want to select the file in the solution explorer on command and don't want to install anything then I would recommend this macro.
I've tested it, setting the shortcut to Alt+T, and I can confirm that it works with VS 2010.
Thanks to Dan Vanderboom for writing it.
For Visual Studio 2017 using a French AZERTY keyboard the command is the same as stated by Aaron Carlson but the keyboard shortcut is different.
The AZERTY keyboard shortcut to navigate to the active file for c# is Ctrl+),Ctrl+S
I checked the shortcut hadn't changed for QWERTY users in VS2017 on this page
http://visualstudioshortcuts.com/2017/
Visual Studio doesn’t offer an easy way to locate the current file you’re editing in the Solution Explorer on demand. You can set the solution explorer to always stay in sync with this simple setting:
Tools > Options > Projects and Solutions > General. Check “Track active item in Solution Explorer”.
Thanks to Cory House

Visual Studio IDE Issue

Can someone tell me why my Ctrl+F5 disappeared in Visual Studio 2008? Its not even in the menu. In the Debug menu, All I have is Windows, Start Debugging, Step Into, Step Over, Exceptions, and Toggle Breakpoints.
I'm using the professional edition of Visual Studio 2008 and for some reason, this morning, it just vanished.
You can re-add it: Tools -> Customize... -> Commands tab -> Select Debug -> Drag the "Start Without Debugging" command to the Debug menu and place it where you want it to be.
As for why it happened, hard to tell.
Was it the button there before becuase I just checked on mine and saw that there was no button with Ctrl+F5, but when you do the command, it works fine.
Right click on the menu bar and click Customize... from there you can add in any options that are missing.
Could this happen if the current "Startup Project" - the one in bold in the Solution Explorer - is not an executable?
(I don't have access to VS to check)

Resources