用途:面向 .NET 项目的构建配置与错误处理,在构建项目、诊断构建错误或配置构建选项时使用。
主要能力: 构建命令:dotnet build 可构建解决方案或指定项目,支持 --configuration Release、-c Debug、--no-incremental 等选项。可在不还原包的情况下构建:dotnet build --no-restore。输出可指定目录 --output ./artifacts、运行时 --runtime win-x64/linux-x64、目标框架 --framework net8.0。 配置:在 .csproj 中按 Configuration 区分 Debug 与 Release(DefineConstants、Optimize、DebugType)。可用 TreatWarningsAsErrors 将警告视为错误,WarningsAsErrors 指定特定警告码,NoWarn 抑制警告。 多项目解决方案:dotnet build MySolution.sln,可用 --project 构建指定项目;默认并行构建,--maxcpucount:1 改为顺序;依赖通过 ProjectReference 声明。 错误分类:编译错误(CS0103、CS0246、CS1061、CS0029、CS0120)、项目错误(MSB3202、MSB4019、MSB3644、MSB3245)、NuGet 错误(NU1101、NU1103、NU1202、NU1605),资料给出描述与常见修复方向。 包还原:dotnet restore,可指定源 --source https://api.nuget.org/v3/index.json;dotnet nuget locals all --clear 清理缓存;dotnet list package 及 --outdated 列出包。 诊断:--verbosity detailed/diagnostic/quiet 控制输出,-bl 生成二进制日志,配合 MSBuild Structured Log Viewer(https://msbuildlog.com/)查看。 清理:dotnet clean,可指定配置,或手动删除 bin/obj。 常见问题:框架需在各项目保持一致;用 dotnet --list-sdks 检查 SDK,可用 global.json 指定版本(如 "version": "8.0.100");文件被占用时 Windows 用 taskkill /F /IM dotnet.exe,Linux/Mac 用 pkill dotnet。
限制:资料为技能说明文档,未提供安装步骤、适用平台限制或收费信息;价格与完整支持范围暂未提供。