Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This article describes the MSB3277 warning.
Message text
MSB3277: Found conflicts between different versions of 'assembly-name' that could not be resolved.
Description
This warning occurs during a build when more than one version of the same dependent assembly is referenced in a build of the same project. In a .NET build, all assemblies that are referenced, directly or indirectly through other referenced assemblies, have to resolve to the same version. You shouldn't reference two different and conflicting versions of the same assembly when building the same binary. The ResolveAssemblyReference task emits this warning. The task inspects all the referenced assemblies, and all assemblies referenced indirectly by those assemblies, and so on. The task works through the process until all assembly references are resolved.
Diagnose the warning
To diagnose the issue, first enable diagnostic log output by using the -verbosity:diag
command-line switch, and then check the MSBuild log file with the full diagnostics output. For longer output logs on large projects, consider using the binary log -bl
command-line switch and the MSBuild Structured Log Viewer to view the output more easily.
In MSBuild 16.x or later, the specific assembly versions in conflict are written to the log file. In earlier versions of MSBuild, the content isn't added to the log file. Instead, follow the assembly dependency chain to locate the conflicting reference. Look at each assembly that your project references, and then the assemblies that the initial assemblies reference, and so on. Follow this process until you identify the conflicting assembly versions.
The diagnostics log should identify the specific assembly versions that are in conflict and the reasons for the conflicts. For example, a reference to assembly1.dll, which references assembly2.dll version x, but also references assembly2.dll version y. MSBuild can't determine which version to use for the assembly.
The following example is an excerpt from a diagnostic log showing a conflict between two versions of StreamJsonRpc
:
There was a conflict between "StreamJsonRpc, Version=2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and "StreamJsonRpc, Version=2.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
"StreamJsonRpc, Version = 2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "StreamJsonRpc, Version=2.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "StreamJsonRpc, Version = 2.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [C:\Users\user\.nuget\packages\streamjsonrpc\2.1.74\lib\netstandard2.0\StreamJsonRpc.dll].
C:\Users\user\.nuget\packages\streamjsonrpc\2.1.74\lib\netstandard2.0\StreamJsonRpc.dll
Project file item includes which caused reference "C:\Users\user\.nuget\packages\streamjsonrpc\2.1.74\lib\netstandard2.0\StreamJsonRpc.dll".
C:\Users\user\.nuget\packages\streamjsonrpc\2.1.74\lib\netstandard2.0\StreamJsonRpc.dll
C:\Users\user\.nuget\packages\microsoft.servicehub.framework\2.0.72\lib\netstandard2.0\Microsoft.ServiceHub.Framework.dll
Project file item includes which caused reference "C:\Users\user\.nuget\packages\microsoft.servicehub.framework\2.0.72\lib\netstandard2.0\Microsoft.ServiceHub.Framework.dll".
C:\Users\user\.nuget\packages\microsoft.servicehub.framework\2.0.72\lib\netstandard2.0\Microsoft.ServiceHub.Framework.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.15.0\16.4.29318.21\lib\net472\Microsoft.VisualStudio.Shell.15.0.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.datadesign.common\16.0.28321-alpha\lib\net472\Microsoft.VisualStudio.DataDesign.Common.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.projectsystem\16.2.133-pre\lib\net472\Microsoft.VisualStudio.ProjectSystem.VS.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.design\16.0.28316-pre\lib\net45\Microsoft.VisualStudio.Shell.Design.dll
C:\Users\user\.nuget\packages\microsoft.vsdesigner\16.0.28321-alpha\lib\net472\Microsoft.VSDesigner.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.language\16.0.428\lib\net472\Microsoft.VisualStudio.Language.dll
Project file item includes which caused reference "C:\Users\user\.nuget\packages\microsoft.visualstudio.language\16.0.428\lib\net472\Microsoft.VisualStudio.Language.dll".
C:\Users\user\.nuget\packages\microsoft.visualstudio.language\16.0.428\lib\net472\Microsoft.VisualStudio.Language.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.editor\16.0.428\lib\net472\Microsoft.VisualStudio.Editor.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
Project file item includes which caused reference "C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll".
C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.utilities\16.4.29317.144\lib\net46\Microsoft.VisualStudio.Utilities.dll
Project file item includes which caused reference "C:\Users\user\.nuget\packages\microsoft.visualstudio.utilities\16.4.29317.144\lib\net46\Microsoft.VisualStudio.Utilities.dll".
C:\Users\user\.nuget\packages\microsoft.visualstudio.utilities\16.4.29317.144\lib\net46\Microsoft.VisualStudio.Utilities.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.imaging\16.4.29317.144\lib\net472\Microsoft.VisualStudio.Imaging.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.languageservices\3.2.0-beta4-19359-03\lib\net472\Microsoft.VisualStudio.LanguageServices.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.15.0\16.4.29318.21\lib\net472\Microsoft.VisualStudio.Shell.15.0.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.datadesign.common\16.0.28321-alpha\lib\net472\Microsoft.VisualStudio.DataDesign.Common.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.projectsystem\16.2.133-pre\lib\net472\Microsoft.VisualStudio.ProjectSystem.VS.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.design\16.0.28316-pre\lib\net45\Microsoft.VisualStudio.Shell.Design.dll
C:\Users\user\.nuget\packages\microsoft.visualstudio.shell.framework\16.4.29318.21\lib\net472\Microsoft.VisualStudio.Shell.Framework.dll
C:\Users\user\.nuget\packages\microsoft.vsdesigner\16.0.28321-alpha\lib\net472\Microsoft.VSDesigner.dll
References which depend on "StreamJsonRpc, Version = 2.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
You can also set the MSBuildDebugEngine
environment variable to 1 to get all possible logs. For more information, see Building MSBuild for the .NET Framework - Logs.
Resolution
How you resolve this issue depends on your project configuration and assembly dependency requirements:
- Update the version of an assembly on disk by upgrading or reinstalling a NuGet package or SDK.
- Update all packages to the latest versions with the
Update-Package -reinstall
command in the Package Manager Console for Visual Studio. For more information, see Reinstalling and updating packages. - For projects with multiple versions of a referenced assembly on disk, update the project or the dependencies to reference the latest version of the installed conflicting assembly. The Global Assembly Cache (GAC) might also be a source of a potential conflict, in cases where you reference a specific version of an assembly, but the GAC overrides it. For more information, see Global Assembly Cache.
External components
If the conflict is in a non-Microsoft component, the component might not be supported with the version of the conflicting assembly you're using in your project. Check the provider of the other component to see if they offer an updated, compatible version. If a fix isn't available, the solution might be to downgrade the version of the conflicting assembly you're referencing to match the version that the other component uses.
Binding redirects
In some cases, your project might specify or might need to specify binding redirects, which force calls to use a specified version of an assembly. For more information, see Redirecting assembly versions to understand how binding redirects work.
Visual Studio or settings in project files can enable or disable automatic binding redirection. For more information, see Enable and disable automatic binding redirection. Check the settings and make sure you understand how and why your project is using binding redirects.
Multiple versions of assembly loaded
In advanced scenarios, your project might intentionally require more than one version of the same assembly. You can use special techniques to override the normal assembly loading process to accomplish the goal. For more information, see Resolve assembly loads. Be sure to understand and follow the guidance in Best practices for assembly loading.
For a guide on resolving issues with assembly references, see Troubleshoot assembly references and How the runtime locates assemblies.
Applies to
All versions of MSBuild