基于 SOC 职业分类
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/rudironsoni/Ghost --skill dotnet-version-detection命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Rulesync CLI tool documentation - unified AI rule file management for various AI coding tools
Publishes .NET artifacts from Azure DevOps. NuGet push, containers to ACR, pipeline artifacts.
Configures artifacts output layout. UseArtifactsOutput, ArtifactsPath, impact on CI and Docker.
| name | dotnet-version-detection |
| description | Detects TFM/SDK from .csproj, global.json, Directory.Build.props. Runs first. |
| allowed-tools | ["Read","Grep","Glob","Bash","Write","Edit"] |
Detects .NET version information from project files and provides version-specific guidance. This skill runs first before any .NET development work. All other skills depend on the detected version to adapt their guidance.
Cross-cutting skill referenced by [skill:dotnet-advisor] and virtually all specialist skills. See also [skill:dotnet-file-based-apps] for .NET 10+ file-based apps that run without a .csproj.
For large repos, run the bundled scanner first to quickly inventory TFM/SDK signals before applying the precedence algorithm below:
python3 skills/dotnet-version-detection/scripts/scan-dotnet-targets.py --root . --json
Use the script output (project_target_frameworks, global_json.sdk_version, workflow_dotnet_versions) as discovery input. The precedence rules below remain authoritative for final TFM selection.
Read project files in this strict order. Higher-numbered sources are lower priority. Stop falling through once a TFM is resolved.
<TargetFramework> in .csproj (highest priority)Read the nearest .csproj file to the current working file/directory.
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
If found and the value is a literal TFM (e.g., net10.0, not $(SomeProperty)), this is the authoritative TFM. Report it and proceed to additional detection (Step 5).
If the value is an MSBuild property expression (starts with $(), skip to Step 4 for unresolved property handling.
<TargetFrameworks> in .csproj (multi-targeting)<PropertyGroup>
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
</PropertyGroup>
If found:
Directory.Build.props shared TFMIf no <TargetFramework> or <TargetFrameworks> found in the .csproj (or if the .csproj inherits from shared props), read Directory.Build.props in the current directory or any parent directory up to the solution root.
<!-- Directory.Build.props -->
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
If found, use this as the TFM. Note: per-project .csproj values override Directory.Build.props.
If the TFM value is an MSBuild property expression rather than a literal:
<TargetFramework>$(MyCustomTfm)</TargetFramework>
Emit warning:
Warning: Unresolved MSBuild property
$(MyCustomTfm). Cannot determine TFM statically. Falling back to SDK version fromglobal.json.
Then fall through to global.json SDK version (Step 4a) or dotnet --version (Step 4b).
global.json SDK version{
"sdk": {
"version": "10.0.100"
}
}
Map SDK version to approximate TFM:
8.0.xxx -> net8.09.0.xxx -> net9.010.0.xxx -> net10.011.0.xxx-preview.x -> net11.0Report: "Inferred TFM from global.json SDK version. Verify actual TFM in project file."
dotnet --version (last resort)If no global.json exists, use dotnet --version output to infer SDK version. Same mapping as 4a.
Report: "Inferred TFM from installed SDK version. No global.json or .csproj found. Consider creating a project with dotnet new."
After resolving the TFM, also check these files for supplementary version information. Always perform these checks regardless of which precedence step resolved the TFM.
global.json SDK VersionEven if TFM was resolved from .csproj, read global.json for:
sdk.version -- the pinned SDK versionsdk.rollForward -- the rollForward policy (e.g., latestFeature, latestPatch)Report the SDK version alongside the TFM. Flag inconsistencies:
Warning: TFM
net10.0butglobal.jsonpins SDK9.0.100. The project targets a newer framework than the pinned SDK. Updateglobal.jsonor verify the build environment has the correct SDK.
Check for explicit <LangVersion> in .csproj or Directory.Build.props:
<LangVersion>preview</LangVersion>
preview -- report "C# preview features enabled. Unlocks the next C# version available in the installed SDK (e.g., C# 15 preview features with a .NET 11 preview SDK)."latest -- report the default C# version for the detected TFM12.0) -- report that version, warn if it's below the TFM defaultCheck for these properties in .csproj or Directory.Build.props:
EnablePreviewFeatures:
<EnablePreviewFeatures>true</EnablePreviewFeatures>
Report: ".NET preview features enabled. Access to preview APIs and types."
Runtime-async feature flag (.NET 11+):
<Features>$(Features);runtime-async=on</Features>
Report: "Runtime-async enabled. Async/await uses runtime-level execution instead of compiler state machines."
Note: runtime-async requires <EnablePreviewFeatures>true</EnablePreviewFeatures> as well.
If multi-targeting was detected (Step 2), also note:
After detection, present results in this structured format:
.NET Version Detection Results
==============================
TFM: net10.0 (or net8.0;net10.0 for multi-targeting)
Highest TFM: net10.0
C# Version: 14 (default for net10.0)
SDK Version: 10.0.100 (from global.json)
Preview Features: none
Runtime-Async: not enabled
Warnings: none
Guidance: This project targets .NET 10 LTS with C# 14. Use modern patterns
including field-backed properties, collection expressions, and primary
constructors. All guidance will target net10.0 capabilities.
For multi-targeting:
.NET Version Detection Results
==============================
TFMs: net8.0;net10.0
Highest TFM: net10.0
C# Version: 14 (default for highest TFM)
SDK Version: 10.0.100 (from global.json)
Preview Features: none
Warnings: net8.0 reaches end of support Nov 2026
Guidance: Multi-targeting net8.0 and net10.0. Guide on net10.0 patterns.
For net8.0 compatibility, use PolySharp/Polyfill for language features.
See [skill:dotnet-multi-targeting] for detailed polyfill guidance.
If no .csproj exists in the workspace:
.sln or .slnx files and look for referenced projectsglobal.json for SDK version (Step 4a) and infer TFM from itglobal.json, use dotnet --version (Step 4b) to infer TFMdotnet new to create a project."If <TargetFramework> contains $(PropertyName):
$(PropertyName). Cannot determine TFM from static analysis."global.json SDK version, then dotnet --versiondotnet --list-sdks or dotnet msbuild -getProperty:TargetFrameworkIf .csproj says net10.0 but global.json pins SDK 9.0.100:
global.json to matchIf dotnet --version fails or is not found:
.fsproj and .vbprojThe same detection logic applies to F# (.fsproj) and VB.NET (.vbproj) projects. The <TargetFramework> element is identical across all .NET project types.
Version detection results should be cached per-project (per .csproj path). Re-detect when:
.csproj, Directory.Build.props, or global.json file is modifiedLast updated: 2026-02-11
This reference data maps .NET versions to their C# language versions, key features, and support lifecycle. This section is separate from the detection logic above -- detection determines which version is in use; this data maps that version to available features.
| .NET Version | Status | C# Version | TFM | Support End | Notes |
|---|---|---|---|---|---|
| .NET 8 | LTS (active) | C# 12 | net8.0 | Nov 2026 | Approaching end of support |
| .NET 9 | STS | C# 13 | net9.0 | May 2026 | Approaching end of support |
| .NET 10 | LTS (current) | C# 14 | net10.0 | Nov 2028 | Recommended for new projects |
| .NET 11 | Preview 1 | C# 15 (preview) | net11.0 | TBD (expected STS end: ~May 2028 if Nov 2026 GA) | Preview only -- not for production |
C# 12 (net8.0)
[1, 2, 3])ref readonly parametersusingC# 13 (net9.0)
params collections (any collection type)Lock type (System.Threading.Lock)\eref and unsafe in iterators/asyncC# 14 (net10.0)
field contextual keyword)nameof for unbound generic typesSpan<T> in more contextsallows ref struct anti-constraint for genericsC# 15 preview (net11.0)
with() syntax for capacity/comparers):
List<int> nums = [with(capacity: 32), 0, ..evens, ..odds];
HashSet<string> names = [with(comparer: StringComparer.OrdinalIgnoreCase), "Alice"];
These features are available when net11.0 TFM is detected with preview features enabled:
<EnablePreviewFeatures>true</EnablePreviewFeatures> + <Features>$(Features);runtime-async=on</Features>)System.IO.Compression.Zstandard (2-7x faster than Brotli/Deflate)System.Numerics.BFloat16 for AI/ML workloadsConnectAlgorithm.Parallel for dual-stack networkingWhen reporting version information, include lifecycle context: