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

Azure Agent构建含netstandard2.0包的.NET项目兼容性问题

Azure DevOps Windows代理构建.NET项目的包兼容性问题及解决方案

问题现象

在Azure DevOps的windows-default代理(预装Visual Studio 2022)上构建C#解决方案时,出现大量包兼容性错误。本地使用同版本Visual Studio 2022可正常构建,但代理端构建失败。

错误日志示例

2023-07-24T16:31:26.9143960Z Package System.Diagnostics.EventLog 4.7.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package System.Diagnostics.EventLog 4.7.0 supports:
2023-07-24T16:31:26.9144942Z   - net461 (.NETFramework,Version=v4.6.1)
2023-07-24T16:31:26.9145369Z   - net472 (.NETFramework,Version=v4.7.2)
2023-07-24T16:31:26.9145986Z   - netstandard2.0 (.NETStandard,Version=v2.0)

2023-07-24T15:53:57.3643861Z     Package Topshelf 4.3.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Topshelf 4.3.0 supports:
2023-07-24T15:53:57.3644513Z       - net452 (.NETFramework,Version=v4.5.2)
2023-07-24T15:53:57.3644975Z       - netstandard2.0 (.NETStandard,Version=v2.0)
2023-07-24T15:53:57.3645521Z     One or more packages are incompatible with .NETCoreApp,Version=v3.1.

排查过程

  • 项目初始目标框架为.NET Core 3.1,根据官方文档,.NET Core 3.1兼容netstandard2.0规格的包,本地验证构建正常,但代理端报错
  • 尝试将项目目标框架切换至.NET 6,兼容性错误依然存在

解决方案

将Azure代理环境中的NuGet版本升级至6.6.0后,构建成功,所有兼容性错误消失。


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.15 06:35:03