Compile,Build,Rebuild

本文深入解析了Visual Studio中Build、Rebuild、Compile三个选项的功能及其区别,包括如何使用它们来高效管理项目编译过程,避免不必要的编译操作,以及如何设置和优化编译配置以提升开发效率。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在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%

 

### 如何在 IntelliJ IDEA 中重新编译和构建项目 在 IntelliJ IDEA 中重新编译和构建项目的操作可以通过内置工具完成。以下是具体方法: #### 使用 Build 菜单进行重新编译和构建 通过 `Build` 菜单可以执行多种构建任务,包括重新编译整个项目或单独的模块。 - **重新编译整个项目** 可以选择菜单栏中的 `Build -> Rebuild Project` 来完全清理并重新构建当前项目[^3]。此选项会清除之前的构建结果,并从头开始重新编译所有的源文件。 - **仅编译更改的部分** 如果只需要编译最近修改过的部分,可以选择 `Build -> Compile 'File Name'` 或者直接按快捷键 `Ctrl+F9`(Windows/Linux)/ `Cmd+F9`(Mac)。这将只针对已更改的内容进行增量编译。 #### 配置 Gradle 构建工具 如果项目使用的是 Gradle 构建工具,则可以在 `build.gradle` 文件中定义依赖项以及构建逻辑。例如,在根目录下的 `build.gradle` 文件中添加如下配置来指定所需的插件版本: ```groovy dependencies { classpath 'com.android.tools.build:gradle:0.12.+' } ``` 上述代码片段用于设置 Android Gradle 插件的版本号[^1]。当更新了该文件之后,记得同步 Gradle 设置以便应用新的变化到环境中。 #### 执行 Maven 命令生成可运行 JAR 文件 对于基于 Maven 的 Java 应用程序来说,还可以利用命令行或者 IDE 自带终端来进行打包工作。比如下面这条指令将会创建一个新的包含所有依赖关系在内的 JAR 文件位于目标路径下: ```bash mvn assembly:single ``` 完成后即可通过以下方式启动应用程序[^2]: ```bash java -jar target/mvn-example-1.0-SNAPSHOT-jar-with-dependencies.jar ``` 以上就是关于如何在 IntelliJ IDEA 中重新编译与构建项目的详细介绍。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值