在Build菜单下有Compile,Build,Rebuild All三个菜单项用于编译程序。
其中Compile用于编译当前打开的活动文档;
Build只编译工程中上次修改过的文件,并链接程序生成可执行文件。如果以前没有作过编译,它会自动调用Rebuild All操作,依次编译资源文件、源程序文件等;
Rebuild All不管文件是否作过修改,都会编译工程中的所有源文件。由于编译链接过程中会产生大量的中间文件和目标文件,它们占用许多硬盘空间,
因此Visual Studio在Build下提供了Clean菜单项用于清除这些中间文件。用户在完成一个工程后,应及时清理这些中间文件,否则硬盘很快会被耗尽。
(修改头文件(.h, .hxx, .hpp)需要rebuild, 修改源码文件(*.cpp, *.cxx)build就可以)
compile只生成.obj文件。
build先compile出.obj文件,然后link出.exe文件。
一般来说
Rebuild=99%*(Clean+Build),效果在非常小的可能性下会不同,一般可以忽略
Rebuild是对Solution下的所有项目,逐个进行 Clean+Build。不论文件更改与否
Clean+Build是对选中的项目(如果选中Solution的话,全部Clean之后,再全部Build)先执行Clean再执行Build。
一般不需要执行Clean。
Build只是针对有更改过的文件进行编译。而Rebuild会编译所有。
推荐用 Clean+Build 或者Build。
Build / Rebuild / Compile ASP.NET C#
C# rebuilds because a file has been changed, or a dependency has been changed, but also frequently for "no obvious reason". You can often build 2 or 3 times in a row without making a single change and C# will trundle off and rebuild vast amounts of the code.
Turn on Tools > Options > Projects and Solutions > Build and Run > Only build startup projects and dependencies on run. This will minimise the build to only the dependencies of the project you intend to execute, so unless everything is one massive dependency tree, this will significantly reduce the number of projects considered in the build.
The better solution, however, is to avoid asking it to compile in the first place.
Every project adds an additional overhead to the build. On my PC this is around 3 seconds. By merging the code of two projects into one .csproj files I save 3 seconds of build time. So for 300+ projects you could knock 10 minutes off the build time just by merging projects - i.e. where possible use many modules/namespaces in one assembly rather than many assemblies. You'll find your application startup time is improved too.
Many projects don't need building all the time. Break these out as library projects and just link to (reference) the binaries
Also disable "copy local" and instead point all OutputPaths to a shared folder - this will significantly reduce the overheads by avoiding making 320 copies of 320 dlls all over your hard drive.
Add new build configurations (e.g. "Debug FastBuild") that only build the assemblies you are actually working on.With the configguration manager you can untick projects you don't want to build, and presto, they are ignored by the build system. After you get code from source control, build a full "Debug" build to refresh everything, and then switch back to "fastbuild"
3.http://www.isallstars.com/Blog/1003_Script_to_Compile_and_Build_C%20%20NET_appli.aspx
Script to Compile and Build C#.NET application
@echo off
REM *** csc parameters ***
SET dll=CompileDotNet.dll
SET src=%cd%
SET dst=bin
SET csc=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe /nologo
SET out=/out:%src%\%dst%\%dll%
SET target=/target:library
SET recurse=/recurse:%src%\*.cs
REM *** Referrences ***
SET ref=
REM *** delete existing dlls, etc ***
del /F /Q %src%\%dst%\*.*
REM *** compile the dll ***
%csc% %out% %target% %ref% %recurse%