Unable to publish iOS with Rider - PublishTrimmed must be true

I'm beside myself here.  I've got 2 MAUI apps (both support iOS and Android) that I need to release updated versions for, but I keep running into the error here:

Xamarin.Shared.Sdk.targets(285,3): Error  : iOS projects must build with PublishTrimmed=true. Current value: false. Set 'MtouchLink=None' instead to disable trimming for all assemblies

In my .csproj I have <PublishTrimmed>true</PublishTrimmed> declared in the initial Property Group (that also has target framworks, app id, etc).  I've read the MS documents on trimming.  Prior versions of the apps were published via VS for Mac, .Net 7 framework, but for some reason I decided to move to .Net 8.0 and give Rider a try.  Love Rider, well work paying for, but I'm in a corner now with VS Mac not supporting .Net 8, and trying to run VS on a Windows 11 VM and connecting back to my host MacOS, is cumbersome at best.  I know the trimming thing is not a Rider issue.  For the life of me I cannot find any resolution for this.

Any help or guidance would be greatly appreciated.  Thanks, 

Kurt Mackall - Silver Ridge Software LLC

1
9 comments

Hello Kmackall ,

Thank you for reaching the Rider forum.

Can you please provide me with a sample solution to reproduce the issue? You may want to upload it to our shared storage at https://uploads.jetbrains.com and send the ID of the upload. 

Thank you in advance.

 

0

I am having the exact same issue described by Kurt above and arrived here by almost identical means.  

Error message:

  Xamarin.Shared.Sdk.targets(285, 3): iOS projects must build with PublishTrimmed=true. Current value: false. Set 'MtouchLink=None' instead to disable trimming for all assemblies.

Here is my .csproj file:

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

	<PropertyGroup>
		<TargetFrameworks>net8.0-android;net8.0-ios;net8.0-maccatalyst</TargetFrameworks>
		<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net8.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);net7.0-tizen</TargetFrameworks> -->
		<OutputType>Exe</OutputType>
		<RootNamespace>[redacted]</RootNamespace>
		<UseMaui>true</UseMaui>
		<SingleProject>true</SingleProject>
		<ImplicitUsings>enable</ImplicitUsings>
	
		<!-- Display name -->
		<ApplicationTitle>[redacted]</ApplicationTitle>

		<!-- App Identifier -->
		<ApplicationId>[redacted]</ApplicationId>
		<ApplicationIdGuid>[redacted]</ApplicationIdGuid>

		<!-- Versions -->
		<ApplicationDisplayVersion>1.1.1</ApplicationDisplayVersion>
		<ApplicationVersion>19</ApplicationVersion>

		<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</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=" '$(Configuration)' == 'Release' ">
		<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
	  	<CodesignKey>[redacted]</CodesignKey>
	  	<CodesignProvision>[redacted]</CodesignProvision>
	  	<AndroidSupportedAbis>armeabi-v7a;x86;arm64-v8a;x86_64</AndroidSupportedAbis>
	  	<AndroidKeyStore>true</AndroidKeyStore>
	  	<AndroidSigningKeyStore>[redacted]</AndroidSigningKeyStore>
	  	<AndroidSigningStorePass>[redacted]</AndroidSigningStorePass>
	  	<AndroidSigningKeyAlias>[redacted]</AndroidSigningKeyAlias>
	  	<AndroidSigningKeyPass>[redacted]</AndroidSigningKeyPass>
	  	<!-- <MtouchLink>None</MtouchLink> -->
		<PublishTrimmed>true</PublishTrimmed>
		<RunAOTCompilation>false</RunAOTCompilation>
		<!-- Line above is the only way I could get the Android publish to work-->
		<!--      iOS result is the same even if commented out -->

	</PropertyGroup>
	
	<!-- ItemGroup removed to keep succinct, can provide if needed -->
	
</Project>

After saving changes to my .csproj file, I have tried:

  1. Unloading and Reloading project
  2. Cleaning Solution
  3. Rebuilding Solution
  4. Restarting Rider
  5. Restarting my machine

Here is what my Publish Config looks like in Rider:

0

My .csproj file looks similar to what Adam posted.  I cannot upload any files even to a secure site as the project is a commercial application.  I also went through the steps Adam outlined (probably multiple times probably).

My workaround to get a build to publish, was to open the MAUI project in Visual Studio 2022 in my Windows 11 Parallels VM.  There, I made sure the distribution signing certificate and the publishing profile were correct from what I put into the project file in Rider, and then in VS Windows I was able to build and publish the MAUI project without a problem.  So thinking that maybe VS Windows made a change to the .csproj file or project properties that Rider would find useful, I then went back to Rider Mac and tried to publish the project, and I got the same error as above.  Going back to Win 11 VS 22, I opened the MAUI app back up and successfully published the project.

0

I'm having the same issue but with a .net-ios project using .Net8.0 framework.

 

1

Hello Kmackall ,

Thank you for the update. 

I tried reproducing the issue with the similar .csproj, but met no error publishing. Thus, is it possible to provide me with the following details?

  1.  Rider version (If the version is below 2023.3.3, please try updating it and/or using EAP build);
  2. Xcode version (please update if below the current one or does not support 17.2 SDK for iOS);
  3. If possible, please provide logs from Help > Collect Logs and Diagnostic Data. You may want to upload it to our shared storage at https://uploads.jetbrains.com and send the ID of the upload. 


ismart @Adam,

Is it possible for you to provide the same information and, if possible, a test solution to reproduce the issue? 

Thank you in advance. Looking forward to your reply.

 

 

0

Anna Morozyuk 
 

  1. Rider 2023.3.2 when I posted my first issue, 2023.3.3 now
  2. Xcode 15.2
  3. 2024_01_25_jrW1rm5u7fTNJD4zfoeNWf

Sterilized Solution file: 2024_01_25_uonb8LwZh7gU7wGNX9kRch

 

1

Hello,

Thank you for the patience. 

From all the provided information, it seems that you've been affected by the consequences of this issue: 

RIDER-76797 Archive for publish doesn't work for MAUI projects

And thus, once it is implemented, all should work just fine. At the moment, it is planned to be included in the next major release of Rider. Please upvote it or follow to get updates on the progress. 

Thank you and have a nice day. 

0

<OutputType>Exe</OutputType> removing this worked for me

1

Annoying and inexplicable but Sonny S's OutputType removal worked for me to resolve this. 

0

Please sign in to leave a comment.