Declare the Sdk element in Microsoft.Build.Core.xsd - #14637
Merged
Conversation
Contributor
|
Hello @copilot, I noticed that you’re changing an .swr file or any file under src/Package/MSBuild.VSSetup.. Please make sure to validate this change by an experimental VS insertion. This is accomplished by pushing to an exp/* branch, which requires write permissions to this repo. |
Co-authored-by: ViktorHofer <7412651+ViktorHofer@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix Microsoft.Build.Core.xsd to include Sdk element
Declare the Sdk element in Microsoft.Build.Core.xsd
Aug 4, 2026
ViktorHofer
marked this pull request as ready for review
August 4, 2026 13:34
ViktorHofer
approved these changes
Aug 4, 2026
ViktorHofer
enabled auto-merge (squash)
August 4, 2026 13:36
AR-May
approved these changes
Aug 4, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Adds explicit <Sdk /> element support to the MSBuild core XSD so editors (notably Visual Studio) can provide IntelliSense for SDK-style projects, aligning the schema with MSBuild’s existing behavior of lowering <Sdk /> to implicit imports.
Changes:
- Extends
Microsoft.Build.Core.xsdto declare anSdkelement and a correspondingSdkType(withName,Version,MinimumVersionattributes). - Updates the schema’s project-level content model groups so
<Sdk />is allowed (including as the required “at least one …” member viaTargetOrImportType). - Adds unit tests validating that projects with
<Sdk />elements validate, and that missing requiredNameis rejected.
Show a summary per file
| File | Description |
|---|---|
| src/MSBuild/MSBuild/Microsoft.Build.Core.xsd | Declares SdkType and allows <Sdk /> in the relevant project-level schema groups. |
| src/MSBuild.UnitTests/ProjectSchemaValidationHandler_Tests.cs | Adds schema-validation tests for valid/invalid <Sdk /> element usage. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
Removed the Build target from the test project schema.
AR-May
approved these changes
Aug 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Microsoft.Build.Core.xsddeclares anSdkattribute onProjectandImport, but never declares theSdkelement. Visual Studio therefore offers no IntelliSense for<Sdk />or itsName/Version/MinimumVersionattributes, even though MSBuild fully supports the element and translates it into implicit imports.Changes Made
SdkTypecomplex type —Name(required,non_empty_string),VersionandMinimumVersion(optional), mirroringProjectSdkElementandProjectRootElement.GetImplicitImportNodes.SdkfromTargetOrImportTypeandProjectLevelTagType— theProjectcontent model requires at least one Target/Import, so membership inTargetOrImportTypeis what makes a project whose only child is<Sdk />valid. Consistent with<Sdk>lowering to implicit imports.ProjectLevelTagExceptTargetOrImportType— theProjectmodel isA* B C*; puttingSdkin bothAandBmakes it non-deterministic and the schema fails to compile (UPA violation).Testing
Two tests in
ProjectSchemaValidationHandler_Tests.cs: a project usingSdkelements (with all attributes, multiple elements, interleaved withTarget) validates; anSdkelement missingNameis rejected.Those tests are gated on
FEATURE_XML_SCHEMA_VALIDATION(net472/Windows), so the schema was additionally exercised on Linux via a standaloneXmlSchemaSetharness: the schema set compiles without UPA errors, the cases above behave as expected, and existing shapes (Target-only,Sdkattribute onProject) still validate.Notes
Schema changes here need to be mirrored into the internal VS repo — see
src/MSBuild/Update-MSBuildXsds.ps1anddocumentation/wiki/Interactions-with-the-internal-repository.md._locID_textcomments follow the existing localization convention in the file.