You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jenkins执行dotnet restore及build命令失败,请求技术排查

Jenkins构建失败问题分析

问题场景

在Jenkins的「执行Windows批处理命令」步骤中,执行dotnet restore更新依赖后,运行dotnet build编译解决方案,最终构建失败。

执行的批处理命令

dotnet restore
"C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln\WCFServiceGX.sln"
dotnet build "C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln\WCFServiceGX.sln" /t:rebuild /property:Configuration=Release  /p:GenerateSerializationAssemblies=Off

控制台关键输出

[C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln\WebNetAgent\WebNetAgent.csproj]
C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln\WebNetAgent\CommonClass\PickupDetail.cs(54,23): warning CS0414: 字段“PickupDetail.formatString”已赋值但从未使用 [C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln\WebNetAgent\WebNetAgent.csproj]
C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln\WebNetAgent\NetShipService.cs(87,29): warning CS0414: 字段“NetagentService.iFlightStatusService”已赋值但从未使用 [C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln\WebNetAgent\WebNetAgent.csproj]
C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln\WebNetAgent\NetShipService.cs(1879,107): error CS7036: 没有与“OperationServiceClient.FinalEndRoute(int, DateTime, ref JSONToken, out FaultContract, string)”的必需形参“isAgentService”对应的实参 [C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln\WebNetAgent\WebNetAgent.csproj]
23 个警告
1 个错误

已用时间 00:00:05.13

C:\Users\nraut.SIPL.jenkins\workspace\WebNetAgentSln-build>exit 1
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

错误原因与解决建议

  • 核心失败原因:编译错误CS7036,在NetShipService.cs第1879行调用OperationServiceClient.FinalEndRoute方法时,缺少必填参数isAgentService,该问题与dotnet restore的依赖更新无关,属于代码调用逻辑错误。
  • 修复步骤:
    1. 打开WebNetAgent\NetShipService.cs文件,定位到第1879行的FinalEndRoute调用代码。
    2. 按照方法定义,补充最后一个字符串类型的参数isAgentService的取值(根据业务需求传入对应值)。
  • 其他优化建议:
    • 23个CS0414警告是代码中存在已赋值但未使用的字段,不影响构建,若需代码整洁可删除这些无用字段。
    • dotnet build命令默认会自动执行restore操作,无需单独编写dotnet restore步骤,可简化批处理命令。

内容的提问来源于stack exchange,提问作者user21480787

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.27 13:37:50