Skip to content

Document #:include support in file-based apps#53350

Open
Copilot wants to merge 16 commits into
mainfrom
copilot/update-file-based-apps-article
Open

Document #:include support in file-based apps#53350
Copilot wants to merge 16 commits into
mainfrom
copilot/update-file-based-apps-article

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

The file-based apps article was missing the new #:include directive introduced with .NET 11 Preview 3 and now available in .NET SDK 10.0.300. This update adds directive coverage and clarifies how included files participate in compilation.

  • Supported directives

    • Added #:include to the top-level list of supported file-based app directives.
  • New #:include directive section

    • Added dedicated documentation for #:include.
    • Added version availability note immediately under the #:include heading: .NET 11 Preview 3 and .NET SDK 10.0.300+.
    • Added syntax examples for:
      • Including files from the app root and subfolders.
      • Glob patterns (for example, shared/**/*.cs).
      • MSBuild-property-based paths (for example, $(MSBuildProjectName).*.cs).
  • Included item behavior clarification

    • Documented file type support and item mappings in .NET SDK 10.0.300:
      • *.cs -> Compile
      • *.resx -> EmbeddedResource
      • *.json -> None
      • *.razor -> Content
    • Clarified that included .cs files are compiled as part of the same app and can add declarations, but can't add top-level statements.
    • Documented that using glob patterns currently disables file-based app build caching.
    • Added a reference to MSBuild reserved and well-known properties.
#:include helpers.cs
#:include models/customer.cs
#:include shared/**/*.cs
#:include $(MSBuildProjectName).*.cs

Internal previews

📄 File 🔗 Preview link
docs/core/sdk/file-based-apps.md docs/core/sdk/file-based-apps

Internal previews

📄 File 🔗 Preview link
docs/core/sdk/file-based-apps.md docs/core/sdk/file-based-apps

Agent-Logs-Url: https://github.com/dotnet/docs/sessions/27329bc4-87c0-469b-b146-55d906707455

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copilot AI changed the title [WIP] Update article on file-based apps with include syntax Document #:include support in file-based apps Apr 22, 2026
Copilot AI requested a review from gewarren April 22, 2026 21:14
Comment thread docs/core/sdk/file-based-apps.md Outdated
Comment thread docs/core/sdk/file-based-apps.md Outdated
Comment thread docs/core/sdk/file-based-apps.md Outdated
@gewarren
Copy link
Copy Markdown
Contributor

@copilot Please respond to feedback.

Reordered the list of supported directives for clarity and moved the `#:project` section to a new position.
Removed duplicate section for the `#:include` directive in the documentation.
Comment thread docs/core/sdk/file-based-apps.md Outdated
@gewarren gewarren marked this pull request as ready for review April 22, 2026 22:03
@gewarren gewarren requested a review from a team as a code owner April 22, 2026 22:03
Copilot AI review requested due to automatic review settings April 22, 2026 22:03
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

Updates the file-based apps documentation to cover the newly supported #:include directive so developers can split a file-based app across multiple source files.

Changes:

  • Adds #:include to the supported directives list.
  • Adds a new #:include subsection with examples and an availability note.

Comment thread docs/core/sdk/file-based-apps.md Outdated
Copilot AI and others added 4 commits April 22, 2026 22:07
Agent-Logs-Url: https://github.com/dotnet/docs/sessions/a2dfc33b-80ca-4bce-a649-cb0f6ef97058

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/docs/sessions/a2dfc33b-80ca-4bce-a649-cb0f6ef97058

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 22, 2026

@copilot Please respond to feedback.

Done—feedback has been applied in 95713a7.

Copilot AI requested a review from gewarren April 22, 2026 22:10
@gewarren gewarren requested a review from adegeo April 28, 2026 17:57
Comment thread docs/core/sdk/file-based-apps.md Outdated
#:include models/customer.cs
```

The `#:include` directive is available in .NET 11 Preview 3 and .NET SDK 10.0.3xx and later.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should wait for this to actually land in 3xx. It might not, you never know.

Do you think it's a good idea to put this up front? Someone may get here, try it, find it not working, never see that paragraph and complain it doesn't work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should put this up front, yeah, immediately under the heading.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in 043d1cc. I moved the availability note directly under the #:include heading so readers see version support immediately.

@gewarren
Copy link
Copy Markdown
Contributor

Feature PR is closed, so abandoning this PR.

@gewarren gewarren closed this May 14, 2026
@DamianEdwards
Copy link
Copy Markdown
Member

This feature landed in 10.0.300 last week so reopening.

@DamianEdwards DamianEdwards reopened this May 17, 2026
Comment thread docs/core/sdk/file-based-apps.md Outdated

Includes another C# source file in the file-based app.

Included files compile as part of the same app. They can add types, top-level statements, and other declarations.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

included files can't add top-level statements, only the entry-point file can have top-level statements

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 043d1cc. I removed the top-level statements claim and updated the text to describe supported declarations in included .cs files.

Comment thread docs/core/sdk/file-based-apps.md Outdated

### `#:include`

Includes another C# source file in the file-based app.
Copy link
Copy Markdown
Member

@DamianEdwards DamianEdwards May 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#:include supports other file types, not just .cs. In .NET 10.0.300 it supports .cs, .resx, .json, and .razor, with each being mapped to the appropriate item type:

  • .cs -> Compile
  • .resx -> EmbeddedResource
  • .json -> None
  • .razor -> Content

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in 043d1cc. The section now documents *.cs, *.resx, *.json, and *.razor support, with their mapped item types.


```csharp
#:include helpers.cs
#:include models/customer.cs
Copy link
Copy Markdown
Member

@DamianEdwards DamianEdwards May 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path also supports globs, e.g. #:include shared/**/*.cs, but it's worth noting that globs will disable the build caching currently. Also you can use MSBuild properties too, e.g. #:include $(MSBuildProjectName).*.cs in an app.cs file will result in app.helpers.cs, etc. being included (maybe worth a link to https://learn.microsoft.com/visualstudio/msbuild/msbuild-reserved-and-well-known-properties).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in 043d1cc. I added examples for glob and MSBuild-property paths, and noted that glob patterns currently disable file-based app build caching, with an MSBuild properties link.

@gewarren
Copy link
Copy Markdown
Contributor

@copilot Please respond to all feedback.

Copilot AI and others added 5 commits May 18, 2026 16:00
Agent-Logs-Url: https://github.com/dotnet/docs/sessions/9e2da8dc-710b-4505-890e-2e264be1aa13

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/docs/sessions/9e2da8dc-710b-4505-890e-2e264be1aa13

Co-authored-by: gewarren <24882762+gewarren@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 18, 2026

@copilot Please respond to all feedback.

Done—I've applied and responded to the actionable feedback in 043d1cc and follow-up wording refinements through 261ed22.

Copilot AI and others added 2 commits May 18, 2026 16:03
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.

File-based apps can include other code files

5 participants