Skip to content

docs(readme): document workaround for XML schema collection xsd files#902

Draft
nmummau wants to merge 1 commit intorr-wfm:masterfrom
nmummau:issue/861-workaround-docs-clean
Draft

docs(readme): document workaround for XML schema collection xsd files#902
nmummau wants to merge 1 commit intorr-wfm:masterfrom
nmummau:issue/861-workaround-docs-clean

Conversation

@nmummau
Copy link
Copy Markdown
Contributor

@nmummau nmummau commented Apr 10, 2026

This is for issue #861 where we will recommend the workaround with, where it seems there are no plans to implement full xsd support.

  This is for issue rr-wfm#861 where we will recommend the workaround with
  no plans to implement full xsd support.
@nmummau
Copy link
Copy Markdown
Contributor Author

nmummau commented Apr 10, 2026

@DanielLoth does this documentation align with what worked for you as a manual workaround?

nmummau added a commit to nmummau/MSBuild.Sdk.SqlProj that referenced this pull request Apr 10, 2026
@ErikEJ ErikEJ requested a review from Copilot April 10, 2026 04:55
Comment thread README.md

Wildcards are supported for all nodes (`Content`, `None`, etc.). For example, `<None Include="Directory\**" />`.

## XML schema collections (`.xsd`)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be near the bottom of the file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe let's hold off on this until we have the dedicated docusaurus docs site -- and this will be on a dedicated page.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nmummau Agree!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR can sit open for a bit of time then until that docusaurus PR finalizes. And I'll work to "merge" this xsd workaround into those docs. Then, we can close this PR with a link to the better docs site as a reference.

Copy link
Copy Markdown
Collaborator

@ErikEJ ErikEJ left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ErikEJ ErikEJ requested a review from jmezach April 10, 2026 04:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Documents a recommended workaround for SQL Server XML schema collections when using MSBuild.Sdk.SqlProj, addressing Issue #861 where .xsd build includes are not handled like classic .sqlproj projects.

Changes:

  • Added a README section explaining the current limitation around .xsd build inputs for XML schema collections.
  • Provided a workaround using a .sql script with CREATE XML SCHEMA COLLECTION and an embedded XSD payload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md
Comment on lines +109 to +112
CREATE XML SCHEMA COLLECTION [dbo].[XMLSchemaCollection1]
AS N'<?xml version="1.0" encoding="utf-16"?>
<xs:schema id="XMLSchemaCollection1"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guidance says to copy the .xsd contents into the N'...' literal, but many .xsd files include an XML declaration like encoding="utf-8". When passed as an NVARCHAR literal, SQL Server can fail XML parsing if the declaration encoding doesn’t match (typically you should remove the XML declaration entirely, or ensure it’s utf-16). Consider adding an explicit note about this to prevent copy/paste failures.

Copilot uses AI. Check for mistakes.
Comment thread README.md
</xs:schema>';
```

In practice, the workaround is to copy the contents of the `.xsd` file into the `N'...'` string of a `CREATE XML SCHEMA COLLECTION` statement and include that `.sql` file in your project instead of the `.xsd` file.
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copying an .xsd into a N'...' string also requires escaping any single quotes by doubling them, and large schemas may exceed the 4,000-character NVARCHAR literal limit unless you split/concatenate (or otherwise construct an NVARCHAR(MAX) value). Adding a brief note about escaping and size limits would make this workaround more reliable in practice.

Suggested change
In practice, the workaround is to copy the contents of the `.xsd` file into the `N'...'` string of a `CREATE XML SCHEMA COLLECTION` statement and include that `.sql` file in your project instead of the `.xsd` file.
In practice, the workaround is to copy the contents of the `.xsd` file into the `N'...'` string of a `CREATE XML SCHEMA COLLECTION` statement and include that `.sql` file in your project instead of the `.xsd` file. If the schema content contains single quotes, escape them by doubling them (`''`). Also note that large schemas may exceed the 4,000-character `NVARCHAR` literal limit, in which case you will need to split and concatenate the string or otherwise construct an `NVARCHAR(MAX)` value.

Copilot uses AI. Check for mistakes.
@nmummau
Copy link
Copy Markdown
Contributor Author

nmummau commented Apr 10, 2026

Discussion above. This PR can sit open for a bit of time then until that docusaurus PR finalizes. And I'll work to "merge" this xsd workaround into those docs. Then, we can close this PR with a link to the better docs site as a reference.

@nmummau nmummau marked this pull request as draft April 10, 2026 05:12
nmummau added a commit to nmummau/MSBuild.Sdk.SqlProj that referenced this pull request Apr 13, 2026
@ErikEJ
Copy link
Copy Markdown
Collaborator

ErikEJ commented Apr 15, 2026

@nmummau Interested in following up on this using the new docs structure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants