dotnet-file-based-apps
Skill1 starsChanged 3 months agoApache-2.0View on GitHub
Use for .NET 10 file-based C# applications that run from a single .cs file without a traditional .csproj project file.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- glennawatson/CSharpAgentSkillstheir own version, first seen Oct 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- glennawatson/CSharpAgentSkills★ 3same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- aspnet-core-apiSkill
- aspnet-mvcSkill
- blazorSkill
- docker-dotnetSkill
- dotnet-expertSkill
- dotnet-messagingSkill
- dotnet-observabilitySkill
- dotnet-performanceSkill
- dotnet-testingSkill
- dotnet-version-guideSkill
- efcore-postgresqlSkill
- gitlab-basicsSkill
- gitlab-ci-dotnetSkill
- pandocSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
17 rules. About 0 are common, 17 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈17
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 24
Use for .NET 10 SDK file-based apps: scripts, command-line utilities, prototypes, small tools, one-off automation, and applications that …
- Distinctive: line 28
Do not use this model for a large multi-project solution, a service with complex build configuration, a shared library, or an application …
- Distinctive: line 47
Run it with an explicit file option:
- Distinctive: line 63
Place directives at the top of the C# file.
- Distinctive: line 71
Prefer explicit package versions.
- Distinctive: line 86
Do not place application statements before directives.
- Distinctive: line 104
Test trimming, reflection, serializers, dynamic loading, and platform-specific dependencies before relying on Native AOT.
- Distinctive: line 108
Use the SDK conversion command when the app needs a normal project structure:
- Distinctive: line 120
Use user secrets instead of source-controlled credentials:
- Distinctive: line 127
Never put real secrets in the source file or command history.
- Distinctive: line 146
Keep each independent file-based app in an isolated directory when it needs different build settings.
- Distinctive: line 147
Do not place a file-based app inside the directory cone of an unrelated .csproj.
- Distinctive: line 148
Keep included files and resources close to the entry file and document their role.
- Distinctive: line 149
Use a traditional project when tests, multiple executables, analyzers, packaging, or deployment settings become substantial.
- Distinctive: line 153
Verify SDK version, directives, package versions, implicit build files, restore, build, run arguments, publish output, Native AOT …
- Distinctive: line 167
Run it explicitly when the directory also contains a project:
- Distinctive: line 174
Keep package versions intentional and convert the file to a normal project when it needs tests, multiple source files, complex build …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
.NET File-Based Apps
When to Use
Use for .NET 10 SDK file-based apps: scripts, command-line utilities, prototypes, small tools, one-off automation, and applications that benefit from a single self-contained C# source file.
When Not to Use
Do not use this model for a large multi-project solution, a service with complex build configuration, a shared library, or an application that needs extensive IDE/project tooling. Convert it to a traditional project when the source, dependencies, tests, or deployment process outgrow one file.
Requirements
File-based apps require the .NET 10 SDK or later. Check the active SDK and repository-level global.json before using them:
dotnet --info
dotnet --list-sdksThe SDK creates a virtual project from the directives in the source file. A traditional .csproj is not required.
Minimal File
Console.WriteLine("Hello from a file-based app");Run it with an explicit file option:
dotnet run --file app.csThe shorthand forms are dotnet run app.cs and dotnet app.cs. If a project file exists in the current directory, prefer --file because dotnet run app.cs may run the existing project and pass app.cs as an application argument.
Pass arguments after the separator:
dotnet run --file app.cs -- input.json --verboseConfiguration Directives
Place directives at the top of the C# file. Supported directives are:
- #:package Package.Name@1.2.3 — add an explicit NuGet package reference;
- #:project ../Shared/Shared.csproj — reference another project;
- #:property TargetFramework=net10.0 — set an MSBuild property;
- #:sdk Microsoft.NET.Sdk.Web — select an SDK such as the web SDK;
- #:include helpers.cs — include additional source/resource files where supported by the SDK.
Prefer explicit package versions. A version can be omitted only when central package management is configured; otherwise use a version or the documented @* form.
Example:
#:
#:sdk Microsoft.NET.Sdk.Web
#:package Spectre.Console@0.49.1
#:property PublishAot=false
using Spectre.Console;
AnsiConsole.MarkupLine("[green]Ready[/]");Do not place application statements before directives. Included .cs files can add declarations, but cannot add another set of top-level statements.
Build, Publish, and Pack
dotnet restore app.cs
dotnet build app.cs --output ./build
dotnet publish app.cs --output ./publish
dotnet pack app.csNative AOT publishing and PackAsTool are enabled by default. Disable them explicitly when the application or dependency graph is not compatible:
#:property PublishAot=false
#:property PackAsTool=falseTest trimming, reflection, serializers, dynamic loading, and platform-specific dependencies before relying on Native AOT.
Convert to a Traditional Project
Use the SDK conversion command when the app needs a normal project structure:
dotnet project convert app.csThe command creates a copy and a .csproj with equivalent SDK items, properties, and package references. It leaves the original .cs file untouched. Review the generated project before committing it.
Configuration and Secrets
File-based apps respect global.json, Directory.Build.props, Directory.Build.targets, Directory.Packages.props, and nuget.config in their directory or parent directories. Isolate file-based apps from a nearby .csproj project when implicit settings could interfere.
Use user secrets instead of source-controlled credentials:
dotnet user-secrets set "ApiKey" "value" --file app.cs
dotnet user-secrets list --file app.csNever put real secrets in the source file or command history.
Launch Profiles
For app.cs, a flat app.run.json next to the source can define development profiles. A traditional Properties/launchSettings.json takes priority when both exist. Use launch profiles for local behavior, not production secrets.
Caching and Concurrency
The SDK caches file-based app build outputs under a temporary runfile directory. Changes to implicit build files or moving files can be confusing during development. If concurrent invocations contend for the same output, build once and run without rebuilding:
dotnet build app.cs
dotnet run app.cs --no-buildClear stale file-based caches with dotnet clean file-based-apps or clean the individual file before rebuilding.
Layout Rules
- Keep each independent file-based app in an isolated directory when it needs different build settings.
- Do not place a file-based app inside the directory cone of an unrelated .csproj.
- Keep included files and resources close to the entry file and document their role.
- Use a traditional project when tests, multiple executables, analyzers, packaging, or deployment settings become substantial.
Quality Gate
Verify SDK version, directives, package versions, implicit build files, restore, build, run arguments, publish output, Native AOT compatibility, secrets handling, cache behavior, and the conversion path to .csproj.
Official reference: https://learn.microsoft.com/en-us/dotnet/core/sdk/file-based-apps
Example: Single-File Utility
#:package Spectre.Console@0.49.1
using Spectre.Console;
AnsiConsole.MarkupLine("[green]File-based app started[/]");Run it explicitly when the directory also contains a project:
dotnet run --file tools/report.cs -- --input data.json
dotnet project convert tools/report.csKeep package versions intentional and convert the file to a normal project when it needs tests, multiple source files, complex build properties, or team-scale maintenance.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

