为什么Visual Studio 2008会在启用调试时询问是否启用调试?

时间:2021-11-21 02:52:10

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:

我有一个生成(通过MSBuild)Web.config,它在Build目标之前运行,其内容包括 。生成的Web.config将复制到根目录并放入“内容”项目组。但是当我在Visual Studio 2008中运行Debug构建时(通过F5),我得到以下对话框:

为什么Visual Studio 2008会在启用调试时询问是否启用调试?

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?

如果我选择“添加...”并单击“确定”,则会显示将生成的Web.config添加到项目中,它将作为项目文件显示在IDE中。所以问题应该是:为什么Web.config文件需要成为项目的一部分?

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?

由于源代码控制,我真的想避免在项目中包含生成的配置文件。如果运行应用程序时Web.config文件存在,我不明白为什么要关注Visual Studio。那么有没有一种方法可以让Visual Studio接受生成的Web.config而不通过IDE添加它?

1 个解决方案

#1


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.

事实证明Visual Studio需要Web.config来部分项目,没有ifs,ands或buts。无论如何,这篇MSDN文章似乎暗示了这一点。

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.

为了解决这个问题,我必须在根目录中创建一个Web.config,有效地删除 元素中的所有内容,将其留空并将其添加到项目中。然后在我的一个自定义构建目标中,备份空的Web.config并将生成的Web.config复制到根目录。除此之外,我的自定义清理目标还原备份的Web.config。通过上面的步骤,源代码控制和Visual Studio对我的轻微手掌一无所知。

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

这种解决方法让我感到畏缩,所以如果有人有真正的解决方案,我会很乐意改变我选择的答案。

#1


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.

事实证明Visual Studio需要Web.config来部分项目,没有ifs,ands或buts。无论如何,这篇MSDN文章似乎暗示了这一点。

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.

为了解决这个问题,我必须在根目录中创建一个Web.config,有效地删除 元素中的所有内容,将其留空并将其添加到项目中。然后在我的一个自定义构建目标中,备份空的Web.config并将生成的Web.config复制到根目录。除此之外,我的自定义清理目标还原备份的Web.config。通过上面的步骤,源代码控制和Visual Studio对我的轻微手掌一无所知。

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

这种解决方法让我感到畏缩,所以如果有人有真正的解决方案,我会很乐意改变我选择的答案。