An error from Azure DevOps Build: Could not locate the assembly "System.ComponentModel.Annotations"
Asked Answered
P

1

5

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?

Pace answered 28/10, 2018 at 10:3 Comment(2)
could you try with these solutionsDorpat
@Dorpat - I should have installed the NuGet pack: https://mcmap.net/q/246142/-an-error-from-azure-devops-build-could-not-locate-the-assembly-quot-system-componentmodel-annotations-quotPace
P
9

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

Pace answered 28/10, 2018 at 14:22 Comment(1)
Thanks, that was it. I added manually some attributes (in my case [NotMapped]) on top of some properties and I resolved it, including the wrong library. So adding the correct package (yours) fixed my pipeline build errors. Strange why this does not happen when you build in Visual Studio.Overabound

© 2022 - 2024 — McMap. All rights reserved.