Skip to content

Publish XML documentation during optimized Native AOT builds - #56620

Merged
marcpopMSFT merged 2 commits into
release/11.0.1xxfrom
copilot/110-rc2-fix-native-aot-publish-error
Oct 19, 2026
Merged

marcpopMSFT merged 2 commits into
release/11.0.1xxfrom
copilot/110-rc2-fix-native-aot-publish-error

Conversation

Copilot AI commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Native AOT publish can fail with MSB3030 when GenerateDocumentationFile is enabled: optimized publish skips the Build step that copies the XML file to bin, but publish expects it there.

  • Publish targets: Use the compiler-generated DocFileItem as the XML source for optimized AOT publish; preserve FinalDocFile for regular publish.
  • Regression coverage: Verify AOT publish includes the generated XML documentation without producing managed build files in bin.
<PropertyGroup>
  <PublishAot>true</PublishAot>
  <GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

Tactics

Summary

Optimized (UseOptimizedPublish) Native AOT publish skips the Build step that copies the compiler-generated XML documentation file to bin, but the publish targets still expected it there, causing MSB3030. The fix in Microsoft.NET.Publish.targets uses the compiler-generated DocFileItem (intermediate output) as the XML source for optimized AOT publish, and keeps FinalDocFile for regular publish. This is a small, targeted fix for a regression that breaks AOT publish when GenerateDocumentationFile is enabled.

Customer Impact

Publishing a PublishAot project with GenerateDocumentationFile=true fails with error MSB3030: Could not copy the file ".../bin/.../API.xml" because it was not found (reported in #56618 on 11.0.100-rc.2). Any AOT project generating documentation is affected. Workaround: set <UseOptimizedPublish>false</UseOptimizedPublish>.

Regression?

Yes, introduced in .NET 11 RC.1 by #54515 (per #56618).

Testing

Adds assertions (3 lines) to GivenThatWeWantToPublishAnAotApp covering AOT publish with generated XML docs, verifying the XML is published without managed build files in bin. Reviewed and approved by baronfel; Copilot review found no issues. CI pipelines were triggered; no manual or private validation is documented in the PR.

Risk

Low. Change is ~9 added/1 removed lines in one targets file, scoped to the optimized AOT publish path, with regular publish unchanged and regression test coverage.

@azure-pipelines

azure-pipelines Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
2 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix native AOT publish failure with documentation file Publish XML documentation during optimized Native AOT builds Oct 13, 2026
Copilot AI requested a review from marcpopMSFT October 13, 2026 21:44
@marcpopMSFT
marcpopMSFT marked this pull request as ready for review October 14, 2026 00:09
@marcpopMSFT
marcpopMSFT requested review from a team as code owners October 14, 2026 00:09
Copilot AI balanced review requested due to automatic review settings October 14, 2026 00:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The targeted fix preserves existing behavior and includes scenario-accurate regression coverage.

0 open findings

What changed in this PR

Fixes optimized Native AOT publishing so generated XML documentation is sourced from compiler output.

Changes:

  • Uses DocFileItem for optimized publish while preserving regular publish behavior.
  • Adds regression coverage verifying XML publication without managed bin artifacts.
File Description
Microsoft.NET.Publish.targets Selects the correct XML documentation source.
GivenThatWeWantToPublishAnAotApp.cs Covers the failing Native AOT scenario.

🧠 Review effort: Balanced

@marcpopMSFT

Copy link
Copy Markdown
Member

@baronfel the difference in those items:
image

@marcpopMSFT

Copy link
Copy Markdown
Member

/tactics

@marcpopMSFT
marcpopMSFT merged commit 18fba1e into release/11.0.1xx Oct 19, 2026
24 checks passed
@marcpopMSFT
marcpopMSFT deleted the copilot/110-rc2-fix-native-aot-publish-error branch October 19, 2026 15:30
mgravell added a commit to protobuf-net/protobuf-net that referenced this pull request Oct 21, 2026
…1377)

Main CI has been red since 2026-10-19, failing in `native-aot-linux` →
"Publish and run the gRPC smoke test":

```
error MSB3030: Could not copy the file "bin/Release/net8.0/linux-x64/AotGrpcSmoke.xml" because it was not found.
```

Nothing in the repo caused it - the first failing run was a docs-only
commit. The `11.0.x` channel in setup-dotnet rolled from 11.0.100-rc.1
(last green run, Oct 13) to 11.0.100-rc.2, which has a known regression:
a native-AOT publish fails with MSB3030 when XML documentation
generation is enabled (dotnet/sdk#56618, minimal repro in
dotnet/sdk#56653; fix proposed upstream in dotnet/sdk#56620 but not in
any released SDK).

`src/Directory.Build.props` turns `GenerateDocumentationFile` on for
every Release build, and AotGrpcSmoke was the one natively-published
project without the opt-out every other smoke/test project already has.
AotSmoke publishes identically on the same rc.2 SDK and passes *because*
it opts out, so the same run that found the bug also proved the fix. A
smoke exe was never meant to ship API docs anyway - the dozen CS1591
"missing XML comment" warnings on `Contracts.cs` go away with it.

One line plus a comment recording why, so it survives the rc.2 bug being
fixed upstream.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[11.0-rc.2] Native AOT publish fails with MSB3030 for the XML documentation file when GenerateDocumentationFile is true

4 participants