【发布时间】:2022-06-16 04:04:50
【问题描述】:
我使用这些资源来学习如何发布 MAUI 应用:
https://docs.microsoft.com/en-us/dotnet/maui/ios/deployment/overview
https://github.com/dotnet/maui/issues/4397
https://github.com/dotnet/sdk/issues/21877
基于这些,我尝试了不同的变体来发布,但它们都不起作用:
dotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64
错误:RuntimeIdentifier 'ios-arm64' 无效。
dotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 --no-restore
错误 NETSDK1032:RuntimeIdentifier 平台“ios-arm64”和 PlatformTarget 'x64' 必须兼容。
dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true
错误:RuntimeIdentifier 'ios-arm64' 无效。
dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true --no-restore
错误 NETSDK1032:RuntimeIdentifier 平台“ios-arm64”和 PlatformTarget 'x64' 必须兼容。
更新
环境:
Windows 10 家庭版 - 21H2
VS 2022 版本 17.3.0 预览版 1.1
更新 2
根据答案,我现在有这个 csproj 文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-ios</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>MonkeyFinder</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>MonkeyFinder</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.testapp.monkeyfinder</ApplicationId>
<ApplicationIdGuid>E46570A0-D087-4FC2-ADFE-58FEAB0BEBB9</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<!-- Required for C# Hot Reload -->
<UseInterpreter Condition="'$(Configuration)' == 'Debug'">True</UseInterpreter>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
<CodesignKey>xxx</CodesignKey>
<CodesignProvision>Development Test Provisioning</CodesignProvision>
<ArchiveOnBuild>true</ArchiveOnBuild>
<TcpPort>58181</TcpPort>
<ServerAddress>xxx</ServerAddress>
<ServerUser>xxx</ServerUser>
<ServerPassword>xxx</ServerPassword>
<_DotNetRootRemoteDirectory>/Users/xxx/Library/Caches/Xamarin/XMA/SDKs/dotnet/</_DotNetRootRemoteDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-ios|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-maccatalyst|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-maccatalyst|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-windows10.0.19041|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-windows10.0.19041|AnyCPU'">
<MtouchDebug>True</MtouchDebug>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\appicon.svg" ForegroundFile="Resources\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\appiconfg.svg" Color="#512BD4" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
然后我根据收集到的更多信息尝试了这些命令,结果如下:
dotnet publish -f:net6.0-ios -c:Release
必须指定设备架构的运行时标识符才能发布此项目。 'iossimulator-x64' 是一个 模拟器架构。
dotnet build -c:Release /p:BuildIpa=true
成功,但是bin/Release/net6.0-ios/ios-arm64/publish中没有*.ipa文件
我还删除了其他 PropertyGroup 标记,但没有任何区别。期望删除第一个时,错误是:
错误 NETSDK1013:无法识别 TargetFramework 值“”。它可能拼写错误。如果不是,则必须明确指定 TargetFrameworkIdentifier 和/或 TargetFrameworkVersion 属性。
而且项目也无法正确加载。
更新 3:
当我从模板创建一个全新的 .NET MAUI 项目时,它开始使用命令编译
dotnet publish -f:net6.0-ios -c:Release
但即使我将 csproj 文件中的 xml 从工作项目复制到不工作项目,我也会收到错误:
设备架构的运行时标识符必须在 为了发布这个项目。 'iossimulator-x64' 是一个模拟器
我猜这表明错误的原因实际上不是在csproj文件中找到的,而是在其他地方?
【问题讨论】:
-
来自 Windows 还是 Mac VS?更新到最新的 VS 2022 预览版?你能从命令行
buildDebug版本吗? (没有 BuildIpa) -
来自 Windows,带有最新的 VS 2022 预览版。命令“dotnet build -c:Debug”运行成功。
-
你有多个项目吗?尝试专门发布 csproj。所以 dotnet 发布 YourProject.csproj 然后是其余的选项
-
这只是一个项目。我可能不小心弄明白了:我将标签 RuntimeIdentifier 更改为 RuntimeIdentifiers,然后它开始编译。但是现在我遇到了下一个错误:“在钥匙串中找不到代码签名密钥”