Nuget fails to add lightinject 4.0.6 to portable class library

267 Views Asked by At

I'm trying to use lightinject for xamarin application. Common code is inside separate portable class library. This project is configured for TargetFrameWorkProfile Profile78. When I'm adding lightinject 4.0.6 following error appears:

Attempting to gather dependencies information for package 'LightInject.4.0.6' with respect to project 'ProjectName', targeting '.NETPortable,Version=v4.5,Profile=Profile78'
Attempting to resolve dependencies for package 'LightInject.4.0.6' with DependencyBehavior 'Lowest'
Resolving actions to install package 'LightInject.4.0.6'
Resolved actions to install package 'LightInject.4.0.6'
Install failed. Rolling back...
Package 'LightInject.4.0.6 : ' does not exist in project 'ProjectName'
Package 'LightInject.4.0.6 : ' does not exist in folder '<path_to_packages_folder>'
Could not install package 'LightInject 4.0.6'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', 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.

I've found this issue, so I tried to switch to Profile111, but even with this profile this library couldn't be added to PCL.

Maybe I'm missing something else?

2

There are 2 best solutions below

0
On BEST ANSWER

Changed the TFM for profile 111. https://github.com/seesharper/LightInject/commit/8ddb35723d460c0007ac63d7fe249874fbccb960

LightInject 4.0.7 has just been published to the official NuGet feed.

2
On

Looking at the LightInject 4.0.6 NuGet package it has a portable class library folder of:

net45+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10

The Mono and Xamarin parts are optional so if we ignore these we have:

net45+win81+wpa81

PCL profile 111 is the following, ignoring any Mono and Xamarin frameworks:

net45+win+wpa81

win here means win8 (Windows 8).

Looking at Profile 111 and the LightInject NuGet package they are not compatible. The LightInject supports win81 (Windows 8.1) as part of its profile whilst PCL Profile 111 supports win8. In order for LigthInject to be compatible it would have to target win8 not win81.

There does not seem to be an exact PCL Profile that matches what LightInject seems to be targeting. The nearest is Profile 151:

net451+win81+wpa81

Changing the Portable Class Library so it targets Profile 151 allows LightInject to be installed. It seems to be the only profile that I can see which is compatible.