如何在Tfs Build中参数化DeployIisAppPath Msbuild参数 [英] How to parametrize DeployIisAppPath Msbuild argument in Tfs Build
问题描述
我正在使用Tfs 2012来构建/部署我们的Asp.Net Web应用程序.我们有一个构建定义,可构建5个解决方案(.sln文件).这就是我们的MsBuild参数的样子:
I am using Tfs 2012 to build/deploy our Asp.Net web apps. We have a build definition that builds 5 solutions (.sln files). This is how our MsBuild arguments look like:
/p:DeployOnBuild=True /p:AllowUntrustedCertificate=True /p:DeployIisAppPath="Test" /p:DeployTarget=MsDeployPublish /p:CreatePackageOnPublish=True /p:MSDeployPublishMethod=WMSVC /p:MSDeployServiceUrl="https://{server}:8172/msdeploy.axd" /p:UserName="{user}" /p:Password="{password}"
我需要使用此构建定义通过Web Deploy部署所有5个站点.它们共享除DeployIisAppPath之外的所有参数.它适用于1个解决方案,但是对于1个以上的解决方案,我需要为每个解决方案输入一个不同的DeployIisAppPath,以便每个解决方案都可以部署到IIS中的正确站点.
I need to deploy all 5 sites with Web Deploy using this build definition. They share all the parameters except for the DeployIisAppPath of course. It works for 1 solution, but for more than 1, I need to input a different DeployIisAppPath for each solution, so that each one deploys to the correct site in IIS.
我已经检查了这些问题和其他文档,但是还没有运气:
I've checked these questions and other documentation but with no luck yet:
我也尝试将每个sln的参数作为属性传递给{siteName} .Web.csproj.
I've tried passing the arguments as properties to the {siteName}.Web.csproj for each sln as properties too.
任何帮助将不胜感激.
推荐答案
执行此操作的一种可能方法是提出自己的一组参数.让我们说,我们将它们称为DeployIisAppPath_One
,DeployIisAppPath_Two
等.只要它们是唯一的,无论哪种名称都对您有用.
One of the possible ways to do this is to come up with your own set of parameters. Let us say, we call them DeployIisAppPath_One
, DeployIisAppPath_Two
, etc. Whatever names work for you, as long as they are unique.
然后,在每个需要部署的项目文件中进行少量编辑.在最前面的<PropertyGroup>
部分中,添加以下行.例如.在第一个项目中,添加
Then, make a small edit in every project file that needs to be deployed. In the very first <PropertyGroup>
section, add following line. E.g. in first project, add
<DeployIisAppPath Condition="'$(DeployIisAppPath_One)' != ''">$(DeployIisAppPath_One)</DeployIisAppPath>
在第二个项目中,同样地:
In second project, simalarly:
<DeployIisAppPath Condition="'$(DeployIisAppPath_Two)' != ''">$(DeployIisAppPath_Two)</DeployIisAppPath>
为要部署的所有项目重复.现在,您的新命令行将如下所示:
Repeat for all project that you want to deploy. Now, your new command line would look like this:
msbuild ... /p:DeployIisAppPath_One="MySite/one" /p:DeployIisAppPath_Two="MySite/two" ...
这篇关于如何在Tfs Build中参数化DeployIisAppPath Msbuild参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!