asp.net - TeamCity 构建任务以自动启动 ASP.NET 网站

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

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

效果很好。

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

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

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

是否有更好的解决方案 - 也许是作为 MSBuild 部署任务的一部分的选项?

最佳答案

使用简单的 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()  

关于asp.net - TeamCity 构建任务以自动启动 ASP.NET 网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11661469/

相关文章:

ssl - IIS 7 - 我可以将 EV SSL 与通配符证书结合使用吗?

c# - MVC 应用程序可以在 Visual Studio 中运行,但不能在 IIS7 中运行

msbuild - 如何从项目中排除文件夹但不从发布中排除?

batch-file - 在 Jenkins 上以管理员身份运行批处理文件?

asp.net - 如何按需加载两个 ASP.NET UserControl?

asp.net-mvc - 在 Asp.net MVC 中抛出/返回 404 actionresult 或异常并让 IIS 处理它

asp.net - 如何在Visual Studio 2019中创建ASP.NET网站?

node.js - 在 Visual Studio 2015 中构建 node-gyp 项目时出现 LNK1104 错误

c# - 使用点 (.) 或感叹号 (!) 拆分字符串,但忽略新字符串开头的空格

jquery - 对 RadioButtonList 的不同元素应用不同的颜色