Fix PublishSingleFile failure when GenerateDocumentationFile=true and CopyDocumentationFileToOutputDirectory=false#53156
Open
Fix PublishSingleFile failure when GenerateDocumentationFile=true and CopyDocumentationFileToOutputDirectory=false#53156
Conversation
…tory=false When GenerateDocumentationFile=true and CopyDocumentationFileToOutputDirectory=false, the XML doc file is never copied to the output (bin/) directory. However, the ResolvedFileToPublish item group was using @(FinalDocFile) which points to the bin/ path, causing GenerateBundle to throw FileNotFoundException. Fix: add CopyDocumentationFileToOutputDirectory != false condition, mirroring how PDB files gate on CopyOutputSymbolsToPublishDirectory. Also adds a regression test in GivenThatWeWantToPublishASingleFileApp. Co-authored-by: baronfel <573979+baronfel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix PublishSingleFile publish failure with XML docs
Fix PublishSingleFile failure when GenerateDocumentationFile=true and CopyDocumentationFileToOutputDirectory=false
Feb 25, 2026
baronfel
approved these changes
Feb 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a FileNotFoundException that occurs during PublishSingleFile when GenerateDocumentationFile=true and CopyDocumentationFileToOutputDirectory=false. The issue was that the XML documentation file was being added to the publish list even though it was never copied to the output directory.
Changes:
- Added a condition check in
Microsoft.NET.Publish.targetsto prevent adding XML doc files to the publish list whenCopyDocumentationFileToOutputDirectory=false - Added a regression test to verify the fix works correctly with
PublishSingleFile
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Publish.targets |
Added CopyDocumentationFileToOutputDirectory != 'false' condition to prevent FileNotFoundException when XML docs are generated but not copied to output |
test/Microsoft.NET.Publish.Tests/GivenThatWeWantToPublishASingleFileApp.cs |
Added regression test verifying PublishSingleFile succeeds when GenerateDocumentationFile=true and CopyDocumentationFileToOutputDirectory=false |
MiYanni
approved these changes
Feb 25, 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.
When
GenerateDocumentationFile=trueandCopyDocumentationFileToOutputDirectory=false, the XML doc file is never written to thebin/output directory. However,ComputeResolvedFilesToPublishListwas unconditionally adding it toResolvedFileToPublishvia@(FinalDocFile)(which resolves to thebin/path), causingGenerateBundleto throwFileNotFoundExceptionduringPublishSingleFile.Changes
Microsoft.NET.Publish.targets: Add'$(CopyDocumentationFileToOutputDirectory)' != 'false'to the condition guarding the XML doc file entry inResolvedFileToPublish, mirroring how PDB publishing already gates on$(CopyOutputSymbolsToPublishDirectory):GivenThatWeWantToPublishASingleFileApp.cs: Add regression testIt_succeeds_when_xml_docs_generated_but_not_copied_to_outputcovering theGenerateDocumentationFile=true+CopyDocumentationFileToOutputDirectory=false+PublishSingleFile=truecombination.Original prompt
This section details on the original issue you should resolve
<issue_title>PublishSingleFile publish fails when XML docs are generated but not copied to the output directory</issue_title>
<issue_description>### Describe the bug
dotnet publishfails whenGenerateDocumentationFileandPublishSingleFileare set to true whileCopyDocumentationFileToOutputDirectoryis set to false.To Reproduce
dotnet publishFurther technical details
details of dotnet --info
.NET SDK: Version: 10.0.100 Commit: b0f34d51fc Workload version: 10.0.100-manifests.5fb86115 MSBuild version: 18.0.2+b0f34d51f
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\10.0.100\
.NET workloads installed:
There are no installed workloads to display.
Configured to use workload sets when installing new manifests.
No workload sets are installed. Run "dotnet workload restore" to install a workload set.
Host:
Version: 10.0.0
Architecture: x64
Commit: b0f34d51fc
.NET SDKs installed:
9.0.112 [C:\Program Files\dotnet\sdk]
10.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 9.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 10.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
DOTNET_CLI_UI_LANGUAGE [en-US]
DOTNET_GCHeapCo...
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.