By default, Xamarin.iOS and Xamarin.Android projects use a package.config
file to manage Nuget dependencies. The Microsoft page about Package references (PackageReference) in project files says:
By default, PackageReference is used for .NET Core projects, .NET Standard projects, and UWP projects targeting Windows 10 Build 15063 (Creators Update) and later. .NET full framework projects support PackageReference, but currently default to packages.config. To use PackageReference, migrate the dependencies from packages.config into your project file, then remove packages.config.
I think this is not clear about the use of PackageReference style in Xamarin.Android or Xamarin.iOS projects.
My question: is it possible to use PackageReference in Xamarin.iOS and Xamarin.Android projects?
Mobile cross-platform support – Xamarin offers sophisticated cross-platform support for the three major platforms of iOS, Android, and Windows. Applications can be written to share up to 90% of their code, and Xamarin. Essentials offers a unified API to access common resources across all three platforms.
In a project file, you can use the @() notation in tasks to specify an entire item list as the input for a build. You can use this notation whether you list all files separately or use wildcards.
Xamarin. Forms will continue to receive service releases through November 2022.
Yes, PackageReference
works for Xamarin.iOS|Android projects and in Visual Studio for Windows or Mac or via the cmd-line (nuget restore or via msbuild).
Add the following to the top of your Xamarin.iOS
and/or Xamarin.Android
.csproj
file:
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
My current steps are:
packages.config
as a backup
Xamarin.iOS
or Xamarin.Android
)PackageReference
Note: I do the manual package remove one-by-one via the IDE in order to properly update the project references. Also, when re-adding them after the PackageReference additional, the csproj is updated correctly (you can do this manually in the csproj text but it is a pain and easy to screwup).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With