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

Create a macOS universal binary #313

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

baronfel
Copy link
Member

Adds a target that

  • creates arch-specific macos binaries
  • stitches them together using lipo to create a universal binary (thanks @rolfbjarne!)

Things we need to think about:

  • how are these signed/notarized?
  • how is the universal binary passed to the rest of the build process in the azdo pipelines?
  • How does the azdo pipeline on mac call the build? Because we'd need it to either call this new target directly or have this target be a dependency of the existing build entry point

cc @joeloff / @marcpopMSFT

<_LipoOuputPath>$(PublishDir)\osx-universal\$(AssemblyName)</_LipoOuputPath>
</PropertyGroup>

<Exec Command="lipo @(_RidSpecificSingleFile, ' ') -create -output $(_LipoOuputPath)" Condition="$([MSBuild]::IsOSPlatform('OSX'))" />
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if you care, but this won't work if any of these paths have spaces in them.

src/dotnet-core-uninstall/dotnet-core-uninstall.csproj Outdated Show resolved Hide resolved
src/dotnet-core-uninstall/dotnet-core-uninstall.csproj Outdated Show resolved Hide resolved
@baronfel
Copy link
Member Author

Tested this on a m2 machine and it works as expected:

% file dotnet-core-uninstall 
dotnet-core-uninstall: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]
dotnet-core-uninstall (for architecture x86_64):	Mach-O 64-bit executable x86_64
dotnet-core-uninstall (for architecture arm64):	Mach-O 64-bit executable arm64

@joeloff
Copy link
Member

joeloff commented Oct 29, 2024

Don't think we do notarization for this.

@@ -37,4 +37,23 @@
</EmbeddedResource>
</ItemGroup>

<Target Name="PublishMacOSUniversalBinary">
Copy link
Member

Choose a reason for hiding this comment

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

who/what calls this target?

Copy link
Member Author

Choose a reason for hiding this comment

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

I need help making the macOS build call this - it's one of the questions in the issue description :)

Copy link
Member

Choose a reason for hiding this comment

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

probably here: https://github.com/dotnet/cli-lab/blob/25e91f1d39ad446131c0fe4bc998c5a33e766773/.vsts-ci.yml#L137C1-L144C33

You can tweak the .yml, then push your branch internal to trigger an official build against your branch, that's the only way to verify yaml changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants