I have created a Xamarin Forms project within VS 2017 Community Edition. I would like to use FluentMigrator to create a a database for use within the application.
When I attempt to use NuGet PM to install FluentMigrator into the project, I get the following error:
Could not install package 'FluentMigrator 1.6.2'. 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.
I am guessing it's the fact that my project is using.NETPortable.
Is it possible to use FluentMigrator within a Xamarin PCL? If so, what needs to be changed in my project configuration?
The FluentMigrator does not have any assemblies that are compatible with PCL projects. It contains two lib directories: 35 and 40. These seem to have .NET assemblies for .NET 3.5 and .NET 4.0. So you cannot install this into a PCL project.
I would instead see if you can just create a .NET project, say targeting .NET 4.5, and install the FluentMigrator NuGet package into that project and define your migrations there.
Related
I'm not sure if this is a Visual Studio issue or a genuine incompatibility but trying to install SocketIoClientDotNet into a Xamarin forms PCL project I get
Could not install package 'SocketIoClientDotNet 1.0.6'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile7', 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 project targets .NetFramework 4.5 which seems to be supported by the package - what could be going wrong here?
I suggest you add the following packages in your .Droid and .iOS projects (and not in the "common" project):
EngineIoClientDotNet (v.0.9.22)
SocketIoClientDotNet (v.0.9.13)
WebSocket4Net (v.0.14.1)
These versions of packages were the stablest 6 months ago when I had to use sockets in my project. If you want more information don't hesitate to ask me!
I'm trying to install the NUnit package in my Xamarin Forms project and I'm getting this error:
Severity Code Description Project File Line Suppression State
Error Could not install package 'NUnit 3.9.0'. You are trying to install
this package into a project that targets
'.NETPortable,Version=v4.5,Profile=Profile111', 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. 0
I'm working with Visual Studio 2017 and Windows 10.
Does anyone have any experience with this issue? It seems strange that there could be errors like this with such a common package...
Thanks so much!
NUnit 3.9 does not contain any assemblies that are compatible with Portable Class Library (PCL) projects. It has a .NET Standard 1.3 assembly but .NETStandard version 1.3 is not compatible with any PCL profiles.
So your options are:
Use an older NUnit NuGet version, such as 2.6.4, as suggested by Nkosi.
Convert your PCL project to a .NET Standard project.
Create your NUnit tests in a project that targets the full .NET Framework and have the test project reference the PCL project.
The Visual Studio adapter and the NUnit Console cannot run Xamarin based tests because they are both based on the full framework. You can however use the NUnit Xamarin runner to run on devices. See https://github.com/nunit/nunit.xamarin.
Personally, I find it much easier to just target .NET 4.5.x in your test project and reference the Xamarin PCL project that you are testing. That allows you to use the latest version of NUnit and run your tests in Visual Studio or on the command line. See Testing Xamarin Projects using NUnit for more information.
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.
I am currently working on a Xamarin.Android project for a FieldService app. I looked into the standard Xamarin SQLite.NET component for the Data Access Layer, but it does not meet my needs. (I cannot create a PK with multiple fields, for example).
I tried to use the Dapper framework, since I have more experience with that and I think it's pretty awesome.
Couldn't get it to work with Xamarin.Android. I am using Xamarin with Visual Studio 2013. Anyone who knows how to do this?
I tried 3 ways:
Adding Dapper to a Xamarin.Android Class Library. - No errors, but Dapper was not under the References group in solution explorer and I couldn't use the namespace Dapper
Adding Dapper to a "normal" .net Class Library. - Everything worked, I was able to add it, I could use the Dapper namespace and Query methods etc. BUT there was an error referencing the project to the main Xamarin.Android application project. (different target framework)
Adding Dapper to a Portable Class Library targeting .NET Framework 4.5 and Xamarin.Android. - Error when adding the NuGet package.
Brief question: How to add Dapper (or other NuGet packages) to Xamarin.Android?
Thanks in advance.
The Dapper NuGet package contains assemblies that target:
.NET 3.5
.NET 4.0
.NET 4.5
So you will not be able to the NuGet package with an Xamarin Android project since this project will target MonoAndroid.
Dapper would need to be recompiled against the MonoAndroid target framework, if possible. Otherwise you would need to look at other alternatives.
Looking at the Dapper GitHub site all the various classes available in the NuGet package are from one SqlMapper.cs file which seems to compile inside an Android project.
Mono for Android has access to most of .NET 4.0 from the Mono framework. Unfortunately, when I try to add NuGet packages in Visual Studio that specifically target .NET 3.5 or beyond, with a /lib/net*/ folder structure, it tosses up an error.
You are trying to install this package into a project that targets
'MonoAndroid,Version=v2.1', but the package does not contain any
assembly references that are compatible with that framework.
If a NuGet package doesn't have the .NET version breakdown, or one where you removed that subdirectory structure and published it to a NuGet source, it works fine. For example, NUnit just has a /lib/ folder with no further breakdown by .NET framework version and installed fine.
It appears NuGet could be checking compatibility by using the <TargetFrameworkVersion> project file XML element. If so, that is the problem as Mono for Android usurps that element to mean a "target Android framework version". For example, to target Android v2.2, it looks like this:
<TargetFrameworkVersion>v2.1</TargetFrameworkVersion>
In the project properties dialog, where the "[.NET] Target framework" drop-down would be is a drop-down for "Minimum Android to target" that affects this XML element.
If this is the problem NuGet is encountering, I won't be able to use unmodified NuGet for version-specific packages until targeting an Android app for a minimum of Ice Cream Sandwich (v4.0).
Side note
You can reference the DLLs from these packages via project reference. It definitely throws a warning at you, but you can ignore it fairly safely (assuming the assembly doesn't wander too far from the code implemented in Mono).
'Some.dll', or one of its dependencies, requires a later version of
the .NET Framework than the one specified in the project...
No, assemblies must be compiled against the 2.0.5 profile in order to be used by Mono for Android. You can achieve this by using the Mono for Android Class Library template or by using assemblies compiled for Silverlight.
The Android version (2.2, 3.0, 4.0) is not related to the version of the .NET BCL an assembly is compiled against.