Visual Studio 2012 Web Deploy Publish ignores selected Configuration for transform and build

kaptan picture kaptan · Aug 17, 2012 · Viewed 10.3k times · Source

When I create a publish profile I have the option to select which Configuration I want the publish to use for this profile. The options are like Debug, Release or any custom defined one like Staging. The problem is that if I select any Configuration other than Release or Debug, say Staging, visual studio totally ignores my selection and uses Web.Release.config for transform and build. Am I doing something wrong or is this by design? It seems that Publish only recognizes Release and Debug as acceptable Configuration. Any thoughts on this issue?

I am using Visual Studio 2012 RTM.

Update 1 :: "NightlyLive - Any CPU" configuration selected:

Here I select my own custom Configuration "NightlyLive":

enter image description here

And here is what happens when I publish:

6>------ Build started: Project: UI.Next, Configuration: Release Any CPU ------
7>------ Publish started: Project: UI.Next, Configuration: Release Any CPU ------
7>Transformed Web.config using [...]\UI.Next\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.

As you can see it builds the project using Release Any CPU (instead of NightlyLive - Any CPU) and also it transforms the Web.config using Web.Release.config (instead of Web.NightlyLive.config).

Update 2 :: Profile name renamed to "NightlyLive":

Here i rename the profile name from "test" to "NightlyLive".

enter image description here

Here is the console output:

6>------ Build started: Project: UI.Next, Configuration: Release Any CPU ------
7>------ Publish started: Project: UI.Next, Configuration: Release Any CPU ------
7>Transformed Web.config using [...]\UI.Next\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
7>[...]\UI.Next\Web.NightlyLive.config(23,18): Warning : Argument 'debug' did not match any attributes
7>[...]\UI.Next\obj\Release\TransformWebConfig\transformed\Web.config(78,6): Warning : No attributes found to remove
7>Transformed obj\Release\TransformWebConfig\transformed\Web.config using [...]\UI.Next\\Web.NightlyLive.config into obj\Release\ProfileTransformWebConfig\transformed\Web.config.

So here, still it is building using Release Any CPU.

But for Web.config it first transforms using Web.Release.config then it does a second transformation on top of the previous one using Web.NightlyLive.config.

The double transformation i think is by design and makes sense. But the fact that you have to rename your profile name to the configuration name to force use your custom transformation file, does not look right.

Update 3 :: TestSolution added

You can download the stripped down solution from here.

First I created a brand new vs2012 solution and everything worked fine. So I decided to strip down my current solution and upload as test case.

Please note that my solution was originally a vs2010 solution that i opened in vs2012 and vs2012 did the necessary modifications to the solution.

Update 4 :: Verdict

I guess my solution configurations were all messed up. So basically to solve this issue, I deleted all my customized solution and project configurations and created them again along with the web.config transform files.

Problem solved.

Answer

Andreas Presthammer picture Andreas Presthammer · May 23, 2013

I experienced exactly the same behavior.

The issue for me was that the custom solution configuration didn't properly reference the custom configuration in the web project I was trying to deploy.

Try the following:

  1. Right click the Solution and enter properties
  2. Select your custom configuration from the top left dropdown
  3. Expand Configuration Properties and select Configuration
  4. Make sure that you web project has the correct custom configuration selected in the table.

After doing this the web deploy with custom configuration worked properly.