在 Visual Studio 中查找错误/警告

发布于 2024-07-04 08:16:01 字数 167 浏览 9 评论 0原文

我在使用 Visual Studio 2005 时遇到了一个烦人的问题...有时当我重建时,即使我执行重建解决方案,它也会返回,没有错误或警告,但当我稍后编辑另一个代码文件时,即使没有更改并重建,它会在另一个文件中发现错误或警告。 显然,早期的重建解决方案没有重新编译该文件! 如何强制 VS 完全重新编译每个文件?

I have experienced an annoying issue with Visual Studio 2005... sometimes when I rebuild, and even if I do a Rebuild Solution, it will come back with no errors or warnings, but then when I later edit another code file, even without changing it, and rebuild, it will find an error or warning in that other file. Clearly, the earlier Rebuild Solution did not recompile that file! How can I force VS to completely recompile every file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

你与清晨阳光 2024-07-11 08:16:01

这听起来很奇怪 - 无论发生什么变化,重建都应该构建所有内容,而构建应该只构建已更改的内容。

仅当您修改了未更改文件引用的某些内容,使其现在不正确时,才会发生您所描述的行为。

This sounds strange - Rebuild should build everything regardless of changes and Build should only build things that have changed.

The behaviour you've described should only happen if you have modified something that is referenced by the unchanged file so that it is now incorrect.

浪荡不羁 2024-07-11 08:16:01

这与配置管理器有关吗? 您可以在其中选择解决方案构建中的项目。 不确定这是否有帮助。

Is this related to the Configuration Manager? There you can select which projects in your solution build. Not sure if this helps.

无边思念无边月 2024-07-11 08:16:01

我和 Guy Starbuck 在一起,但要补充一点,重建解决方案应该先执行一个干净的解决方案,然后执行构建解决方案,然后,它应该已经解决了您的问题。 但 VS 2005 在这方面可能很糟糕。 有时它在几次重建后才开始工作。 如果无法升级到 2008,请考虑手动清除 bin 文件夹。

I'm with Guy Starbuck here, but would add that Rebuild Solution is supposed to do a Clean Solution followed by Build Solution, which should, then, have solved your issue to begin with. But VS 2005 can be terrible in this regard. Sometimes it just starts working after several rebuilds. If upgrading to 2008 isn't an option, consider manually clearing the bin folder.

花开浅夏 2024-07-11 08:16:01

根据警告的类型,如果我没记错的话是不可能的。

例如,仅当文件打开时才会显示有关 XHTML 合规性的警告消息。 您可以检查VS内的容差设置,看看是否可以更改它。

Depending on the types of warnings it is not possible if I recall correctly.

For example, warning messages for XHTML compliance are ONLY displayed when the file is open. You might check the tolerance settings inside VS to see if you can change it.

白芷 2024-07-11 08:16:01

在重建之前清理解决方案可能会有所帮助 - 右键单击​​解决方案资源管理器中的解决方案并选择“清理解决方案” - 这将删除临时文件并应该清除 bin 和 obj 文件夹,因此所有内容都会重建。

It might help to clean the solution prior to rebuilding -- right click on the solution in the Solution Explorer and choose "clean solution" -- this deletes temporary files and is supposed to clear out the bin and obj folders, so everything is rebuilt.

债姬 2024-07-11 08:16:01

当您的解决方案中有多个项目并且引用混淆时,我以前见过这种情况发生。

假设您的解决方案中有四个项目:Common、Business、Data 和 UI。 假设 Common 被其他三个项目引用。

我们希望 Common 成为其他三个项目的“项目参考”——然后它们将从 Common 的构建输出目录中获取其副本。

但是,有时,其中一个项目的参考会混淆。 假设,在这种情况下,UI 开始引用 Data 的构建输出目录中的 Common 副本。 现在,任何编译“UI”而不编译“Data”的更改都将导致两个可能不兼容的“Common”版本成为 UI 的依赖项。

另一种情况是引用二进制文件,例如来自“lib”目录。 然后,其中一个项目最终引用构建输出位置而不是 lib。

我不知道是什么原因造成的——但不幸的是,我一直看到这种情况。

解决方法是检查每个项目的引用并找到指向错误位置的一个(或多个)。

I've seen this happen before when you have multiple projects in your solution and the references get mixed up.

Say you have four projects in your solution, Common, Business, Data, and UI. Assume that Common is referenced by the other three projects.

What we want is for Common to be a "project reference" from the other three projects - they'll then pick up their copy from the build output directory of Common.

But, sometimes, one of the projects will get it's reference mixed up. Say, in this case, that UI starts referencing the copy of Common in the build output directory of Data. Now, any change that compiles "UI" without also compiling "Data" will result in two, possibly incompatible, versions of "Common" being a dependency of UI.

Another scenario is where the reference is to a binary, such as from a "lib" directory. Then, one of the projects ends up referring to a build output location instead of lib.

I don't know what causes this - but I see it all the time, unfortunately.

The fix is to go through the references of each project and find the one (or more) that point to the wrong place.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文