【问题标题】:TeamCity Build Task to autostart ASP.NET WebsiteTeamCity 构建任务以自动启动 ASP.NET 网站
【发布时间】:2012-07-26 02:29:14
【问题描述】:

我已将 TeamCity 设置为我的 CI 解决方案,用于构建、打包和部署(通过 MSBuild/Web 部署)我的 ASP.NET MVC 3 Web 应用程序。

效果很好。

但是,在我的应用程序的 Application_Start 事件中,我执行了各种启动活动,例如预热缓存。

我想添加一个 TeamCity 构建任务(部署后)以某种方式调用此方法(因此第一个手动用户请求不会等待)。

唯一想到的是使用 powershell 脚本基本上 ping/wget 网站。

是否有更好的解决方案 - 可能是 MSBuild 部署任务的一部分?

【问题讨论】:

    标签: asp.net iis-7 msbuild teamcity global-asax


    【解决方案1】:

    使用简单的 powershell 脚本,作为 TeamCity 构建步骤:

    来源:MSDN

    # webclient.ps1
    # Web client sample recoded in PowerShell
    # Converted from MSDN C# Sample
    # Thomas Lee  - tfl@psp.co.uk
    
    # get a web page (author's blog)
    $client = new-object system.net.WebClient
    $client.Headers.Add("user-agent", "PowerShell")
    $data = $client.OpenRead("http://www.mywebsite.com/")
    $reader = new-object system.io.StreamReader $data
    [string] $s = $reader.ReadToEnd()
    # display output
    "The returned document is {0} bytes" -f $s.length.tostring("###,###,##0")
    
    # close
    $data.Close()
    $reader.Close()  
    

    【讨论】:

      最近更新 更多