在 Visual Studio 中编译和生成Compile and build in Visual Studio

若要初步了解如何在 IDE 中进行生成,请参阅演练:生成应用程序For a first introduction to building within the IDE, see Walkthrough: Building an application.

可以使用以下任何方法来生成应用程序:Visual Studio IDE、MSBuild 命令行工具和 Azure Pipelines:You can use any of the following methods to build an application: the Visual Studio IDE, the MSBuild command-line tools, and Azure Pipelines:

生成方法Build Method 优点Benefits
IDEIDE - 立即创建生成并在调试程序中对其进行测试。- Create builds immediately and test them in a debugger.
- 运行 C++ 和 C# 项目的多处理器生成。- Run multi-processor builds for C++ and C# projects.
- 自定义生成系统的不同方面。- Customize different aspects of the build system.
CMakeCMake - 使用 CMake 工具生成项目- Build projects using the CMake tool
-跨 Linux 和 Windows 平台使用同一生成系统。- Use the same build system across Linux and Windows platforms.
MSBuild 命令行MSBuild command line - 在无需安装 Visual Studio 的情况下生成项目。- Build projects without installing Visual Studio.
- 运行所有项目类型的多处理器生成。- Run multi-processor builds for all project types.
- 自定义生成系统的大多数区域。- Customize most areas of the build system.
Azure PipelinesAzure Pipelines - 自动执行生成过程作为持续集成/持续交付管道的一部分。- Automate your build process as part of a continuous integration/continuous delivery pipeline.
- 将自动测试应用于每个生成。- Apply automated tests with every build.
- 为生成过程采用几乎无限的基于云的资源。- Employ virtually unlimited cloud-based resources for build processes.
- 修改生成工作流,并创建生成活动以执行深层的自定义任务。- Modify the build workflow and create build activities to perform deeply customized tasks.

本节中的文档将详细介绍基于 IDE 的生成过程。The documentation in this section goes into further details of the IDE-based build process. 有关其他方法的详细信息,请分别参阅 MSBuildAzure PipelinesFor more information on the other methods, see MSBuild and Azure Pipelines, respectively.

备注

本主题适用于 Visual Studio Windows 版。This topic applies to Visual Studio on Windows. 对于 Visual Studio for Mac,请参阅在 Visual Studio for Mac 中编译和生成For Visual Studio for Mac, see Compile and build in Visual Studio for Mac.

从 IDE 生成的概述Overview of building from the IDE

创建项目时,Visual Studio 创建了该项目的默认生成配置和包含该项目的解决方案。When you create a project, Visual Studio created default build configurations for the project and the solution that contains the project. 这些配置定义如何生成和部署解决方案和项目。These configurations define how the solutions and projects are built and deployed. 尤其对目标平台(如 Windows 或 Linux)和生成类型(如调试或发布)而言,项目配置必须唯一。Project configurations in particular are unique for a target platform (such as Windows or Linux) and build type (such as debug or release). 但是,你可以根据喜好编辑这些配置,也可以根据需要创建自己的配置。You can edit these configurations however you like, and can also create your own configurations as needed.

若要初步了解如何在 IDE 中进行生成,请参阅演练:生成应用程序For a first introduction to building within the IDE, see Walkthrough: Building an application.

接下来,请参阅在 Visual Studio 中生成和清理项目和解决方案,了解你可以对过程进行哪些不同方面的自定义设置。Next, see Building and cleaning projects and solutions in Visual Studio to learn about the different aspects customizations you can make to the process. 自定义包括更改输出目录指定自定义生成事件管理项目依赖项管理生成日志文件以及禁止显示编译器警告Customizations include changing output directories, specifying custom build events, managing project dependencies, managing build log files, and suppressing compiler warnings.

你还可以浏览各种其他任务:From there, you can explore a variety of other tasks:

另请参阅See also