问题
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:
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.
来源:https://stackoverflow.com/questions/53030310/an-error-from-azure-devops-build-could-not-locate-the-assembly-system-componen