csharp-scripts

Runs file-based C# apps with the .NET CLI without creating a project.

1|Updated Jun 1, 2026
One-click install
npx skills add https://github.com/D1ssolve/craft-agents --skill csharp-scripts-d1ssolve
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: csharp-scripts
Source: https://github.com/D1ssolve/craft-agents/tree/main/skills/csharp-scripts
Command: npx skills add https://github.com/D1ssolve/craft-agents --skill csharp-scripts-d1ssolve

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing and running quick C# experiments normally requires scaffolding a full project with a .csproj file, which adds overhead for one-off tests, API explorations, and small utilities. This Skill lets you run single-file or small multi-file C# apps directly with the .NET CLI, no project file needed. ## Core Features & Use Cases - File-based app execution: Run a single .cs file with top-level statements using dotnet hello.cs, with cached builds for fast reruns. - Inline directives: Add NuGet packages (#:package), MSBuild properties (#:property), project references (#:project), SDK selection (#:sdk), and multi-file composition (#:include/#:exclude/#:ref) directly in the source file. - Version-aware fallbacks: Detects the installed SDK and falls back to a temporary console project on .NET 9 and earlier. - Use Case: You want to test how System.Text.Json source generation behaves under native AOT. Write one .cs file with a JsonSerializerContext, run it with dotnet file.cs, and delete it when done—no project scaffolding required. ## Quick Start Ask the AI to write and run a quick file-based C# app that tests a specific API or language feature without creating a project.

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, write a .cs file using top-level statements and run it with `dotnet hello.cs`. The CLI builds and runs the file automatically, caching the build so subsequent runs are fast.

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

Add a `#:package` directive at the top of the file, before any using directives, with an explicit version such as `#:package [email protected]`. Use `@*` for the latest version or `@*-*` to include pre-release versions.

Does file-based C# work on .NET 9 or earlier?

No, file-based apps require .NET SDK 10 or later, and multi-file directives like #:include require SDK 10.0.300 or later. On older SDKs, create a temporary console project with `dotnet new console` and run it with `dotnet run` instead.

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

File-based apps enable native AOT by default, so reflection-based serialization like `JsonSerializer.Serialize<T>(value)` fails at runtime. Use source-generated serialization with a `JsonSerializerContext` partial class annotated with `[JsonSerializable]`.

When should I use #:ref instead of #:include in C# file-based apps?

Use `#:include` for helper files that should compile into the same assembly as the entry point. Use `#:ref` when the referenced file should compile as a separate project-like assembly, and set `#:property OutputType=Library` in that file if it has no top-level statements.

When should I convert a file-based C# app to a full project?

Convert when the app needs build customization, tests, publish configuration, or integration into an existing solution. Run `dotnet project convert hello.cs` to generate a full project from the file-based app.