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/import-element-msbuild.md
+5-4Lines changed: 5 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,7 @@ Imports the contents of one project file into another project file.
46
46
|---------------|-----------------|
47
47
|`Project`|Required attribute.<br /><br /> The path of the project file to import. The path can include wildcards. The matching files are imported in sorted order. By using this feature, you can add code to a project just by adding the code file to a directory.|
48
48
|`Condition`|Optional attribute.<br /><br /> A condition to be evaluated. For more information, see [Conditions](../msbuild/msbuild-conditions.md).|
49
+
|`Label`|Optional attribute.<br /><br /> Applies an identifier to this import element.|
49
50
|`Sdk`| Optional attribute.<br /><br /> References a project SDK.|
50
51
51
52
### Child elements
@@ -61,15 +62,15 @@ Imports the contents of one project file into another project file.
61
62
62
63
## Remarks
63
64
64
-
By using the `Import` element, you can reuse code that is common to many project files. This makes it easier to maintain the code because any updates you make to the shared code get propagated to all the projects that import it.
65
+
By using the `Import` element, you can reuse code that is common to many project files. Using imports makes it easier to maintain the code, because any updates you make to the shared code get propagated to all the projects that import it.
65
66
66
-
By convention, shared imported project files are saved as *.targets* files, but they are standard MSBuild project files. MSBuild does not prevent you from importing a project that has a different file name extension, but we recommend that you use the *.targets* extension for consistency.
67
+
By convention, shared imported project files are saved as `.targets` files, but they are standard MSBuild project files. MSBuild does not prevent you from importing a project that has a different file name extension, but we recommend that you use the `.targets` extension for consistency.
67
68
68
69
Relative paths in imported projects are interpreted relative to the directory of the importing project (with a few exceptions described later in this paragraph). Therefore, if a project file is imported into several project files in different locations, the relative paths in the imported project file will be interpreted differently for each imported project. There are two exceptions. One exception is that in `Import` elements, the path is always interpreted relative to the project that contains the `Import` element. Another exception is that the `UsingTask` always interprets the relative path for the `AssemblyFile` attribute relative to the file that contains the `UsingTask` element.
69
70
70
-
All MSBuild reserved properties that relate to the project file, for example, `MSBuildProjectDirectory` and `MSBuildProjectFile`, that are referenced in an imported project are assigned values based on the importing project file.
71
+
All MSBuild reserved properties that relate to the project file that are referenced in an imported project (for example, `MSBuildProjectDirectory` and `MSBuildProjectFile`) are assigned values based on the importing project file.
71
72
72
-
If the imported project does not have a `DefaultTargets` attribute, imported projects are inspected in the order that they are imported, and the value of the first discovered `DefaultTargets` attribute is used. For example, if ProjectA imports ProjectB and ProjectC (in that order), and ProjectB imports ProjectD, MSBuild first looks for `DefaultTargets` specified on ProjectA, then ProjectB, then ProjectD, and finally ProjectC.
73
+
If the imported project doesn't have a `DefaultTargets` attribute, imported projects are inspected in the order that they are imported, and the value of the first discovered `DefaultTargets` attribute is used. For example, if ProjectA imports ProjectB and ProjectC (in that order), and ProjectB imports ProjectD, MSBuild first looks for `DefaultTargets` specified on ProjectA, then ProjectB, then ProjectD, and finally ProjectC.
73
74
74
75
The schema of an imported project is identical to that of a standard project. Although MSBuild may be able to build an imported project, it is unlikely because an imported project typically does not contain information about which properties to set or the order in which to run targets. The imported project depends on the project into which it is imported to provide that information.
0 commit comments