Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does NUGET package management works on Microsoft MAUI?

Tags:

xamarin

maui

There are significant differences compared to Xamarin and I couldn't find docs or even a discussion about the matter, and I am interested in knowing. It was pretty straight forward in Xamarin. If I wanted a nuget package for the android project and not the whole solution I could do that, but now it's just one project.


1 Answers

You could specify the name and version of the package in .csproj file and set the certain platform with property Condition .

For example

  1. If you just want to add the package to single platform
<ItemGroup>
      <PackageReference Include="Newtonsoft.Json" Version="13.0.1"  Condition="'$(TargetFramework)' == 'net6.0-ios'" />
</ItemGroup>
  1. If you want to add the package to multiple platforms
<ItemGroup>
      <PackageReference Include="Newtonsoft.Json" Version="13.0.1"  Condition="'$(TargetFramework)' == 'net6.0-ios' or '$(TargetFramework)' == 'net6.0-android'" />
</ItemGroup>

PS : Firstly make sure the package support net6.0 and net6.0 - xx before you add the package .

like image 119
ColeX - MSFT Avatar answered Oct 24 '25 13:10

ColeX - MSFT



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!