Search code examples
msbuildmsdeploy

How to specify MSDeploy parameters from MSbuild


I have a web application that I am trying to deploy and have the web.config file parametrised. I can build the package by running

msbuild myproj.csproj /T:package

now when it produces the package, i get a file in the directory.

Archive.SetParameters.Xml

This file has Parameters in it that if I change they would end up in the deployed package. My Question is, how can i define more parameters so that when I build the project it has my extra parameters in the file.

I belive i could do it using MSDeploy -declareParam But how would I do this from MSBuild? or the .csproj file.

My end goal is to have a parametrised Web.config file for deployment into multiple environments.


Solution

  • Ok so turns out this is fairly easy, after some significant googling eventually found this post

    http://vishaljoshi.blogspot.com/2010/07/web-deploy-parameterization-in-action.html

    VS 2010 makes your life easier by allowing you to simply drop the Parameters file in the root of your web project and if a file with the name Parameters.xml is found in the root of your project it passes it to Web Deploy which then parameterizes your web…