Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have Visual Studio automatically search for source code when debugging

Given:

  • a dll which has been built in directory "A"
  • a debugging PC with source code put in directory "B"

Then when debugging, VisualStudio will search for source code in "A", will not find it (as it is in "B"), and will display the dialog called "Find Source". Then you will browse to the correct location of source file, and everything will work fine.

In order to avoid this dialog to appear (and its associated browsing), is there a mean to have Visual Studio automatically look for source code in "B" ?

like image 752
sthiers Avatar asked May 11 '12 11:05

sthiers


2 Answers

It seems that you have set some configuration related to debugging in project.

This property page specifies where the debugger will look for source files when debugging the solution.

To access the Debug Source Files property page, right-click on your Solution in Solution Explorer and select Properties from the shortcut menu. Expand the Common Properties folder, and click the Debug Source Files page.

Directories containing source code
Contains a list of directories in which the debugger searches for source files when debugging the solution.

Do not look for these source files
Enter the names of any files that you do not want the debugger to read. If the debugger finds one of these files in one of the directories specified above, it will ignore it. If the Find Source dialog box comes up while you are debugging and , you click Cancel, the file you were searching for gets added to this list so that the debugger will not continue searching for that file.

like image 171
Romil Kumar Jain Avatar answered Sep 23 '22 19:09

Romil Kumar Jain


It is possible to automate the source code search using the autoHotKey scripting tool: it will open nicely the correct source code without any user input. The first time a file is search, it will take a few seconds, and then it will become instant.

The script code is provided below. It's used with VS2010:

SourcesRoot = D:\MySourceCodeIsHere
Loop
{
  WinWait, Find Source:, 
  IfWinNotActive, Find Source: , , WinActivate, Find Source:, 
  WinWaitActive, Find Source:, 
  ControlGetText, Filename, Edit1,
  Loop, %SourcesRoot%\%Filename%, , 1  
  {
    ControlSetText, Edit1, %A_LoopFileFullPath%
    break  
  }
  ControlClick Button2
}
like image 21
sthiers Avatar answered Sep 25 '22 19:09

sthiers