Skip to content

Style config sync overwrites repo-specific .gitattributes rules, and the only escape is opting out of all syncing #68

Open

Description

@matt-edmondson

What's wrong

_KtsuSyncStyleConfigFiles (Sdk/Sdk.targets, origin/main bafee81) copies the package's gitattributes over the consumer's root .gitattributes before every build. A rule a repository adds for its own file types is erased by the next build.

The only escape is <KtsuSyncStyleConfigFiles>false</KtsuSyncStyleConfigFiles>. That turns off syncing for .editorconfig, .gitignore, and .runsettings too, so a repository has to give up every shared default to keep one line.

Failure scenario

  1. ktsu-dev/ImageGui commits binary test fixtures with a custom extension (.imagegui, a zip archive).
  2. It adds *.imagegui binary to the root .gitattributes, so Git never normalizes line endings in them.
  3. The next dotnet build restores the SDK's copy and the rule is gone. The fixtures are safe only because Git's text=auto detection happens to see NUL bytes in them.

ImageGui now keeps the rule in tests/.gitattributes to survive the sync (ktsu-dev/ImageGui#50). That works for this case, but it hides a repository-wide rule in a subfolder.

The same problem applies to .gitignore and .editorconfig additions.

Suggested fix

Let a repository extend each synced file instead of replacing it. For example:

  • Keep a marked section that the sync preserves, such as everything below a # --- repo-specific --- comment.
  • Or append a sibling file such as .gitattributes.local (or .gitignore.local) to the synced file.

A per-file opt-out (for example KtsuSyncGitAttributes=false) would be a smaller improvement, since it at least keeps the other shared defaults.

Acceptance criteria

  • A repository can add its own .gitattributes rules at the root, and they survive a build.
  • The SDK's shared rules still update when the package changes.
  • The README's "Style/config file sync" section documents how to extend a synced file.

Activity

  1. matt-edmondson commented on Sep 30, 2026

    @matt-edmondson
    ContributorAuthor

    Triage

    • Category: Improvement
    • Priority: Medium. Every build erases repo-specific rules from the synced .gitattributes, .gitignore and .editorconfig. The only escape turns off syncing for all four files. ImageGui has already had to move a repository-wide rule into a subfolder to work around it (ktsu-dev/ImageGui#50). There is a workaround, so this isn't High.
    • Area / suggested assignment: Sdk/Sdk.targets, the _KtsuSyncStyleConfigFiles target, plus the README's "Style/config file sync" section. A per-file opt-out is a small first step. The .local sibling-file merge is the fuller fix, and it needs a design decision on the convention before any code is written.
    • Duplicates: none. Related: After a build is killed mid-sync, other MSBuild nodes wait 120 s on every style-config sync #65 (MSBuild nodes wait 120 s after a killed sync), which is in the same target but is a different defect.
    • In progress: no matching open PR.

    Generated by Claude Code

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions