Both project settings allow me to execute custom commands. What are the benefits or drawbacks of each?
Big difference. A custom build step allows you to specify dependencies and outputs. Which allows the build system to determine when to execute the step and to skip it when the output is already up to date. A post-build event is always executed when the project requires building and its timing is fixed.
echo HELLO WORLD
to my Post-Build Event. (1) HELLO WORLD
is displayed as expected. (2) If I simply right-click Build on my project again... HELLO WORLD
is not displayed in the Visual Studio Output, Show output from Build window. (3) Executing Clean followed by Build... and HELLO WORLD
appears again. So it appears that in Visual Studio 2012 (with Platform Tooolset set to v90 in project configuration)... the post-build event only executes when something is actually built. Am I missing something? –
Polyhydric seems @Hans answer got it switched, main difference is that if no files need to be built, no build events will occur.
from the msdn documentation:
Build events and custom build steps run in the following order along with other build steps:
Pre-Build event
Custom build tools on individual files
MIDL
Resource compiler
The C/C++ compiler
Pre-Link event
Linker or Librarian (as appropriate)
Manifest Tool
BSCMake
Custom build step on the project
Post-Build event
The custom build step on the project and a post-build event run sequentially after all other build processes finish.
Build events are executed only if the build successfully reaches those points in the build process. If an error occurs in the build, the post-build event will not occur; if the error occurs before the linking phase, neither the pre-link nor the post-build event will occur. Additionally, if no files need to be linked, the pre-link event will not occur. The pre-link event is also not available in projects that do not contain a link step. If no files need to be built, no build events will occur.
From within the Visual Studio C++ development environment, there are three basic ways to customize the build process:
Custom Build Steps A custom build step is a build rule associated with a project. A custom build step can specify a command line to execute, any additional input or output files, and a message to display. For more information, see How to: Add a Custom Build Step to MSBuild Projects.
Custom Build Tools A custom build tool is a build rule associated with one or more files. A custom build step can pass input files to a custom build tool, which results in one or more output files. For example, the help files in an MFC application are built with a custom build tool. For more information, see How to: Add Custom Build Tools to MSBuild Projects and Specifying Custom Build Tools. Build Events
Build events let you customize a project's build. There are three build events: pre-build, pre-link, and post-build. A build event lets you specify an action to occur at a specific time in the build process. For example, you could use a build event to register a file with regsvr32.exe after the project finishes building. For more information, see Specifying Build Events.
© 2022 - 2024 — McMap. All rights reserved.