使用 msdeploy 部署 MVC 站点,包括来自没有虚拟目录设置的 CI 服务器的 IIS 设置

发布于 2025-01-07 22:33:50 字数 6442 浏览 0 评论 0原文

我试图弄清楚如何将 msdeploy 与我的 MVC 站点一起使用,以便能够自动执行部署,包括在远程服务器上设置 IIS。

我使用以下命令来创建包:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe Clients\PokerLeagueWebSite\PokerLeagueWebSite.csproj /T:Package /p:Configuration=Deployment

我的设置如下:

local dev box using VS2010 + GIT
GITHUB for repo
Teamcity for CI server (different machine to dev box)
remote (same network) UAT server

如果我勾选“包括 IIS 中配置的 IIS 设置”和“包括此 Web 项目使用的应用程序池设置”并在我的开发盒上构建包,那么从那里发布它效果很好。这是我使用的命令:

C:\myproject\Packages\Deployment\PokerLeagueWebSite>PokerLeagueWebSite.deploy.cmd /Y /M:192.168.10.98:8172 /U:administrator /P:password

这会在我的 UAT 服务器中创建虚拟目录,一切都很好。问题是当我提交到 github 并且 CI 服务器下载并构建它时。当然,CI 服务器上没有设置虚拟目录,因此构建/打包失败。

我想要做的是使用 msdeploy 提供的打包并能够远程部署站点和 IIS。我想有几个选项:

1) 将 MVC 项目文件更改为硬编码 iis 设置,以便无论何时/何地运行构建包,它都会创建具有正确设置的 XML 文件,以便可以从任何计算机进行部署。我认为这可以通过项目根目录中的 package.xml 文件来完成,但我不知道如何设置所有应用程序池和虚拟目录设置。感觉我已经成功了一半,但无法最后冲过终点线。

2) 使用 powershell 更改创建的包 XML 文件,以便添加提取 IIS 设置。

第一个选项更可取,因为它将所有信息保存在一个位置,并且您不需要记住在部署之前运行额外的脚本。

我相信我可以通过使用 VS 创建包并获取我需要的设置然后编写脚本来找出第二个选项,但我没有任何线索,花了很长时间阅读它,但我如何做却没有成功选项一。

注意,

在发布本文之前阅读一些建议的问题,我可以看到某种可能性:

MSdeploy 使用错误的虚拟目录名称部署 MVC 2 应用程序

这个问题讨论了在 msdeploy 命令上传递额外的值,看起来不错,但不是内部的可以这么说,构建过程。不确定要使用的所有命令,但可以通过谷歌搜索我确定。

此链接似乎继续上述内容: http://msdn.microsoft.com /en-us/library/ee814764.aspx

此页面介绍选项 2 的可能性。http://learn.iis.net/page.aspx/1082/web -deploy-parameterization/

认为是这样的:在站点的根目录中使用parameters.xml来处理项目内容: http://vishaljoshi.blogspot.com/2010/ 07/web-deploy-parameterization-in-action.html

编辑

我继续围绕此进行阅读和测试。使用项目根目录中的parameters.xml 文件,我认为我几乎可以在那里获取参数。我的问题似乎是 archive.xml 文件。这是非常不同的,如果我没有勾选使用 IIS 设置复选框,这就是导致包无法正确安装的原因。我已经开始阅读有关 [project].wpp.targets 文件的内容,该文件可能会有所帮助,但在该自动取款机上却迷失了方向。

编辑2

所以我认为我需要做的是获取 [project].sourcemanifest.xml 文件来更改其一些设置。我相信这就是驱动 archive.xml 的原因,而现在有所不同。我认为parameters.xml 工作正常。

当不使用 IIS 时,sourcemanifest.xml 看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
  <IisApp path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" managedRuntimeVersion="v4.0" />
  <setAcl path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclResourceType="Directory" />
  <setAcl path="C:\hoh_code\GIT\ai-poker-    project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp"     setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>

但是当我勾选使用 IIS 设置时,它看起来像这样:

<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
  <appHostConfig path="Default Web Site/PokerLeague" />
  <contentPath path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" />
  <setAcl path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclResourceType="Directory" />
  <setAcl path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>

不确定如何更改它,正在处理 [project].wpp.targets 文件,但在黑暗的 atm 中摸索。

编辑3

好的,所以我想我已经掌握了一分钟了。在我的 [project].wpp.targets 文件中,我有:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>

    <AddContentPathToSourceManifestDependsOn>
      SetCustomACLs;
    </AddContentPathToSourceManifestDependsOn >
  </PropertyGroup>

  <Target Name="SetCustomACLs">
    <ItemGroup>
      <MsDeploySourceManifest Include="appHostConfig">
        <Path>Default Web Site/PokerLeague</Path>
      </MsDeploySourceManifest>
    </ItemGroup>
    <ItemGroup>
        <MsDeploySourceManifest Include="contentPath">
            <Path>$(_MSDeployDirPath_FullPath)</Path>
        </MsDeploySourceManifest>
    </ItemGroup>
  </Target>
</Project>

哪个构建,创建一个部署包,然后我可以将其从我的开发盒部署到 UAT 服务器并且它可以工作。但是当我在 CI 服务器上运行它时,它不会构建部署包,它会在清单阶段退出并出现错误:

One or more entries in the manifest 'sitemanifest' are not valid. 

清单文件如下所示:

<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
  <appHostConfig path="Default Web Site/PokerLeague" />
  <contentPath path="C:\TeamCity\buildAgent\work\71e78d4c543e0594\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" />
  <IisApp path="C:\TeamCity\buildAgent\work\71e78d4c543e0594\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" managedRuntimeVersion="v4.0" />
  <setAcl path="C:\TeamCity\buildAgent\work\71e78d4c543e0594\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclResourceType="Directory" />
  <setAcl path="C:\TeamCity\buildAgent\work\71e78d4c543e0594\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>

我猜这是因为它仍然具有 IisApp 以及我添加的appHostConfig。我只是猜测这一点,还不知道如何删除它。

编辑4

好的,我找到了从清单和参数中删除 IISAPP 的设置:

<DeployAsIisApp>False</DeployAsIisApp>

这会进入 wpp.targets 文件。

现在这产生了一个新问题,它将不再部署。我相信这与处理站点的 apphostconfig 和处理虚拟目录的 iisapp 有关。

编辑 5

所以我一直在研究 IIS 和我的自定义之间的差异。

sourcemanifest.xml 文件是相同的 systeminfo.xml 相同

setparameters.xml:

IIS Web 应用程序名称部分不同。 IIS 版本的值是“默认网站/pokerleague”,但我的版本是“C:\websites\pokerleague”。

我认为这就是导致parameters.xml中错误的原因:

IIS Web应用程序具有相同的值,并且标签属性具有物理属性而不是iisapp属性。

I am trying to figure out how to use msdeploy with my MVC site to be able to automate the deployments including setting up IIS on the remote server.

I use the following command to create the package:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe Clients\PokerLeagueWebSite\PokerLeagueWebSite.csproj /T:Package /p:Configuration=Deployment

My setup is as follows:

local dev box using VS2010 + GIT
GITHUB for repo
Teamcity for CI server (different machine to dev box)
remote (same network) UAT server

If I tick the "Include IIS Settings as configured in IIS" and "Include application pool settings used by this web project" and build the package on my dev box then publish from there it works great. Here is the command I use:

C:\myproject\Packages\Deployment\PokerLeagueWebSite>PokerLeagueWebSite.deploy.cmd /Y /M:192.168.10.98:8172 /U:administrator /P:password

This creates the virtual directory within my UAT server and all is well. The problem is when I commit to github and the CI server downloads and builds it. Naturally the virtual directory is not setup on the CI server so the build / package fails.

What I want to do is use the packaging that msdeploy gives and be able to deploy the site and IIS remotely. I guess there are a few options:

1) Alter the MVC project file to hard code iis settings so that when ever / where ever you run the build package it creates the XML files with the correct settings so it can be deployed from any machine. I think this might be able to be done with the package.xml file in the root of the project, but I have no idea how I setup all the app pool and virtual directory settings. Feel like I am half way there but can't get the final push across the line.

2) Use powershell to alter created package XML files so that the extract IIS settings are added.

The first option is preferable as it keeps all the information in one place and you don't need to remember to run an extra script before deployments.

I believe I could figure the second option out by using VS to create the package and get the settings I need then script it, but I don't have a clue and spent a fair while reading about it without any success on how I would do option one.

N.B.

Reading some of the suggested questions before I posted this I can see some sort of possibilities:

MSdeploy deploys an MVC 2 application with wrong virtual directory name

This question talks about passing extra values on the msdeploy command, seems OK but not internal to the build process so to speak. Not sure of all the commands to use but can google that I am sure.

This links seems to continue with the above: http://msdn.microsoft.com/en-us/library/ee814764.aspx

This page takes about the possibilities for option 2. http://learn.iis.net/page.aspx/1082/web-deploy-parameterization/

Think this is the way: using parameters.xml in teh root of the site for project stuff:
http://vishaljoshi.blogspot.com/2010/07/web-deploy-parameterization-in-action.html

EDIT

I have continued reading and testing around this. Using the parameters.xml file in the root of the project I can get the parameters pretty much there I think. My issue seems to be the archive.xml file. This is pretty different and is what is causing the package to not install correctly if I do not have the use IIS settings check box ticked. I have started to read about [project].wpp.targets file that might help but pretty darn lost with that atm.

EDIT 2

So what I think I need to do is get the [project].sourcemanifest.xml file to change a few of its settings. I believe this is what drives the archive.xml which is what is different now. I have the parameters.xml working correctly I think.

When NOT using IIS the sourcemanifest.xml looks like this:

<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
  <IisApp path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" managedRuntimeVersion="v4.0" />
  <setAcl path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclResourceType="Directory" />
  <setAcl path="C:\hoh_code\GIT\ai-poker-    project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp"     setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>

But when I tick the use IIS settings it looks like this:

<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
  <appHostConfig path="Default Web Site/PokerLeague" />
  <contentPath path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" />
  <setAcl path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclResourceType="Directory" />
  <setAcl path="C:\hoh_code\GIT\ai-poker-project\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>

Not sure how to change it, working on the [project].wpp.targets file, but fumbling in the dark atm.

EDIT 3

OK so I thought I had it for a minute. in my [project].wpp.targets file I have:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <PropertyGroup>

    <AddContentPathToSourceManifestDependsOn>
      SetCustomACLs;
    </AddContentPathToSourceManifestDependsOn >
  </PropertyGroup>

  <Target Name="SetCustomACLs">
    <ItemGroup>
      <MsDeploySourceManifest Include="appHostConfig">
        <Path>Default Web Site/PokerLeague</Path>
      </MsDeploySourceManifest>
    </ItemGroup>
    <ItemGroup>
        <MsDeploySourceManifest Include="contentPath">
            <Path>$(_MSDeployDirPath_FullPath)</Path>
        </MsDeploySourceManifest>
    </ItemGroup>
  </Target>
</Project>

Which builds, creates a deployment package that I can then deploy from my dev box to the UAT server and it works. But when I run it on my CI server it will not build the deployment package, it drops out at the manifest stage with the error:

One or more entries in the manifest 'sitemanifest' are not valid. 

The manifest file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
  <appHostConfig path="Default Web Site/PokerLeague" />
  <contentPath path="C:\TeamCity\buildAgent\work\71e78d4c543e0594\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" />
  <IisApp path="C:\TeamCity\buildAgent\work\71e78d4c543e0594\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" managedRuntimeVersion="v4.0" />
  <setAcl path="C:\TeamCity\buildAgent\work\71e78d4c543e0594\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclResourceType="Directory" />
  <setAcl path="C:\TeamCity\buildAgent\work\71e78d4c543e0594\Clients\PokerLeagueWebSite\obj\Deployment\Package\PackageTmp" setAclUser="anonymousAuthenticationUser" setAclResourceType="Directory" />
</sitemanifest>

I am guessing it is because it still has the IisApp as well as the appHostConfig that I added. I am just guessing about this, and don't know how to remove that yet.

EDIT 4

OK so I found the setting to remove the IISAPP from the manifest and parameters:

<DeployAsIisApp>False</DeployAsIisApp>

This goes into the wpp.targets file.

This has now created a new issue that it will no longer deploy. I believe this is something to do with apphostconfig dealing with sites and iisapp dealing with virtual directories.

EDIT 5

so I have been going through the differences left between ticking with IIS and my custom one.

sourcemanifest.xml files are the same
systeminfo.xml are the same

setparameters.xml:

The IIS web applicaiton name section is different. With IIS version is has the "Default Web Site/pokerleague" value but mine has "C:\websites\pokerleague".

I think this is what is driving the error in the parameters.xml:

the IIS web application has those same values and the tags attribute has physical rather than iisapp.

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

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

发布评论

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

评论(2

破晓 2025-01-14 22:33:50

我有类似的工具,并进行自动化构建和部署:

  • git repo
  • vs 2010 、 asp.net mvc 3
  • teamcity 7.1
  • msbuild
  • msdeploy

我将构建、打包和部署步骤分开。我不使用 msdeploy xml 文件,但在命令行上执行相同的操作。

以下是我的步骤:

步骤1:编辑Visual Studio项目属性

右键单击“MyAppName”项目->属性...,选项卡“打包/发布 Web”...

  • 配置:活动(调试)- 这意味着“调试”配置在 VS 中处于活动状态,并且您正在编辑它。 “调试”和“发布”配置都可以选择并独立编辑。
  • Web 部署包设置 - 选中“将部署包创建为 zip 文件”。我们需要 ZIP 文件,以便稍后可以单独部署。
  • IIS 网站/应用程序名称 - 这必须与目标服务器上的 IIS 网站条目匹配。我使用“MyAppName/”,路径后没有应用程序名称,因为我在 IIS 中手动创建它。这就是它在网络服务器配置上的样子。

我第一次手动创建 IIS 网站(也许您可以自动化,但我不这样做)。使用 MSDeploy 时,它会将您的应用程序推送到匹配的网站名称 - 您不必对任何目标文件夹路径或任何内容进行硬编码。

将其与您的项目一起保存,并确保您的更改已签入 Git(推送到 origin/master)。当 CI 服务器运行构建步骤时,这些设置将从版本控制中提取。

步骤 2:在 TeamCity 配置中添加构建步骤

我编辑构建步骤,并添加第二个构建步骤,以使用 msbuild 直接构建 MyAppName.sln。您可以根据需要进行修改,因为您可能已经以某种方式这样做了。

步骤 3:通过安装 Microsoft Visual Studio 2010 Shell(集成)可再发行组件包来修复构建错误

基本上,我们需要在构建服务器上安装 VS、手动复制文件或安装 Microsoft Visual Studio 2010 Shell(集成)可再发行软件包

找不到 Microsoft.WebApplication.targets ,在构建服务器上。你的解决方案是什么?

这将使它构建。仍然没有部署到服务器。

步骤 5:安装 MS Web 部署工具

我在Web 部署工具此处获取并安装。重新启动后,TeamCity 登录出现 404 错误。事实证明,Web Deploy 有一个侦听端口 80 的服务,但 TeamCity Tomcat 服务器也是如此。短期内,我在控制面板中停止 Web Deploy Web 服务,并启动 TeamCity Web 服务。 Web 部署代理服务的目的是接受其他服务器对该服务器的请求。我们不需要它,因为 TeamCity 服务器将充当客户端,并部署到其他 Web 服务器。

Web 部署工具还必须安装在目标 Web 服务器上。我不会在这里详细介绍,但您还必须配置服务来侦听,因此当您运行部署命令时,它会接受它并安装在服务器上。对于服务器,我设置了一个名为“webdeploy”的新帐户,并具有安装权限。

步骤 6:创建 MSBuild 命令来打包 Web 项目

我对打包和部署执行了单独的步骤。如果需要,这将允许构建发布包但手动部署它的情况。

这是 msbuild 包命令:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" 
           MyAppName/MyAppName/MyAppName.csproj 
           /T:Package 
           /P:Configuration=Debug;PackageLocation="C:\Build\MyAppName.Debug.zip"

让我解释一下命令部分:

MyAppName.csproj :要构建的 VS 项目文件的路径。其中有一些重要的选项可以从项目属性选项卡中设置。

/T:Package :创建 ZIP 包

/P:Configuration=Debug;PackageLocation=*** :运行调试配置。这与在 Visual Studio 中选择“调试”设置进行构建相同。 “包位置”就是它所创建的。我们稍后将在部署命令中引用包文件。

步骤 7:创建 Web Deploy 命令来部署项目 ##

"C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy.exe" -verb:sync 
     -source:package="C:\Build\MyAppName.Debug.zip" 
     -dest:auto,wmsvc=webservername,username=webdeploy,password=******* 
     -allowUntrusted=true

该命令也值得详细解释:

-verb:sync :使网站从源同步到目标

-source:package="C:\Build\ MyAppName.Debug.zip" :源是 MSBuild zip 文件包

-dest:auto,wmsvc=webservername :使用包文件中的设置部署到服务器。用户帐户是具有权限的操作系统级别帐户。指定了主机名,但未指定 IIS 网站名称(之前在项目属性的 MSBuild 项目文件中指定)。

部署后,我检查了 IIS Web 服务器文件,以确保它们具有最新的 DLL 和 web.config 文件。

步骤 8:从 TeamCity 构建步骤调用 MSDEPLOY

由于现在有 2 个好的命令(用于打包的 MSBUILD.exe,用于部署的 MSDEPLOY.exe),请将它们添加到构建步骤中。我使用命令行运行程序,只需输入与前两个步骤相同的命令。

全部运行

当您使用这些步骤运行构建时,如果成功,您可以直接从 git 自动部署。

现在,每次新代码合并并推送到 git origin/master 分支时,它都会自动构建和部署开发服务器。

正如您所看到的,这避免了您原来的问题:

问题是当我提交到 github 并且 CI 服务器下载并
构建它。当然,CI 上没有设置虚拟目录
服务器,因此构建/包失败。

CI 服务器仅构建和打包。然后它部署到目标 Web 服务器。

I have similar tools, and do automated build and deployment:

  • git repo
  • vs 2010 , asp.net mvc 3
  • teamcity 7.1
  • msbuild
  • msdeploy

I separate the build, packaging, and deployment steps. I don't use the msdeploy xml files, but do the same thing on the command line.

These are my steps:

Step 1: edit the Visual Studio project properties

right-click "MyAppName" project -> Properties... , tab "Package/Publish Web" ...

  • Configuration: Active (Debug) - this means the 'Debug' config is active in VS, and you are editing it. The 'Debug' and 'Release' configurations both can be selected and independently edited.
  • Web Deployment Package Settings - check "Create deployment package as zip file". We want the ZIP file so it can be deployed separately later.
  • IIS Web Site/application name - This must match the IIS Web site entry on the target server. I use "MyAppName/" with no app name after the path, because i create that in IIS manually. That is how it looks on the web server config.

I create the IIS web site manually the first time (maybe you can automate, i don't). When using MSDeploy, it will push your app to the matching Web Site name - you don't have to hardcode any destination folder paths or anything.

Save it with your project, and make sure your changes are checked into Git (pushed to origin/master). Those settings will be pulled from version control when the CI server runs the build steps.

Step 2: add a Build Step in the TeamCity config

I edit the Build Steps, and add a second build step, to build the MyAppName.sln directly, using msbuild. You can modify as you like, as you probably already do this some way.

Step 3: fix build error by installing Microsoft Visual Studio 2010 Shell (Integrated) Redistributable Package

Basically, either we need to install VS on the build server, manually copy files, or install the Microsoft Visual Studio 2010 Shell (Integrated) Redistributable Package.

Microsoft.WebApplication.targets was not found, on the build server. What's your solution?

This will get it to build. Still no deployment to a server yet.

Step 5: Install the MS Web Deployment tool

I get the Web Deployment Tool here and install. After reboot, the TeamCity login has a 404 error. Turns out Web Deploy has a service which listens on port 80, but so does TeamCity Tomcat server. For short term, i stop the Web Deploy web service in control panel, and start the TeamCity web service. The purpose of the Web Deployment Agent Service is to accept requests to that server from other servers. We don't need that, because the TeamCity server will act as a client, and deploy out to other web servers.

The Web Deployment Tool also has to be installed on the target web server. I'm not going to go too far into detail here, but you have to configure the service to listen as well, so when you run the deployment command, it accepts it and installs on the server. For the server, i set up a new account named 'webdeploy' with permission to install.

Step 6: Create a MSBuild command to package the Web project

I do separate steps for packaging and deployment. This will allow cases for building a Release package but manually deploying it, if you want.

This is the msbuild package command:

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" 
           MyAppName/MyAppName/MyAppName.csproj 
           /T:Package 
           /P:Configuration=Debug;PackageLocation="C:\Build\MyAppName.Debug.zip"

Let me explain the command parts:

MyAppName.csproj : path to VS project file to build. There are important options in there which get set from the project Properties tabs.

/T:Package : create a ZIP package

/P:Configuration=Debug;PackageLocation=*** : run the Debug configuration. This is the same as Build in Visual Studio with the 'Debug' setting selected. The 'Package Location' is what it created. We will reference the package file later in the deployment command.

Step 7: Create a Web Deploy command to deploy the project ##

"C:\Program Files\IIS\Microsoft Web Deploy V2\msdeploy.exe" -verb:sync 
     -source:package="C:\Build\MyAppName.Debug.zip" 
     -dest:auto,wmsvc=webservername,username=webdeploy,password=******* 
     -allowUntrusted=true

This command is also worth explaining in detail:

-verb:sync : makes the web site sync from the source to the destination

-source:package="C:\Build\MyAppName.Debug.zip" : source is an MSBuild zip file package

-dest:auto,wmsvc=webservername : use the settings in the package file to deploy to the server. The user account is an OS-level account with permission. The hostname is specified, but not the IIS web site name (which is previously specified in the MSBuild project file in the project properties).

After deployment, i checked the IIS web server files, to make sure they had the latest DLLs and web.config file.

Step 8: Call the MSDEPLOY from the TeamCity build steps

Since there are now have 2 good commands (MSBUILD.exe to package, MSDEPLOY.exe to deploy), add them to the build steps. I use the command line runner, and just put in the same command as the prior 2 steps.

run it all

When you run the build with these steps, if they succeed, you have automatic deployment directly from git.

Now every time new code gets merged and pushed to git origin/master branch, it will automatically build and deploy the the development server.

As you can see, this avoids your original problem:

The problem is when I commit to github and the CI server downloads and
builds it. Naturally the virtual directory is not setup on the CI
server so the build / package fails.

The CI server only builds and packages. Then it deploys to the target web server.

↘人皮目录ツ 2025-01-14 22:33:50

看看Appveyor。我们刚刚发布了 v2.0,恕我直言,它是 WebDeploy 的一个非常强大的替代品。整个部署过程可以通过 CI 服务器上的 PowerShell 编写脚本,并且有 PS 挂钩来自定义该过程。

免责声明:我是 Appveyor 开发人员。我并不是想在这里做广告,但很高兴看看这是否适合您。

Take a look at Appveyor. We've just released v2.0 and IMHO it is a really strong alternative to WebDeploy. The entire deployment process could be scripted through PowerShell on CI server and there are PS hooks to customize the process.

Disclaimer: I'm Appveyor developer. I'm not trying to advertise here, but it would be great to see if that works for you.

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