I am in the process of setting up push notifications in my .NET MAUI application, using Firebase. When trying to include the google-services.json file in the project, however, I cannot set the build action correctly.
After doing research, the build action is tied to Xamarin.GooglePlayServices.Basement
package (which is usually accessed through Xamarin.GooglePlayServices.Base
) however the build action never shows up - I can only assume that this is due to the .Base
package being made for .NET 6.0.
My code makes use of packages which are built for .NET 7.0 (Maui.CommunityToolkit & Maui.Controls.Maps), so rolling back to .NET 6.0 is not an ideal solution.
I have tried to install Xamarin.GooglePlayServices.Base
(net6.0), build action doesn't show up.
I have cleaned solution, rebuilt, restarted Visual Studio, reloaded project - nothing helps.
I have tried manually setting build action in .csproj file after install - doesn't work.
I have tried to install other libraries which include Base or Basement - no change.
I have ensured that the .csproj conditions are referring to .net 7.0 and not 6.0.
I have looked for any pre-release or branch versions of GooglePlayServices.Base - there is only a branch for .net 8.0.
Thanks in advance.
I assume that you mean that build action isn't showing up in the Visual Studio UI. That doesn't mean it's not available.
Install the package needed and add this to your csproj file:
<ItemGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'"">
<GoogleServicesJson Include="google-services.json" />
</ItemGroup>
Also see a complete guide here: https://cedricgabrang.medium.com/firebase-push-notifications-in-net-maui-android-32c808844d7e