当前位置: 首页 > 工具软件 > REBUILD > 使用案例 >

Compile,Build,Rebuild

翟缪文
2023-12-01

在Build菜单下有Compile,Build,Rebuild   All三个菜单项用于编译程序。

其中Compile用于编译当前打开的活动文档;

Build只编译工程中上次修改过的文件,并链接程序生成可执行文件。如果以前没有作过编译,它会自动调用Rebuild   All操作,依次编译资源文件、源程序文件等;

Rebuild   All不管文件是否作过修改,都会编译工程中的所有源文件。由于编译链接过程中会产生大量的中间文件和目标文件,它们占用许多硬盘空间,

因此Visual   Studio在Build下提供了Clean菜单项用于清除这些中间文件。用户在完成一个工程后,应及时清理这些中间文件,否则硬盘很快会被耗尽。

(修改头文件(.h, .hxx, .hpp)需要rebuild, 修改源码文件(*.cpp, *.cxx)build就可以)

 

 VC++中COMPILE和BUILD的区别

 compile只生成.obj文件。   
 build先compile出.obj文件,然后link出.exe文件。

 

 VS2008 Clean+Build Rebuild 区别

一般来说

Rebuild=99%*(Clean+Build),效果在非常小的可能性下会不同,一般可以忽略

 

Rebuild是对Solution下的所有项目,逐个进行 Clean+Build。不论文件更改与否

Clean+Build是对选中的项目(如果选中Solution的话,全部Clean之后,再全部Build)先执行Clean再执行Build。

 

一般不需要执行Clean。

Build只是针对有更改过的文件进行编译。而Rebuild会编译所有。

推荐用 Clean+Build 或者Build。

 

http://stackoverflow.com/questions/1247457/difference-between-rebuild-and-clean-build-in-visual-studio-2008

 

 

Build / Rebuild / Compile ASP.NET C#

Build means compile and link only the source files that have changed since the last build, while Rebuild means compile and link all source files regardless of whether they changed or not. Build is the normal thing to do and is faster. Sometimes the versions of project target components can get out of sync and rebuild is necessary to make the build successful. In practice, you never need to Clean.

Build or Rebuild Solution builds or rebuilds all projects in the your solution, while Build or Rebuild builds or rebuilds the StartUp project, "hello" in the screen shot above. To set the StartUp project, right click on the desired project name in the Solution Explorer tab and select Set as StartUp project. The project name now appears in bold. Since the homework solutions typically have only one project, Build or Rebuild Solution is effectively the same as Build or Rebuild .

Compile just compiles the source file currently being edited. Useful to quickly check for errorswhen the rest of your source files are in an incomplete state that would prevent a successful build of the entire project. Ctrl-F7 is the shortcut key for Compile.

Other References
1.http://stackoverflow.com/questions/5429781/reasons-for-c-projects-to-rebuild-in-visual-studio
Reasons for C# projects to rebuild in Visual Studio

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"



2.http://msdn.microsoft.com/en-us/library/78f4aasd.aspx
Command-line Building With csc.exe

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%

 

 类似资料: