Microsoft ASP.NET Web API Odata nuget package is failing to install - asp.net-web-api

Attempting to resolve dependency 'Microsoft.Data.Edm (= 5.0.1)'.
Attempting to resolve dependency 'Microsoft.Data.OData (= 5.0.1)'.
Attempting to resolve dependency 'System.Spatial (≥ 5.0.1)'.
Attempting to resolve dependency 'Microsoft.Net.Http (≥ 2.0.20710.0 && < 2.1)'.
Attempting to resolve dependency 'System.Spatial (= 5.0.1)'.
Already referencing a newer version of 'System.Spatial'.
Anyone got any ideas? why this package is not install? Google search is empty

Alex James posted on his blog that this has been fixed.
The issue was that ODataLib was released after this OData package was released and that broke the dependencies (version numbers didn't add up). Everything works now, at least for me.

Related

Error NU1107 Version conflict detected for Xamarin.AndroidX.Lifecycle.LiveData

I get the following error:
Error NU1107 Version conflict detected for Xamarin.AndroidX.Lifecycle.LiveData.
Install/reference Xamarin.AndroidX.Lifecycle.LiveData 2.4.1.1 directly to project MyProject.Android to resolve this issue.
MyProject.Android -> Xamarin.GooglePlayServices.Ads 121.2.0 -> Xamarin.GooglePlayServices.Ads.Lite 121.2.0 ->
Xamarin.AndroidX.Work.Runtime 2.7.1.3 ->
Xamarin.AndroidX.Lifecycle.LiveData (>= 2.4.1.1)
MyProject.Android -> Xamarin.Forms 5.0.0.2515 -> Xamarin.AndroidX.Lifecycle.LiveData (>= 2.3.1.1 && < 2.4.0).
Which packages should I upgrade or downgrade in order to achieve compatibility?
I have created a new project to test the packages you mentioned. And I found two solutions:
Just use the following package in your project's android part:
Xamarin.AndroidX.Browser version 1.4.0.1
Xamarin.AndroidX.Lifecycle.LiveData version 2.4.1.1
Xamarin.GooglePlayServices.Ads version 121.2.0
Xamarin.Forms version 5.0.0.2515
This solution just adds the reference to the project's android part according to the error messages. And the project will build successfully even though there are still some warnings about the package.
The second solution:
use the Xamarin.Forms version 5.0.0.2545
and the Xamarin.GooglePlayServices.Ads version 120.4.0
The Xamarin.GooglePlayServices.Ads version 120.4.0 is the newest version which is compatible with the Xamarin.AndroidX.Browser (>= 1.3.0.6 && < 1.4.0). If you use the two packages above, there will not be any warnings or errors about the reference.
If you can, you should upgrade to Xamarin.Forms 5.0.0.2545. It allows for LiveData to be high enough. It's a minor upgrade for XF, so it shouldn't cause you any issues to upgrade.
If for whatever reason you can't upgrade Xamarin Forms, you'll need to downgrade GooglePlayServices.Ads to a version that allows for the lower Work.Runtime version which in turn allows for the lower LiveData version.

Xamarin MSAL NuGet error - Version conflict detected for Xamarin.Android.Support.Compat

I'm trying to add the MSAL NuGet package https://www.nuget.org/packages/Microsoft.Identity.Client to a Xamarin forms project but keep getting the following error:
Package restore failed. Rolling back package changes for
'MobileApp.Android'.
Error NU1107 Version conflict detected for
Xamarin.Android.Support.Compat. Install/reference
Xamarin.Android.Support.Compat 27.0.2.1 directly to project
MobileApp.Android to resolve this issue.
MobileApp.Android -> Xamarin.Android.Support.v7.MediaRouter
27.0.2.1 -> Xamarin.Android.Support.v7.Palette 27.0.2.1 ->
Xamarin.Android.Support.Compat (= 27.0.2.1)
MobileApp.Android -> Microsoft.Identity.Client 2.2.0-preview ->
Xamarin.Android.Support.CustomTabs 27.0.2 -> Xamarin.Android.Support.Compat
(= 27.0.2).
I've tried clearing the NuGet cache from Visual Studio 2017 -> Tools -> Options -> NuGet Package Manager, and also manually clearing the cache by deleting the contents of the following folders:
%userprofile%\.nuget\packages
%localappdata%\NuGet\v3-cache
%temp%\NuGetScratch
%localappdata%\NuGet\plugins-cache
I've also tried creating a new blank project and just adding the NuGet package but continue to receive the same error. NuGet seems to working OK for other types of projects.
Any ideas much appreciated.
Xamarin MSAL NuGet error - Version conflict detected for Xamarin.Android.Support.Compat
This is nuget package version conflict issue.
To resolve this issue, you should install the package Xamarin.Android.Support.CustomTabs 27.0.2.1 at first, then install the package Microsoft.Identity.Client.
The reason for this issue:
Since you have already installed the package Xamarin.Android.Support.v7.MediaRouter
27.0.2.1 in your project, which have a indirect dependence Xamarin.Android.Support.Compat (= 27.0.2.1). When you install the package Microsoft.Identity.Client to the project, which also have a indirect dependence Xamarin.Android.Support.Compat (= 27.0.2). You could notice that the versions are different, a project cannot reference the same reference different version, which cause the version conflict.
To resolve this issue, we need to unify the references of these two different versions. Check the Dependencies of the package Microsoft.Identity.Client 2.2.0-preview, this package have a dependency Xamarin.Android.Support.CustomTabs (>= 27.0.2) and the dependency Xamarin.Android.Support.CustomTabs (>= 27.0.2) also have a dependency Xamarin.Android.Support.Compat (= 27.0.2). So to resolve this issue, we just need to install the dependency Xamarin.Android.Support.CustomTabs (>= 27.0.2.1) at first, which have the dependency is Xamarin.Android.Support.Compat (= 27.0.2.1):
Hope this helps.

Installing Microsoft.Extensions.DependencyInjection in .NET Framework 4.7.1 project

I'm attempting to install the Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.DependencyInjection.Abstractions 2.0.0 nuget packages into a .NET Framework 4.7.1 project (Microsoft.AspNet.OData), however I'm getting the error:
Could not install package 'Microsoft.Extensions.DependencyInjection
2.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.1', but the package does not
contain any assembly references or content files that are compatible
with that framework. For more information, contact the package author.
The dependency for these packages is .NETStandard,Version=v2.0. I understand that .NET Standard isn't .NET Framework, however I thought that .NET Framework 4.6 and greater projects could install .NET Standard projects? If this isn't possible, then are there other equivalent versions of these nuget packages for .NET Framework?
The whole reason that I'm going through this exercise is because many developers are completely blocked by Microsoft.AspNet.OData only supporting DI 1.0, not 2.0. This means that we cannot upgrade our nuget packages in our OData web api, as other packages require DI 2.0 but OData is stuck on 1.0. The rest of our applications are using the latest and greatest, so really it means that our OData web api solution can't leverage ANY of our shared code, and is completely quarantined until this compatibility block is resolved.
Installing Microsoft.Extensions.DependencyInjection in .NET Framework 4.7.1 project
I think the error message is not accurate. When I install the nuget package Microsoft.Extensions.DependencyInjection 2.0.0 to the project (Microsoft.AspNet.OData), I got the following error message:
Unable to resolve dependencies.
'Microsoft.Extensions.DependencyInjection 2.0.0' is not compatible
with 'Microsoft.AspNet.OData 7.0.0-beta2 constraint:
Microsoft.Extensions.DependencyInjection (>= 1.0.0 && < 2.0.0)'.
That is exactly what you said "because many developers are completely blocked by Microsoft.AspNet.OData only supporting DI 1.0, not 2.0."
Check the dependencies of package Microsoft.AspNet.OData, we could know there are strict restrictions for the dependencies Microsoft.Extensions.DependencyInjection and Microsoft.Extensions.DependencyInjection.Abstractions ((>= 1.0.0 && < 2.0.0))
So, this is really a issue that the package Microsoft.AspNet.OData don't support DI 2.0. Many other communities also report this issue on Github, but there is still no any workaround and solution.
My current workaround is:
Create a new project without installing package Microsoft.AspNet.OData.
Install the other dependencies of package Microsoft.AspNet.OData: Microsoft.OData.Core (>= 7.2.0 && < 8.0.0), Microsoft.AspNet.WebApi.Core (>= 5.2.2 && < 5.3.0) and Microsoft.AspNet.WebApi.Client (>= 5.2.2 && < 5.3.0) (The latter two packages should be included in the template by default).
Install the nuget package Microsoft.Extensions.DependencyInjection 2.0.0
Install the nuget package Microsoft.AspNet.OData with option -IgnoreDependencies in the Package Manager Console:
update-package Microsoft.AspNet.OData -IgnoreDependencies -IncludePrerelease
With this workaround, we could use Microsoft.AspNet.OData and DI 2.0, but I could fully confirm whether breaking the dependency limition will cause any problem for the Microsoft.AspNet.OData package. Simple tests are not problematic.
Hope this helps.

Unable to add Xamarin Google Play Services

I'm unable to add GCM to my Xamarin app. This is the output from the package console:
Adding Xamarin.GooglePlayServices.Gcm...
Attempting to resolve dependency 'Xamarin.GooglePlayServices.Base (= 29.0.0.1)'.
Attempting to resolve dependency 'Xamarin.GooglePlayServices.Basement (= 29.0.0.1)'.
Attempting to resolve dependency 'Xamarin.Android.Support.v4 (≥ 23.1.1.1)'.
Attempting to resolve dependency 'Xamarin.GooglePlayServices.Measurement (= 29.0.0.1)'.
Updating 'Xamarin.Android.Support.v4 23.0.1.3' to 'Xamarin.Android.Support.v4 23.3.0' failed. Unable to find a version of 'Xamarin.Forms' that is compatible with 'Xamarin.Android.Support.v4 23.3.0'.
For this version you must install an earlier version of Xamarin.GooglePlayServices.Gcm. I had no problems with 27.0.0.
If you need the newest version, you could do this:
uninstall xamarin.forms nuget package
update all android packages to 23.3.0
install Xamarin.GooglePlayServices.Gcm
search for xamarin.forms and set in options ignore dependencies
install newest version
Of course you must be aware of problems, since this is not recommended with good reasons.
You need to Update your Xamarin.Forms package. Open Packages (Dropdown) in Solutions pane and Right-Click on Xamarin.Forms and click on Update
If you are using PCL, you can find this package in the PCL (Xamarin.Forms) project.
If you are using Shared Asset Project, you will find this package in both Xamarin.Android and Xamarin.iOS project.
You have to update Android SDK Platform-tools to revision 26.0.2 (or equivalent).
Open Android SDK Manager, check update, and select
"Update avaiable rev.26.0.2" and install it.

Creating interceptors with Autofac and MVC3

I need to create a performance monitoring interceptor that will be hooked up via Autofac. Unfortunately, it's for an MVC3 project, meaning that I'm using Autofac 2.6.3, because Autofac 3 is only compatible with MVC4. As such, I cannot use the Autofac.Extras.DynamicProxy2 Nuget package, because it isn't compatible with MVC3.
I've found AutofacContrib.DynamicProxy2, which is compatible with Autofac 2.6.3. The problem is, the Nuget package doesn't install due to a version mismatch between the dependencies. The problem is highlighted below:
AutofacContrib.DynamicProxy2
Depends on 'Autofac (>= 2.4.5.724)'
Depends on 'Castle.Core (>= 2.5.2)'.
Depends on 'Castle.DynamicProxy (>= 2.2.0)'.
Depends on 'Castle.Core (= 1.2.0)'.
I get the following Nuget package install error:
Updating 'Castle.Core 2.5.2' to 'Castle.Core 1.2.0' failed. Unable to find a version of 'AutofacContrib.DynamicProxy2' that is compatible with 'Castle.Core 1.2.0'
How can I perform method interception with MVC3 and Autofac?
Looks like I can install 'DynamicProxy2', thanks to this article
Basically, after installing AutofacContrib.DynamicProxy2 and getting the error, I need to install it again with the -ignoredependencies flag and it installs OK.
Run this command:
install-package autofaccontrib.dynamicproxy2
Followed by this command:
install-package autofaccontrib.dynamicproxy2 -ignoredependencies

Resources