[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6DYRC6CESQCWVHMV4VNMCCR":3,"skill-same:01M6DYRC6CESQCWVHMV4VNMCCR":83},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":23,"publishedAt":48,"linkOnly":49,"markdownContent":50,"markdownBody":51,"frontMatter":52,"refName":53,"commitSha":54,"skillDirectory":55,"forksCount":56,"repositoryHtmlUrl":57,"repositoryHomepageUrl":58,"ownerHtmlUrl":59,"ownerBlogUrl":60,"ownerDescription":61,"updatedAt":62,"install":63,"resources":76},"01M6DYRC6CESQCWVHMV4VNMCCR","csharp-scripts",null,"Run file-based C# apps with the .NET CLI when the user explicitly wants C#\u002F.NET code without creating a project. Use for C# language\u002FAPI experiments, one-file C# apps, small multi-file C# apps composed with `#:include`\u002F`#:exclude`, or C# file-based apps linked with `#:ref`. Do not use for language-agnostic throwaway scripts, generic computations, Python\u002FPowerShell-style automation, full projects, or existing app integration.","managedcode\u002Fdotnet-skills","managedcode","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F78253589?v=4","01M6DYDJR3EG8KB5G4PC65XCTT","Managed Code","01M6DYDJX0ZT432N04NYJW89DN",515,"MIT","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FPlatform\u002FOfficial-DotNet-Advanced\u002Fskills\u002Fcsharp-scripts\u002FSKILL.md",[18],{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000030","开发工程师","PROFESSION","适用职业",[24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47],"csharp","csharp scripts","scripts","do","when","generic","throwaway","for","style","apps","app","full","project","cli","use","projects","api","powershell","file","code","run","experiments","automation","python","2026-11-10 10:12:30",false,"---\nname: csharp-scripts\ndescription: \"Run file-based C# apps with the .NET CLI when the user explicitly wants C#\u002F.NET code without creating a project. Use for C# language\u002FAPI experiments, one-file C# apps, small multi-file C# apps composed with `#:include`\u002F`#:exclude`, or C# file-based apps linked with `#:ref`. Do not use for language-agnostic throwaway scripts, generic computations, Python\u002FPowerShell-style automation, full projects, or existing app integration.\"\nlicense: MIT\n---\n\n# File-Based C# Apps\n\n## When to Use\n\n- Testing a C# concept, API, or language feature with a quick file-based app\n- Prototyping logic before integrating it into a larger project\n- Building a small utility from one entry-point file and a few helper `.cs` files\n\n## When Not to Use\n\n- The user asks for a language-agnostic quick script, throwaway computation, or shell\u002FPython\u002FPowerShell-style automation\n- The user needs a full project, solution integration, or project references in an existing app\n- The user is working inside an existing .NET solution and wants to add code there\n- The app is large enough that project structure, build customization, tests, or publish configuration should live in a `.csproj`\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| C# code or intent | Yes | The code to run, or a description of what the file-based app should do |\n\n## Workflow\n\n### Step 1: Check the .NET SDK version\n\nRun `dotnet --version` to verify the SDK is installed and note the full version, including the feature band. File-based apps require .NET 10 or later. `#:include`, `#:exclude`, and transitive directive processing require SDK 10.0.300 or later; SDK 10.0.100\u002F10.0.200 builds can run single-file apps but do not support those multi-file directives. If the version is below 10, follow the [fallback for older SDKs](#fallback-for-net-9-and-earlier) instead.\n\n### Step 2: Write the app file\n\nCreate an entry-point `.cs` file using top-level statements. Place it outside any existing project directory to avoid conflicts with `.csproj` files.\n\n```csharp\n#!\u002Fusr\u002Fbin\u002Fenv dotnet\n\u002F\u002F hello.cs\nConsole.WriteLine(\"Hello from a file-based app!\");\n\nvar numbers = new[] { 1, 2, 3, 4, 5 };\nConsole.WriteLine($\"Sum: {numbers.Sum()}\");\n```\n\nGuidelines:\n\n- Use top-level statements (no `Main` method, class, or namespace boilerplate)\n- Place `using` directives at the top of the file (after the `#!` line and any `#:` directives if present)\n- Place type declarations (classes, records, enums) after all top-level statements\n\n### Step 3: Run the app\n\n```bash\ndotnet hello.cs\n```\n\nBuilds and runs the file automatically. Cached so subsequent runs are fast. Pass arguments after `--`:\n\n```bash\ndotnet hello.cs -- arg1 arg2 \"multi word arg\"\n```\n\n### Step 4: Add directives (if needed)\n\nPlace directives at the top of the file (immediately after an optional shebang line), before any `using` directives or other C# code. All directives start with `#:`.\n\n#### `#:package` — NuGet package references\n\nSpecify a version unless the app intentionally uses central package management. Use `@*` when the latest available package is acceptable (or `@*-*` for pre-release):\n\n```csharp\n#:package Humanizer@2.14.1\n\nusing Humanizer;\n\nConsole.WriteLine(\"hello world\".Titleize());\n```\n\n#### `#:property` — MSBuild properties\n\nSet any MSBuild property inline. Syntax: `#:property PropertyName=Value`\n\n```csharp\n#:property AllowUnsafeBlocks=true\n#:property PublishAot=false\n#:property NoWarn=CS0162\n```\n\nMSBuild expressions and property functions are supported:\n\n```csharp\n#:property LogLevel=$([MSBuild]::ValueOrDefault('$(LOG_LEVEL)', 'Information'))\n```\n\nCommon properties:\n\n| Property | Purpose |\n|----------|---------|\n| `AllowUnsafeBlocks=true` | Enable `unsafe` code |\n| `PublishAot=false` | Disable native AOT (enabled by default) |\n| `NoWarn=CS0162;CS0219` | Suppress specific warnings |\n| `LangVersion=preview` | Enable preview language features |\n| `InvariantGlobalization=false` | Enable culture-specific globalization |\n\n#### `#:project` — Project references\n\nReference another project by relative path:\n\n```csharp\n#:project ..\u002FMyLibrary\u002FMyLibrary.csproj\n```\n\n#### `#:ref` — File-based app references\n\nReference another `.cs` file as a separate file-based app project when it should compile into a separate assembly instead of being included in the same compilation. Use `#:include` for ordinary helper files that should share the same assembly as the entry point; use `#:ref` when you want project-reference-like boundaries.\n\n```csharp\n#:property ExperimentalFileBasedProgramEnableRefDirective=true\n#:ref ..\u002FShared\u002FFormatter.cs\n\nConsole.WriteLine(Formatter.Title(\"hello world\"));\n```\n\nGuidelines:\n\n- The referenced file is compiled as its own virtual project and added as a project reference.\n- If the referenced file is a library without top-level statements, put `#:property OutputType=Library` in that referenced file.\n- Members that must be consumed by the referencing app should be public; internal members are not visible across the assembly boundary.\n- `#:ref` is transitive: a referenced file can contain its own `#:ref` and other `#:` directives.\n- Relative paths are resolved relative to the file containing the directive.\n- Some SDK builds require `#:property ExperimentalFileBasedProgramEnableRefDirective=true`; remove that property if the SDK accepts `#:ref` without it.\n\n#### `#:sdk` — SDK selection\n\nOverride the default SDK (`Microsoft.NET.Sdk`):\n\n```csharp\n#:sdk Microsoft.NET.Sdk.Web\n```\n\n#### `#:include` and `#:exclude` — Multi-file apps\n\nIn .NET SDK 10.0.300 and later, file-based apps can include additional files in the same virtual project. Check the full `dotnet --version` output before using these directives; a 10.0.100 or 10.0.200 SDK is still .NET 10 but does not support them. Use `#:include` for helper source files and supported assets, and `#:exclude` to remove files from an include pattern or default item set.\n\n```csharp\n#!\u002Fusr\u002Fbin\u002Fenv dotnet\n#:include Helpers.cs\n#:include Models\u002F*.cs\n#:exclude Models\u002FGenerated\u002F*.cs\n\nConsole.WriteLine(Formatter.Title(\"hello world\"));\n```\n\nGuidelines:\n\n- Treat the file passed to `dotnet` as the entry point; put top-level statements there.\n- Put declarations such as classes, records, and enums in included `.cs` files.\n- Prefer explicit globs such as `Helpers.cs` or `Models\u002F*.cs` over broad recursive globs.\n- Paths are resolved relative to the file containing the directive.\n- Include directives from non-entry-point C# files are processed too, so a helper file can declare its own `#:package`, `#:property`, `#:sdk`, `#:project`, `#:ref`, `#:include`, or `#:exclude` directives.\n- Avoid duplicate directives across included files unless the directive kind explicitly supports duplicates; duplicate `#:package`, `#:property`, `#:sdk`, `#:include`, and `#:exclude` entries can fail.\n- When an app uses `#:include`, add a shebang (`#!\u002Fusr\u002Fbin\u002Fenv dotnet`) to the entry-point file on Unix-like systems to make the entry point clear to tools. Use `LF` line endings and no BOM for shebang files.\n\nExample layout:\n\n```text\nscratch\u002F\n    hello.cs\n    Helpers.cs\n    Models\u002F\n        Person.cs\n```\n\n```csharp\n#!\u002Fusr\u002Fbin\u002Fenv dotnet\n\u002F\u002F hello.cs\n#:include Helpers.cs\n#:include Models\u002F*.cs\n\nvar person = new Person(\"Ada\");\nConsole.WriteLine(Formatter.Title(person.Name));\n```\n\n```csharp\n\u002F\u002F Helpers.cs\nstatic class Formatter\n{\n    public static string Title(string value) => value.ToUpperInvariant();\n}\n```\n\n```csharp\n\u002F\u002F Models\u002FPerson.cs\nrecord Person(string Name);\n```\n\n### Step 5: Clean up\n\nRemove the app files when the user is done. To clear cached build artifacts:\n\n```bash\ndotnet clean hello.cs\n```\n\n## Unix shebang support\n\nOn Unix platforms, make a `.cs` file directly executable:\n\n1. Add a shebang as the first line of the file:\n\n    ```csharp\n    #!\u002Fusr\u002Fbin\u002Fenv dotnet\n    Console.WriteLine(\"I'm executable!\");\n    ```\n\n2. Set execute permissions:\n\n    ```bash\n    chmod +x hello.cs\n    ```\n\n3. Run directly:\n\n    ```bash\n    .\u002Fhello.cs\n    ```\n\nUse `LF` line endings (not `CRLF`) when adding a shebang. This directive is ignored on Windows.\n\n## Source-generated JSON\n\nFile-based apps enable native AOT by default. Reflection-based APIs like `JsonSerializer.Serialize\u003CT>(value)` fail at runtime under AOT. Use source-generated serialization instead:\n\n```csharp\nusing System.Text.Json;\nusing System.Text.Json.Serialization;\n\nvar person = new Person(\"Alice\", 30);\nvar json = JsonSerializer.Serialize(person, AppJsonContext.Default.Person);\nConsole.WriteLine(json);\n\nvar deserialized = JsonSerializer.Deserialize(json, AppJsonContext.Default.Person);\nConsole.WriteLine($\"Name: {deserialized!.Name}, Age: {deserialized.Age}\");\n\nrecord Person(string Name, int Age);\n\n[JsonSerializable(typeof(Person))]\npartial class AppJsonContext : JsonSerializerContext;\n```\n\n## Converting to a project\n\nWhen a file-based app outgrows this workflow, convert it to a full project:\n\n```bash\ndotnet project convert hello.cs\n```\n\n## Fallback for .NET 9 and earlier\n\nIf the .NET SDK version is below 10, file-based apps are not available. Use a temporary console project instead:\n\n```bash\nmkdir -p \u002Ftmp\u002Fcsharp-file-based-app && cd \u002Ftmp\u002Fcsharp-file-based-app\ndotnet new console -o . --force\n```\n\nReplace the generated `Program.cs` with the app content and run with `dotnet run`. Add NuGet packages with `dotnet add package \u003Cname>`. Remove the directory when done.\n\n## Validation\n\n- [ ] `dotnet --version` reports 10.0 or later (or fallback path is used)\n- [ ] If the app uses `#:include`, `#:exclude`, or transitive directives from included files, `dotnet --version` reports SDK 10.0.300 or later\n- [ ] The app compiles without errors (can be checked explicitly with `dotnet build \u003Cfile>.cs`)\n- [ ] `dotnet \u003Cfile>.cs` produces the expected output\n- [ ] Multi-file apps include every required helper file and exclude unintended matches\n- [ ] App files and cached artifacts are cleaned up after the session\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| `.cs` file is inside a directory with a `.csproj` | Move the app outside the project directory, or use `dotnet run --file file.cs` |\n| `#:package` without a version | Specify a version: `#:package PackageName@1.2.3` or `@*` for latest |\n| `#:property` with wrong syntax | Use `PropertyName=Value` with no spaces around `=` and no quotes: `#:property AllowUnsafeBlocks=true` |\n| Directives placed after C# code | All `#:` directives must appear immediately after an optional shebang line (if present) and before any `using` directives or other C# statements |\n| Helper file is not compiled | Add `#:include Helper.cs` or an appropriate glob to the entry-point file |\n| Shared file needs an assembly boundary | Use `#:ref Shared.cs` instead of `#:include Shared.cs`, and set `#:property OutputType=Library` in the referenced file if it has no entry point |\n| Broad include pulls in unrelated files | Prefer narrow include patterns and use `#:exclude` for generated, backup, or experimental files |\n| Duplicate directives in included files | Keep package, property, SDK, include, and exclude directives unique across the entry point and included C# files |\n| Reflection-based JSON serialization fails | Use source-generated JSON with `JsonSerializerContext` (see [Source-generated JSON](#source-generated-json)) |\n| Unexpected build behavior or version errors | File-based apps inherit `global.json`, `Directory.Build.props`, `Directory.Build.targets`, and `nuget.config` from parent directories. Move the app to an isolated directory if the inherited settings conflict |\n\n## More info\n\nSee https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcore\u002Fsdk\u002Ffile-based-apps for a full reference on file-based apps.\n","# File-Based C# Apps\n\n## When to Use\n\n- Testing a C# concept, API, or language feature with a quick file-based app\n- Prototyping logic before integrating it into a larger project\n- Building a small utility from one entry-point file and a few helper `.cs` files\n\n## When Not to Use\n\n- The user asks for a language-agnostic quick script, throwaway computation, or shell\u002FPython\u002FPowerShell-style automation\n- The user needs a full project, solution integration, or project references in an existing app\n- The user is working inside an existing .NET solution and wants to add code there\n- The app is large enough that project structure, build customization, tests, or publish configuration should live in a `.csproj`\n\n## Inputs\n\n| Input | Required | Description |\n|-------|----------|-------------|\n| C# code or intent | Yes | The code to run, or a description of what the file-based app should do |\n\n## Workflow\n\n### Step 1: Check the .NET SDK version\n\nRun `dotnet --version` to verify the SDK is installed and note the full version, including the feature band. File-based apps require .NET 10 or later. `#:include`, `#:exclude`, and transitive directive processing require SDK 10.0.300 or later; SDK 10.0.100\u002F10.0.200 builds can run single-file apps but do not support those multi-file directives. If the version is below 10, follow the [fallback for older SDKs](#fallback-for-net-9-and-earlier) instead.\n\n### Step 2: Write the app file\n\nCreate an entry-point `.cs` file using top-level statements. Place it outside any existing project directory to avoid conflicts with `.csproj` files.\n\n```csharp\n#!\u002Fusr\u002Fbin\u002Fenv dotnet\n\u002F\u002F hello.cs\nConsole.WriteLine(\"Hello from a file-based app!\");\n\nvar numbers = new[] { 1, 2, 3, 4, 5 };\nConsole.WriteLine($\"Sum: {numbers.Sum()}\");\n```\n\nGuidelines:\n\n- Use top-level statements (no `Main` method, class, or namespace boilerplate)\n- Place `using` directives at the top of the file (after the `#!` line and any `#:` directives if present)\n- Place type declarations (classes, records, enums) after all top-level statements\n\n### Step 3: Run the app\n\n```bash\ndotnet hello.cs\n```\n\nBuilds and runs the file automatically. Cached so subsequent runs are fast. Pass arguments after `--`:\n\n```bash\ndotnet hello.cs -- arg1 arg2 \"multi word arg\"\n```\n\n### Step 4: Add directives (if needed)\n\nPlace directives at the top of the file (immediately after an optional shebang line), before any `using` directives or other C# code. All directives start with `#:`.\n\n#### `#:package` — NuGet package references\n\nSpecify a version unless the app intentionally uses central package management. Use `@*` when the latest available package is acceptable (or `@*-*` for pre-release):\n\n```csharp\n#:package Humanizer@2.14.1\n\nusing Humanizer;\n\nConsole.WriteLine(\"hello world\".Titleize());\n```\n\n#### `#:property` — MSBuild properties\n\nSet any MSBuild property inline. Syntax: `#:property PropertyName=Value`\n\n```csharp\n#:property AllowUnsafeBlocks=true\n#:property PublishAot=false\n#:property NoWarn=CS0162\n```\n\nMSBuild expressions and property functions are supported:\n\n```csharp\n#:property LogLevel=$([MSBuild]::ValueOrDefault('$(LOG_LEVEL)', 'Information'))\n```\n\nCommon properties:\n\n| Property | Purpose |\n|----------|---------|\n| `AllowUnsafeBlocks=true` | Enable `unsafe` code |\n| `PublishAot=false` | Disable native AOT (enabled by default) |\n| `NoWarn=CS0162;CS0219` | Suppress specific warnings |\n| `LangVersion=preview` | Enable preview language features |\n| `InvariantGlobalization=false` | Enable culture-specific globalization |\n\n#### `#:project` — Project references\n\nReference another project by relative path:\n\n```csharp\n#:project ..\u002FMyLibrary\u002FMyLibrary.csproj\n```\n\n#### `#:ref` — File-based app references\n\nReference another `.cs` file as a separate file-based app project when it should compile into a separate assembly instead of being included in the same compilation. Use `#:include` for ordinary helper files that should share the same assembly as the entry point; use `#:ref` when you want project-reference-like boundaries.\n\n```csharp\n#:property ExperimentalFileBasedProgramEnableRefDirective=true\n#:ref ..\u002FShared\u002FFormatter.cs\n\nConsole.WriteLine(Formatter.Title(\"hello world\"));\n```\n\nGuidelines:\n\n- The referenced file is compiled as its own virtual project and added as a project reference.\n- If the referenced file is a library without top-level statements, put `#:property OutputType=Library` in that referenced file.\n- Members that must be consumed by the referencing app should be public; internal members are not visible across the assembly boundary.\n- `#:ref` is transitive: a referenced file can contain its own `#:ref` and other `#:` directives.\n- Relative paths are resolved relative to the file containing the directive.\n- Some SDK builds require `#:property ExperimentalFileBasedProgramEnableRefDirective=true`; remove that property if the SDK accepts `#:ref` without it.\n\n#### `#:sdk` — SDK selection\n\nOverride the default SDK (`Microsoft.NET.Sdk`):\n\n```csharp\n#:sdk Microsoft.NET.Sdk.Web\n```\n\n#### `#:include` and `#:exclude` — Multi-file apps\n\nIn .NET SDK 10.0.300 and later, file-based apps can include additional files in the same virtual project. Check the full `dotnet --version` output before using these directives; a 10.0.100 or 10.0.200 SDK is still .NET 10 but does not support them. Use `#:include` for helper source files and supported assets, and `#:exclude` to remove files from an include pattern or default item set.\n\n```csharp\n#!\u002Fusr\u002Fbin\u002Fenv dotnet\n#:include Helpers.cs\n#:include Models\u002F*.cs\n#:exclude Models\u002FGenerated\u002F*.cs\n\nConsole.WriteLine(Formatter.Title(\"hello world\"));\n```\n\nGuidelines:\n\n- Treat the file passed to `dotnet` as the entry point; put top-level statements there.\n- Put declarations such as classes, records, and enums in included `.cs` files.\n- Prefer explicit globs such as `Helpers.cs` or `Models\u002F*.cs` over broad recursive globs.\n- Paths are resolved relative to the file containing the directive.\n- Include directives from non-entry-point C# files are processed too, so a helper file can declare its own `#:package`, `#:property`, `#:sdk`, `#:project`, `#:ref`, `#:include`, or `#:exclude` directives.\n- Avoid duplicate directives across included files unless the directive kind explicitly supports duplicates; duplicate `#:package`, `#:property`, `#:sdk`, `#:include`, and `#:exclude` entries can fail.\n- When an app uses `#:include`, add a shebang (`#!\u002Fusr\u002Fbin\u002Fenv dotnet`) to the entry-point file on Unix-like systems to make the entry point clear to tools. Use `LF` line endings and no BOM for shebang files.\n\nExample layout:\n\n```text\nscratch\u002F\n    hello.cs\n    Helpers.cs\n    Models\u002F\n        Person.cs\n```\n\n```csharp\n#!\u002Fusr\u002Fbin\u002Fenv dotnet\n\u002F\u002F hello.cs\n#:include Helpers.cs\n#:include Models\u002F*.cs\n\nvar person = new Person(\"Ada\");\nConsole.WriteLine(Formatter.Title(person.Name));\n```\n\n```csharp\n\u002F\u002F Helpers.cs\nstatic class Formatter\n{\n    public static string Title(string value) => value.ToUpperInvariant();\n}\n```\n\n```csharp\n\u002F\u002F Models\u002FPerson.cs\nrecord Person(string Name);\n```\n\n### Step 5: Clean up\n\nRemove the app files when the user is done. To clear cached build artifacts:\n\n```bash\ndotnet clean hello.cs\n```\n\n## Unix shebang support\n\nOn Unix platforms, make a `.cs` file directly executable:\n\n1. Add a shebang as the first line of the file:\n\n    ```csharp\n    #!\u002Fusr\u002Fbin\u002Fenv dotnet\n    Console.WriteLine(\"I'm executable!\");\n    ```\n\n2. Set execute permissions:\n\n    ```bash\n    chmod +x hello.cs\n    ```\n\n3. Run directly:\n\n    ```bash\n    .\u002Fhello.cs\n    ```\n\nUse `LF` line endings (not `CRLF`) when adding a shebang. This directive is ignored on Windows.\n\n## Source-generated JSON\n\nFile-based apps enable native AOT by default. Reflection-based APIs like `JsonSerializer.Serialize\u003CT>(value)` fail at runtime under AOT. Use source-generated serialization instead:\n\n```csharp\nusing System.Text.Json;\nusing System.Text.Json.Serialization;\n\nvar person = new Person(\"Alice\", 30);\nvar json = JsonSerializer.Serialize(person, AppJsonContext.Default.Person);\nConsole.WriteLine(json);\n\nvar deserialized = JsonSerializer.Deserialize(json, AppJsonContext.Default.Person);\nConsole.WriteLine($\"Name: {deserialized!.Name}, Age: {deserialized.Age}\");\n\nrecord Person(string Name, int Age);\n\n[JsonSerializable(typeof(Person))]\npartial class AppJsonContext : JsonSerializerContext;\n```\n\n## Converting to a project\n\nWhen a file-based app outgrows this workflow, convert it to a full project:\n\n```bash\ndotnet project convert hello.cs\n```\n\n## Fallback for .NET 9 and earlier\n\nIf the .NET SDK version is below 10, file-based apps are not available. Use a temporary console project instead:\n\n```bash\nmkdir -p \u002Ftmp\u002Fcsharp-file-based-app && cd \u002Ftmp\u002Fcsharp-file-based-app\ndotnet new console -o . --force\n```\n\nReplace the generated `Program.cs` with the app content and run with `dotnet run`. Add NuGet packages with `dotnet add package \u003Cname>`. Remove the directory when done.\n\n## Validation\n\n- [ ] `dotnet --version` reports 10.0 or later (or fallback path is used)\n- [ ] If the app uses `#:include`, `#:exclude`, or transitive directives from included files, `dotnet --version` reports SDK 10.0.300 or later\n- [ ] The app compiles without errors (can be checked explicitly with `dotnet build \u003Cfile>.cs`)\n- [ ] `dotnet \u003Cfile>.cs` produces the expected output\n- [ ] Multi-file apps include every required helper file and exclude unintended matches\n- [ ] App files and cached artifacts are cleaned up after the session\n\n## Common Pitfalls\n\n| Pitfall | Solution |\n|---------|----------|\n| `.cs` file is inside a directory with a `.csproj` | Move the app outside the project directory, or use `dotnet run --file file.cs` |\n| `#:package` without a version | Specify a version: `#:package PackageName@1.2.3` or `@*` for latest |\n| `#:property` with wrong syntax | Use `PropertyName=Value` with no spaces around `=` and no quotes: `#:property AllowUnsafeBlocks=true` |\n| Directives placed after C# code | All `#:` directives must appear immediately after an optional shebang line (if present) and before any `using` directives or other C# statements |\n| Helper file is not compiled | Add `#:include Helper.cs` or an appropriate glob to the entry-point file |\n| Shared file needs an assembly boundary | Use `#:ref Shared.cs` instead of `#:include Shared.cs`, and set `#:property OutputType=Library` in the referenced file if it has no entry point |\n| Broad include pulls in unrelated files | Prefer narrow include patterns and use `#:exclude` for generated, backup, or experimental files |\n| Duplicate directives in included files | Keep package, property, SDK, include, and exclude directives unique across the entry point and included C# files |\n| Reflection-based JSON serialization fails | Use source-generated JSON with `JsonSerializerContext` (see [Source-generated JSON](#source-generated-json)) |\n| Unexpected build behavior or version errors | File-based apps inherit `global.json`, `Directory.Build.props`, `Directory.Build.targets`, and `nuget.config` from parent directories. Move the app to an isolated directory if the inherited settings conflict |\n\n## More info\n\nSee https:\u002F\u002Flearn.microsoft.com\u002Fen-us\u002Fdotnet\u002Fcore\u002Fsdk\u002Ffile-based-apps for a full reference on file-based apps.\n",{"name":5,"license":15,"description":7},"main","497cc9aba79a931ac6fb8d36a48cc22fe3d6d74b","catalog\u002FPlatform\u002FOfficial-DotNet-Advanced\u002Fskills\u002Fcsharp-scripts",41,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills","https:\u002F\u002Fskills.managed-code.com","https:\u002F\u002Fgithub.com\u002Fmanagedcode","https:\u002F\u002Fwww.managed-code.com","Open Source Community for .NET Developers: Reliable, Actively Maintained, and Community-Driven. Made in Ukraine 🇺🇦 with ❤️","2026-11-14 19:05:44",{"source":8,"skillName":5,"commands":64,"prompt":74,"zipAvailable":75},[65,68,71],{"tool":66,"command":67},"npx","npx skills add managedcode\u002Fdotnet-skills --skill csharp-scripts",{"tool":69,"command":70},"bunx","bunx skills add managedcode\u002Fdotnet-skills --skill csharp-scripts",{"tool":72,"command":73},"pnpm","pnpm dlx skills add managedcode\u002Fdotnet-skills --skill csharp-scripts","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FPlatform\u002FOfficial-DotNet-Advanced\u002Fskills\u002Fcsharp-scripts\u002FSKILL.md",true,[77],{"path":78,"resourceType":79,"resourceTypeDesc":80,"sizeBytes":81,"sourceHtmlUrl":82},"manifest.json","REFERENCE","参考文档",109,"https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FPlatform\u002FOfficial-DotNet-Advanced\u002Fskills\u002Fcsharp-scripts\u002Fmanifest.json",[84,114,137,166,176,202],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":96,"publishedAt":48},"01M6DYQE1Y9FHAQHEDTVFQ3447","xtwitter-scraper","Use XTwitterScraper when a .NET application needs typed access to Xquik's X automation REST API for tweet search, user lookup, posting workflows, extraction jobs, monitors, webhooks, or giveaway draws. USE FOR: integrating the XTwitterScraper NuGet package; reviewing Xquik API client usage; modeling API-key configuration, pagination, binary exports, raw responses, retries, and webhook\u002Fevent flows in .NET. DO NOT USE FOR: unrelated stacks; direct browser automation; generic social-media strategy; or code that does not call Xquik. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FXTwitterScraper\u002Fskills\u002Fxtwitter-scraper\u002FSKILL.md",[90,95],{"categoryNo":91,"categoryName":92,"taxonomyType":93,"taxonomyTypeDesc":94},"01JBSEEDCAT000000000000010","后端与接口","SCENARIO","使用场景",{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[97,98,99,44,43,100,101,102,40,103,104,105,106,107,108,109,110,111,112,113],"xtwitter scraper","browser automation","workflows","browser","search","repository","Media","api client","access","edit","unrelated","webhooks","files","social","commands","modeling","webhook",{"skillNo":115,"name":116,"nameZh":6,"description":117,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":118,"categories":119,"keywords":126,"publishedAt":48},"01M6DYQ9S4PE1H6G8MCH9T21HR","sep","Use Sep for high-performance separated-value parsing and writing in .NET, including delimiter inference, explicit parser\u002Fwriter options, and low-allocation row\u002Fcolumn workflows. USE FOR: delimited data needs are performance-sensitive and allocation-aware; project needs explicit control over separator inference, escaping, trimming, and header behavior;. DO NOT USE FOR: unrelated stacks; generic tasks that do not need this specific guidance. INVOKES: inspect the repository context, edit targeted files, and run relevant build, test, lint, or validation commands when changes are made.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fcatalog\u002FLibraries\u002FSep\u002Fskills\u002Fsep\u002FSKILL.md",[120,123],{"categoryNo":121,"categoryName":122,"taxonomyType":93,"taxonomyTypeDesc":94},"01JBSEEDCAT000000000000018","写作与文案",{"categoryNo":124,"categoryName":125,"taxonomyType":21,"taxonomyTypeDesc":22},"01JBSEEDCAT000000000000036","内容创作者",[116,127,128,99,129,44,102,130,131,132,106,133,107,109,27,134,135,36,111,136],"writing","performance","tasks","data","parsing","parser","context","writer","options","high-performance",{"skillNo":138,"name":139,"nameZh":6,"description":140,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":48},"01M6DZS2DNEPXCGGF6SSCW6G5V","webgpu-threejs-tsl","Comprehensive guide for developing WebGPU-enabled Three.js applications using TSL (Three.js Shading Language). Covers WebGPU renderer setup, TSL syntax and node materials, compute shaders, post-processing effects, and WGSL integration. Use this skill when working with Three.js WebGPU, TSL shaders, node materials, or GPU compute in Three.js.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fwebgpu-claude-skill\u002Fskills\u002Fwebgpu-threejs-tsl\u002FSKILL.md",[],[144,145,146,147,148,149,150,151,152,153,154,155,38,156,157,158,159,160,161,162,31,163,164,165,28],"webgpu","threejs","webgpu threejs tsl","setup","shaders","gpu","integration","applications","js","node","syntax","guide","language","three","compute","post","processing","with","renderer","materials","wgsl","effects",{"skillNo":167,"name":168,"nameZh":6,"description":169,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":170,"categories":171,"keywords":172,"publishedAt":48},"01M6DZS0BQXW2B56A289XF1X76","roslynk","Use Roslynk for semantic inspection and edits of *.cs, *.razor and *.cshtml solution files.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Froslynk\u002Fskills\u002Froslynk\u002FSKILL.md",[],[168,38,109,173,174,31,175],"semantic","razor","inspection",{"skillNo":177,"name":178,"nameZh":6,"description":179,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":180,"categories":181,"keywords":182,"publishedAt":48},"01M6DZRW6MEJCVW80K3S4XV60K","system-text-json-net11","Imperative guidance for the System.Text.Json APIs added in .NET 11: the built-in `JsonNamingPolicy.PascalCase` naming policy, and the strongly-typed generic `JsonSerializerOptions.GetTypeInfo` and `JsonSerializerOptions.TryGetTypeInfo` metadata accessors (generic overloads that return a typed `JsonTypeInfo`). USE ONLY when the user is targeting net11.0 or later and needs PascalCase JSON property or dictionary-key names without writing a custom naming policy, a strongly-typed generic `JsonTypeInfo` instead of the non-generic `JsonTypeInfo`, or a no-throw way to probe whether a type's serialization metadata is resolved. DO NOT USE when the target is earlier than net11.0, the requested behavior uses an established pre-net11 naming policy, or the user explicitly selected another JSON library.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fsystem-text-json-net11\u002FSKILL.md",[],[183,184,185,186,127,187,188,189,190,191,192,38,193,194,195,196,27,197,198,199,200,31,201,29,28],"system","json","text","system text json net11","policy","metadata","library","serialization","behavior","user","only","probe","guidance","later","type","dictionary","naming","targeting","custom",{"skillNo":203,"name":204,"nameZh":6,"description":205,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":206,"categories":207,"keywords":210,"publishedAt":48},"01M6DZRRJP3S662NFSG1RSPQQ7","process-api-net11","Provides guidance on the new System.Diagnostics.Process APIs introduced in .NET 11: Process.Run, Process.RunAndCaptureText, Process.StartAndForget, Process.ReadAllText\u002FBytes\u002FLines, KillOnParentExit, InheritedHandles, and StartDetached. USE FOR: starting, orchestrating, or capturing output from external processes in applications targeting net11.0 or later. DO NOT USE FOR: applications targeting .NET 10 or earlier, or basic pre-.NET 11 Process.Start usage without new APIs.","https:\u002F\u002Fgithub.com\u002Fmanagedcode\u002Fdotnet-skills\u002Fblob\u002Fmain\u002Fexternal-sources\u002Fupstreams\u002Fdotnet-skills\u002Fplugins\u002Fdotnet11\u002Fskills\u002Fprocess-api-net11\u002FSKILL.md",[208,209],{"categoryNo":91,"categoryName":92,"taxonomyType":93,"taxonomyTypeDesc":94},{"categoryNo":19,"categoryName":20,"taxonomyType":21,"taxonomyTypeDesc":22},[40,211,212,213,44,214,151,183,38,195,196,27,215,216,217,218,200,31,219],"process","process api net11","diagnostics","start","basic","processes","output","usage","new"]