Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
748 views
in Technique[技术] by (71.8m points)

visual studio 2010 - How to tell TFS to deploy multiple webapps containing in one solution?

We have a single solution which contains one webapp project and some accompanying projects. Our TFS 2010 is building this solution every night and deploys the webapp to an IIS server. It runs like a breeze.

In the Process tab of the TFS build definition you can specify the "MSBuild Arguments". This is the value which is set in our build definition (all in one line):

/p:DeployOnBuild=True 
/p:DeployTarget=MsDeployPublish 
/p:CreatePackageOnPublish=True 
/p:MSDeployPublishMethod=WMSVC
/p:MSDeployServiceUrl=<service url of IIS> 
/p:DeployIisAppPath="<a website>" 
/p:UserName=<domain><user 
/p:Password=<password> 

This blog post explains the whole setup: http://vishaljoshi.blogspot.com/2010/11/team-build-web-deployment-web-deploy-vs.html.

So far, so good.

Now we have added a second webapp project which we want to be deployed also to the same IIS every night. Unfortunately in this case the setup is not applicable. The TFS deploys only one webapp.

There are others with the same problem out there:

TFS 2010 + MSDeploy when solution has multiple web applications

and

WebDeploy to deploy multiple web sites

Vishal R. Joshi suggests to add some properties to each webapp project. Now the release build will generate the webpackage (zip file) for each webapp project which has the following properties defined:

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DeployOnBuild>True</DeployOnBuild>
    <DeployTarget>Package</DeployTarget>
    <CreatePackageOnPublish>true</CreatePackageOnPublish>
</PropertyGroup>

Ok. But how to bring the TFS to deploy each webapp to the IIS? Any other ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

As Vishal describes in the blog article you linked to yourself, all the MSBuild paramaters can be moved inside the csproj. This then means each project can have its own settings.

I have a single solution with 6 projects, 4 class libraries and 2 web (WCF and MVC app). I followed the directive from Vishal's blog and simply moved all my MSBuild paramaters into each csproj file.. i.e.

  <PropertyGroup>
    <DeployOnBuild>True</DeployOnBuild>
    <DeployTarget>MsDeployPublish</DeployTarget>
    <CreatePackageOnPublish>True</CreatePackageOnPublish>
    <MSDeployPublishMethod>InProc</MSDeployPublishMethod>
    <MSDeployServiceUrl>localhost</MSDeployServiceUrl>
    <DeployIisAppPath>Dev.AuzzyWeb</DeployIisAppPath>
    <UserName>Username</UserName>
    <Password>Password</Password> 
    ...

Make sure you then remove the paramaters from the build definition.

TFS then deploys as expected.. each project into the correct folder specified as the home directory for each IIS site.

Also its worth noting that you can not include the DeployIisAppPath in the PropertyGroup as above but use the project's properties page to specify this for each build configuration. (Right Click on each project > Properties > Package/Publish Web).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...