-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Microsoft.CSharp conflict #1261
Comments
It is rather a Microsoft.Build issue. At least from xamarin-android developers' perspective, we have no control over how NuGet package dependencies are resolved, how *.csproj is modified, or how MSBuild resolves those dependencies within itself (we offer framework assemblies along with MSBuild manner, no chance to control nuget side of things). The project references in *.csproj after adding Newtonsoft.Json package is simple:
It is msbuild's responsibility to appropriately resolve the reference to the appropriate assembly. Actually msbuild is doing almost the right job by (1) warning the possibility that the app may not be actually running the assembly the developer expects, and (2) choosing the "right" one in Xamarin.Android framework.
As long as I tested by myself, the reference to Newtonsoft.Json.dll is resolved to the one in I cannot think of any solution for this situation (maybe MSBuild devs would), but it's worth noting that the result is just warning, not error. |
Following the link to the original bug, the fix is to remove the explicit reference to the Microsoft.CSharp 2.0.5. This will allow MSBuild to include the correct net standard version which NewtonSoft is referencing. |
Thank you I'll try to do that. |
@stijnvanbossuyt I have no idea, probably best to open and issue for the iOS team. |
The fix is to remove the Microsoft.CSharp 2.0.5 and allow the one from Nuget to be used. |
Don't dare to remove the right one (2.0.5). Let msbuild pick the right one. Warning is much better than possible run-time failures due to implementation mismatch. |
as mentioned above, it's caused by Newtonsoft.Json package referenced in a netstandard 2.0 project. Fortunately, updating Newtonsoft.Json to the latest version( current is 11.0.1 ) will fix this problem. This is because this version of Newtonsoft.Json package for netstandard 2.0 has no dependency to Microsoft.CSharp |
Repair Visual Studio worked for me. I tried everything but nothing worked. I hope this can help someone. Best Regards. |
Seems to be also an issue with dapper now as well if you have it in a project. |
I am also getting this warning in our project with a message |
From what I can see in my project, it seem to be related to the fact that all the Mono.Android.dll files in (default) If you have Android v9.0 as target framework and select properties for the Mono.Android in your solution explorer, you will see the Path be to the correct /V9.0/Mono.Android.dll, but during compilation, msbuild will use /V1.0/Mono.Android.dll as reference, and the 1.0 version is referencing Microsoft.CSharp 2.0.5.0 instead of 4.0.0.0. I'm guessing the build pipeline simply choose the first file it finds due to them all having version number 0.0.0.0 and are considered the same, and thus produces the warning. That being said, so far I have not seen any bad effects of this, apart from the annoying warning in the error log. |
We've gained a build warning in DayTrack.Android after installing EFCore.BulkExtensions. After 2 hours of research, I can't seem to resolve it. dotnet/android#1261 (comment)
Is there a solution for this? |
Same issue with Microsoft.Graph - Recently upgraded to xamarin.forms 5.0 and upgraded Microsoft Graph and now I cannot compile anymore... Latest Version 3.21.0 uses net framework net standard 2.0 and 4.6.1 but all Versions which start with 1..* still use 4.5 and net standard 1.3, Microsoft graph 1.15 still uses netstandard 1.1 but currently I cannot compile with any of the version Is there any workarround yet? tried removing the andorid Csharp.targets from the Android project but just cased a warning of a unknown netframework version... When are we moving xamarin finally to netstandard
|
Ok here are the acutal steps to reproduce it: Using Visual Studio 2019 Version 16.10.0 Preview 2.1 Create a Xamarin Forms 5 Project (with android and ios, type flyout in my case) Add to the Shared Net Standard 2.1 Project: Add NuGetPackage Microsoft.Identity.Client 4.30.0 Build the android project - the error should appear. If not I can upload sample project. As suggested here, adding the references directory to the android project also didn't solve the problem Solving Attept: I spend again at least half a day on this and saw Where it is asked and recommended to remove the 2.0.5 Reference by Xamarin and just let 4.0 override. Which microsoft responds is save. Sorry I overlooked the answer @dellis1972 could you provide maybe a more detailed answer for this problem Currently I don't find where I can remove the reference to net 2.0.5 Or can somebody else maybe help me how to remove this dependency? Inside the Android csproj is the line
Just deleting this line leads to a Rebuild Error Latter line references at my Maschine But so far I have nto reached the point where Microsoft.CSharp 4.0.0 was referenced. Thank you for everybody in assitance in this problem! |
I am also seeing this same behavior with the newest drop of 16.9. I added Mapster to my project and now I get these errors. I cannot find any explicit reference to the 2.0.5 version of Microsoft.CSharp |
Please reopen this issue, I think this problem is exist until now I have the same problem with AutoMapper
@dellis1972 Please reopen this issue |
Yeah, same here. None of the options this or related issues worked. |
Any update ? Conflicts for Microsoft.CSharp :
Conflict for System.Numeric.Vector :
Thanks for reopenning this issue. |
I also have the same for System.Numerics.Vectors and the fix is to target for .net6.0-android in MAUI project to use the new .net 6 dlls. |
Sorry but I can't fix this by migrating to MAUI... and it doesn't fix the problem with Xamarin.Forms(/Android). These bugs are from my projects in production (more than 20) and done with Xamarin.Forms |
I know, I see the same for my XF apps. I gave it up on this as the apps work so far |
@jonpryor can you weigh in on this one? I'm not 100% sure its something we can fix in Legacy Xamarin.Android. |
I appreciate that we should be forward looking (into Maui), but please note that for many people migration may only be feasible if third party controls for instance become feature compatible. For instance, people using for instance SyncFusion Xamarin Components quickly will miss controls when switching to MAUI:
Telerik looks similar... |
Hi,
I'm facing Microsoft.CSharp conflict due to Newtonsoft.Json.10.0.3. I found this https://bugzilla.xamarin.com/show_bug.cgi?id=59600
Here is the build log:
Is there a way to fix this?
(related Newtonsoft.Json issue)
The text was updated successfully, but these errors were encountered: