.NET 11 broke jetbrains Maui published builds - what i did to fix

I upgraded my maui project to .NET 11 and it worked fine in the IDE and even worked when i ran run on the phone if connected. Eventually with the help of AI we worked out that it was the PublishReadyToRun flag, which by default seems to be false. In .NET 10 this setting was ok, but in .NET 11 it caused an immediate crash.  I believe Microsoft's change in .NET 11 to use CoreCLR and not mono (https://learn.microsoft.com/en-us/dotnet/core/compatibility/maui/11/mobile-code-generation) means that you MUST set PublishReadyToRun=true in publish builds now. This setting is not exposed to the UI and the AI inserted the below in the project file. I think Jetbrains need to possible fix something here…


<Target Name="ValidateIosReleaseReadyToRun" BeforeTargets="PrepareForBuild"
        Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' and '$(Configuration)' == 'Release' and '$(UseMonoRuntime)' == 'false' and '$(PublishAot)' != 'true'">
  <!-- Rider can silently disable R2R; that mode reproduces this app's immediate device startup crash. -->
  <Error Condition="'$(PublishReadyToRun)' != 'true'"
         Text="iOS Release builds require PublishReadyToRun=true. Rider's folder publisher can override it to false; enable it in the publish configuration or pass -p:PublishReadyToRun=true." />
</Target>
0
2 comments
Official comment

Hello,

Thank you for contacting the Rider forum and for sharing your fix.

Unfortunately, it looks like you have faced a known issue: RIDER-145200 MAUI iOS publish fails: iOS projects do not support setting 'PublishTrimmed'. Please upvote it to get further status updates.

Glad to know that your project-file change works for you.

Have a great day!

ok - previous suggestion didn't fix it, the PublishReadyToRun flag was still being set to false. The following inserted into the project file did fix it:

<!-- Set this before SDK props select the R2R pipeline and native startup environment.
     Rider's iOS folder publisher otherwise supplies PublishReadyToRun=false globally. -->

<PropertyGroup Condition="'$(TargetFramework)' == '' or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">
  <PublishReadyToRun Condition="'$(PublishAot)' != 'true'">true</PublishReadyToRun>
</PropertyGroup>

0

Please sign in to leave a comment.