什么时候你应该选择重建而不是构建?
为了让我更清楚,我想问一下你们的
项目或解决方案重建而不是构建< 的正确条件/strong> 在 Visual Studio 中?
如果我换个说法:为什么 MS 需要在 Visual Studio 中创建“重新构建所有”选项?他们这样做的主要动机是什么?
谢谢!
Just to make it more clear for me, I would like to ask you guys the correct condition(s) to have your
project or solution Rebuild instead of build in Visual Studio?
If I rephrase it: Why the MS needed to create "Re-build ALL" option in Visual Studio? What was their main motive to do that?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
DRY :依次为每个项目重新构建 = 清理 + 构建。
构建不会删除以前的构建输出。
重建会删除它们并再次构建(如果您处于解决方案中,则一次一个项目:删除 proj1\bin\Debug、构建 proj1、删除 proj2\bin\Debug ...)。
我进行重建(或干净构建)时的主要情况是我需要更新解决方案的第三个依赖项。让我们看看下面的文件夹树:
如果我更改依赖项中的 dll 并且不进行重建,VS(和 MsBuild)仍将使用 PROJ_N\bin\Debug(或 bin\Release)中的先前 dll 版本,由于依赖项查找顺序(请参阅 http://www.beefycode .com/post/Resolving-Binary-References-in-MSBuild.aspx) :
{CandidateAssemblyFiles}
$(ReferencePath)
指示- 引用路径属性,来自.USER
文件。{HintPathFromItem}
指示。...
bin 文件夹中的 dll 出现在第一个查找情况中, Dependency 文件夹中的 dll 出现在第二种情况中...
在这种情况下,我会执行清理(调试)、清理(发布),然后构建根除 bin 文件夹中的所有先前版本。我可能有点矫枉过正,重建可能就足够了,但我不确定,因为 dll 位于调试和发布文件夹中......
DRY : Rebuild = Clean + Build for each project in turn.
Build does not delete the previous builds outputs.
Rebuild does delete them and build again (one project at a time if you are in a solution : delete proj1\bin\Debug, build proj1, delete proj2\bin\Debug ...).
The main case when I do a rebuild (or a clean build) is when I need to update my solution third dependencies. Let's see the following folder tree :
If I change my dlls in Dependencies and don't do a rebuild, VS (and MsBuild) would still use the previous dll version that is in PROJ_N\bin\Debug (or in bin\Release), because of the Dependency lookup order (see http://www.beefycode.com/post/Resolving-Binary-References-in-MSBuild.aspx) :
{CandidateAssemblyFiles}
$(ReferencePath)
- the reference path property, which comes from the.USER
file.{HintPathFromItem}
....
The dll in bin folder goes in the the first lookup case, the dll in Dependencies folder comes in the second case...
In such a case I would do a clean (Debug), clean (Release) and then a build to eradicate all previous version in the bin folder. I'm maybe a bit overkill and a rebuild may be enough but I'm not sure because the dlls are in the Debug and in the Release folders...
有时会出现问题,构建无法正常工作。
例如,当我没有正确更新依赖库,而这些依赖库没有正确复制到构建的 bin 路径时,就会发生这种情况。还有其他例子,但没有想到。
这就是我使用重建的时候。
Sometimes things go wrong and the build just doesn't work.
This happens e.g. when I do not correctly update dependent libraries which then aren't correctly copied to the bin paths of the build. There are other examples, non spring to mind.
That's when I use rebuild.