TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
211 stars 49 forks source link

"CA1416" error when "dotnet publish" in Azure Pipelines #135

Closed nhstsoda closed 1 year ago

nhstsoda commented 1 year ago

Description

We created a solution consisting of the MauiApp project and the NotificationExtension project. We are trying to build with Azure Pipelines. Publish fails with "CA1416" error.

Steps to Reproduce

  1. Create a new MauiApp project
  2. Create a new iOS NotificationExtension project
  3. Install Plugin.Firebase in MauiApp project
  4. Opening project settings, change to property, save project
    • project settings
      • TargetFrameworks
      • net6.0-android31.0
      • net6.0-ios16.0
      • SupportedOSPlatformVersion
      • Android: 21.0
      • iOS: 12.0
      • TreatWarningsAsErrors
      • true
  5. Implement initialization processing in MauiProgram.cs
  6. Implement text replacement processing in NotificationService.cs

Link to public reproduction project repository

Version with bug

1.3.0

Last version that worked well

Unknown/Other

Affected platforms

Android/iOS/Other

Affected platform versions

Unknown/Other

Did you find any workaround?

Probably workaround if Plugin.Firebase has SupportedOSPlatformVersion setting.

Other

If I set TreatWarningsAsErrors to false, the build succeeds but the app crashes.

Relevant log output

dotnet publish(Android)

/Users/runner/hostedtoolcache/dotnet/dotnet publish /Users/runner/work/1/s/MauiApp1/MauiApp1.csproj -c Release -f net6.0-android31.0 -o /Users/runner/work/1/a --no-restore -p:ApplicationId=jp.co.test -p:ApplicationTitle=DEV_MauiApp1 -p:ApplicationDisplayVersion=1.0.0 -p:ApplicationVersion=2453 -p:AndroidKeyStore=True -p:AndroidSigningKeyStore=/Users/runner/work/_temp/keystore.jks -p:AndroidSigningStorePass=*** -p:AndroidSigningKeyAlias=alias -p:AndroidSigningKeyPass=***
MSBuild version 17.3.2+561848881 for .NET
/Users/runner/work/1/s/MauiApp1/MauiProgram.cs(65,16): error CA1416: This call site is reachable on: 'Android' 21.0 and later. 'CrossFirebaseSettings' is only supported on: 'Android' 31.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MauiProgram.cs(59,9): error CA1416: This call site is reachable on: 'Android' 21.0 and later. 'IFirebaseAuth' is only supported on: 'Android' 31.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MainPage.xaml.cs(16,27): error CA1416: This call site is reachable on: 'Android' 21.0 and later. 'CrossFirebaseCloudMessaging.Current' is only supported on: 'Android' 31.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MainPage.xaml.cs(15,15): error CA1416: This call site is reachable on: 'Android' 21.0 and later. 'IFirebaseCloudMessaging.CheckIfValidAsync()' is only supported on: 'Android' 31.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MainPage.xaml.cs(16,27): error CA1416: This call site is reachable on: 'Android' 21.0 and later. 'IFirebaseCloudMessaging.GetTokenAsync()' is only supported on: 'Android' 31.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MainPage.xaml.cs(15,15): error CA1416: This call site is reachable on: 'Android' 21.0 and later. 'CrossFirebaseCloudMessaging.Current' is only supported on: 'Android' 31.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MauiProgram.cs(53,21): error CA1416: This call site is reachable on: 'Android' 21.0 and later. 'CrossFirebase.Initialize(Activity, Bundle, CrossFirebaseSettings, FirebaseOptions, string)' is only supported on: 'Android' 31.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MauiProgram.cs(59,44): error CA1416: This call site is reachable on: 'Android' 21.0 and later. 'CrossFirebaseAuth.Current' is only supported on: 'Android' 31.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
##[error]Error: The process '/Users/runner/hostedtoolcache/dotnet/dotnet' failed with exit code 1
##[warning].NET 5 has some compatibility issues with older Nuget versions(<=5.7), so if you are using an older Nuget version(and not dotnet cli) to restore, then the dotnet cli commands (e.g. dotnet build) which rely on such restored packages might fail. To mitigate such error, you can either: (1) - Use dotnet cli to restore, (2) - Use Nuget version 5.8 to restore, (3) - Use global.json using an older sdk version(<=3) to build
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
##[error]Dotnet command failed with non-zero exit code on the following projects : [ '/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj' ]
Finishing: Publish MAUI Android App

dotnet publish(iOS)

/usr/local/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command . '/Users/runner/work/_temp/5baf8afd-0a07-49c3-a362-4d9b1056b6e1.ps1'
MSBuild version 17.3.2+561848881 for .NET
  Detected signing identity:
    xxxxx
  Detected signing identity:
    xxxxx
  MauiLib1 -> /Users/runner/work/1/s/MauiLib1/bin/Release/net6.0-ios16.0/ios-arm64/MauiLib1.dll
/Users/runner/hostedtoolcache/dotnet/packs/Microsoft.iOS.Sdk/16.2.19/targets/Xamarin.Shared.Sdk.targets(975,3): warning : Some features may not work correctly, because the generation of the runtime configure file (*.runtimeconfig.json) has been disabled. [/Users/runner/work/1/s/MauiLib1/MauiLib1.csproj]
  Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
/Users/runner/work/1/s/MauiApp1/MainPage.xaml.cs(16,27): error CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 12.0 and later. 'IFirebaseCloudMessaging.GetTokenAsync()' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MainPage.xaml.cs(15,15): error CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 12.0 and later. 'IFirebaseCloudMessaging.CheckIfValidAsync()' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MauiProgram.cs(65,16): error CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 12.0 and later. 'CrossFirebaseSettings' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MainPage.xaml.cs(16,27): error CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 12.0 and later. 'CrossFirebaseCloudMessaging.Current' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MainPage.xaml.cs(15,15): error CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 12.0 and later. 'CrossFirebaseCloudMessaging.Current' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MauiProgram.cs(59,44): error CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 12.0 and later. 'CrossFirebaseAuth.Current' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MauiProgram.cs(44,21): error CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 12.0 and later. 'CrossFirebase.Initialize(UIApplication, NSDictionary, CrossFirebaseSettings, Options, string)' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
/Users/runner/work/1/s/MauiApp1/MauiProgram.cs(59,9): error CA1416: This call site is reachable on: 'iOS' 12.0 and later, 'maccatalyst' 12.0 and later. 'IFirebaseAuth' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later. [/Users/runner/work/1/s/MauiApp1/MauiApp1.csproj]
  Created the package: 
##[error]PowerShell exited with code '1'.
Finishing: Publish MAUI iOS App
nhstsoda commented 1 year ago

I uploaded the source to reproduce.

nhstsoda commented 1 year ago

I'm sorry. I set TreatWarningsAsErrors to false and checked again, and it worked. This is not a bug, so I will close it.