How to execute a PowerShell script only before a web deploy Publish task in VS 2012?

It depends on how you define before but below is one technique. When you create a publish profile with VS2012 it will create you a .pubxml file in the Properties\PublishProfiles folder (My Project\PublishProfiles for VB). These are MSBuild files and you can edit them to customize the publish process. In your case you can inject … Read more

How do I get msdeploy to create App_Data if it doesn’t exist, but not delete any contents of the remote directory?

Getting App_Data deployed when starting from scratch @tdykstra got this part right. To get App_Data out there (and ACLs set automatically), I did the following: Adding a placeholder file in App_Data Set the build action to content on the placeholder (my placeholder file has text in it to let people stumbling across it know why … Read more

_CopyWebApplication with web.config transformations

I’ve been hitting my head against the wall for this. After hiking through the MSBuild targets I’ve come across something very “opaque”. Long story short: Try using the new _WPPCopyWebApplication. It works on my machine. The old _CopyWebApplication does not support transformations for legacy reasons. This is what I do: msbuild /t:Rebuild /p:OutDir=..\publish\;Configuration=Release;UseWPP_CopyWebApplication=True;PipelineDependsOnBuild=False MvcApplication1\MvcApplication1.csproj # … Read more

How to get Visual Studio ‘Publish’ functionality to include files from post build event?

I answered a similar but different question at How do you include additional files using VS2010 web deployment packages?. In your scenario you are using post build event, I would recommend dropping the post build event and implement your actions using your own MSBuild targets instead of post build event. Below you’ll find the text … Read more

How to use command line msbuild to deploy VS2012 Web Site project without precompiling it?

For website project the publish process is not plumbed into the build process. For website project since there is no formal build process there was nothing for us to really extend. Note: the below contents requires to have VS 2012 (or VS2010 for that matter) and the Azure SDK on top of that. The features … Read more

Make MSDeploy (Visual Studio) not delete App_Data folder but delete everything else

It can be done when you invoke msdeploy manually – just add the following parameter: -skip:Directory=\\App_Data See Web Deploy Operation Settings. The path is a regular expression, so it is quite flexible. If you deploy using the VS-generated ProjectName.deploy.cmd script, you can also pass this parameter in the _MsDeployAdditionalFlags environment variable (when running that script). … Read more

How do I configure MSBuild to use a saved publishProfile for WebDeploy?

I’m sorry to tell you that the publish.xml file which VS2010 uses was not designed to be used in this way. In fact it was not even designed to be checked-in/shared with others. The logic for reading/writing those files are strictly contained inside Visual Studio and not available through MSBuild. So there is no straight … Read more

Valid Parameters for MSDeploy via MSBuild

Here’s a list I’ve compiled for my own reference, along with some of the legal values that can be used. Note that these are passed into MSBuild using the /p:<PropertyName>=<Value> syntax. DeployOnBuild True False DeployTarget MsDeployPublish Package Configuration Name of a valid solution configuration CreatePackageOnPublish True False DeployIisAppPath <Web Site Name>/<Folder> MsDeployServiceUrl Location of MSDeploy … Read more

How do you call msdeploy from powershell when the parameters have spaces?

Using the technique from Keith’s answer to How to run exe in powershell with parameters with spaces and quotes question you linked to, running echoargs -verb:dump -source:appHostConfig=$sitename -verbose gave me this output: Arg 0 is <-verb:dump> Arg 1 is <-source:appHostConfig=default> Arg 2 is <web> Arg 3 is <site> Arg 4 is <-verbose> This would explain … Read more