csharp-scripts

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

Updated Jul 2, 2026
One-click install
npx skills add https://github.com/ecoDriverltd/FoundryAgentsExperiment --skill csharp-scripts-ecodriverltd
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: csharp-scripts
Source: https://github.com/ecoDriverltd/FoundryAgentsExperiment/tree/main/.agents/skills/csharp-scripts
Command: npx skills add https://github.com/ecoDriverltd/FoundryAgentsExperiment --skill csharp-scripts-ecodriverltd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing and running quick C# experiments traditionally requires creating a full project with a .csproj file, which adds overhead for simple tests, prototypes, and one-off utilities. This Skill lets you run single-file or small multi-file C# apps directly with the .NET CLI, skipping project scaffolding entirely. ## Core Features & Use Cases - File-Based App Execution: Run a single .cs file with top-level statements using dotnet hello.cs, with support for NuGet packages, MSBuild properties, and SDK selection via #: directives. - Multi-File Composition: Compose small apps from multiple files using #:include/#:exclude, or link separate file-based apps across assembly boundaries with #:ref. - Version-Aware Fallbacks: Detects the installed SDK version 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 directly, and clean up afterward without ever creating a project. ## Quick Start Ask the AI to write and run a file-based C# app that tests the C# concept or API you want to try.

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?▼

Use file-based apps in .NET 10 or later by running `dotnet hello.cs` directly on a .cs file with top-level statements. The CLI builds and runs the file automatically, caching the build so subsequent runs are fast.

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

Add a `#:package` directive at the top of the file, before any using directives, with a version such as `#:package Humanizer@2.14.1`. 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 my file-based C# app fail to compile helper files?▼

Helper .cs files are not compiled automatically; the entry-point file must reference them with `#:include Helpers.cs` or a glob pattern. Check that your SDK is 10.0.300 or later, since earlier 10.0.x builds do not support include directives.

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

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

When should I convert a file-based 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 standard project from the file-based app.