|
1 | 1 | --- |
2 | 2 | title: 'Specify build events (Visual Basic)' |
3 | 3 | description: Explore how to use build events in Visual Basic to run scripts, macros, or other actions as a part of the compilation process. |
4 | | -ms.date: 12/13/2024 |
| 4 | +ms.date: 2/20/2025 |
5 | 5 | ms.subservice: compile-build |
6 | 6 | ms.topic: how-to |
7 | 7 | helpviewer_keywords: |
@@ -54,14 +54,16 @@ Build events are specified in the **Build Events** dialog box, available from th |
54 | 54 | :::moniker-end |
55 | 55 |
|
56 | 56 | > [!NOTE] |
57 | | -> Add a `call` statement before all post-build commands that run *.bat* files. For example, `call C:\MyFile.bat` or `call C:\MyFile.bat call C:\MyFile2.bat`. |
| 57 | +> Add a `call` statement before all post-build commands that run `.bat` files. For example, `call C:\MyFile.bat` or `call C:\MyFile.bat call C:\MyFile2.bat`. |
58 | 58 |
|
59 | 59 | > [!NOTE] |
60 | 60 | > If your pre-build or post-build event does not complete successfully, you can terminate the build by having your event action exit with a code other than zero (0), which indicates a successful action. |
61 | 61 |
|
| 62 | +You can reference "macros" (actually MSBuild property names) in the scripts. To reference a property, use the syntax `$(PropertyName)`, which is substituted with the property value when the event script is executed. For a list of commonly used values, see [MSBuild common properties](../msbuild/common-msbuild-project-properties.md). There may be other properties as well as defined in the project file, in any imported files in the project file, in environment variables, or passed on the command line using the `-p` MSBuild switch during command-line builds. |
| 63 | + |
62 | 64 | ## Example: How to change manifest information using a post-build event |
63 | 65 |
|
64 | | -The following procedure shows how to set the minimum operating system version in the application manifest using an *.exe* command called from a post-build event (the *.exe.manifest* file in the project directory). The minimum operating system version is a four-part number such as 4.10.0.0. To do this, the command will change the `<dependentOS>` section of the manifest: |
| 66 | +The following procedure shows how to set the minimum operating system version in the application manifest using an `.exe` command called from a post-build event (the `.exe.manifest` file in the project directory). The minimum operating system version is a four-part number such as 4.10.0.0. To do this, the command will change the `<dependentOS>` section of the manifest: |
65 | 67 |
|
66 | 68 | ```xml |
67 | 69 | <dependentOS> |
@@ -159,9 +161,9 @@ The following procedure shows how to set the minimum operating system version in |
159 | 161 |
|
160 | 162 | `C:\TEMP\ChangeOSVersionVB.exe "$(TargetPath).manifest" 5.1.2600.0` |
161 | 163 |
|
162 | | - When you build the project, this command will change the minimum operating system version in the application manifest to 5.1.2600.0. |
| 164 | + When you build the project, this command changes the minimum operating system version in the application manifest to 5.1.2600.0. |
163 | 165 |
|
164 | | - The `$(TargetPath)` macro expresses the full path for the executable being created. Therefore, *$(TargetPath).manifest* will specify the application manifest created in the *bin* directory. Publishing will copy this manifest to the publishing location that you set earlier. |
| 166 | + The `$(TargetPath)` macro expresses the full path for the executable being created. Therefore, `$(TargetPath).manifest` specifes the application manifest created in the *bin* directory. Publishing copies this manifest to the publishing location that you set earlier. |
165 | 167 |
|
166 | 168 | 8. Publish the project again. Go to the **Publish** page and click **Publish Now**. |
167 | 169 |
|
|
0 commit comments