2

The question is a follow up to this one: Generate Web.Debug config which could be debugged](Generate Web.Debug.config which could be debugged)

I have defined a transformation for web.debug.config. During compilation I see the following:

Transformed Web.config using C:\data\Main\WebRole\Web.Debug.config into
C:\data\Main\obj\obj\x64\Debug\WebRole.csproj\TransformWebConfig\ [...]
   transformed\Web.config.

Checked Web.config in the specified location - it is correct (transformation succeeded)

But when I start the service in the azure emulator I get an alert that Debugging not enabled alert

Why does it happen? Looks that incorrect web.config is taken. Where should I specify the location of correct (transformed) file?

Community
  • 1
  • 1
YAKOVM
  • 9,805
  • 31
  • 116
  • 217

2 Answers2

1

The key thing to realise with web.config Transforms (and is mentioned in the answer to your linked question) is that they are only part of the story.

When you build your sources, the transformed web.config file is built into the /obj/ folder, ready for deployment.

It is only the act of deploying your solution somewhere that puts the transformed config file into use - as noted in the docs:

When you deploy the Web application by using the selected build configuration and by using either a deployment package or one-click publish, the Web.config file is transformed according to your specifications.

How are you running the application after you build it? You need to publish or deploy it using one of the built in mechanisms that support web transforms to see those changes on your site.

If you are running the emulator against the original source files, they won't see the transformed web.config file - which is why typically the debug build doesn't have any transforms and you then turn off debugging with your Release build which is then deployed to production.

As you're trying to test this in the emulator you should be able to do the following:

  1. In the Solution Explorer, ensure you've selected a file within the project that runs in the emulator.
  2. From the Build menu, select "Publish [Project Name".
  3. In the Publish Wizard, create a new "Profile" using the "Custom" publish target.
  4. In the "Connection" pane select "File System" as the publish method, and give it a suitable target location.
  5. In the "Settings" pane choose the appropriate configuration (in your case probably "Debug"), and set any other options that you'd like.

Then press "Publish", and the project should be built, and then deployed to the new file location.

You should then be able to start the emulator from this newly published location, which will be using your transformed web.config.

Zhaph - Ben Duguid
  • 26,785
  • 5
  • 80
  • 117
  • I am running it in azure emulator. – YAKOVM Dec 15 '14 at 12:51
  • Can I change to run the emulator with transferred file? – YAKOVM Dec 15 '14 at 12:53
  • You'd need to produce and run a deployment package for the emulator to see the transformed file - or alternatively (and as suggested) reverse the transform so that your emulator/debug build is always `debug="true"` and the release build does the (default) transform to remove that - how are you deploying the solution to Azure - by hand or through a build agent? – Zhaph - Ben Duguid Dec 15 '14 at 12:55
  • I can`t make it debug=true. Will need to remain with debug=false. – YAKOVM Dec 15 '14 at 13:22
  • run a deployment package for the emulator - how? – YAKOVM Dec 15 '14 at 13:22
  • 1
    Though my solution solves my problem I will give you the award for your effort – YAKOVM Dec 21 '14 at 21:22