How to Install MVVMLight in Xamarin Studio Xamarin.Forms PCL - mvvm-light

I think this is related to this -
Cannot install MvvmLight for Windows Phone 8.1 app project
Trying to install libs only nuget. Seen a PCL version mentioned somewhere but its not in the Nuget list.
Could not install package 'MvvmLightLibs 4.4.32.1'. You are trying to
install this package into a project that targets
'portable-net45+win+MonoAndroid10+MonoTouch10', 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.
When I try to install in Xamarin Studio.
Can I assume that I need the latest version of NuGet and the version 2.8.1 is not new enough in XS?
Does MVVMLight support Xamarin Studio? Does anyone know a workaround, I am currently on Indie license and would love to progress with this on a Forms based prototype.

Looking at the MvvmLightLibs 4.4.32.1 NuGet package it does not have any Portable Class Libraries (PCLs) so you will not be able to install it into a PCL project.
Take a look at the Portable.MvvmLightLibs NuGet package instead. That package has a PCL assembly and you should be able to install it into the Xamarin.Forms PCL project.

Related

Using SQLite with Xamarin.Forms cross-platform project

I have used Visual Studio 2017 Community edition to create a plain vanilla cross platform PCL project, and would like to use SQLite. The only thing done to the project(s) was the use of Nuget to update all packages that needed updating.
Then, following the instructions on the Xamarin website at
https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/databases/
I used Nuget to install sqlite-net-pcl,
It all seemed to work OK, except at the end the following error appears.
I presume the documentation is slightly dated. Should I change the target .NET framework. If so, to what?
As of v1.3 SQLite-Net-PCL is actually no longer a PCL, it is a .Net standard library.
You need to install version 1.2.0 of the NuGet package to use it inside a PCL - from the nuget package manager you can select a version so install v1.2.0 into all your projects.
The library above worked OK as a PCL library, but what I disliked was that the platforms were split out in to separate DLLs so you had a different dependency for each platform.
This library is for .NET Standard and only has a single DLL for all platforms:
https://github.com/MelbourneDeveloper/SQLite.Net.Standard
It does not support the ORM like functionality in the above library though.

Visual Studio for Mac and Xamarin Forms PCL - can't install NodaTime 2.0 with NuGet

I'd like to use NodaTime with Xamarin Forms in a PCL, however the NuGet install fails with this message:
Could not install package 'NodaTime 2.0.0'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259',
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 NuGet package information says it doesn't have any dependencies, what's up?
NodaTime 2.0.0 only supports .NET45 or .NET Standard. You either need to update your Xamarin Forms project to .NET Standard, or downgrade your NodaTime version 1.3.4.

Error installing System.IdentityModel.Token.Jwt in Xamarin.Forms

I'm trying to use the System.IdentityModel.Token.Jwt NuGet package for my Xamarin.Forms app. When I try to add the package to my PCL, it installs in my Android and iOS projects, but I get the following error when adding it to the shared code project:
Could not install package 'System.IdentityModel.Tokens.Jwt 5.1.3'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.6,Profile=Profile44', 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 how to get around this? I think it has to do with what my project targets but I've tried a few combinations and all of them have produced the same error, just with a different profile listed.
Unfortunately the System.IdentityModel.Tokens.Jwt 5.1.3 NuGet package only contains assemblies that support:
.NET Framework 4.5.1
.NET Standard 1.4
No portable class library profile supports .NET Standard 1.4. The highest they support is .NET Standard 1.2.
So unless you can find another NuGet package that does support portable class libraries you are left with trying to compile the Jwt source code for the portable class library profile you need, or converting your portable class library project into a .NET Standard project and target at least 1.4. You should be able to convert your portable class library project into a .NET Standard project in the project options.

I am developing iOS and Android app with Xamarin Forms in MAC. I am installing PCL Xamarin.Mobile, but i am getting error

The error i am getting while installing PCL. Any idea about below mentioned error?
Could not install package 'xamstore-xamarin.mobile 0.7.1'. You are
trying to install this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile259', 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.
From Xamarin Developer Matt Ward on the Xamarin Forums
The NuGet package xamstore-xamarin.mobile 0.7.1 only supports MonoAndroid and MonoTouch. It contains MSBuild property files for these two frameworks. You will not be able to install it into a Portable Class Library (PCL) project since it does not have any files that target any PCL framework.
Instead you should be able to add it to a Android or iOS project.
Similarly Xamarin.Mobile from the component store supports Android and iOS projects. It has assemblies for those platforms as well as for Windows Phone 7/8 and Windows 8 (WinRT). So you would be able to add that component into an Android or iOS project but not a PCL project.

Why NuGet is it getting MVVMLight for all frameworks and all platforms?

NuGet is getting MVVMLight binaries for WPF, SL3, SL4, SL5, WP7
I don't really like that.
Is there a way to make it get just for the framework which the project is using?
How is generally NuGet working for other packages, it maybe something which the MVVMLight author should do when creating the NuGet package?
Thanks,
Andrew
It's a nuget convention to include libraries of different framework versions inside a unique package. This makes it easier for the package consumer, there's only one version of a package to install.
When installing a package through NuGet Package Manager (UI or console), NuGet will only add references to libraries that targets your project's framework. Note: all the package content is unpacked to "\packages\", including libraries that aren't used.
Example:
I created a SL4 application and installed MVVMLightLibs. Only GalaSoft.MvvmLight.Extras.SL4 and GalaSoft.MvvmLight.SL4 are added as a reference.
see nuget documentation : Supporting_Multiple_.NET_Framework_Versions_and_Profiles

Resources