Skip to content

Fix gitattributes template missing from source-built distributions#53062

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/fix-dotnet-new-gitattributes
Draft

Fix gitattributes template missing from source-built distributions#53062
Copilot wants to merge 3 commits intomainfrom
copilot/fix-dotnet-new-gitattributes

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

The .gitattributes template content file contains export-ignore rules that cause it to exclude itself from git archives due to attribute precedence (file-level rules override repo root). Source-built distributions (Fedora, NixPkgs) use git archive and were missing this file.

Changes

  • Renamed template content file: .gitattributesgitattributes_file
  • Added sources.rename configuration in template.json to restore .gitattributes name on instantiation
  • Added test coverage for both template aliases (gitattributes and .gitattributes)

The renamed file bypasses git attribute processing during archive creation while the template engine handles the rename at instantiation time.

{
  "sources": [
    {
      "rename": {
        "gitattributes_file": ".gitattributes"
      }
    }
  ]
}
Original prompt

This section details on the original issue you should resolve

<issue_title>[10.0.101]dotnet new gitattributes emits no file</issue_title>
<issue_description><!--
Please keep in mind that the GitHub issue tracker is not intended as a general support forum, but for reporting non-security bugs and feature requests.

If you believe you have an issue that affects the SECURITY of the platform, please do NOT create an issue and instead email your issue details to secure@microsoft.com. Your report may be eligible for our bug bounty but ONLY if it is reported through email.
For other types of questions, consider using StackOverflow.

-->

Describe the bug

No file was created after dotnet new gitattributes

To Reproduce

$ dotnet --version
10.0.101
$ dotnet new gitattributes
The template "dotnet gitattributes file" was created successfully.
$ # .gitattributes is not created

Exceptions (if any)

Further technical details

details of dotnet --info

$ dotnet --info
.NET SDK:
 Version:           10.0.101
 Commit:            fad253f51b
 Workload version:  10.0.100-manifests.1773493e
 MSBuild version:   18.0.6+fad253f51

Runtime Environment:
 OS Name:     nixos
 OS Version:  26.05
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /nix/store/qjcwx5f3gbm9h3wnlqrqiyr8q8mic2yl-dotnet-sdk-10.0.101/share/dotnet/sdk/10.0.101/

.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.1
  Architecture: x64
  Commit:       fad253f51b

.NET SDKs installed:
  9.0.308 [/nix/store/539cpwjk23lbgngmg9v14bgh2bbjc5ib-dotnet-combined/share/dotnet/sdk]
  10.0.101 [/nix/store/539cpwjk23lbgngmg9v14bgh2bbjc5ib-dotnet-combined/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.11 [/nix/store/539cpwjk23lbgngmg9v14bgh2bbjc5ib-dotnet-combined/share/dotnet/shared/Microsoft.AspNetCore
.App]
  Microsoft.AspNetCore.App 10.0.1 [/nix/store/539cpwjk23lbgngmg9v14bgh2bbjc5ib-dotnet-combined/share/dotnet/shared/Microsoft.AspNetCore
.App]
  Microsoft.NETCore.App 9.0.11 [/nix/store/539cpwjk23lbgngmg9v14bgh2bbjc5ib-dotnet-combined/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 10.0.1 [/nix/store/539cpwjk23lbgngmg9v14bgh2bbjc5ib-dotnet-combined/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  DOTNET_PATH                              [/nix/store/13bsw2xj251zn5b96a19f2y54l62gc30-dotnet-wrapped-combined/bin/dotnet]
  DOTNET_ROOT                              [/nix/store/13bsw2xj251zn5b96a19f2y54l62gc30-dotnet-wrapped-combined/share/dotnet]

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
- The IDE (VS / VS Code/ VS4Mac) you're running on, and its version

<agent_instructions>The gitattributes content file needs to be renamed away from .gitattributes, and in the template.json for that template we need to use a name transform to ensure that the generated file is called .gitattributes.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@marcpopMSFT Didn't repro for me on windows. Linux only issue? @marcpopMSFT Triage: We tried this on ubuntu and it did make the file. Are you running `ls -la` or `ls .gitattributes` to show hidden files as that file is hidden by default on non-windows so maybe it's there but you can't see it? @baronfel It looks like we added this gitattributes template only in 10.0.100, so not having it on 9.0.xxx makes sense to me. @marcpopMSFT Triage: The original issue report said you were using 10.0.101 but later you said the official tar.gz install worked. What install of the .NET SDK are you seeing this not work on? Sounds like it's a product construction issue rather than SDK issue if it works in one version of 10.0.101 but not a different version. @marcpopMSFT Triage: This is likely some ...

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 17, 2026 21:37
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.

[10.0.101]dotnet new gitattributes emits no file

2 participants