SimonSimCity / Xamarin-CrossDownloadManager

A cross platform download manager for Xamarin
MIT License
149 stars 68 forks source link

.NET Standard Support #75

Open manikandantk88 opened 6 years ago

manikandantk88 commented 6 years ago

Not able to install this plugin in .NET Standard based Xamarin Forms project

SimonSimCity commented 6 years ago

Just an internal note:

This could be worth looking into as a point of starting ... https://github.com/jamesmontemagno/DeviceInfoPlugin/pull/28

SimonSimCity commented 6 years ago

@manikandantk88 I haven't had any problems ... I just needed to add the nuget-package to every of the native projects and I was able to use it. If it doesn't for you, please show me the error you're facing.

Maybe this helps you? https://solidbrain.com/2017/09/12/xamarin-is-it-time-to-move-from-pcl-to-net-standard/ (scroll down to Referencing PCLs in .NET Standard libraries)

It advises you to add the following XML to the csproj-file of the project, targeting .NET Standard and teaches your project that PCL 259 is compatible with .NET Standard 1.0:

<PropertyGroup>
  <TargetFramework>netstandard1.0</TargetFramework>
  <PackageTargetFallback>$(PackageTargetFallback);portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10</PackageTargetFallback>
</PropertyGroup>

But as said, I didn't have to do it. It only avoids the warning you might get when adding this package.

SimonSimCity commented 6 years ago

@manikandantk88 I've now myself tried to add my NuGet package to a plain project targeting .NET Standard - ignoring the fact that you mentioned Xamarin Forms. When targeting .NET Standard 2.0 it worked without any adjustments needed - I just got a warning but when I changed to another version, I had to add the XML I've posted in the last comment to make it work.

Does this solve it for you?

manikandantk88 commented 6 years ago

@SimonSimCity Thank you for response. I checked. It is resolved when I configure below in my project

<PropertyGroup>
  <TargetFramework>netstandard1.0</TargetFramework>
  <PackageTargetFallback>$(PackageTargetFallback);portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10</PackageTargetFallback>
</PropertyGroup>
toussam commented 6 years ago

Hi @SimonSimCity,

I have a similar issue with my PCL that is targeting .NET Standard 2.0. The .csproj of this last one is already containing a similar code that you previously shared:

<TargetFramework>netstandard2.0</TargetFramework>
<PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>

Even by doing so, I still got the next warning:

Package 'Xam.Plugins.DownloadManager 1.3.2' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETStandard,Version=v2.0'. This package may not be fully compatible with your project.

Could you help me this ? :) I thank you in advance for your response and wish you a great weekend !

SimonSimCity commented 6 years ago

The latest version of this package is compatible with the following target: portable-net45+wp8+wpa81+win8+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10, so I guess it's best to have exactly this line in your configuration.

Maybe this can also help ... https://stackoverflow.com/questions/45569378/upgrading-to-net-core-2-0-packagetargetfallback-and-assettargetfallback-cannot

Let me know if you still can't add it after replacing (or removing, as proposed in the stackoverflow answer) the line.

toussam commented 6 years ago

I tried both of these solutions and also to replace PackageTargetFallback by AssetTargetFallback, but nothing changed.

Just want to precise that I added successfully the package, but the compilation of my project is leading to the given warning (cf. above).

Another idea maybe ? I thank you one more time for everything !

SimonSimCity commented 5 years ago

@toussam Since I haven't had time to get back on this yet, would you have some time to start on a PR which allows this package to be used on .NET Standard 2.0 projects? I'd be happy to merge your PR or allow you to do it yourself, but I'd like to see your commitment to this problem first 😉

drewkeller commented 4 years ago

FYI see https://github.com/SimonSimCity/Xamarin-CrossDownloadManager/pull/121