Visual Studio中的构建解决方案、重新构建解决方案和清洁解决方案之间的区别是什么?

什么时候使用这些工具比较合适?


当前回答

我只是认为重建是先执行清理,然后再执行构建。也许我错了……评论?

其他回答

我所知道的是一个清洁不做什么“使清洁”用来做-如果我清洁一个解决方案,我希望它删除obj和bin文件/文件夹,这样它就像是一个新的签出源。根据我的经验,虽然我经常发现,清洁和构建或重建仍然会在已知编译的源代码上产生奇怪的错误,需要手动删除bin/obj文件夹,然后它就会构建。

我只是认为重建是先执行清理,然后再执行构建。也许我错了……评论?

我认为人们忽略的一件重要事情是,构建和清理都是基于Visual Studio对项目/解决方案的了解来执行的任务。我看到很多人抱怨Clean不能工作,或者留下剩余的文件,或者不值得信赖,而事实上,你说它不值得信赖的原因实际上使它更值得信赖。

Clean只会删除Visual Studio或编译器自己实际创建的文件和/或目录。如果你复制自己的文件,或者从外部工具或源创建的文件/文件夹结构,那么Visual Studio不会“知道它们的存在”,因此不应该接触它们。

你能想象如果Clean操作基本上执行了“del *”。*”?这可能是灾难性的。

Build对更改的或必要的项目执行编译。

不管更改或需要什么,Rebuild都会执行编译。

Clean会删除过去创建的文件/文件夹,但会保留最初与之无关的任何内容。

我希望这能说明一点问题并有所帮助。

Build solution will perform an incremental build: if it doesn't think it needs to rebuild a project, it won't. It may also use partially-built bits of the project if they haven't changed (I don't know how far it takes this) Rebuild solution will clean and then build the solution from scratch, ignoring anything it's done before. The difference between this and "Clean, followed by Build" is that Rebuild will clean-then-build each project, one at a time, rather than cleaning all and then building all. Clean solution will remove the build artifacts from the previous build. If there are any other files in the build target directories (bin and obj) they may not be removed, but actual build artifacts are. I've seen behaviour for this vary - sometimes deleting fairly thoroughly and sometimes not - but I'll give VS the benefit of the doubt for the moment :)

(这些链接指向devenv.exe命令行开关,但它们的功能与菜单项相同。)

这只涉及“构建解决方案”选项。

我完全受够了Visual Studio无法真正清理解决方案,所以写了这个小工具来为你做这件事。

首先在VS中关闭你的解决方案,并将它的文件夹从Windows资源管理器拖到这个应用程序或它的图标中。根据窗口底部的设置,它还可以删除额外的东西,这将有助于你手动上传你的解决方案到GitHub或与他人共享:

简而言之,它会把所有的“调试”文件夹、智能感知和其他可以被VS重建的缓存放入回收站。