Xamarin-CrossDownloadManager icon indicating copy to clipboard operation
Xamarin-CrossDownloadManager copied to clipboard

.NET Standard Support

Open manikandantk88 opened this issue 7 years ago • 9 comments

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

manikandantk88 avatar Jan 19 '18 15:01 manikandantk88

Just an internal note:

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

SimonSimCity avatar Feb 22 '18 06:02 SimonSimCity

@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 avatar Feb 24 '18 17:02 SimonSimCity

@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?

SimonSimCity avatar Feb 24 '18 17:02 SimonSimCity

@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>

manikandantk88 avatar Feb 26 '18 13:02 manikandantk88

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 !

toussam avatar Aug 24 '18 10:08 toussam

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.

SimonSimCity avatar Aug 28 '18 15:08 SimonSimCity

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 !

toussam avatar Sep 09 '18 15:09 toussam

@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 😉

SimonSimCity avatar Oct 10 '18 06:10 SimonSimCity

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

drewkeller avatar May 06 '20 02:05 drewkeller