Found conflicts between different versions of "Microsoft.Bcl.AsyncInterfaces" - c#

I have a netstandard2.0 library that is used by net5.0 applications
One of packages used by the library references Microsoft.Bcl.AsyncInterfaces 5.0.0
But I get this warning for every application:
47>C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2203,5):
warning MSB3277: Found conflicts between different versions of "Microsoft.Bcl.AsyncInterfaces" that could not be resolved.
There was a conflict between "Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" and "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51".
"Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was chosen because it was primary and "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" was not.
References which depend on "Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll].
C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll
Project file item includes which caused reference "C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll".
C:\Users\IgorBe\.nuget\packages\microsoft.bcl.asyncinterfaces\1.1.1\ref\netstandard2.1\Microsoft.Bcl.AsyncInterfaces.dll
References which depend on "Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51" [].
Please note that "Project file item includes which caused reference" is not a project but the dll itself. My guess is that 1.0.0 version is used by compiler with .net standard to provide some core async functionality
But how can I get rid of this message? There seems to be no binding redirection for .Net 5.0

Related

Found conflicts between different versions of "Microsoft.CSharp" that could not be resolved

Trying to Archive for Publishing our Xamarin.iOS app in Visual Studio on Mac but I get this error.
"Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was chosen because it was primary and "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" was not.
References which depend on "Microsoft.CSharp, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Microsoft.CSharp.dll].
/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Microsoft.CSharp.dll
Project file item includes which caused reference "/Library/Frameworks/Xamarin.iOS.framework/Versions/Current/lib/mono/Xamarin.iOS/Microsoft.CSharp.dll".
Microsoft.CSharp
References which depend on "Microsoft.CSharp, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" [].
/Users/user193748/Documents/repos/APP/APP/APP/bin/Release/netstandard2.0/APP.dll
Project file item includes which caused reference "/Users/user193748/Documents/repos/APP/APP/APP/bin/Release/netstandard2.0/APP.dll".
/Users/user193748/Documents/repos/APP/APP/APP/bin/Release/netstandard2.0/APP.dll
This has happened since I update Xamarin.Forms from 5.0.0.2196 to 5.0.0.2244. I tried to reverting the version and deploying but the same error occurs. I also tried going from .NET Standard 2.0 to 2.1. I've had the warning before and I was still able to Archive for Publishing. The app can be deployed on Visual Studio in Windows to the Android store but for some reason the iOS side of things is preventing it.
We had to update to a new MacInCloud server which had the latest iOS version (Monterey). This solved the issue.

How to resolve .net version conflicts

I have the following warning messages during build.
No way to resolve conflict between "System.ComponentModel.Annotations,
Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" and
"System.ComponentModel.Annotations, Version=4.0.10.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a". Choosing
"System.ComponentModel.Annotations, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a" arbitrarily.
We have around 70 C# projects (net framework 462, net core, net standard). Are there any automated tools to fix the version conflicts problem?

Conflict between System, Version=4.0.0.0 and System, Version=2.0.5.0 in ServiceStack.Interfaces

I am trying to resolve build warnings but I cannot get past this one. I am targeting .Net 4.6.2, but it appears that ServiceStack.Interfaces is targeting a lower version? In the detailed output:
There was a conflict between "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes".
1> "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not.
1> References which depend on "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" [C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll].
1> C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll
1> Project file item includes which caused reference "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\System.dll".
Then followed by many regular assemblies which looks good, then the conflict:
1> References which depend on "System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" [].
1> C:\Code\Trunk\packages\ServiceStack.Interfaces.4.5.6\lib\portable-wp80+sl5+net45+win8+wpa81+monotouch+monoandroid+xamarin.ios10\ServiceStack.Interfaces.dll
1> Project file item includes which caused reference "C:\Code\Trunk\packages\ServiceStack.Interfaces.4.5.6\lib\portable-wp80+sl5+net45+win8+wpa81+monotouch+monoandroid+xamarin.ios10\ServiceStack.Interfaces.dll".
1> ServiceStack.Common, Version=4.5.6.0, Culture=neutral, processorArchitecture=MSIL
1> ServiceStack.Interfaces, Version=4.0.0.0, Culture=neutral, PublicKeyToken=e06fbc6124f57c43, processorArchitecture=MSIL
1> ServiceStack.Redis, Version=4.5.6.0, Culture=neutral, processorArchitecture=MSIL
So it appears that ServiceStack.Interfaces is causing the problem, yet I need to reference it. Am I referencing it wrong in some way? How can I resolve the warning?
ServiceStack.Interfaces is a plain PCL library that's just built with the System.Runtime.Serialization it references using VS2017's new MSBuild format. It doesn't explicitly reference any version, the PCL build decides on what version it uses.
Once .NET Standard 2.0 and .NET Core 2.0 is released we'll be merging .NET Standard libraries together into the main ServiceStack NuGet packages in a major v5 release of ServiceStack that will replace the PCL libraries with .NET Standard which will resolve this warning, but we'll need to wait for v5 before we make any structural changes.

MSBuild conflict between mscorlib 4.x and mscorlib 2.x

I was investigating a build failure recently and saw a warning about conflicts between assemblies. I dug deeper and MSBuild told me this:
There was a conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes".
"mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not.`
My solution contains several console applications, lots of class libraries and ASP.NET application. We build on .NET 4.5.2.
Should I be concerned?
When using PCL libraries it is better add Microsoft.Bcl.Build Nuget package which will attempt to resolve this issue for your.
Also you should investigate dependencies of your class libraries and find where you depends on the PCL library.

Xamarin - Could not load assembly 'PCLStorage.Abstractions

After adding the FlurlHttp Nuget package to my PCL project my app will no longer deploy to my emulator due to an assembly loading error
Error Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'PCLStorage.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'PCLStorage.Abstractions.dll'
at Xamarin.Android.Tuner.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters)
at
Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.AddAssemblyReferences(ICollection`1 assemblies, AssemblyDefinition assembly, Boolean topLevel)
at Xamarin.Android.Tasks.ResolveAssemblies.Execute() InfoSupport.AV.MobileClient.Droid C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets 1347
The build system is also reporting conflicts :
There was a conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes". (TaskId:77)
2> "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" was chosen because it was primary and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes" was not. (TaskId:77)
There was a conflict between "PCLStorage.Abstractions, Version=0.9.6.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64" and "PCLStorage.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64". (TaskId:142)
2> "PCLStorage.Abstractions, Version=0.9.6.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64" was chosen because it was primary and "PCLStorage.Abstractions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=286fe515a2c35b64" was not. (TaskId:142)
These errors appeared after adding the Microsoft.Build.Async (1.0.168), Microsoft.Bcl.Build(1.0.21), Microsoft.Net.Http(2.2.29), Microsoft.Bcl (1.1.10) nuget packages to my
PCL project, Xamarin forms project and Xamarin Droid project.
In addition, the Nuget packages Xamarin.Forms.Maps (v2.1.0.6508) and Xamarin.Forms (v2.1.0.6508-pre3) are used.
Adding the nuget package PclStorage v1.0.2 to the PCL project resolves both warnings and the deployment error.
I'm not sure why this dependency is there.

Categories