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.

commit 9aaed0a · authored · 1 min read

Azure DevOps Build - Could not locate the assembly

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,

pool:
vmImage: "windows-latest"
variables:
buildConfiguration: "Release"
steps:
- task: DotNetCoreCLI@2
displayName: "dotnet build $(buildConfiguration)"
inputs:
command: "build"
projects: |
path/to/project/*.csproj
arguments: "--configuration $(buildConfiguration)"

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

Restore 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.

local graph · open full graph

"Azure DevOps Build - Could not locate the assembly" is connected to the topics Azure DevOps, ASP.NET Core, .NET Core and related to 6 other entries. GitHub vs Azure DevOps - For Code GitHub vs Azure DevOps - Fo… ASP.NET Core - OAuth 2.0 Client Access Token Management ASP.NET Core - OAuth 2.0 Cl… Azure DevOps - CI/CD Pipeline involving Helm 3, ACR & AKS Azure DevOps - CI/CD Pipeli… ASP.NET Core - Using Mutliple Authentication Schemes ASP.NET Core - Using Mutlip… Serilog - Console Sink Themes Serilog - Console Sink Them… .NET Core - NuGet Packages CI & CD Using GitHub Actions .NET Core - NuGet Packages … Azure DevOps #azure-devops ASP.NET Core #aspnet-core .NET Core #dotnet-core Azure DevOps Build - Could not lo…

comments

loading discussion…