Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions docs/core/sdk/file-based-apps.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: File-based apps
description: Learn how to create, build, and run C# applications from a single file without a project file.
ms.date: 12/05/2025
ms.date: 04/22/2026
ai-usage: ai-assisted
---
# File-based apps
Expand All @@ -21,7 +21,32 @@ In this article, learn how to create, configure, and work with file-based apps e

## Supported directives

File-based apps use directives prefixed with `#:` to configure the build and run the application. Supported directives include: `#:package`, `#:project`, `#:property`, and `#:sdk`. Place these directives at the top of the C# file.
File-based apps use directives prefixed with `#:` to configure the build and run the application. Supported directives are: `#:include`, `#:package`, `#:project`, `#:property`, and `#:sdk`. Place these directives at the top of the C# file.

### `#:include`

> [!NOTE]
> This directive is available in .NET 11 Preview 3 and .NET SDK 10.0.300 and later.

Includes another file in the file-based app.

The SDK maps included files to item types based on file extension:

- `*.cs` to `Compile`
- `*.resx` to `EmbeddedResource`
- `*.json` to `None`
- `*.razor` to `Content`

The compiler includes `.cs` files as part of app compilation. These files can add types, methods, namespaces, and other declarations, but they cannot add top-level statements.

```csharp
#:include helpers.cs
#:include models/customer.cs
Comment thread
gewarren marked this conversation as resolved.
#:include shared/**/*.cs
#:include $(MSBuildProjectName).*.cs
```

The `#:include` directive supports literal paths, glob patterns, and MSBuild properties. When you use glob patterns, file-based app build caching is currently disabled. For more information about available properties, see [MSBuild reserved and well-known properties](/visualstudio/msbuild/msbuild-reserved-and-well-known-properties).

### `#:package`

Expand Down
Loading