Skip to content

Commit d28b216

Browse files
authored
Merge pull request #10403 from MicrosoftDocs/repo_sync_working_branch
Confirm merge from repo_sync_working_branch to main to sync with https://github.com/MicrosoftDocs/visualstudio-docs (branch main)
2 parents 328ff78 + e889946 commit d28b216

File tree

1 file changed

+46
-43
lines changed

1 file changed

+46
-43
lines changed

docs/msbuild/how-to-use-project-sdk.md

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -45,53 +45,56 @@ During evaluation of the project, MSBuild adds implicit imports at the top and b
4545

4646
There are three ways to reference a project SDK:
4747

48-
- Use the `Sdk` attribute on the `<Project/>` element:
49-
50-
```xml
51-
<Project Sdk="My.Custom.Sdk">
52-
...
53-
</Project>
54-
```
55-
56-
An implicit import is added to the top and bottom of the project as discussed previously.
57-
58-
To specify a specific version of the SDK, append it to the `Sdk` attribute:
59-
60-
```xml
61-
<Project Sdk="My.Custom.Sdk/1.2.3">
62-
...
63-
</Project>
64-
```
65-
66-
- Use the top-level `<Sdk/>` element:
67-
68-
```xml
69-
<Project>
70-
<Sdk Name="My.Custom.Sdk" Version="1.2.3" />
71-
...
72-
</Project>
73-
```
74-
75-
An implicit import is added to the top and bottom of the project as discussed previously.
76-
77-
The `Version` attribute is not required.
48+
### Use the `Sdk` attribute on the `<Project/>` element
49+
50+
```xml
51+
<Project Sdk="My.Custom.Sdk">
52+
...
53+
</Project>
54+
```
55+
56+
An implicit import is added to the top and bottom of the project as discussed previously.
57+
58+
To specify a specific version of the SDK, append it to the `Sdk` attribute:
59+
60+
```xml
61+
<Project Sdk="My.Custom.Sdk/1.2.3">
62+
...
63+
</Project>
64+
```
65+
66+
### Use the top-level `<Sdk/>` element
67+
68+
```xml
69+
<Project>
70+
<Sdk Name="My.Custom.Sdk" Version="1.2.3" />
71+
...
72+
</Project>
73+
```
74+
75+
An implicit import is added to the top and bottom of the project as discussed previously.
76+
77+
The `Version` attribute is not required.
78+
79+
### Use the `<Import/>` element anywhere in your project
7880

79-
- Use the `<Import/>` element anywhere in your project:
81+
```xml
82+
<Project>
83+
<PropertyGroup>
84+
<MyProperty>Value</MyProperty>
85+
</PropertyGroup>
86+
<Import Project="Sdk.props" Sdk="My.Custom.Sdk" />
87+
...
88+
<Import Project="Sdk.targets" Sdk="My.Custom.Sdk" />
89+
</Project>
90+
```
8091

81-
```xml
82-
<Project>
83-
<PropertyGroup>
84-
<MyProperty>Value</MyProperty>
85-
</PropertyGroup>
86-
<Import Project="Sdk.props" Sdk="My.Custom.Sdk" />
87-
...
88-
<Import Project="Sdk.targets" Sdk="My.Custom.Sdk" />
89-
</Project>
90-
```
92+
Explicitly including the imports in your project allows you full control over the order.
9193

92-
Explicitly including the imports in your project allows you full control over the order.
94+
When using the `<Import/>` element, you can specify an optional `Version` attribute as well. For example, you can specify `<Import Project="Sdk.props" Sdk="My.Custom.Sdk" Version="1.2.3" />`.
9395

94-
When using the `<Import/>` element, you can specify an optional `Version` attribute as well. For example, you can specify `<Import Project="Sdk.props" Sdk="My.Custom.Sdk" Version="1.2.3" />`.
96+
> [!WARNING]
97+
> If you are changing project to use `<Import/>` elements, make sure you add both `.props` and `.targets` imports and that you remove the SDK from the `<Project/>` element and `<Sdk/>` elements. Failure to do so will result in doubled imports and an `MSB4011` warning.
9598
9699
## How project SDKs are resolved
97100

0 commit comments

Comments
 (0)