Visual Studio当中的Build、Rebuild和Clean

本文主要介绍在Visual Studio当中Build、Rebuild和Clean的区别

原文地址:WHAT IS THE DIFFERENCE BETWEEN BUILD AND REBUILD IN VISUAL STUDIO?


总的来说,Build是最“懒惰”的,也是最快的;Rebuild是Clean和Build的组合;Clean则是清除由Build命令生成的文件,但值得注意的事情是,并不是清除所有的文件。


针对Clean存在的这个问题,在StackOverflow上有一个解决方法:

As others have responded already Clean will remove all artifacts that are generated by the build. But it will leave behind everything else.

If you have some customizations in your MSBuild project this could spell trouble and leave behind stuff you would think it should have deleted.

You can circumvent this problem with a simple change to your .*proj by adding this somewhere near the end :


<Target Name="SpicNSpan"
        AfterTargets="Clean">
    <RemoveDir Directories="$(OUTDIR)"/>
</Target>

Which will remove everything in your bin folder of the current platform/configuration.



以下是原文的内容:


BUILD SOLUTION

This is actually Visual Studio's lazier and possibly faster option when it comes to compiling a solution. When you Build a solution, Visual Studio will perform an incremental build under the hood(under the hood 在后台,在底层). This means that if it doesn't think it's necessary to rebuild a certain project within the solution it won't. This can be quite useful if you are only working in one project in a solution and can be noticeably faster.

REBUILD SOLUTION

When you Rebuild a solution, this command actually cleans and then builds each project in the solution from scratch. It is quite clever in that it will ignore a project that it has already cleaned and built.

CLEAN SOLUTION

I have found myself in many a sticky( 极不愉快的) situation and the Clean Solution command has helped me out. Under the hood, this command will remove all intermediary(中间的;) files and output directories (your bin and obj folders) from the previous build. After performing a Clean and navigating to your output directories, you may notice that not all of the files are actually removed. This might happen because Clean only removes files that are associated with a build and not everything else. If you are looking for a way to remove all files when you run the Clean command, there is a great post on Stack Overflow worth checking out.

If you'd like to find out more about the different build and rebuild commands in Visual Studio, I recommend taking a look at the MSDN docs.


你可能感兴趣的:(Build,clean,rebuild,Visual,Studio)