# Dotnet Runfile

> How to use the .NET 10 `dotnet run app.cs` feature. Use this skill when you need to run an existing single-file C# script, create a new C# script, run an ad-hoc C# script (e.g. to test the behavior of a C# snippet), or work on an existing C# script already in the repo. Covers how to run C# scripts and their syntax. Use when this capability is needed.

- Skill: `tomevault-io/dotnet-runfile` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add tomevault-io/dotnet-runfile`
- Raw SKILL.md: https://api.skillmd.com/api/skills/tomevault-io/dotnet-runfile/raw
- Safety review: pending (external: skill-scanner PASS, skillspector PASS)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: tomevault-io (https://skillmd.com/u/tomevault-io)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/tomevault-io/dotnet-runfile

---


# dotnet run app.cs

Run C# files directly without `.csproj` project files. Requires .NET 10 (SpeedReader uses .NET 10, so this should already be installed).

```bash
dotnet run hello.cs
```

## Usage Examples

```csharp
#!/usr/bin/env dotnet run           // shebang (unix)
#:sdk Microsoft.NET.Sdk             // sdk (default; also .Web, .Worker)
#:package Humanizer@2.14.1          // nuget package (version required, wildcards ok)
#:property LangVersion=preview      // msbuild property
#:project ../src/MyLibrary          // project reference

Console.WriteLine("Hello, World!");
```

```bash
dotnet run hello.cs                   # run
dotnet run hello.cs -- arg1 arg2      # run with args
chmod +x hello.cs && ./hello.cs       # run via shebang
cat hello.cs | dotnet run -           # run from stdin
dotnet publish hello.cs -c Release    # publish
dotnet project convert hello.cs       # convert to full project w/ csproj
```

## Shared Configuration

Share settings across multiple single-file apps by placing a `Directory.Build.props` file in the same or parent directory:

```xml
<Project>
  <PropertyGroup>
    <LangVersion>preview</LangVersion>
    <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
  </ItemGroup>
</Project>
```

All `.cs` files in that directory tree inherit these settings.

---
> Converted and distributed by [TomeVault](https://tomevault.io/claim/j-r-beckett) — claim your Tome and manage your conversions.
<!-- tomevault:4.0:skill_md:2026-04-11 -->

