在Visual Studio 2008中进行重建和清洁+构建之间的区别是什么?清洁+重建与清洁+重建不同吗?
当前回答
重建=清洁+构建(通常)
值得注意的细节:
For a multi-project solution, "rebuild solution" does a "clean" followed by a "build" for each project (possibly in parallel). Whereas a "clean solution" followed by a "build solution" first cleans all projects (possibly in parallel) and then builds all projects (possibly in parallel). This difference in sequencing of events can become significant when inter-project dependencies come into play. All three actions correspond to MSBuild targets. So a project can override the Rebuild action to do something completely different.
其他回答
Visual Studio 2022的文档解释说:
Choose Build or Build Solution, or press Ctrl+Shift+B, to compile only those project files and components that have changed since the most recent build. The Build command becomes Build Solution when a solution includes more than one project. Choose Rebuild Solution to "clean" the solution and then build all project files and components. Choose Clean Solution to delete any intermediate and output files. With only the project and component files left, new instances of the intermediate and output files can then be built.
更多信息请访问:https://learn.microsoft.com/en-us/visualstudio/ide/building-and-cleaning-projects-and-solutions-in-visual-studio?view=vs-2022
另一个不同之处是:Clean会清除测试资源管理器中的测试结果,而Rebuild不会。
重建=清洁+构建(通常)
值得注意的细节:
For a multi-project solution, "rebuild solution" does a "clean" followed by a "build" for each project (possibly in parallel). Whereas a "clean solution" followed by a "build solution" first cleans all projects (possibly in parallel) and then builds all projects (possibly in parallel). This difference in sequencing of events can become significant when inter-project dependencies come into play. All three actions correspond to MSBuild targets. So a project can override the Rebuild action to do something completely different.
让我们根据默认的Clean和Build实现来定义默认的Rebuild实现:
每个项目:重建项目=清理项目+构建项目。 每个解决方案:重建sln = sln中的foreach项目(清洁项目+构建项目)。
注意,由于执行顺序的不同,重建sln与(Clean sln + Build sln) = (sln Clean项目中的foreach项目)+ (sln Build项目中的foreach项目)并不相同。此外,这个“foreach”可以并发执行,因此不同的任务可以在两种场景中并发运行。
假设您有一个包含proj1、proj2和proj3的sln。
Rebuild sln = (Clean proj1 + Build proj1) & (Clean proj2 + Build proj2) & (Clean proj3 + Build proj3) Clean Sln + Build Sln = (Clean proj1 & Clean proj2 & Clean proj3) + (Build proj1 & Build proj2 & Build proj3)
+表示连续,&表示并发。
因此,如果项目依赖项没有正确配置,那么在执行Rebuild sln时,可能会有一些项目链接到一个过时的库。这是因为不能保证在第一次构建开始之前完成所有清理。如果你执行Clean sln + Build sln,他们会给出一个链接错误,并立即让你知道,而不是给你一个有奇怪行为的应用程序。
Earl在99%的情况下重建=清洁+构建是正确的。
但不能保证它们是一样的。这3个动作(重建、构建、清除)代表不同的MSBuild目标。每一个都可以被任何项目文件覆盖以执行自定义操作。因此,在启动clean + build(或完全删除它们)之前,完全有可能覆盖rebuild来执行几个操作。
这是一个非常极端的情况,但由于评论讨论而指出了它。
推荐文章
- 在Mac OS X上安装/升级gradle
- 如何在解决方案中找到未使用的NuGet包?
- 查看Visual Studio 2010+中的所有断点
- 错误:执行失败的任务':app:compileDebugKotlin'。>编译错误。详细信息请参见日志
- 如何禁用诊断工具?
- Visual Studio单击“查找结果”在错误的窗口中打开代码
- 无法打开Visual Studio -抛出错误“安装过程中无法运行”
- 我在哪里可以找到安装在Visual Studio中的TypeScript版本?
- Visual Studio代码如何解决合并冲突与git?
- _references.js是用来做什么的?
- Go是如何编译得这么快的?
- 如何为新的c#类/接口编辑Visual Studio模板?
- IIS Express Windows身份验证
- 配置系统初始化失败
- 在Visual Studio中是否有标准的快捷键来构建当前项目?