You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/msbuild/how-to-build-specific-targets-in-solutions-by-using-msbuild-exe.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ You can use *MSBuild.exe* to build specific targets of specific projects in a so
22
22
23
23
1. At the command line, type `MSBuild.exe <SolutionName>.sln`, where `<SolutionName>` corresponds to the file name of the solution that contains the target that you want to execute.
24
24
25
-
2. Specify the target after the `/target:` switch in the format `<ProjectName>:<TargetName>`. If the project name contains any of the characters `%`, `$`, `@`, `;`, `.`, `(`, `)`, or `'`, replace them with an `_` in the specified target name.
25
+
2. Specify the target after the `/target:` switch in the format \<ProjectName>:\<TargetName>. If the project name contains any of the characters `%`, `$`, `@`, `;`, `.`, `(`, `)`, or `'`, replace them with an `_` in the specified target name.
26
26
27
27
## Example
28
28
The following example executes the `Rebuild` target of the `NotInSlnFolder` project, and then executes the `Clean` target of the `InSolutionFolder` project, which is located in the *NewFolder* solution folder.
Copy file name to clipboardExpand all lines: docs/msbuild/how-to-clean-a-build.md
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -30,9 +30,10 @@ When you clean a build, all intermediate and output files are deleted, leaving o
30
30
31
31
2. Use the [MakeDir](../msbuild/makedir-task.md) task to create the directory if the directory does not exist. For example:
32
32
33
-
`<MakeDir Directories = "$(builtdir)"`
34
-
35
-
`Condition = "!Exists('$(builtdir)')" />`
33
+
```xml
34
+
<MakeDir Directories = "$(builtdir)"
35
+
Condition = "!Exists('$(builtdir)')" />
36
+
```
36
37
37
38
## Remove the output items
38
39
Prior to creating new instances of intermediate and output files, you may want to clear all previous instances of intermediate and output files. Use the [RemoveDir](../msbuild/removedir-task.md) task to delete a directory and all files and directories that it contains from a disk.
Copy file name to clipboardExpand all lines: docs/msbuild/how-to-extend-the-visual-studio-build-process.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -17,14 +17,14 @@ ms.workload:
17
17
- "multiple"
18
18
---
19
19
# How to: Extend the Visual Studio build process
20
-
The [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] build process is defined by a series of [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)]*.targets* files that are imported into your project file. One of these imported files, *Microsoft.Common.targets*, can be extended to allow you to run custom tasks at several points in the build process. This topic explains two methods you can use to extend the [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] build process:
20
+
The [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] build process is defined by a series of [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)]*.targets* files that are imported into your project file. One of these imported files, *Microsoft.Common.targets*, can be extended to allow you to run custom tasks at several points in the build process. This article explains two methods you can use to extend the [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] build process:
21
21
22
22
- Overriding specific predefined targets defined in *Microsoft.Common.targets*.
23
23
24
24
- Overriding the "DependsOn" properties defined in *Microsoft.Common.targets*.
25
25
26
26
## Override predefined targets
27
-
The *Microsoft.Common.targets* file contains a set of predefined empty targets that are called before and after some of the major targets in the build process. For example, [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)] calls the `BeforeBuild` target before the main `CoreBuild` target and the `AfterBuild` target after the `CoreBuild` target. By default, the empty targets in *Microsoft.Common.targets* do nothing, but you can override their default behavior by defining the targets you want in a project file that imports *Microsoft.Common.targets*. By doing this, you can use [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)] tasks to give you more control over the build process.
27
+
The *Microsoft.Common.targets* file contains a set of predefined empty targets that is called before and after some of the major targets in the build process. For example, [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)] calls the `BeforeBuild` target before the main `CoreBuild` target and the `AfterBuild` target after the `CoreBuild` target. By default, the empty targets in *Microsoft.Common.targets* do nothing, but you can override their default behavior by defining the targets you want in a project file that imports *Microsoft.Common.targets*. By overriding the predefined targets, you can use [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)] tasks to give you more control over the build process.
28
28
29
29
#### To override a predefined target
30
30
@@ -45,18 +45,18 @@ The [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] build process is d
45
45
```
46
46
47
47
3. Build the project file.
48
-
49
-
The following table shows all of the targets in *Microsoft.Common.targets* that you can safely override.
48
+
49
+
The following table shows all of the targets in *Microsoft.Common.targets* that you can safely override.
50
50
51
51
|Target name|Description|
52
52
|-----------------|-----------------|
53
53
|`BeforeCompile`, `AfterCompile`|Tasks inserted in one of these targets run before or after core compilation is done. Most customizations are done in one of these two targets.|
54
-
|`BeforeBuild`, `AfterBuild`|Tasks inserted in one of these targets will run before or after everything else in the build. **Note:** The `BeforeBuild` and `AfterBuild` targets are already defined in comments at the end of most project files. This allows you to easily add pre- and post-build events to your project file.|
54
+
|`BeforeBuild`, `AfterBuild`|Tasks inserted in one of these targets will run before or after everything else in the build. **Note:** The `BeforeBuild` and `AfterBuild` targets are already defined in comments at the end of most project files, allowing you to easily add pre- and post-build events to your project file.|
55
55
|`BeforeRebuild`, `AfterRebuild`|Tasks inserted in one of these targets run before or after the core rebuild functionality is invoked. The order of target execution in *Microsoft.Common.targets* is: `BeforeRebuild`, `Clean`, `Build`, and then `AfterRebuild`.|
56
-
|`BeforeClean`, `AfterClean`|Tasks inserted in one of these targets run before or after the core clean functionality is invoked.|
57
-
|`BeforePublish`, `AfterPublish`|Tasks inserted in one of these targets run before or after the core publish functionality is invoked.|
58
-
|`BeforeResolveReference`, `AfterResolveReferences`|Tasks inserted in one of these targets run before or after assembly references are resolved.|
59
-
|`BeforeResGen`, `AfterResGen`|Tasks inserted in one of these targets run before or after resources are generated.|
56
+
|`BeforeClean`, `AfterClean`|Tasks that are inserted in one of these targets run before or after the core clean functionality is invoked.|
57
+
|`BeforePublish`, `AfterPublish`|Tasks that are inserted in one of these targets run before or after the core publish functionality is invoked.|
58
+
|`BeforeResolveReference`, `AfterResolveReferences`|Tasks that are inserted in one of these targets run before or after assembly references are resolved.|
59
+
|`BeforeResGen`, `AfterResGen`|Tasks that are inserted in one of these targets run before or after resources are generated.|
60
60
61
61
## Override "DependsOn" properties
62
62
Overriding predefined targets is an easy way to extend the build process, but, because [!INCLUDE[vstecmsbuild](../extensibility/internals/includes/vstecmsbuild_md.md)] evaluates the definition of targets sequentially, there is no way to prevent another project that imports your project from overriding the targets you already have overridden. So, for example, the last `AfterBuild` target defined in the project file, after all other projects have been imported, will be the one that is used during the build.
0 commit comments