How to Fix Warning MSB3277 on Visual Studio

aspnetcore Aug 26, 2019

I encountered these warnings on building my Visual Studio solution.


5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "Microsoft.AspNetCore.Authentication" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "Microsoft.AspNetCore.Diagnostics" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "Microsoft.Extensions.Caching.Abstractions" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.
5>C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2106,5): warning MSB3277: Found conflicts between different versions of "Microsoft.Extensions.Caching.Memory" that could not be resolved.  These reference conflicts are listed in the build log when log verbosity is set to detailed.

The warnings refer to different assemblies, but they all have the same error code - MSB3277.

Reference conflicts are usually caused by having multiple versions of NuGet packages installed in one solution.

First, I verified that my NuGet packages were all referencing a single version by going to Manage NuGet Packages for Solution > Consolidate tab.

Here I found that my ASP.NET Core API project was still referencing MicrosoftAspNetCore.All instead of Microsoft.AspNetCore.App. I changed this directly in the .csproj file and did not include a version number as recommended by the ASP.NET Core team.


<PackageReference Include="Microsoft.AspNetCore.App" />

Still, the problem didn't go away. After studying my build output I discovered that my xUnit test project was the source of the warnings. The test project has a reference to the API project.

Somehow the test project is loading or referencing the wrong version of the dependencies of the API project. To fix the warnings, I opted to include the Microsoft.AspNetCore.App dependency to the test project, even though it's supposed to be an indirect dependency.

It's not the best solution, but at least the build output is now clean. Hopefully this problem will be fixed by the ASP.NET Core team.

unsplash-logoZach Savinar

Kristina Alberto

Software engineer from Sydney. I work at Domain Group.