在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.
Earl在99%的情况下重建=清洁+构建是正确的。
但不能保证它们是一样的。这3个动作(重建、构建、清除)代表不同的MSBuild目标。每一个都可以被任何项目文件覆盖以执行自定义操作。因此,在启动clean + build(或完全删除它们)之前,完全有可能覆盖rebuild来执行几个操作。
这是一个非常极端的情况,但由于评论讨论而指出了它。
来自http://www.cs.tufts.edu/r/graphics/resources/vs_getting_started/vs_getting_started.htm,(刚刚谷歌了一下):
Build意味着编译并链接自上次构建以来已经更改的源文件,而Rebuild意味着编译并链接所有源文件,而不管它们是否更改。构建是正常的事情,而且更快。有时项目目标组件的版本可能会不同步,为了使构建成功,必须重新构建。在实践中,你永远不需要Clean。
构建或重建解决方案构建或重建解决方案中的所有项目,而构建或重建则构建或重建StartUp项目,上面的屏幕截图中的“你好”。要设置StartUp项目,请在“解决方案资源管理器”选项卡中右键单击所需的项目名称,并选择“设置为StartUp项目”。项目名称现在以粗体显示。由于作业解决方案通常只有一个项目,因此构建或重建解决方案实际上与构建或重建相同。
Compile只编译当前正在编辑的源文件。当其余源文件处于不完整状态时,可以快速检查错误,这将阻止整个项目的成功构建。Ctrl-F7是编译的快捷键。
让我们根据默认的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,他们会给出一个链接错误,并立即让你知道,而不是给你一个有奇怪行为的应用程序。
在这篇博客文章中,作者链接了对这个问题的评论:
其实不! !它们是不平等的。 不同之处在于项目从清洁到构建的顺序。让 假设我们在一个解决方案中有两个项目。清洁,然后建立意志 对两个项目执行clean,然后将单独进行构建 而在重建时,项目A将获得和清洁,然后再建造 项目B将会是干净的,然后建造等等。
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
推荐文章
- 有Grunt生成index.html不同的设置
- csproj文件中的“Service Include”是干什么用的?
- 如何在Visual Studio中找到堆栈跟踪?
- 使用不同的Web。在开发和生产环境中进行配置
- 是否有一种方法可以在Visual Studio中删除一行而不剪切它?
- Microsoft Visual Studio的推荐插件
- Visual Studio: ContextSwitchDeadlock
- Visual Studio:如何打破处理异常?
- VS 2017 Git本地提交数据库。每次提交时锁定错误
- 无法启动IIS Express Web服务器,注册URL失败,访问被拒绝
- VS2013外部构建错误"error MSB4019: The imported project <path> was not found"
- 如何下载Visual Studio社区版2015(不是2017)
- 查找和替换-添加回车符或换行符
- 在子目录中测试Golang
- Visual Studio Community和其他付费版本的区别是什么?