csharp-scripts

Run single-file C# programs as scripts using .NET file-based apps.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing and testing a small C# program normally requires creating a full project with a .csproj file, boilerplate structure, and build configuration. This Skill lets you run a single .cs file directly with the dotnet CLI, making quick experimentation, prototyping, and concept testing fast and friction-free. ## Core Features & Use Cases - File-Based App Execution: Run a single .cs file with top-level statements using dotnet hello.cs, with automatic build caching for fast subsequent runs. - NuGet Package References: Add packages inline with the #:package PackageName@Version directive, no project file needed. - AOT-Safe JSON Serialization: Guidance for source-generated JSON with JsonSerializerContext, since file-based apps enable native AOT by default. - Fallback for Older SDKs: A temporary console project workflow for .NET 9 and earlier, plus a conversion path to a full project via dotnet project convert. - Use Case: You want to verify how a LINQ query or a new API behaves. Write a 10-line .cs file, run it with dotnet file.cs, inspect the output, and delete the file when done. ## Quick Start Ask the AI to write and run a single-file C# script that demonstrates the concept or logic you want to test.

Frequently Asked Questions about csharp-scripts

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

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

With .NET 10 or later, run a single .cs file directly using `dotnet hello.cs`. The file uses top-level statements with no Main method or class boilerplate, and builds are cached so subsequent runs are fast.

How do I add NuGet packages to a C# script file?▼

Add a `#:package` directive at the top of the file with an explicit version, such as `#:package Humanizer@2.14.1`. You can also use `@*` for the latest version, then add normal using directives below it.

Does dotnet run file.cs work on .NET 8 or .NET 9?▼

No, file-based apps require .NET 10 or later. On older SDKs, create a temporary console project with `dotnet new console`, replace Program.cs with your script, and run it with `dotnet run`.

Why does JsonSerializer fail in a C# file-based app?▼

File-based apps enable native AOT by default, so reflection-based JsonSerializer calls fail at runtime. Use source-generated serialization by defining a partial JsonSerializerContext class annotated with JsonSerializable attributes.

When should I convert a C# script to a full project?▼

Convert when the program outgrows a single file, needs multiple files or project references, or must integrate into an existing solution. Run `dotnet project convert hello.cs` to generate a full project from the script.