azure-devops | aspnet-core | dotnet-core

Azure DevOps Build - Could not locate the assembly

.NET Core build failing for Azure DevOps? Check if there is any assembly reference and replace it with proper NuGet package.

Edson Frainlar
Edson FrainlarJanuary 23, 2020 · 2 min read · Last Updated:

We were configuring CI/CD for one of our .NET Core 3.1 API project in the Azure DevOps. When trying dotnet build from our local workstation, it was successfull but when CI triggered the build on the Azure DevOps, it was failing.

The Azure Pipeline yml looks like,

1pool:
2 vmImage: "windows-latest"
3
4variables:
5 buildConfiguration: "Release"
6
7steps:
8 - task: DotNetCoreCLI@2
9 displayName: "dotnet build $(buildConfiguration)"
10 inputs:
11 command: "build"
12 projects: |
13 path/to/project/*.csproj
14 arguments: "--configuration $(buildConfiguration)"

The build step successfully restored the NuGet packages which we can see in the logs,

1Restore completed in 14.41 sec for d:\a\1\s\path\to\project\Project.Name.csproj.

But the step was failing with the following reference missing error.

C:\Program Files\dotnet\sdk\3.1.100\Microsoft.Common.CurrentVersion.targets(2106,5): 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. [d:\a\1\s\path\to\project\Project.Name.csproj]

Azure DevOps Build Error
Azure DevOps Build Error

When checked the project reference, found out that the reference to System.ComponentModel.Annotations was added from assembly instead of Nuget. Fixed it by removing the assembly reference and adding the NuGet package of System.ComponentModel.Annotations.

DotNet Core Reference Fix
DotNet Core Reference Fix

Commited the changes and initiated a hotfix release. Tada, the build succeeded.

This page is open source. Noticed a typo? Or something unclear?
Improve this page on GitHub


Edson Frainlar

Written byEdson Frainlar
Mission-driven Full-stack Developer with a passion for developing KTern, Dev Collaboration, and teaching. Curious to explore Quantum Information and Computing.
Connect

Is this page helpful?

Related ArticlesView All

Related VideosView All

Don't Use AutoMapper in C#! Do THIS Instead!

DevOps Series - Introduction to Azure DevOps S1 E1

Exploring Source Generation for Logging

Related Tools & ServicesView All

flurl.dev

Flurl

Flurl is a modern, fluent, asynchronous, testable, portable, buzzword-laden URL builder and HTTP client library for .NET.