如何将 IIS 7 Web 部署与 MSBuild 集成 (TeamCity)

发布于 2024-09-01 18:46:32 字数 47 浏览 4 评论 0原文

如何将 IIS 7 Web 部署与 MSBuild (TeamCity) 集成?

How-To Integrate IIS 7 Web Deploy with MSBuild (TeamCity) ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

嘴硬脾气大 2024-09-08 18:46:32

Troy Hunt 有一个出色的5 部分博客系列 详细讨论了这个主题。

他有效地编译了所有其他资源并将它们变成了教程。

这是做你想做的事情的最清晰(不管你相信与否,最简洁)的方式。

Troy Hunt has an excellent 5-part blog series that goes over this topic in detail.

He has effectively compiled all of the other resources out there and turned them into a tutorial.

It's the clearest (and believe it or not, the most concise) way to do what you want.

最初的梦 2024-09-08 18:46:32

经过几天的努力,我终于让它工作了。它最终归结为 MSBuild 脚本,在临时/测试服务器上安装和配置 Web 部署,并在 Team City 中进行设置。

步骤很多,而且都可能出错。我将进一步调查并在博客中介绍它,但这是我第一次尝试。

我正在使用以下设置:

  • .NET 4
  • ASP.NET MVC 2
  • TFS 2008
  • Team City
  • IIS7
  • Web Deploy

这是 MSBuild 脚本:

    <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <Configuration>Release</Configuration>
        <Platform>AnyCPU</Platform>
    </PropertyGroup>

    <Import Project="Webapplication.csproj" />

    <Target Name='Deploy' DependsOnTargets='Build;Package' >
        <Exec Command='"C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" 
                -source:contentpath="$(teamcity_build_checkoutDir)\Main\source\Webapplication\obj\Release\Package\PackageTmp\" 
                -dest:contentpath="c:\inetpub\Webapplication\www",includeAcls=false,computername="https://(stagingserver-name):8172/msdeploy.axd?Site=Webapplication",authType=Basic,userName=(staginserver-name)\webdeploy,password=******** 
                -allowUntrusted 
                -verb:sync' />
    </Target>
</Project>

要点:

  • 我设置了 Web.Release.config 以在临时环境中工作
  • 构建脚本必须位于与 Webapplication.csproj 相同的目录中
  • Web 部署必须安装在 Team City 服务器以及 Web(登台)服务器上
  • c:\inetpub\Webapplication\www 是 Web 服务器上的目录
  • webdeploy 用户名是Web 服务器上的本地 Windows 帐户,具有对 c:\inetpub\Webapplication\www 的完全访问权限

准备工作:

Team City 创建了一条 contentPath 规则:

我使用上面的 MSBuild 脚本设置了一个新的构建配置,并将目标设置为部署

I finally managed to get it to work after several days of struggle. It finally boils down to a MSBuild script, installing and configuring web deploy on the staging/test server and setting it up in Team City.

It's a lot of steps and all can go wrong. I will investigate further and blog about it but this is my first attempt that works.

I'm using this setup:

  • .NET 4
  • ASP.NET MVC 2
  • TFS 2008
  • Team City
  • IIS7
  • Web Deploy

Here is the MSBuild script:

    <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <PropertyGroup>
        <Configuration>Release</Configuration>
        <Platform>AnyCPU</Platform>
    </PropertyGroup>

    <Import Project="Webapplication.csproj" />

    <Target Name='Deploy' DependsOnTargets='Build;Package' >
        <Exec Command='"C:\Program Files\IIS\Microsoft Web Deploy\msdeploy.exe" 
                -source:contentpath="$(teamcity_build_checkoutDir)\Main\source\Webapplication\obj\Release\Package\PackageTmp\" 
                -dest:contentpath="c:\inetpub\Webapplication\www",includeAcls=false,computername="https://(stagingserver-name):8172/msdeploy.axd?Site=Webapplication",authType=Basic,userName=(staginserver-name)\webdeploy,password=******** 
                -allowUntrusted 
                -verb:sync' />
    </Target>
</Project>

Key points:

  • I set up the Web.Release.config to work in the staging environment
  • The build script must be located in the same directory as Webapplication.csproj
  • Web deploy must be installed on the Team City server as well as on the web (staging) server
  • c:\inetpub\Webapplication\www is a directory on the web server
  • The webdeploy username is a local windows account on the web server with full access to c:\inetpub\Webapplication\www

Preparations:

Team City:

I set up a new build configuration using the MSBuild script above and set the target to Deploy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文