Jonathon Watney
Jonathon Watney

Reputation: 22128

Why does Visual Studio 2008 ask about enabling debugging when debugging is already enabled?

I have a generated (via MSBuild) Web.config that runs prior to the Build target whose content includes, among other things, <compilation debug="true">. The generated Web.config is copied to the root and put in the Content item group. But when I run the Debug build in Visual Studio 2008 (via F5) I get the following dialog:

Debugging Not Enabled

If I select "Add ..." and click OK it appears to add the generated Web.config to the project and it shows up in the IDE as a project file. So maybe the question should be: Why does the Web.config file need to be a part of the project?

I'd really like to avoid including generated config files in the project because of source control. If the Web.config file is there when the application runs I don't see why Visual Studio should be concerned. So is there a way for Visual Studio to accept a generated Web.config without it being added through the IDE?

Upvotes: 1

Views: 443

Answers (1)

Jonathon Watney
Jonathon Watney

Reputation: 22128

Turns out Visual Studio requires the Web.config to part of the project, no ifs, ands or buts. This MSDN article seems to imply it anyway.

To get around this I had to create a Web.config in the root, remove everything in the <configuration> element effectively leaving it empty and add it to the project. Then in one of my custom build targets, backup the empty Web.config and copy the generated Web.config to the root. In addition to that, my custom clean target restores the backed-up Web.config. With the above steps source control and Visual Studio are oblivious to my slight of hand.

This workaround makes me cringe so if anyone has a real solution I'll gladly change my selected answer.

Upvotes: 1

Related Questions