maui – Errors with dotnet publish

I’ve used these resources to learn how to publish a MAUI app:

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

Based on these, I tried different variants to publish, but none of them work:

dotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 

error : The RuntimeIdentifier ‘ios-arm64’ is invalid.

dotnet publish -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 --no-restore

error NETSDK1032: The RuntimeIdentifier platform ‘ios-arm64’ and the PlatformTarget ‘x64’ must be compatible.

dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true

error : The RuntimeIdentifier ‘ios-arm64’ is invalid.

dotnet build -f:net6.0-ios -c:Release /p:RuntimeIdentifier=ios-arm64 /p:BuildIpa=true --no-restore

error NETSDK1032: The RuntimeIdentifier platform ‘ios-arm64’ and the PlatformTarget ‘x64’ must be compatible.

Update
Environment:
Windows 10 Home – 21H2
VS 2022 Version 17.3.0 Preview 1.1

Update 2
Based on the answers I have now this csproj file:

<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="Resourcesappicon.svg" ForegroundFile="Resourcesappiconfg.svg" Color="#512BD4" />

    <!-- Splash Screen -->
    <MauiSplashScreen Include="Resourcesappiconfg.svg" Color="#512BD4" />

    <!-- Images -->
    <MauiImage Include="ResourcesImages*" />

    <!-- Custom Fonts -->
    <MauiFont Include="ResourcesFonts*" />

    <!-- Raw Assets (also remove the "ResourcesRaw" prefix) -->
    <MauiAsset Include="ResourcesRaw**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>

And then I tried out these commands based on more collected information since, with the following results:

dotnet publish -f:net6.0-ios -c:Release

A runtime identifier for a device architecture must be specified in order to publish this project. ‘iossimulator-x64’ is a simulator architecture.

dotnet build -c:Release /p:BuildIpa=true

Successful, but there is no *.ipa file in bin/Release/net6.0-ios/ios-arm64/publish

I also removed the other PropertyGroup tags, but it made no difference. Expect when removing the first one, then the error is:

error NETSDK1013: The TargetFramework value ” was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly.

And also the project doesn’t load properly anymore.

Update 3:
When I create a brand new .NET MAUI project from the template it starts compiling with the command

dotnet publish -f:net6.0-ios -c:Release

But even when I copy the xml in the csproj file from the working to the not working project I get the error:

A runtime identifier for a device architecture must be specified in order to publish this project. ‘iossimulator-x64’ is a simulator

I guess this indicates that the cause for the error is actually not to be found in the csproj file, but somewhere else?

architecture.

Leave a Comment