Skip to content

Fix repeat builds with persisted source-generated files#27115

Open
powercode wants to merge 1 commit intoPowerShell:masterfrom
powercode:fix_sourcegen
Open

Fix repeat builds with persisted source-generated files#27115
powercode wants to merge 1 commit intoPowerShell:masterfrom
powercode:fix_sourcegen

Conversation

@powercode
Copy link
Copy Markdown
Collaborator

@powercode powercode commented Mar 28, 2026

PR Summary

Remove the removal of existing generated files by source generators to allow persisted generator output to remain visible on disk without compiling it as project source.

PR Context

This change addresses issues with repeat builds by ensuring that source-generated files are not deleted at the start of the build process, thus maintaining their availability for subsequent builds.

PR Checklist

Copilot AI review requested due to automatic review settings March 28, 2026 20:39
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

This PR adjusts the build configuration so source-generator emitted files can persist on disk across builds without being treated as project source, addressing issues seen on repeat builds.

Changes:

  • Stop deleting gen\SourceGenerated at the start of the build (removes RemoveDir from the early build target).
  • Explicitly exclude gen\SourceGenerated\**\*.cs from compilation in System.Management.Automation.csproj.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/System.Management.Automation/System.Management.Automation.csproj Excludes persisted source-generator output under gen\SourceGenerated from Compile items to prevent it from being compiled as project source.
PowerShell.Common.props Removes the build-time deletion of gen\SourceGenerated, allowing generator output to persist across builds.

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.

2 participants