I'm creating a NuGet package that depends on Xamarin.Forms. The package should work fine with any recent version of Forms, so I set it up like:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>MyCompany.FormsExtras</PackageId>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.*" />
</ItemGroup>
</Project>
Build and publish locally to test...
$ dotnet pack -c Release -p:Version=0.9.0
$ nuget add bin/Release/MyCompany.FormsExtras.0.9.0.nupkg -source ~/Dropbox/Packages/
At the time I ran these commands, Xamarin.Forms 4.1.0.555618 was the latest version.
I'm now trying to pull this package into an existing project which has a direct dependency on a different, older version of Xamarin.Forms:
<ItemGroup>
<PackageReference Include="Xamarin.Forms" Version="4.0.0.425677" />
</ItemGroup>
...but it fails to add the package with this error:
Detected package downgrade: Xamarin.Forms from 4.1.0.555618 to 4.0.0.425677. Reference the package directly from the project to select a different version.
MyCompany.ToDo.Forms -> MyCompany.FormsExtras 0.9.0 -> Xamarin.Forms (>= 4.1.0.555618)
MyCompany.ToDo.Forms -> Xamarin.Forms (>= 4.0.0.425677)
I was under the impression that the floating version specified in my package's PackageReference
should have allowed this to work? Am I missing a step, or do I just misunderstand how floating versions work?
I've read through the MS article on package dependency resolution. I also tried searching on the error message and "floating version" but I'm only finding workarounds on the consumer side; I'd like to fix this on my packaging so the consumers don't have to jump through hoops.
Any help much appreciated…