Visual Studio 2005 不断“重新编译” XML模式
我在使用 MS Visual Studio 时遇到以下不便。
我的项目包含一些 C++ 代码和一个架构文件(扩展名为 .xsd
)。 我有一个“自定义构建步骤”用于将文件转换为 C 源代码;生成的文件如下所示:
extern const char xmlSchema[] = {
0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, // <?xml ...
...
}
我注意到,当我在 Visual Studio 外部编辑架构文件,或者从源代码控制系统下载新版本时,Visual Studio 会立即注意到这一点并调用“自定义构建”步骤(我希望它应该执行此操作)仅当我“构建”我的项目时)。
当我的项目碰巧正在运行时,这尤其尴尬(我突然出现一个你想停止调试吗?
对话框),并且可能导致编辑丢失(在实际工作中从未发生过,但有可能) )。
如果我将文件重命名为非标准扩展名(例如 .xsk
),则不会发生这种情况,但我不喜欢这样做,因为我失去了语法突出显示(而且它似乎是错误的)。
我想获得对此的想法和见解:
这个“功能”是否有原因,或者它只是一个随机的怪癖?
是否有更好的解决方法?
也许您正在使用另一个 MS-VS 版本,但这种情况不会发生(我使用的是 MS-VS 2005 标准版)?
I have the following inconvenience while working with MS Visual Studio.
My project contains some C++ code, and a Schema file (with extension .xsd
).
I have a "custom build step" for converting the file to a C source; the generated file looks thus:
extern const char xmlSchema[] = {
0x3c, 0x3f, 0x78, 0x6d, 0x6c, 0x20, // <?xml ...
...
}
I noticed that when i edit the schema file outside Visual Studio, or perhaps download a new version from a source control system, Visual Studio immediately notices that and invokes the Custom Build step (which i would expect it should do only when i "build" my project).
This is particularly awkward when my project happens to be running (i get a Do you want to stop debugging?
dialog out of the blue), and can result in lost edits (never happened during real work but possible).
This doesn't happen if i rename my file to have a non-standard extension (e.g. .xsk
), but i don't like this because i lose syntax highlighting (and it just seems wrong).
I would like to get ideas and insights on this:
Is there a reason for this "feature", or is it just a random quirk?
Any better workaround possible?
Maybe you are using another MS-VS version, and it doesn't happen for you (i am using MS-VS 2005 Standard Edition)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这确实是非常烦人的事情。从您的构建中排除架构。确保在所有构建配置中都执行此操作。
右键单击架构并打开属性对话框。在“通用”下,将“从构建中排除”设置为 true。
That is, indeed, very annoying. Exclude the schema from your build. Make sure you do it in all build configurations.
Right-click on the schema and open the properties dialog. Under "Common", set "Excluded from Build" to true.