Skip to content

Add BuildCheck for WriteLinesToFile without Overwrite - #14690

Open
iamhaseebn wants to merge 1 commit into
dotnet:mainfrom
iamhaseebn:fix-writelinestofile-overwrite-check
Open

Add BuildCheck for WriteLinesToFile without Overwrite#14690
iamhaseebn wants to merge 1 commit into
dotnet:mainfrom
iamhaseebn:fix-writelinestofile-overwrite-check

Conversation

@iamhaseebn

Copy link
Copy Markdown

Fixes #11927

Context

WriteLinesToFile defaults Overwrite to false, so repeated incremental builds can append duplicate content when Overwrite is omitted. This adds the proposed opt-in style check without changing existing build behavior.

Changes Made

  • Add opt-in built-in check BC0303 for WriteLinesToFile invocations that omit Overwrite.
  • Preserve invocations with explicit Overwrite="true" or Overwrite="false" and match MSBuild names case-insensitively.
  • Register the check and add resource strings and BuildCheck documentation.
  • Add focused coverage for omitted, explicit, and case-insensitive task and parameter names.

Testing

  • ./build.sh -v quiet - passed with zero warnings or errors.
  • All 7 focused WriteLinesToFileBuildCheck tests - passed.
  • Complete BuildCheck suite - 238 passed with zero failures and one expected Windows-only skip.
  • Bootstrap sample build, help output, and end-to-end BC0303 diagnostic verification - passed.

Notes

The check is opt-in, so existing builds are unaffected unless it is explicitly enabled.

@ViktorHofer

Copy link
Copy Markdown
Member

cc @baronfel in case you have an opinion here. @AR-May and I are OK with requiring to specify the Overwrite metadata under the assumption that this build check is not enabled by default.

@baronfel

Copy link
Copy Markdown
Member

Love it, thanks for the contribution!

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.

Warn about WriteLinesToFile default behavior which is Append

4 participants