msbuild to publish different publishing profile


I have a website project that i did in Visual Studio 2013 and would like to use Bamboo to do CI. I created transformation packages for DEV environment, QA and Prod which basically change web.config when i build the website in Visual Studio and publish using lets say QA publishing profile.  The problem is that when I try to use msbuild.exe to build and publish solution, i can't figure out how to specify which publishing profile to use, so it keeps always publishing the default dev web.config.  Has anyone had similar issue and how did you resolve it? 

If not, is there another approach i can take where i can have a diferent web.config be applied depending on environment?  


Thank you

2 answers

I am using a just web.config file and then using the parameters.xml and profiles I am able to dynamically change the configuration for different environments.

For example I have this configuration in my web.config in order to change some of these attributes dynamically

.. some keys... 
<add key="env" value="ENV" />
<add key="email" value=""/>
<add key="url" value=""/>
.. more keys...

And create a parameters.xml in order to dynamically search and replace those values:

<?xml version="1.0" encoding="utf-8" ?>
<parameter name="env" description="description">
<parameterEntry kind="XmlFile"
match="/configuration/appSettings/add[@key='env']/@value" />
<parameter name="email" description="description">
<parameterEntry kind="XmlFile"
match="/configuration/appSettings/add[@key='email']/@value" />
<parameter name="url" description="description">
<parameterEntry kind="XmlFile"
match="/configuration/appSettings/add[@key='url']/@value" />

then when the profiles I can create a customization for each environment:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="">
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<RemoteSitePhysicalPath />
<MSDeployParameterValue Include="env">
<ParameterValue>dev 1</ParameterValue>
<MSDeployParameterValue Include="email">
<ParameterValue> 1</ParameterValue>
<MSDeployParameterValue Include="url">
<ParameterValue> 1</ParameterValue>

Hey Guys, 

This question is old, but just in case someone come here, Visual Studio has the ability to have config transforms. 

To tell MSBuild what publish profile to use, 

/p:PublishProfile=ProfileName /p:PublishProfileRootFolder="C:\Folder Name"

To transform your files....


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Monday in Jira Ops

Jira Ops Early Access Program Update #1: Announcing our next feature and a new integration

Thanks for signing up for Jira Ops! I’m Matt Ryall, leader for the Jira Ops product team at Atlassian. Since this is a brand new product, we’ll be delivering improvements quickly and sharing updates...

428 views 0 8
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you