使用 Visual Studio 宏 IDE,我如何判断构建是旧的还是过时的?
我目前已重新映射我的 F5 以运行自定义宏,该宏将进入调试模式并附加到浏览器而不构建解决方案。通常,我总是确保在调试之前按下 Control-Shift-B,但我认为我可以更进一步,并将这个过程也编程到宏中。此设置的最佳部分是,如果自上次构建以来我没有更改代码,我总是可以跳入和跳出调试,而无需像使用正常调试 (F5) 模式时那样冗余地重新构建解决方案。
基本上,我想知道是否有变量或某个过程来判断自上次构建以来代码是否已更改。
这是整个宏,带有??? 部分显示我正在尝试做的事情。如果您愿意,可以自己使用它——它在调试大型解决方案时为我节省了大量时间。
Imports System
Imports EnvDTE80
Imports System.Diagnostics
Public Module AttachToWebServer
Public Sub AttachToWebServer()
Dim AspNetWp As String = "aspnet_wp.exe"
Dim W3WP As String = "w3wp.exe"
Dim buildIsOld As Boolean
buildIsOld = ???
If buildIsOld Then
' Build the solution and wait for it to finish
DTE.Solution.SolutionBuild.Build(True)
End If
' Are we at a breakpoint?
If DTE.Debugger.CurrentMode = EnvDTE.dbgDebugMode.dbgBreakMode Then
DTE.Debugger.Go() ' Then continue instead of reattaching
Else ' If not, attach to IIS
If Not (AttachToProcess(AspNetWp)) Then
If Not AttachToProcess(W3WP) Then
System.Windows.Forms.MessageBox.Show(String.Format("Process {0} or {1} Cannot Be Found", AspNetWp, W3WP), "Attach To Web Server Macro")
End If
End If
End If
End Sub
Public Function AttachToProcess(ByVal processName As String) As Boolean
Dim processFound As Boolean = False
For Each Process As EnvDTE.Process In DTE.Debugger.LocalProcesses
If (Process.Name.Substring(Process.Name.LastIndexOf("\") + 1) = processName) Then
Process.Attach()
processFound = True
End If
Next
Return processFound
End Function
End Module