AgentSkillsCN

dotnet-dev

.NET 8 C# WPF项目构建、运行与开发工作流。在构建、运行、测试或向此.NET项目添加依赖项时使用此功能。可通过“dotnet构建错误”、“添加NuGet包”、“运行应用程序”、“在项目结构中创建新类/文件”等短语触发。

SKILL.md
--- frontmatter
name: dotnet-dev
description: ".NET 8 C# WPF project build, run, and development workflow. Use when building, running, testing, or adding dependencies to this .NET project. Triggers on: dotnet build errors, adding NuGet packages, running the app, creating new classes/files in the project structure."

.NET Development Workflow

Project Layout

code
WinContextMenuEditor/
├── WinContextMenuEditor.sln
└── src/WinContextMenuEditor/
    ├── WinContextMenuEditor.csproj  (.NET 8, WPF, UseWPF=true)
    ├── app.manifest                 (requireAdministrator)
    ├── Models/
    ├── ViewModels/
    ├── Views/
    ├── Services/
    ├── Converters/
    └── Resources/

Build & Run

bash
# Build
dotnet build

# Run (requires admin - UAC prompt will appear)
dotnet run --project src/WinContextMenuEditor

# Publish self-contained
dotnet publish src/WinContextMenuEditor -c Release -r win-x64 --self-contained

Adding New Files

Follow existing namespace conventions:

  • Models: namespace WinContextMenuEditor.Models;
  • ViewModels: namespace WinContextMenuEditor.ViewModels; - inherit ViewModelBase
  • Views: namespace WinContextMenuEditor.Views; - XAML + code-behind
  • Services: namespace WinContextMenuEditor.Services; - interface + implementation pair
  • Converters: namespace WinContextMenuEditor.Converters; - implement IValueConverter

Use file-scoped namespaces. Use nullable reference types. Target .NET 8.

Common Build Errors

  • MC3024 property already set: XAML element has both attribute and element syntax for same property. Remove one.
  • NETSDK1031 platform mismatch: Ensure net8.0-windows target framework.
  • Missing WPF types: Verify <UseWPF>true</UseWPF> in csproj.