TFS build definition not deploying mvc application

2019-02-19 14:18发布

问题:

I am attempting to use Visual Studio's Team Explorer and TFS to create a Build Definition to deploy a MVC site to IIS.

I followed the Pluralsight tutorial called 'Continuous Deployment with Team Foundation Server 2010'.

The steps I followed from the tutorial included:

  • Installed IIS Management Scripts and Tools
  • Installed Management Service
  • On the Management Service I allowed remote connections and enable Windows Credentials Only
  • Installed Web Deploy
  • Created a deployment domain account
  • Allowed domain account permissions to modify IIS file system
  • Set delegation rules using this domain account
  • Set IIS Permissions using domain account

The MSBuild arguements I set in the build definition were:

/p:DeployOnBuild=true 
/p:DeployTarget=MSDeployPublish 
/p:CreatePackageOnPublish=False 
/p:MSDeployPublishMethod=WMSVC 
/p:SkipExtraFilesOnServer=True 
/p:AllowUntrustedCertificate=True 
/p:MSDeployServiceUrl="https://<iis server name>:8172/msdeploy.axd"
/p:Username="<domain>\<user>" 
/p:Password="<password>" 
/p:DeployIISAppPath="Default Web Site/<site name>"

I queued a build and it passes, is written to the drop folder but NOT to IIS.

I published the MVC application from the Solution Explorer using the same property values and it was successfully deployed to IIS.

Does anyone know what I am missing?

回答1:

I solved the problem by examining the contents on my local machine and the comparing it with the build server.

I found that the 'Web' and 'WebApplication' folders on my local machine at 'C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0' were not present in the same location on the build server.

Once I copied and pasted them across my build worked and the mvc site was deployed to IIS as expected.



回答2:

Here are my settings that worked for me. Try to change the CreatePackageOnPublish=True and see if it works or not.

/p:DeployOnBuild=True
/p:DeployTarget=MsDeployPublish
/p:CreatePackageOnPublish=True
/p:MSDeployPublishMethod=WMSVC
/p:MSDeployServiceUrl=https://ServerName:8172/MSDeploy.axd /p:DeployIisAppPath="NameofWebsiteOnIISServer"
/p:AllowUntrustedCertificate=True
/p:UserName="domain\serviceaccount"
/p:Password="AwesomeSecurePassword"

First I would recommend is to check whether you are able to publish through visual studio directly via webdeploy or not. The best way to figure out the right settings of web deploy inside visual studio is listed below. I recommend this approach because it will give you error messages v/s "queue a new build everytime" to see if site was published or not.

  1. Right click the website inside IIS7 --> WebDeploy -->Click Configure Web Deploy Publishing
  2. Click on Setup and then take the publish settings file that was generated and import those publish settings when you right click on website and click publish website inside visual studio.
  3. Try to publish using visual studio one click publish first because it is easier to find errors with Web Deploy Publishing inside Visual Studio.

If you get errors then this site (http://www.iis.net/learn/publish/troubleshooting-web-deploy/web-deploy-error-codes) has all the error messages related to it.

Make sure if the service account you specified is listed in "IIS Manager Permissions" section under Management.

Also check if "Web Management Service" and "Web Deployment Agent Service" services are running.



标签: tfsbuild