Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An error from Azure DevOps Build: Could not locate the assembly "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?

like image 548
Tohid Avatar asked Oct 28 '18 10:10

Tohid


1 Answers

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.

Show-off

like image 99
Tohid Avatar answered Oct 02 '22 21:10

Tohid