I\'m trying to use the new publish profile support (available in VS2012 and in VS2010 via an update) to create a continuous delivery \"deployment pipeline\", whereby a packa
UPDATE 2014-01-28
Keeping my custom script up to date with the changing versions of VS / Azure SDK ended up being too much hard work, so I've actually reverted to using the generated deploy.cmd script, with one minor difference:
I've started leaving all my parameter values out of the ProfileName.pubxml file and instead putting them in a ProfileName.paramters.xml (example generated in .SetParameters.xml with package, docs here). These will automatically be picked up by Visual Studio / MSBuild by convention and I can use them at runtime by passing in -setParamFile:path\to\ProfileName.parameters.xml when calling deploy.cmd
UPDATE - A newer version of this script is now being maintained (and documented) on GitHub - https://github.com/richardszalay/msdeploy-package-publish
After much digging, I found that several issues in Microsoft.Web.Publishing.targets (v10.5) that prevents this from working. To workaround these issues, I've created the following MSBuild script that can be placed in the same directory as the Web Application's csproj. I've added comments related to fixes and implementation details.
The script uses Microsoft.Web.Publishing.targets, so most of the standard properties should still work. Here are some ways you can use it:
# Convention based
msbuild PackageDeploy.build /p:PublishProfile=Stage;WebPublishPipelineProjectName=Name_of_your_web_application
# Absolute paths to profile + package
msbuild PackageDeploy.build /p:PublishProfile=Path\To\Profile.pubxml;PackageFileName=Path\To\Package.zip;WebPublishPipelineProjectName==Name_of_your_web_application
If you're using VS2012, make sure you declare VisualStudioVersion=v11.0 to import the correct publishing file.
Using this script, you shouldn't need to recheck out your web application in subsequent stages in your deployment pipeline. You'll just need to keep the following artifacts after the build/package stage:
Here's the source for PackageDeploy.build:
v10.5
$(MSBuildProjectDirectory)
$(WebPublishPipelineProjectDirectory)\My Project\PublishProfiles
$(WebPublishPipelineProjectDirectory)\Properties\PublishProfiles
<_PublishMsDeployServiceUrl>$(MsDeployServiceUrl)
<_PublishMsDeployServiceUrl Condition="('$(MSDeployPublishMethod)'=='INPROC')">
@(_MSDeployPackageFile->'%(FullPath)')
$(DeployEncryptKey)
$(_MSDeploySourceWebServerAppHostConfigDirectory)
$(_MSDeploySourceWebServerManifest)
$(_MSDeploySourceWebServerDirectory)
$(_PublishMsDeployServiceUrl)
$(UserName)
$(Password)
$(DeployEncryptKey)
False
$(AuthType)
$(_MSDeployDestinationWebServerAppHostConfigDirectory)
$(_MSDeployDestinationWebServerManifest)
$(_MSDeployDestinationWebServerDirectory)
<_VsPublishParametersFile>
<_VsPublishParametersFile Condition="$(UseDeclareParametersXMLInMsDeploy) and '$(_VsPublishParametersFile)'==''">$(PublishParametersFile)
<_VsPublish_MsDeployDeclareParameters Remove="@(_VsPublish_MsDeployDeclareParameters)" />
<_VsPublish_MsDeployDeclareParameters Include="@(MsDeployDeclareParameters)" />
<_VsPublish_MsDeployDeclareParameters Include="$(DeployParameterIISAppName)" Condition="'$(DeployIisAppPath)' != ''">
$(DeployIisAppPath)