Is there an OData dependency graph somewhere?

2019-09-07 01:26发布

问题:

I'm following this guide to migrate an app I developed to an open framework. I get to the part where I'm supposed to install all the OData references. Specifically these:

Install-Package Angularjs 
Install-Package Microsoft.OData.Client 
Install-Package Microsoft.OData.Core 
Install-Package Microsoft.OData.Edm 
Install-Package Microsoft.Spatial 
Install-Package Microsoft.AspNet.OData 
Install-Package Microsoft.AspNet.WebApi.WebHost

And these are the errors I get:

Unable to resolve dependencies. 'Microsoft.OData.Core 7.0.0' is not compatible with 'Microsoft.OData.Client 6.15.0 constraint: Microsoft.OData.Core (= 6.15.0)'.
Unable to find a version of 'Microsoft.OData.Core' that is compatible with 'Microsoft.OData.Client 6.15.0 constraint: Microsoft.OData.Core (= 6.15.0)'.
Unable to find a version of 'Microsoft.OData.Core' that is compatible with 'Microsoft.OData.Client 6.15.0 constraint: Microsoft.OData.Core (= 6.15.0)'.
Unable to find a version of 'Microsoft.OData.Edm' that is compatible with 'Microsoft.OData.Core 6.15.0 constraint: Microsoft.OData.Edm (= 6.15.0)'.

I started running my app over and over until it throws an exception and then adding a bingindRedirect to my Web.config to target the currently installed versions. But this doesn't seem right and will add a lot of maintenance later on. I know how to install old versions and nightly versions. But I have no idea which versions to install. Is there some place that tells me which versions work together correctly?


According to NuGet, I have version 6.15.0 of each installed. So why am I getting errors?

回答1:

Microsoft.OData.Core, Microsoft.OData.Edm and Microsoft.Spatial were already installed after you run "Install-Package Microsoft.OData.Client" command since they are all the dependencies. You can check it from your project reference. So you don't need these commands anymore:

Install-Package Microsoft.OData.Core 
Install-Package Microsoft.OData.Edm 
Install-Package Microsoft.Spatial 

And since the latest version of Microsoft.OData.Client is 6.15.0 which required Microsoft.OData.Core with version 6.15.0. All these packages are installed with version 6.15.0.

If you run the commands below:

Install-Package Microsoft.OData.Core -Version 6.15.0
Install-Package Microsoft.OData.Edm -Version 6.15.0
Install-Package Microsoft.Spatial -Version 6.15.0

You will get the message like following:

Package 'Microsoft.OData.Core.6.15.0' already exists in project

Another issue is that the latest 6.0.0 version of Microsoft.AspNet.OData requires Microsoft.OData.Core version >= 7.0.0 while the version you already installed is 6.15.0. So you need to install the 5.9.1 version which requires Microsoft.OData.Core > 6.14.0.

Install-Package Microsoft.AspNet.OData -Version 5.9.1


回答2:

You could get the dependencies relationship from the NuGet Package Manager page from Project -> Manage NuGet Packages. When you select one of the package, it will show its dependencies on right side. You could select the package version to check which version of dependencies should be installed for current version of package.

The relationship for the OData packages should be OData.Client 6.15 dependent on OData.Core 6.15 and OData.Core 6.15 dependent on OData.Edm 6.15.

But in your project, you installed OData.Core 7.0 and OData.Edm 7.0, which are not compatible with OData.Core 6.15.

So please install the correct version of OData.Core 6.15 and OData.Edm 6.15.