我使用这些资源来学习如何发布 MAUI 应用程序:
\nhttps://learn.microsoft.com/en-us/dotnet/maui/ios/deployment/overview
\nhttps://github.com/dotnet/maui/issues/4397
\nhttps://github.com/dotnet/sdk/issues/21877
\n基于这些,我尝试了不同的变体来发布,但它们都不起作用:
\ndotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 \n\n\n错误:运行时标识符“ios-arm64”无效。
\n
dotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 --no-restore\n\n\n错误 NETSDK1032:RuntimeIdentifier 平台“ios-arm64”和\nPlatformTarget“x64”必须兼容。
\n
dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true\n\n\n错误:运行时标识符“ios-arm64”无效。
\n
dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true --no-restore\n\n\n错误 NETSDK1032:RuntimeIdentifier 平台“ios-arm64”和\nPlatformTarget“x64”必须兼容。
\n
更新
\n环境:
\nWindows 10 家庭版 - 21H2 
\nVS 2022 版本 17.3.0 预览版 1.1
更新2
 \n根据答案,我现在有了这个 csproj 文件:
<Project Sdk="Microsoft.NET.Sdk">\n\n<PropertyGroup>\n    <TargetFrameworks>net6.0-ios</TargetFrameworks>\n    <OutputType>Exe</OutputType>\n    <RootNamespace>MonkeyFinder</RootNamespace>\n    <UseMaui>true</UseMaui>\n    <SingleProject>true</SingleProject>\n    <ImplicitUsings>enable</ImplicitUsings>\n\n    <!-- Display name -->\n    <ApplicationTitle>MonkeyFinder</ApplicationTitle>\n\n    <!-- App Identifier -->\n    <ApplicationId>com.testapp.monkeyfinder</ApplicationId>\n    <ApplicationIdGuid>E46570A0-D087-4FC2-ADFE-58FEAB0BEBB9</ApplicationIdGuid>\n\n    <!-- Versions -->\n    <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>\n    <ApplicationVersion>1</ApplicationVersion>\n\n    <!-- Required for C# Hot Reload -->\n    <UseInterpreter Condition="\'$(Configuration)\' == \'Debug\'">True</UseInterpreter>\n\n</PropertyGroup>\n\n<PropertyGroup Condition="$(TargetFramework.Contains(\'-ios\')) and \'$(Configuration)\' == \'Release\'">\n    <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>\n    <CodesignKey>\xe2\x80\x8cxxx</CodesignKey>\n    <CodesignProvision>Development Test Provisioning</CodesignProvision>\n            \n    <ArchiveOnBuild>true</ArchiveOnBuild>\n    <TcpPort>58181</TcpPort>\n    <ServerAddress>xxx</ServerAddress>\n    <ServerUser>xxx</ServerUser>\n    <ServerPassword>xxx</ServerPassword>\n    <_DotNetRootRemoteDirectory>/Users/xxx/Library/Caches/Xamarin/XMA/SDKs/dotnet/</_DotNetRootRemoteDirectory>\n\n</PropertyGroup>\n\n<PropertyGroup Condition="\'$(Configuration)|$(TargetFramework)|$(Platform)\'==\'Debug|net6.0-android|AnyCPU\'">\n  <MtouchDebug>True</MtouchDebug>\n</PropertyGroup>\n\n<PropertyGroup Condition="\'$(Configuration)|$(TargetFramework)|$(Platform)\'==\'Release|net6.0-android|AnyCPU\'">\n  <MtouchDebug>True</MtouchDebug>\n</PropertyGroup>\n\n<PropertyGroup Condition="\'$(Configuration)|$(TargetFramework)|$(Platform)\'==\'Debug|net6.0-ios|AnyCPU\'">\n  <MtouchDebug>True</MtouchDebug>\n</PropertyGroup>\n\n<PropertyGroup Condition="\'$(Configuration)|$(TargetFramework)|$(Platform)\'==\'Release|net6.0-ios|AnyCPU\'">\n  <MtouchDebug>True</MtouchDebug>\n</PropertyGroup>\n\n<PropertyGroup Condition="\'$(Configuration)|$(TargetFramework)|$(Platform)\'==\'Debug|net6.0-maccatalyst|AnyCPU\'">\n  <MtouchDebug>True</MtouchDebug>\n</PropertyGroup>\n\n<PropertyGroup Condition="\'$(Configuration)|$(TargetFramework)|$(Platform)\'==\'Release|net6.0-maccatalyst|AnyCPU\'">\n  <MtouchDebug>True</MtouchDebug>\n</PropertyGroup>\n\n<PropertyGroup Condition="\'$(Configuration)|$(TargetFramework)|$(Platform)\'==\'Debug|net6.0-windows10.0.19041|AnyCPU\'">\n  <MtouchDebug>True</MtouchDebug>\n</PropertyGroup>\n\n<PropertyGroup Condition="\'$(Configuration)|$(TargetFramework)|$(Platform)\'==\'Release|net6.0-windows10.0.19041|AnyCPU\'">\n  <MtouchDebug>True</MtouchDebug>\n</PropertyGroup>\n\n<ItemGroup>\n    <!-- App Icon -->\n    <MauiIcon Include="Resources\\appicon.svg" ForegroundFile="Resources\\appiconfg.svg" Color="#512BD4" />\n\n    <!-- Splash Screen -->\n    <MauiSplashScreen Include="Resources\\appiconfg.svg" Color="#512BD4" />\n\n    <!-- Images -->\n    <MauiImage Include="Resources\\Images\\*" />\n\n    <!-- Custom Fonts -->\n    <MauiFont Include="Resources\\Fonts\\*" />\n\n    <!-- Raw Assets (also remove the "Resources\\Raw" prefix) -->\n    <MauiAsset Include="Resources\\Raw\\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />\n</ItemGroup>\n然后我根据收集到的更多信息尝试了这些命令,结果如下:
\ndotnet publish -f:net6.0-ios -c:Release\n\n\n必须指定设备架构的运行时标识符才能发布此项目。\'iossimulator-x64\' 是一个模拟器架构。
\n
dotnet build -c:Release /p:BuildIpa=true\n\n\n成功,但是bin/Release/net6.0-ios/ios-arm64/publish下没有*.ipa文件
\n
我还删除了其他 PropertyGroup 标签,但这没有什么区别。Expect当删除第一个时,则错误为:
\n\n\n错误 NETSDK1013:无法识别 TargetFramework 值 '\'。它可能拼写错误。如果不是,则必须显式指定 TargetFrameworkIdentifier 和/或 TargetFrameworkVersion 属性。
\n
而且该项目也不再正确加载。
\n更新 3:
 \n当我从模板创建一个全新的 .NET MAUI 项目时,它开始使用命令进行编译
dotnet publish -f:net6.0-ios -c:Release\n但即使当我将 csproj 文件中的 xml 从工作项目复制到不工作项目时,我也会收到错误:
\n\n\n必须指定设备体系结构的运行时标识符\n才能发布此项目。\'iossimulator-x64\' 是一个模拟器
\n
我猜这表明错误的原因实际上不是在 csproj 文件中找到的,而是在其他地方找到的?
\n修复1
尝试通过条件属性组包含 RuntimeIdentifier .csproj,并从命令行省略它。
来自添加代码签名...。
.csproj:
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
  <RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
  <CodesignKey>iPhone Distribution: John Smith (AY2GDE9QM7)</CodesignKey>
  <CodesignProvision>MyMauiApp</CodesignProvision>
  <ArchiveOnBuild>true</ArchiveOnBuild>
</PropertyGroup>
命令行:
dotnet publish -f:net6.0-ios -c:Release
修复2
目前,在发布 ios 时,请从.csproj. 注意:这不是必需的,因为您通过指定框架-f,但值得一试。
改变:
dotnet publish -f:net6.0-ios -c:Release
到:
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
| 归档时间: | 
 | 
| 查看次数: | 5973 次 | 
| 最近记录: |