How to deploy project with msdeploy instead of msbuild
Asked Answered
P

1

9

Today I use msbuild to deploy a web application to an iis server. How can I do the same with msdeploy (command line)?

MSBuild.exe myproject.csproj
/P:VisualStudioVersion=11.0
/P:Password=pass
/P:AllowUntrustedCertificate=true
/P:DeployOnBuild=True
/P:PublishProfile=deploytest
/P:DeployIISAppPath="Default Web site"
/P:MsDeployServiceUrl=my.server.com
/P:Configuration=Release
Phenyl answered 24/10, 2013 at 13:6 Comment(0)
U
16

It depends what you would like your workflow to be, if you want to package the output and deploy that seperately then you'll need to create a zip file from your build.

Create Package

Add the following to your msbuild command line to create a package:

/p:DeployTarget=Package
/p:PackageLocation=MyProject.zip
/p:CreatePackageOnPublish=True

Deploy Package

msdeploy.exe 
    -verb:sync 
    -source:Package=MyProject.Zip 
    -destination:auto:ComputerName="my.server.com"

You might also want to promote from one deployed site to another.

Clone Site

msdeploy.exe
    -verb:sync
    -source:appHostConfig="my.server.com"
    -dest:appHostConfig="mynew.server.com"

Or you may already have a site that you want to target.

Clone Application

msdeploy.exe
    -verb:sync
    -source:iisApp="my.server.com/MyApp"
    -dest:iisApp="my.server.com/MyNewApp"
Unflinching answered 24/10, 2013 at 15:6 Comment(3)
Is there a way to use web deploy only?Phenyl
You can't build using msdeploy, but you can build and deploy using msbuild or you can build with msbuild and deploy with msdeploy. I'm not sure of your use case here?Unflinching
Ok. I think I get it now. I regarded msbuild to be the "old way to do it" and msdeploy the cleaner way. But when you put it that way it makes sense. Thanx!Phenyl

© 2022 - 2024 — McMap. All rights reserved.