iosvisual-studio-2022maui.net-maui

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


I've had this error already over here: Errors with dotnet publish but I was able to sneak away from it, by just creating a brand new solution. Well, that's not an option anymore, because I am working on a real project now.

Through all the many days I have spent with these errors, I was able to compile some of the projects and distribute them on an IPhone. It's just, that somewhere in that path from creating a fresh solution, working on it a little bit, suddendly this specific error occurs, and I don't know how to solve it. Maybe someone has an insight.

The project runs perfectly in the simulator on the remote Mac and on the Windows as Windows app.

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

Here is what I have done so far:

dotnet publish -f:net6.0-ios -c:Release /bl:msbuild.binlog

with the XML at the end of this post throws this error at me:

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

Looking into the binlog I see this: enter image description here

While the configuration of the project shows this: enter image description here

Supposedly the PlatformTarget is set to "x64", But it's not. At least not according to the project settings. Unless there is another place to configure it.

It tried changing it to ARM64 and back to Any CPU, I tried specifying in the XML for either one or all PropertyGroups, and I tried specifying it in the command line like this:

dotnet publish -f:net6.0-ios -c:Release /p:Platform="Any CPU"

I've also changed

<PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">

to

<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))>

and then this:

dotnet publish -f:net6.0-ios -c:Debug /p:Platform="Any CPU"

None of these have any effect whatsoever. What am I missing?

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks>
        <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
        <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
        <!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
        <OutputType>Exe</OutputType>
        <RootNamespace>OnesieMobile</RootNamespace>
        <UseMaui>true</UseMaui>
        <SingleProject>true</SingleProject>
        <ImplicitUsings>enable</ImplicitUsings>

        <!-- Display name -->
        <ApplicationTitle>OnesieMobile</ApplicationTitle>

        <!-- App Identifier -->
        <ApplicationId>com.maui.app</ApplicationId>
        <ApplicationIdGuid>447A62C6-2841-41D6-B9AE-444E6E1A908B</ApplicationIdGuid>

        <!-- Versions -->
        <ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
        <ApplicationVersion>1</ApplicationVersion>

        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
        <TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
        <SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
    </PropertyGroup>
    
    <PropertyGroup Condition="$(TargetFramework.Contains('-ios')) and '$(Configuration)' == 'Release'">
        <RuntimeIdentifiers>ios-arm64</RuntimeIdentifiers>
        <CodesignProvision>Maui Provisioning</CodesignProvision>
        <CodesignKey>Apple Distribution: My Name (XXXX)</CodesignKey>

        <ArchiveOnBuild>true</ArchiveOnBuild>
        <TcpPort>58181</TcpPort>
        <ServerAddress>xxxxx</ServerAddress>
        <ServerUser>xxxx</ServerUser>
        <ServerPassword>xxxx</ServerPassword>
        <_DotNetRootRemoteDirectory>/Users/xxxx/Library/Caches/Xamarin/XMA/SDKs/dotnet/</_DotNetRootRemoteDirectory>

    </PropertyGroup>

    <ItemGroup>
        <!-- App Icon -->
        <MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />

        <!-- Splash Screen -->
        <MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />

        <!-- Images -->
        <MauiImage Include="Resources\Images\*" />
        <MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />

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

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

    <ItemGroup>
      <PackageReference Include="CommunityToolkit.Maui" Version="1.0.0" />
      <PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.2" />
      <PackageReference Include="sqlite-net-pcl" Version="1.8.116" />
    </ItemGroup>

    <ItemGroup>
      <Compile Update="View\ActivityDetailPage.xaml.cs">
        <DependentUpon>ActivityDetailPage.xaml</DependentUpon>
      </Compile>
    </ItemGroup>

    <ItemGroup>
      <MauiXaml Update="View\ActivityDetailPage.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
      <MauiXaml Update="View\SettingsPage.xaml">
        <Generator>MSBuild:Compile</Generator>
      </MauiXaml>
    </ItemGroup>

</Project>

Solution

  • I figured it out! it was the *.csproj.user file!!!

    This is what it looked like before I deleted it.

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <ActiveDebugFramework>net6.0-windows10.0.19041.0</ActiveDebugFramework>
        <IsFirstTimeProjectOpen>False</IsFirstTimeProjectOpen>
        <ActiveDebugProfile>Windows Machine</ActiveDebugProfile>
        <SelectedPlatformGroup>Simulator</SelectedPlatformGroup>
        <DefaultDevice>iPhone 13 Pro Max iOS 15.5</DefaultDevice>
      </PropertyGroup>
      <PropertyGroup Condition="'$(TargetPlatformIdentifier)'=='iOS'">
        <RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
        <PlatformTarget>x64</PlatformTarget>
      </PropertyGroup>
      <PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android|AnyCPU'">
        <DebuggerFlavor>ProjectDebugger</DebuggerFlavor>
      </PropertyGroup>
      <ItemGroup>
        <MauiXaml Update="View\ActivityDetailPage.xaml">
          <SubType>Designer</SubType>
        </MauiXaml>
        <MauiXaml Update="View\SettingsPage.xaml">
          <SubType>Designer</SubType>
        </MauiXaml>
      </ItemGroup>
    </Project>
    

    And this is what it looks like after the first opening of the solution file.

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup />
    </Project>
    

    How this

    <PlatformTarget>x64</PlatformTarget>
    

    got in there, I don't know. I can't reproduce it. And why this is overpowering the actual settings of the project or the command line arguments.