Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force visual studio to always 'rebuild all' when debugging

Edit: Basically what I need is for visual studio to always rebuild all when I hit debug.


I'm currently using visual studio to compile my assembly programs, using MASM and in general it's working fine.

However I've run into an annoying issue:

If I include a file (say, a file with functions) like this

Include functions.inc

and compile it, it originally works fine. However if I then change the contents of functions.inc, this is not recognized and the compilers skips over functions.inc and uses the old version from before I changed it.

I cannot find an option anywhere under project properties to fix this. However I'm sure it has something to do with linker options or something - if I make any changes under project properties (even if I change something and change it back, and then press OK), it does compile properly with the new version of functions.inc.

Any ideas?

like image 793
Cam Avatar asked Mar 04 '10 04:03

Cam


People also ask

How do I rebuild an entire solution in Visual Studio?

To build, rebuild, or clean an entire solutionChoose Build All to compile the files and components within the project that have changed since the most recent build. Choose Rebuild All to "clean" the solution and then builds all project files and components. Choose Clean All to delete any intermediate and output files.

How do I keep debugging in Visual Studio?

In most languages supported by Visual Studio, you can edit your code in the middle of a debugging session and continue debugging. To use this feature, click into your code with your cursor while paused in the debugger, make edits, and press F5, F10, or F11 to continue debugging.

What is the difference between build Solution and rebuild solution in Visual Studio?

Build Solution : compiles code files (dll and exe) that have changed. Rebuild Solution : Deletes all compiled files and Compiles them again regardless of whether or not the code has changed.

How do I Debug multiple processes in Visual Studio?

On the Properties page, select Common Properties > Startup Project. Select Current selection, Single startup project and a project file, or Multiple startup projects. If you select Multiple startup projects, you can change the startup order and action to take for each project: Start, Start without debugging, or None.


2 Answers

You can change the behaviour via the EnvironmentEvents macro in Visual Studio's Macro Explorer:

Private Enum IDEMode
    Design = 1
    Break = 2
    Run = 3
End Enum

Private _IDEMode As IDEMode = IDEMode.Design

Public Sub DTEDebuggerEvents_OnDebugRun() Handles _
DebuggerEvents.OnEnterRunMode
    If _IDEMode = IDEMode.Design Then
        DTE.ExecuteCommand("Build.RebuildSolution")
    End If
    _IDEMode = IDEMode.Run
End Sub

Public Sub DTEDebuggerEvents_OnDebugDesign() Handles _
    DebuggerEvents.OnEnterDesignMode
    _IDEMode = IDEMode.Design
End Sub

Public Sub DTEDebuggerEvents_OnDebugBreak() Handles _
    DebuggerEvents.OnEnterBreakMode
    _IDEMode = IDEMode.Break
End Sub

This is a VisualStudio change so it will work across all solutions once set

UPDATE The above solution works, however it has some pitfalls concerning content files where the IDE will change to design mode even if the debugger is running. It will try to build while the debugger is running in some situations. The proper solution is this:

Private _curDebugState As EnvDTE80.dbgProcessState

Public Sub debuggerStateChangedHandler
    (ByVal NewProcess As EnvDTE.Process, 
    ByVal processState As EnvDTE80.dbgProcessState) 
    Handles DebuggerProcessEvents.OnProcessStateChanged
    If _curDebugState = dbgProcessState.dbgProcessStateStop And processState = dbgProcessState.dbgProcessStateRun Then
        DTE.ExecuteCommand("Build.RebuildSolution")
    End If
    _curDebugState = processState
End Sub
like image 64
Jaguar Avatar answered Sep 30 '22 02:09

Jaguar


Make sure, you have selected the startup project for build in the Configuration Manager:

Build -> Configuration Manager -> check the 'Build' column for all relevant projects.

like image 35
user492238 Avatar answered Sep 30 '22 03:09

user492238