4

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>
Chris
  • 305
  • 4
  • 19
  • Your last example mentions `-c:Debug`. Is this happening now on Debug builds also? Or its just when `publish`, and that was a desperate attempt to get something through? I realize you can't keep "starting a new project from scratch", but it would be informative to do that once, now that you have more content, copy all the source files over, see if it works again (at least once). That is, is it something that goes wrong, and gets cached somewhere, or is it inevitable once a project has significant content. Regardless, its clear that iOS publishing support is a work in progress. – ToolmakerSteve Jun 04 '22 at 21:02
  • @ToolmakerSteve Yes. The only way this project runs is by clicking on the "Play Button" for "Windows Machine" or "iOS Simulator". – Chris Jun 04 '22 at 21:14
  • @ToolmakerSteve Sure, I'll give it another try from scratch asap. – Chris Jun 04 '22 at 21:21
  • Another idea: if you commit sources to a git repo, then checkout to a different folder, that should break any connection to cached data (as long as you exclude bin and obj folders, and maybe any hidden folders). Then build. Easier than adding sources to a new project. – ToolmakerSteve Jun 05 '22 at 01:32
  • @ToolmakerSteve That's a great idea! Thank you. I'll include that in my tests today. – Chris Jun 05 '22 at 10:22
  • 1
    @ToolmakerSteve I remembered the comment on another post to delete *.csproj.user and that solved it... Unfortunately that's not the end of the line. Now I'm stuck with "Xamarin.Shared.Sdk.targets(366,3): error : MessagingRe moteException: An error occurred on client Build while executing a reply for topic xvs/build/execute-task/OnesieMobile/ 18e8f3c002fMergeAppBundles" Probably have to write another post for that. I already tried your suggestion to go through the Github and build it in a fresh solution, but it doesn't work either. – Chris Jun 05 '22 at 13:53

1 Answers1

10

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.

Chris
  • 305
  • 4
  • 19