Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac: Fix building unified binary #2211

Merged
merged 1 commit into from May 5, 2022
Merged

Mac: Fix building unified binary #2211

merged 1 commit into from May 5, 2022

Conversation

hazzik
Copy link
Contributor

@hazzik hazzik commented May 4, 2022

The following snippet does not make much sense

<UnifiedFiles TargetPath="$([System.String]::Copy('%(FullPath)').TrimStart('%(BasePath)'))" />

Because '%(BasePath)' is a relative path and so %(FullPath) does not start with it. Therefore %(TargetPath) becomes equal to '%(FullPath)' which is obviously unique (because these are the actual files).

Here is an example produced with a template project (2.6.1) created at~/Projects/Private/eto-test2 (~ is /Users/alex.z/):

  UnifiedFiles.BasePath = bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/
  UnifiedFiles.BasePath = bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/

  UnifiedFiles.Identity = bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Info.plist
  UnifiedFiles.Identity = bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/MacOS/eto-test2
  UnifiedFiles.Identity = bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Resources/MacIcon.icns
  UnifiedFiles.Identity = bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Info.plist
  UnifiedFiles.Identity = bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/MacOS/eto-test2
  UnifiedFiles.Identity = bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Resources/MacIcon.icns

  UnifiedFiles.FullPath = /Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Info.plist
  UnifiedFiles.FullPath = /Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/MacOS/eto-test2
  UnifiedFiles.FullPath = /Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Resources/MacIcon.icns
  UnifiedFiles.FullPath = /Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Info.plist
  UnifiedFiles.FullPath = /Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/MacOS/eto-test2
  UnifiedFiles.FullPath = /Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Resources/MacIcon.icns

Here is part of output of dotnet build if I uncomment this line:

<!-- <Message Importance="high" Text="%(UnifiedFiles.RelativeDir)%(UnifiedFiles.FileName)%(UnifiedFiles.Extension) > %(UnifiedFiles.TargetPath)" /> -->

  bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Info.plist > Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Info.plist
  bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/MacOS/eto-test2 > Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/MacOS/eto-test2
  bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Resources/MacIcon.icns > Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Resources/MacIcon.icns
  bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Info.plist > Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Info.plist
  bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/MacOS/eto-test2 > Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/MacOS/eto-test2
  bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Resources/MacIcon.icns > Users/alex.z/Projects/Private/eto-test2/bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Resources/MacIcon.icns

And here's the output with a fixed version:

  bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Info.plist > Contents/Info.plist
  bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/MacOS/eto-test2 > Contents/MacOS/eto-test2
  bin/Mac64/Debug/net6.0/osx-x64/eto-test2.app/Contents/Resources/MacIcon.icns > Contents/Resources/MacIcon.icns
  bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Info.plist > Contents/Info.plist
  bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/MacOS/eto-test2 > Contents/MacOS/eto-test2
  bin/Mac64/Debug/net6.0/osx-arm64/eto-test2.app/Contents/Resources/MacIcon.icns > Contents/Resources/MacIcon.icns

@@ -24,12 +24,12 @@
<Target Name="MacBuildAppBundle" AfterTargets="AfterBuild" DependsOnTargets="$(MacBuildAppBundleDependsOnTargets);_MacBuildFrameworkAppBundle;_MacBuildUnifiedAppBundle" Condition="$(MacAutoPublishBundle) == 'True' AND $(MacIsBuildingBundle) != 'True'" Outputs="$(OutputAppPath)">
</Target>

<Target Name="_MacBuildUnifiedAppBundle" Condition="@(MacBundleRuntimeIdentifiers->Count()) > 1">
<Target Name="_MacBuildUnifiedAppBundle" Condition="@(MacBundleRuntimeIdentifiers->Count()) > 1 AND $(PublishSingleFile) == True">
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is implied by this comment:

Log.LogWarning($"{group.Key} is different between RuntimeIdentifiers. Creating universal binaries is only supported when PublishSingleFile is true.");

@cwensley
Copy link
Member

cwensley commented May 5, 2022

Hey @hazzik, much appreciated for the fix creating unified binaries! I found the same issue recently and fixed it locally a little differently but either way works for me.

Unfortunately, the second fix I cannot merge in, as if PublishSingleFile is not set, it will still create single file .app bundles by default but will be skipped with that change.

On top of that, it's simply a warning. That might happen if you add different content files for each architecture, and you need the warning so you know they are different and can't be merged. I think the message should probably be updated to reflect that case.

@hazzik
Copy link
Contributor Author

hazzik commented May 5, 2022

@cwensley ok, I've reverted the second commit.

@cwensley
Copy link
Member

cwensley commented May 5, 2022

Awesome, thanks for doing that! Really appreciated.

@cwensley cwensley merged commit 7d8de5c into picoe:develop May 5, 2022
@cwensley cwensley added the bug label May 5, 2022
@cwensley cwensley added this to the 2.6.2 milestone May 5, 2022
@hazzik hazzik deleted the patch-1 branch May 5, 2022 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants