csharp-scripts
यह क्या करती है
यह स्किल .NET command line टूल से C# code को file-based app के रूप में चलाती है, ताकि आप पूरा प्रोजेक्ट बनाए बिना कोई विचार जाँच सकें। यह उन डेवलपर के लिए है जो C# code, language features या छोटी utility जल्दी आज़माना चाहते हैं।
कब इस्तेमाल करें
- ✓जब आप C# concept, API या language feature जल्दी जाँचना चाहें।
- ✓जब आप एक या कुछ फ़ाइलों से छोटी C# utility चलाना चाहें।
- ✓जब आप असली प्रोजेक्ट में जोड़ने से पहले C# logic का प्रोटोटाइप बनाना चाहें।
Skill का लिंक
https://github.com/dotnet/skills/blob/main/plugins/dotnet-advanced/skills/csharp-scripts/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“एक छोटी C# फ़ाइल लिखिए जो CSV पढ़े और कुल योग दिखाए, और उसे बिना प्रोजेक्ट बनाए चलाइए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट जाँचता है कि .NET SDK इंस्टॉल है और पर्याप्त नया है, C# फ़ाइल लिखता है, और dotnet कमांड से चलाता है, ज़रूरत हो तो सहायक फ़ाइलें जोड़ते हुए।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
File-Based C# Apps
When to Use
- Testing a C# concept, API, or language feature with a quick file-based app
- Prototyping logic before integrating it into a larger project
- Building a small utility from one entry-point file and a few helper
.csfiles
When Not to Use
- The user asks for a language-agnostic quick script, throwaway computation, or shell/Python/PowerShell-style automation
- The user needs a full project, solution integration, or project references in an existing app
- The user is working inside an existing .NET solution and wants to add code there
- The app is large enough that project structure, build customization, tests, or publish configuration should live in a
.csproj
Inputs
| Input | Required | Description |
|---|---|---|
| C# code or intent | Yes | The code to run, or a description of what the file-based app should do |
Workflow
Step 1: Check the .NET SDK version
Run 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/10.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 instead.
Step 2: Write the app file
Create an entry-point .cs file using top-level statements. Place it outside any existing project directory to avoid conflicts with .csproj files.
#!/usr/bin/env dotnet
// hello.cs
Console.WriteLine("Hello from a file-based app!");
var numbers = new[] { 1, 2, 3, 4, 5 };
Console.WriteLine($"Sum: {numbers.Sum()}");
Guidelines:
- Use top-level statements (no
Mainmethod, class, or namespace boilerplate) - Place
usingdirectives at the top of the file (after the#!line and any#:directives if present) - Place type declarations (classes, records, enums) after all top-level statements
Step 3: Run the app
dotnet hello.cs
Builds and runs the file automatically. Cached so subsequent runs are fast. Pass arguments after --:
dotnet hello.cs -- arg1 arg2 "multi word arg"
Step 4: Add directives (if needed)
Place 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 #:.
#:package — NuGet package references
Specify a version unless the app intentionally uses central package management. Use @* when the latest available package is acceptable (or @*-* for pre-release):
#:package Humanizer@2.14.1
using Humanizer;
Console.WriteLine("hello world".Titleize());
#:property — MSBuild properties
Set any MSBuild property inline. Syntax: #:property PropertyName=Value
#:property AllowUnsafeBlocks=true
#:property PublishAot=false
#:property NoWarn=CS0162
MSBuild expressions and property functions are supported:
#:property LogLevel=$([MSBuild]::ValueOrDefault('$(LOG_LEVEL)', 'Information'))
Common properties:
| Property | Purpose |
|---|---|
AllowUnsafeBlocks=true |
Enable unsafe code |
PublishAot=false |
Disable native AOT (enabled by default) |
NoWarn=CS0162;CS0219 |
Suppress specific warnings |
LangVersion=preview |
Enable preview language features |
InvariantGlobalization=false |
Enable culture-specific globalization |
#:project — Project references
Reference another project by relative path:
#:project ../MyLibrary/MyLibrary.csproj
#:ref — File-based app references
Reference 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.
#:property ExperimentalFileBasedProgramEnableRefDirective=true
#:ref ../Shared/Formatter.cs
Console.WriteLine(Formatter.Title("hello world"));
Guidelines:
- The referenced file is compiled as its own virtual project and added as a project reference.
- If the referenced file is a library without top-level statements, put
#:property OutputType=Libraryin that referenced file. - Members that must be consumed by the referencing app sh
अक्सर पूछे जाने वाले सवाल
कौन सा .NET वर्ज़न चाहिए?
file-based ऐप के लिए .NET 10 या उसके बाद का वर्ज़न चाहिए, और कुछ multi-file विकल्पों के लिए नया SDK अपडेट।
क्या यह दूसरी भाषाओं की scripts के लिए है?
नहीं। यह सिर्फ़ C# और .NET code के लिए है, सामान्य scripts के लिए नहीं।
पूरा प्रोजेक्ट कब इस्तेमाल करें?
बड़े ऐप के लिए, जिन्हें build settings, tests या publishing चाहिए, पूरा प्रोजेक्ट इस्तेमाल करें।
जानकारी
लेखक का मूल विवरण
Run file-based C# apps with the .NET CLI when the user explicitly wants C#/.NET code without creating a project. Use for C# language/API experiments, one-file C# apps, small multi-file C# apps composed with `#:include`/`#:exclude`, or C# file-based apps linked with `#:ref`. Do not use for language-agnostic throwaway scripts, generic computations, Python/PowerShell-style automation, full projects, or existing app integration.
repo: dotnet/skills
लोकप्रियता
- GitHub स्टार
- 5.8k
- रैंकिंग में स्थान
- #14554
- लाइसेंस
- MIT
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
create-custom-agent
5.8kयह आपके एजेंट को VS Code के custom agent फ़ाइलें बनाने देती है, जिनके अपने tools, निर्देश और दूसरे agents को handoffs होते हैं।
create-skill
5.8kयह आपके एजेंट को सही नाम, साफ़ trigger विवरण और मानक के अनुसार SKILL.md फ़ाइल वाली नई agent skill बनाने में मदद करती है।
dotnet-pinvoke
5.8kयह आपके एजेंट को .NET से native C या C++ libraries सही तरीके से कॉल करने में मदद करती है, जिसमें signatures, string संभालना, memory और सुरक्षित handles शामिल हैं।
nuget-trusted-publishing
5.8kयह आपके एजेंट को GitHub Actions से NuGet trusted publishing सेट करने देती है, ताकि packages संग्रहीत API keys के बजाय अल्पकालिक tokens से प्रकाशित हों।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।