Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 925
kaptan Avatar asked Aug 17 '12 19:08

kaptan


People also ask

How do I enable transformation in web config?

Release. config transformation files that are created by default for the two default build configurations. You can create transformation files for custom build configurations by right-clicking the Web. config file and choosing Add Config Transforms from the context menu.

How to create Web Config transformation file?

If you have a web application project, Right-click on web. config and choose Add Config Transform. This will add any config transforms that are missing from your project based on build configurations (i.e. if you have Production and Staging build configs, both will get a transform added).

Why is add config transform greyed out?

You need to create a configuration in a given project before it can use that transform. Either check "Create new project configurations" to create the configuration in all projects at once, or do it individually like @paulv7260 did.


1 Answers

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.

like image 178
Andreas Presthammer Avatar answered Oct 21 '22 11:10

Andreas Presthammer