Azure DevOps Build中的错误:无法找到程序集“ System.ComponentModel.Annotations”。 [英] An error from Azure DevOps Build: Could not locate the assembly "System.ComponentModel.Annotations"

查看:221
本文介绍了Azure DevOps Build中的错误:无法找到程序集“ System.ComponentModel.Annotations”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个netstandard 2.0项目,其中引用了 System.ComponentModel.Annotations 。它可以在本地计算机上很好地构建,但是当我尝试使用Azure DevOps管道构建它时,出现以下错误:


。 .warning MSB3245:无法解决此引用。无法找到程序集 System.ComponentModel.Annotations。检查以确保程序集在磁盘上。如果您的代码需要此引用,则可能会出现编译错误。 [/home/vsts/work/1/s/src/MyProj/MyProj.csproj]



... MyProj / MyClass.cs(2,29):错误CS0234:类型或名称空间名称 DataAnnotations在名称空间 System.ComponentModel中不存在(是否缺少程序集引用?)[/ home / vsts / work / 1 / s / src / MyProj / MyProj.csproj]


该错误是不言自明的,我理解它的意思,但是问题是我应该如何解决它才能满足Azure DevOps构建?

解决方案

发现了问题。我应该在项目依赖项中引用 System.ComponentModel.Annotations ,而不是安装


I have a netstandard 2.0 project with a reference to System.ComponentModel.Annotations. It builds fine on my local computer, but when I try to build it using Azure DevOps pipeline, I get the following error:

...warning MSB3245: Could not resolve this reference. Could not locate the assembly "System.ComponentModel.Annotations". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [/home/vsts/work/1/s/src/MyProj/MyProj.csproj]

...MyProj/MyClass.cs(2,29): error CS0234: The type or namespace name 'DataAnnotations' does not exist in the namespace 'System.ComponentModel' (are you missing an assembly reference?) [/home/vsts/work/1/s/src/MyProj/MyProj.csproj]

The error is self-explanatory and I understand what it says, but the question is how should I resolve it to satisfy Azure DevOps build?

解决方案

Found the issue. Instead of making a reference to System.ComponentModel.Annotations in my project dependencies, I should have installed System.ComponentModel.Annotations NuGet package.

I installed the package and Azure DevOps Build successfully built the project.

这篇关于Azure DevOps Build中的错误:无法找到程序集“ System.ComponentModel.Annotations”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆