Convert a Nuget Package to match with Xamarin C# - c#

I recently started to develop android apps with Xamarin for Visual studio, but every time I want to install a Nuget package for C#.Net I get this error Message:
The package "System.Reflection.Extensions 4.0.0" couldn't be installed. You try to install the package into a project, which refers to MonoAndroid,Version=v7.1", the package doesn't contain assemblyreferences or contentfiles, which are compatible with this framework. Contact the Autor of the nuget package for more information.
Is there any way to modify the nugetpackage to match my needs or do I really have to contact the author of the package?

You can't install the Overwatch.Net package because it only targets .NET 4.5.2 and does not contain libraries for either PCL or Xamarin.Android.
Looking at the code for the library, there is no reason it could not be a PCL, so you have 2 options.
Ask the author of Overwatch.NET to make a PCL or NETStandard version of the library
Do the work yourself and convert it

Related

Having trouble while Installing a Nuget package(WIndows.winMD)

Getting error while trying to install a Nuget Package
I'm trying to install a pakage and get the following error:
NuGet\Install-Package Microsoft.Windows.WinMD -Version 1.0.210629.2'
NuGet\Install-Package : Could not install package 'Microsoft.Windows.WinMD 1.0.210629.2'. 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.
Please help
Do I understand correctly that you want to write a .net wrapper over a C++?
If so, this is nuget package does not contain dll files. Most likely you need to build the C++ library first and add build result as content in your project.
This nuget package framework is tagged with native.
nuget: Microsoft.Windows.WinMD - Frameworks
The native framework tag is for C++ projects.
DevBlogs: Support for Native Projects
Conclusion: This package can not be consumed or used by any C# project.
However, in the nuget used-by tab of that package is a reference to a C++ github project that uses this package and is described as
C# language projection for the Windows Runtime
You may have a look at that.

How to add System.Data.SqlClient nuget package into .Net Portable (PCL)4.5 profile

I am writing a crossplatform (iOS and android) Xamarin app and I need a sql connection to my database. I found out that I need System.Data.SqlClient to achieve this. But when I try to add System.Data.SqlClient to my core project I get:
Could not install package 'System.Data.SqlClient 4.4.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.
I get that apparently this .NETPortable version is compatible, but what is the solution to this? There must be a way to access a SQL database. Also I found that other posts asked to add System.Data first, but this package doesn't even show up in nuget.
In case that you change your pcl project into .NET Standard you should be able to install this nuget package.
Follow this awesome snack pack!
In Visual Studio Preview there is template to create xamarin project using .netstandard. I can confirm that it works.

Which PCL profile should I use in my Xamarin.Forms app?

I'm new in Xamarin, Xamarin.Forms and C# platform.
I'm starting the development of an app that should support Android and iOS devices. I'm using a PCL project for code sharing. Currently this project is using the profile111 because Visual Studio has selected it by default for me. But when I try to install some NuGet packages I'm getting a message saying the package is not compatible. Something like:
Could not install package 'DocsBrStandard 2.0.1'. 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.
I believe this message is related with the profile I'm using, right?
So which profile should I use for my app that should support only iOS and Android devices? Is profile111 the more appropriate for this scenario?
At least, how can I identify if a package is compatible or not with my Xamarin.Forms app?
Thanks.
You need to target .NET Standard to be able to use the DocsBrStandard package. So you can't work with profile based PCL if you want to use that package.
Check out this article about targeting .NET Standard with Xamarin.Forms:
https://blog.xamarin.com/building-xamarin-forms-apps-net-standard/

Can't install NuGet-Packages (Xamarin Android project)

I have a problem with NuGet installing the "Xamarin.JOSE.JWT" package. I get the following error:
> Could not install package 'Xamarin.JOSE.JWT 1.0.3'. You are trying to
> install this package into a project that targets
> 'MonoAndroid,Version=v6.0', 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 this a known problem or is there a workaround for this?
Xamarin.JOSE.JWT 1.0.3 does not support Xamarin.Android projects. It only contains assemblies for .NET Framework 4.0.
Your options are:
Find another NuGet package that does support Xamarin.Android projects.
See if you can compile the Xamarin.JOSE.JWT project against Xamarin.Android.
Open an issue on the Xamarin.JOSE.JWT GitHub repository.
Try directly referencing the jose-jwt.dll from the NuGet package and see if it works with an Android project. This may not work if it is using parts of the .NET Framework not supported by Xamarin.Android.
Use the Xamarin.JOSE.JWT NuGet package on the server side and not in the Android project.

How to make a NuGet package for this PCL library

I'm trying to create a nuget package for a PCL library I've made.
This nuget package is intended to be used in a Xamarin Forms application though. So I'm not even sure if the things I've ticked are correct.
I really only care about .NET Framework 4. That is my bare minimum framework. For the rest, I don't care at all and have no idea what I should be targetting.
For what it's worth, I'm using NuGet Package Explorer to create my NuGet nupkg files to manually test them before I publish them to NuGet.
Here's a screenshot of what I was trying, but Xamarin Studio failed to add the nuget package (saying it wasn't the right something-or-rather).
and the error message from Xam Studio:
Adding Foo...
Adding 'Foo 1.3.0' to Core.
Could not install package 'Foo 1.3.0'. 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.
For Xamarin.Forms the two profiles that are good ones for your Portable Class Library (PCL) project to use are Profile 78 or Profile 259. Xamarin.Forms can be used in other profiles but if your PCL project targets one of these you should be OK. Your project looks to be targeting Profile 78.
Here are the Xamarin.Forms PCL profiles for reference.
Xamarin.Forms 1.3:
portable-win+net45+wp80+MonoAndroid10+MonoTouch10
Xamarin.Forms 1.4:
portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10
The problem with your NuGet package that it does not indicate that it supports Windows 8 in the PCL. NuGet will look at all the individual frameworks that make up the project's PCL profile (ignoring the Xamarin and Mono ones since they are optional if you do not have them in your NuGet package's PCL profile) and ensure that the NuGet package's PCL profile has a framework which is compatible. If the NuGet PCL does not have a matching framework then NuGet considers it incompatible.
So your NuGet package's portable library folder would need to include win
portable-net4+sl5+wp8+win
Then you can install your NuGet package into your Profile 78 PCL project.

Categories

Resources