5
votes

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?

1
could you try with these solutionsJayendran
@Jayendran - I should have installed the NuGet pack: stackoverflow.com/a/53032512/538387Tohid

1 Answers

8
votes

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