强制视觉工作室始终“重建所有”调试时
编辑:基本上我需要的是 Visual Studio 在我进行调试时始终重建所有内容。
我目前正在使用 Visual Studio 来编译我的汇编程序,使用 MASM,总的来说它工作正常。
然而,我遇到了一个恼人的问题:
如果我包含一个像这样的文件(例如,带有函数的文件)
Include functions.inc
并编译它,它最初可以正常工作。但是,如果我随后更改functions.inc 的内容,则无法识别该内容,编译器会跳过functions.inc 并使用更改之前的旧版本。
我在项目属性下的任何位置都找不到解决此问题的选项。但是我确信它与链接器选项或其他东西有关 - 如果我在项目属性下进行任何更改(即使我更改了某些内容并将其改回来,然后按“确定”),它确实可以使用新版本的函数公司
有什么想法吗?
Edit: Basically what I need is for visual studio to always rebuild all when I hit debug.
I'm currently using visual studio to compile my assembly programs, using MASM and in general it's working fine.
However I've run into an annoying issue:
If I include a file (say, a file with functions) like this
Include functions.inc
and compile it, it originally works fine. However if I then change the contents of functions.inc, this is not recognized and the compilers skips over functions.inc and uses the old version from before I changed it.
I cannot find an option anywhere under project properties to fix this. However I'm sure it has something to do with linker options or something - if I make any changes under project properties (even if I change something and change it back, and then press OK), it does compile properly with the new version of functions.inc.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以通过 Visual Studio 的宏资源管理器中的
EnvironmentEvents
宏更改行为:它将适用于所有解决方案
这是 VisualStudio 的更改,因此一旦设置更新,
上述解决方案有效,但它在内容文件方面存在一些缺陷,即使调试器正在运行,IDE 也会更改为设计模式。在某些情况下,它会在调试器运行时尝试构建。正确的解决方案是这样的:
You can change the behaviour via the
EnvironmentEvents
macro in Visual Studio's Macro Explorer:This is a VisualStudio change so it will work across all solutions once set
UPDATE
The above solution works, however it has some pitfalls concerning content files where the IDE will change to design mode even if the debugger is running. It will try to build while the debugger is running in some situations. The proper solution is this:
确保您已在配置管理器中选择了用于构建的启动项目:
构建 ->配置管理器->检查所有相关项目的“构建”列。
Make sure, you have selected the startup project for build in the Configuration Manager:
Build -> Configuration Manager -> check the 'Build' column for all relevant projects.
VS 中对 ASM 代码的支持并不像 .NET/C++ 那样自动神奇,您必须对其提供一些帮助。我们使用 MAKE 文件在 VS 中编译 ASM 代码。 MAKE 文件定义了所有依赖项,以便下次编译 ASM 文件时编译 INC 文件中的更改。
可以使用 MSBuild 创建类似的构建脚本,但我们从未花时间这样做。
Support for ASM code in VS isn't quite as auto-magical as .NET/C++ and you have to help it a bit. We use a MAKE file to compile our ASM code in VS. The MAKE file defines all the dependencies so that changes in the INC files are compiled the next time the ASM file is compiled.
A similar build script could be created with MSBuild but we've never taken the time to do that.
一种可能是创建一个宏,只需重建所有内容,然后启动调试器。然后将宏映射到某个键。我认为_DTE.ExecuteCommand< /a> 可以用于此目的。如果您想对调试器进行更多控制,Debugger2 界面暴露了相当多的功能。
One possibility might be to create a macro that simply does a rebuild all and then fires off the debugger. Then map the macro to a key. I think the _DTE.ExecuteCommand could be used for this. And if you wanted even more control over the debugger, the Debugger2 interface has quite a bit of functionality exposed.
如果是 VS IDE 无法找出依赖关系(因为它无法解析 .asm 文件并在其中找到 INCLUDE 指令),那么一种与 MASM 配合良好的强力解决方案是重建项目甚至解决方案:
MASM 非常非常快:我有一些非常大的 MASM 项目,几十个 .asm 模块,甚至更多包括:最大的此类项目在(非常)几秒钟内重建。
警告:克鲁奇摆好姿势。
定义一个对所有 .asm 文件进行触摸的预构建将自动强制重建...
属性(左列,解决方案
资源管理器),
构建事件/预构建事件
*.asm”(确保路径中有一个 touch 实用程序)
现在,每次构建时,所有 *.asm 文件都将被触及(即显示为已修改),从而重新编译。并且您不必再记住您有重建所有,因为无论如何都会发生这种情况,不是吗?此外,IDE 会告诉您您的文件在编辑器之外进行了修改,您可以说是!
If it's a matter of the VS IDE not being able to figure out the dependencies (because it's not able to parse the .asm file and locate the INCLUDE directives there), one brute force solution that works very well with MASM is to rebuild the project or even solution:
MASM is very, very fast: I have some very large MASM projects, several tens of .asm modules and even more includes: The largest such project rebuilds in a matter of a (very) few seconds.
Warning: Kludge squared ahead.
Defining a prebuild that does a touch to all you .asm files would automatically force a rebuild...
properties (left column, solution
explorer),
Build Events / Pre-build Event
*.asm" (insure you have a touch utility in the path)
Now every time you build, all *.asm files will be touched (ie appear modified) and thus recompiled. And you won't have to remember anymore that you have to rebuild all, as this will happen anyway. I warned it was a kludge, didn't I? Additionally, the IDE will tell you your files were modified outside the editor and do you want to reload them. You can say yes!