"warning CA1416: This call site is reachable on: 'iOS' 15.4 and later, 'maccatalyst' 15.4 and la



目前我有一个相当大的毛伊岛项目。它包括几个专有软件包,它们都是.net6,并且直接从模板中定义了这个框架:

<TargetFramework>net6.0</TargetFramework>
<TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>

当我现在构建我的Maui应用程序时,我会收到以下消息流:

3>C:MauiMauiProgram.cs(94,13,97,78): warning CA1416: This call site is reachable on: 'iOS' 15.4 and later, 'maccatalyst' 15.4 and later. 'TokenRetrievalHandler<SignInPolicy>' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later.
3>C:MauiMauiProgram.cs(89,13,91,93): warning CA1416: This call site is reachable on: 'iOS' 15.4 and later, 'maccatalyst' 15.4 and later. 'MsalTokenService<SignInPolicy>' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later.
3>C:MauiMauiProgram.cs(89,13,91,93): warning CA1416: This call site is reachable on: 'iOS' 15.4 and later, 'maccatalyst' 15.4 and later. 'ITokenService<SignInPolicy>' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later.
3>C:MauiMauiProgram.cs(96,52,96,100): warning CA1416: This call site is reachable on: 'iOS' 15.4 and later, 'maccatalyst' 15.4 and later. 'Policy.TokenRefresher<SignInPolicy>(IServiceProvider, HttpRequestMessage)' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later.
3>C:MauiMauiProgram.cs(101,13,104,37): warning CA1416: This call site is reachable on: 'iOS' 15.4 and later, 'maccatalyst' 15.4 and later. 'ServiceCollectionExtensions.UseThetaRexCommon(IServiceCollection)' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later.
3>C:MauiMauiProgram.cs(89,13,90,69): warning CA1416: This call site is reachable on: 'iOS' 15.4 and later, 'maccatalyst' 15.4 and later. 'TokenRetrievalHandler<SignInPolicy>' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later.
3>C:MauiMauiProgram.cs(95,35,95,49): warning CA1416: This call site is reachable on: 'iOS' 15.4 and later, 'maccatalyst' 15.4 and later. 'Policy.Retry()' is only supported on: 'iOS' 16.0 and later, 'maccatalyst' 16.0 and later.

在我的任何包或毛伊岛项目代码中,我都不会要求"maccatalyst"16.0,所以似乎无论如何都不会降低框架支持,所以我会尝试提高它

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.4</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.4</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">31.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>

再说一遍,没什么疯狂的。这与模板没有变化。所以我把版本打成:

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">16.0</SupportedOSPlatformVersion>

现在我得到了:

error NETSDK1135: SupportedOSPlatformVersion 16.0 cannot be higher than TargetPlatformVersion 15.4.

我回到了我的开始问题:我从来没有指定15.4的TargetPlatformVersion。

编辑:奇怪的是,如果我将包作为.NET Core 6库直接添加到我的项目中,我不会收到这些错误。只有包装好了我才能拿到。

我遇到了同样的问题。我认为现在发生的事情是,当你使用net6.0-ios创建原始的nuget包时;nuget pack将其放置在文件夹"中;lib\net6.0-ios15.4";默认情况下在nuget包中。然后使用者项目抱怨,因为它认为该调用仅在ios15.4或更高版本中可用。

我能够通过将目标版本附加到ios目标框架来覆盖这一点。简单地改变";net6.0-ios";例如;net6.0-ios10.0";警告将消失,nuget pack将把包裹放在正确的位置。

最新更新