dotnet-file-based-apps

Build, run, and publish C# applications from a single .cs file using .NET 10 SDK directives.

Updated Mar 8, 2026
One-click install
npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill dotnet-file-based-apps-agibuild
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dotnet-file-based-apps
Source: https://github.com/AGIBuild/dotnet.CI.template/tree/main/.cursor/skills/dotnet-file-based-apps
Command: npx skills add https://github.com/AGIBuild/dotnet.CI.template --skill dotnet-file-based-apps-agibuild

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Traditional .NET development requires creating a .csproj project file even for small scripts and utilities, adding scaffolding overhead. This Skill explains how to run C# applications directly from a single .cs file using the .NET 10 SDK's file-based apps feature, with no project file required. ## Core Features & Use Cases - Directive Configuration: Configure builds inline with #:package, #:sdk, #:property, and #:project directives placed at the top of the source file. - Full CLI Workflow: Run, build, clean, publish, pack, and restore file-based apps using familiar dotnet CLI commands, including stdin piping and Unix shebang execution. - Migration Path: Convert a file-based app to a traditional project with dotnet project convert when it outgrows a single file. - Use Case: Write a one-off utility script that needs a NuGet package like Spectre.Console, add #:package Spectre.Console at the top, and run it immediately with dotnet run app.cs without creating any project scaffolding. ## Quick Start Ask the AI to create a single-file C# script that uses a NuGet package and run it with dotnet run without creating a project file.

Frequently Asked Questions about dotnet-file-based-apps

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run a C# file without a project file?▼

With the .NET 10 SDK, pass the file directly to the CLI: dotnet run app.cs. The SDK auto-generates project configuration from #: directives at the top of the file, so no .csproj is needed. You can also use the shorthand dotnet app.cs.

How do I add a NuGet package to a file-based C# app?▼

Add a #:package directive at the top of the .cs file, such as #:package Serilog@3.1.1. Use @* for the latest stable version, or omit the version only when Central Package Management is configured via Directory.Packages.props.

Does dotnet test work with file-based apps?▼

No, dotnet test does not apply to file-based apps. While dotnet build app.cs compiles via a virtual project, test framework support requires converting to a traditional project with dotnet project convert app.cs.

Why does my C# script fail with '/usr/bin/env: dotnet\r: No such file or directory'?▼

This error occurs when a file-based app with a Unix shebang uses CRLF line endings or includes a BOM. Convert the file to LF line endings and remove the BOM, then run chmod +x app.cs and execute it directly.

When should I convert a file-based app to a project?▼

Convert when you need multiple source files, complex MSBuild customization beyond #:property, dotnet test support, CI/CD integration expecting a .csproj, or IDE project features. Run dotnet project convert app.cs to generate the project automatically.

Can I run multiple instances of the same file-based app concurrently?▼

Concurrent execution of the same file-based app can cause build output contention errors. Build first with dotnet build app.cs, then run multiple instances using dotnet run app.cs --no-build.