Question

I have a project that I need to deploy with a couple of different configurations (specifically, deploying the same package to 2 different IIS applications). I have set up 2 Publish Profiles, and each creates a package when invoked individually. I'd like to create both packages with a single command.

I've tried commands like this, but they tend to simply ignore the second profile:

msbuild MyWebProject.csproj /p:DeployOnBuild=True "/p:PublishProfile=FirstProfile;PublishProfile=SecondProfile"

Is there a way that I can use a single command to deploy both profiles?

Was it helpful?

Solution

I know this isn't strictly what you are asking for, but have you considered building once and deploying twice?

To achieve this through msbuild, you could create an msbuild project which calls msdeploy.

Build (Create Package)

msbuild MyWebProject.csproj
    /p:DeployTarget=Package
    /p:PackageLocation=MyWebProject.zip
    /p:CreatePackageOnPublish=True

Deploy Package Twice

msdeploy.exe 
    -verb:sync 
    -source:Package=MyWebProject.Zip 
    -destination:auto:ComputerName="my.server1.com"
    -declareParamFile:Params1.xml

msdeploy.exe 
    -verb:sync 
    -source:Package=MyWebProject.Zip 
    -destination:auto:ComputerName="my.server2.com"
    -declareParamFile:Params2.xml
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top