Automapper has lost pcl compatibility - xamarin

I'm using Automapper in a PCL for 3 years and everything was working well.
But since version 4.2.1 when I try to install it in a PCL I get the following error:
Could not install package 'AutoMapper 4.2.1'.
You are trying to install this package into a project that targets
'portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10',
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.
Is there something new that I'm missing?
Thanks guys

AutoMapper 4.2.1 does not support Windows Phone 8 (wp80). Here wp80 is the Silverlight based Windows Phone target framework. So your portable class library project's profile is incompatible. Looking at AutoMapper 4.2.1 the NuGet package has a PCL directory of:
portable-net45+win+wpa81+MonoAndroid10+Xamarin.iOS10+MonoTouch10
The Xamarin and Mono frameworks are optional so the PCL profile is basically:
net45+win+wpa81
So that is a profile that supports .NET 4.5, Windows 8 and Windows Phone Applications 8.1. Here wpa81 is the WinRT based Windows Phone target framework. This PCL profile seems to be Profile111.
So in order to use AutoMapper 4.2.1 you will need to change your PCL project's profile. Your current profile seems to be Profile78. If you switch to Profile111 or another compatible profile then you should be able to install AutoMapper 4.2.1.
Alternatively you can use an older version of AutoMapper. AutoMapper 4.1.0 targets:
net45+win+wpa81+wp8+MonoAndroid10+Xamarin.iOS10+MonoTouch10
Which supports Profile78. So it looks like the latest AutoMapper has dropped support for Windows Phone 8 (Silverlight).

Related

Could not install package 'Microsoft.Extensions.Logging 2.1.1'

I'm trying to update Bing Ads SDK to version 12.13.5. I am using Visual Studio 2013. Nuget version is 2.12.0.817. When I try to update, I get the following error:
Could not install package 'Microsoft.Extensions.Logging 2.1.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', 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 tried installing Microsoft.Extensions.Logging 3.0.0 (latest version) and get the same error.
I also tried targeting .NET version 4.6.1 and 4.5.2 and got the same error.
For anyone else who may have this problem, the solution was to manually add a package entry
for Microsoft.Extensions.Logging 2.1.1 to packages.config. This allowed the Bing Ads SDK package to update successfully.
As indicated in the docs, your platform needs to be .NETStandard 2.0 or .Net Core 2.1.
The libraries that target .NETStandard2.0, means any .NET Core app that is compatible with the .NET Standard 2.0 can use them, regardless of the .NET SDK they are using.

Xamarin.Forms Package Erorr

Has anyone encountered this error when adding the Xamarin.Forms package through the "Add NuGet package" option?
PS I'm using Xamarin Studio and I only encounter this with Windows.
Error message is:
Could not install package 'Xamarin.Forms 2.2.0.31'. You are trying to
install this package into a project that targets
'.NETFramework,Version=v4.5,Profile=Profile78', but the package does
not contain any assembly references or content files that are
compatible with that framework.
Here is the screenshot
You are having a profile which has portable class Profile78.Profiles are the type of your portable class where you select the target projects which can use your PCL. The more you select the less functionality can be provided.
You need to change it to another one. Usually most classes (including Xamarin.Forms) are supporting Profile111. Profile111 is a profile which does not support Silverlight in contast du Profile78. So you need to go to Properties and deselect Windows Phone Silverlight and Silverlight. You can select everything else (.Net 4.5, Windows 8, Windows Phone 8.1, Android, iOS/iOS classic and ASP.NET Core 1).
Then try adding Xamarin.Forms again.
You can see more information with a list of all(?) profiles here.
Here you see how to change in Visual Studio project Properties:
And here in Xamarin Studio project Option:
The problem is that you do not have the Portable Class Library (PCL) profiles installed on Windows. Xamarin.Forms 2.2.0.31 supports Profile78 so changing it to Profile111 will not fix the problem.
The error message itself indicates that this is the problem since it refers to Profile78. If the NuGet package was really incompatible then NuGet would show the frameworks in the PCL profile in its error message not the profile number. If I try to install Xamarin.Forms 2.2.0.31 into a PCL project that targets Profile1 which is not supported by Xamarin.Forms then I get an error:
Could not install package 'Xamarin.Forms 2.2.0.31'. You are trying to install this package into a project that targets 'portable-net40+sl40+win+wp+Xbox40', 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.
Note that Profile1 is not mentioned.
There are detailed instructions on installing Portable Class Libraries for Xamarin Studio which I will summarize here:
To install the Portable Class Libraries on Windows you have three options:
Install Visual Studio 2013 (full or Express version). Update 2 or
above is required.
Install the Portable Library Tools and the Portable Library Reference Assemblies 4.6.
Install the Portable Library Tools and copy the .NETPortable directory from Mono over to Windows.

How to install 'MvvmCross.HotTuna.MvvmCrossLibraries 4.0.0-beta3' on Xamarin PCL?

Following this tutorial I'm trying to install MvvmCross.HotTuna.MvvmCrossLibraries in Core project. The latest version of this library 'MvvmCross.HotTuna.MvvmCrossLibraries 4.0.0-beta3'.
After adding Nuget Package I have the following error:
Could not install package 'MvvmCross.HotTuna.MvvmCrossLibraries 4.0.0-beta3'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.0,Profile=Profile14', 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.
Does anyone know what the problem is?
Answer to original question:
MvvmCross is not available for ASP.NET. You need to use it in one of the compatible frameworks like UWP, Xamarin.Android, Xamarin.iOS or a PCL.
Updated Question:
MvvmCross uses at least .NET 4.5 with profile 259. Switch to those to be able to install the libraries.

Nuget, PCL, sl40 sl4 win8 win profile differences

I have PCL with ".NET 4 and higher, Silverlight 4 and higher, Windows Phone 7 and higher, Windows Store apps (Windows 8)" (from project->properties window).
I have Microsoft.Bcl version 1.1.3 installed.
When I want to update the reference to 1.1.6 I see following.
Install-Package : Could not install package 'Microsoft.Bcl 1.1.6'. You are trying to install this package into a project that targets
'portable-net40+sl40+wp+win', 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.
Looking at packages folder I see following:
./Microsoft.Bcl.1.1.3/lib/portable-net40+sl4+win8+wp71
./Microsoft.Bcl.1.1.6/lib/portable-net40+sl4+win8+wp71
Now the questions:
What is the difference between sl40 and sl4 profile, win8 and win
profile and wp and wp71 profile?
How can I update Microsoft.Bcl 1.1.6 in my project?
Microsoft.Bcl is targeting a later version of Windows Phone than your PCL project which is why it is failing to install.
Framework differences
sl40 and sl4 - same framework
win8 and win - same framework. win means win version 0.0 but NuGet maps this to win8
wp and wp71 - different frameworks. wp means wp version 0.0 but it is equivalent to wp7 by the way NuGet maps the frameworks.
Updating to Microsoft.Bcl 1.1.6
To install Microsoft.Bcl you will need to update your PCL project so it targets wp71 or above. So you can choose to target Windows Phone 7.5 or later or Windows Phone 8 or later.
If you choose Windows Phone 7.5 or later that seems to map to wp71 in Nuget.

How can I change the targeted framework from 4.0 to 4.0.3

I have the Portable Library Tools beta 2 installed in Visual Studio 2010. I created a new library and set it to be compatible with .Net 4.0.3 and Silverlight 5. I then tried to add a reference to the PCL project from a Silverlight Web project. I got the message:
Unable to add a reference to project "PortableClassLibrary". The
current project's target framework is not one of or compatible with
the target frameworks of Portable Library project
"PortableClassLibrary".
A Portable Library project's target frameworks can be changed via the
Library tab in the project's properties.
I don't want to change the PCL target, I want to change the target of the Web project. I went the the Properties > Application tab and the Target framework is ".Net Framework 4.0". There wasn't an option for 4.0.3. I checked and realised that the update for 4.0.3 (KB2600211) wasn't installed on this machine, so I installed it and rebooted, as requested.
There still isn't a 4.0.3 option in VS and I'm still getting the message. Any ideas?
EDIT
VS 2010 SP1 is already installed.
To target .NET Framework 4.0.3, you need to install KB2600214, and then change the Project Properties -> Application -> Target Framework to .NET Framework 4.0.3.
You may have to consult this page on Microsoft's site. It offers a few workarounds for these Targeted Framework errors. Personally, I ended up manually modifying this line in my csproj file:
<TargetFrameworkVersion>v4.0.3</TargetFrameworkVersion>

Resources