自动停止/上重新构建ASP.NET开发服务器 [英] Automatically stop/restart ASP.NET Development Server on Build

查看:142
本文介绍了自动停止/上重新构建ASP.NET开发服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法,每当我做一个生成自动停止ASP.NET开发服务器(卡西尼)/重建在VS2008(和那么显然需要时它已重新开始)?也许有一些隐藏的配置设置的地方?或者至少一些方法来做到这一点作为一个生成后事件可能?

Is there a way to automatically stop the ASP.NET Development Server (Cassini) whenever I do a build/rebuild in VS2008 (and then obviously have it start again when required)? Maybe there's some hidden configuration setting somewhere? Or at least some way to do it as a post-build event maybe?

有关的一些背景,问题是,我使用Spring.NET依赖注入等,但它加载在应用程序启动的单身人士,这意味着如果我改变任何相关的春天code /配置我有停止开发服务器,使之重新开始下一调试/运行确保应用程序启动事件再次触发。换句话说,即使你换了一堆code /配置和放大器;然后再次开始调试,它实际上并不启动的再次,因为它的已在运行,所以不使用新的code。

For some background, the issue is that I'm using Spring.NET for dependency injection, etc, but it loads its singletons on Application Start, meaning that if I change any spring related code/configuration I have to stop the Development Server, so that it starts again next debug/run ensuring the Application Start event is triggered again. In other words, even if you change a bunch of code/config & then start debugging again, it doesn't actually start again, since its already running, so your new code isn't being used.

推荐答案

所以,我结束了一个解决办法基于关闭Magnus的答案,但使用以下相对简单的宏(为什么他们迫使你用VB宏?我觉得所有脏):

So I ended up with a workaround based off Magnus' answer, but using the following relatively simple macro (why do they force you to use VB for macros? I feel all dirty):

Imports System
Imports System.Diagnostics

Public Module KillCassini

    Sub RestartDebug()
        If (DTE.Debugger.DebuggedProcesses.Count > 0) Then
            DTE.Debugger.Stop(True)
        End If
        KillCassini()
        DTE.Debugger.Go(False)
    End Sub

    Sub KillCassini()
        Dim name As String = "WebDev.WebServer"
        Dim proc As Process
        For Each proc In Process.GetProcesses
            If (proc.ProcessName.StartsWith(name)) Then
                proc.Kill()
            End If
        Next
    End Sub

End Module

基本上,如果调试器正在运行,它会阻止它与放大器;然后杀死名为WebDev.WebServer的进程应该是所有的卡西尼实例,然后重新启动调试器(这将隐式重新开始卡西尼)。我使用 proc.Kill(),因为无论 proc.CloseMainWindow() PROC .WaitForExit(1000)似乎工作...

Basically if the debugger is currently running, it will stop it & then kill any processes named "WebDev.WebServer" which should be all the Cassini instances and then starts the debugger again (which will implicitly start Cassini again). I'm using proc.Kill() because neither proc.CloseMainWindow() or proc.WaitForExit(1000) seemed to work...

无论如何,一旦你有你的宏,您可以将其分配给键盘快捷键,或者创建自定义工具栏按钮来运行它。

Anyway, once you've got your macro you can assign it to keyboard shortcuts, or create custom toolbar buttons to run it.

这篇关于自动停止/上重新构建ASP.NET开发服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆