WebDeploy with MSBuild Not Deploying from TeamCity

≯℡__Kan透↙ 提交于 2019-12-03 06:15:21

We do our WebDeploys with a TeamCity MSBuild step configured as follows:

Build File Path:  Server.csproj

Command Line Parameters:
/p:Configuration=%configuration%
/p:DeployOnBuild=True 
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=https://%web.deploy.server%:8172/MsDeploy.axd
/p:DeployIisAppPath=%web.deploy.site% 
/p:AllowUntrustedCertificate=True
/p:Username=
/p:AuthType=NTLM

We use integrated authentication; change as necessary to fit your scheme. The value of this, I think, is that it builds everything from scratch and doesn't rely on a pre-built package. From the gist you posted I noticed that you do some DB publishing, we don't use WebDeploy for that so I can't offer any guidance there. Hope this helps.

I use MSBuild.exe to package to zip, and MSdeploy.exe to deploy in separate steps.

To deploy the package.zip file on the command line:

"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).

You can modify parameters based on your configuration. I like it this way because with separate steps, its easier to debug problems.

Use TeamCity build step and the command line runner.

Update: If you want an example of how to build the ZIP package using MSBuild, try something like this:

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

This should work the same on your local PC as well as on the CI server.

Here are the config settings that finally worked for me:

/p:Configuration=CONFIG-NAME
/p:DeployOnBuild=True
/p:DeployTarget=MSDeployPublish
/p:MsDeployServiceUrl=http://SITE-URL/MsDeployAgentService
/p:username="USERNAME"
/p:password=PASSWORD
/p:AllowUntrustedCertificate=True 
/P:CreatePackageOnPublish=True 
/p:DeployIisAppPath=SITE-URL
/p:MSDeployPublishMethod=RemoteAgent
/p:IgnoreDeployManagedRuntimeVersion=True
Matt Woodward

I had exactly the same issue! I've posted the solution I used over at: MsBuild not finding publish profile

Basics were:

  • Install the Azure SDK 1.8 on the build server
  • Force the /P:PublishProfileRootFolder value to ensure MSBuild can locate the publish profile

Ensure that you have the Microsoft Web Developer Tools feature installed for Visual Studio. This was missing on my build agent but once I added it the TeamCity build worked just fine.

This can happen when the build target paths are missing from your MSBuild directory. Instead of trying to get those to line up on every developer machine, install the targets from the Nuget. That way it will always be the same for everyone, regardless of how their machine is setup.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!