From 576140474ea0a296a67e2eb3fc3ee19d73e1ccb7 Mon Sep 17 00:00:00 2001 From: theolivenbaum Date: Thu, 9 Jun 2022 10:22:54 +0200 Subject: [PATCH] merge #624 --- .../Actions/GetTargetPlatformInformation.cs | 22 +++++++++++++++---- ElectronNET.CLI/Commands/BuildCommand.cs | 6 +++++ README.md | 3 ++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs b/ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs index a12d427..987e741 100644 --- a/ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs +++ b/ElectronNET.CLI/Commands/Actions/GetTargetPlatformInformation.cs @@ -27,6 +27,10 @@ namespace ElectronNET.CLI.Commands.Actions netCorePublishRid = "osx-x64"; electronPackerPlatform = "mac"; break; + case "osx-arm64": + netCorePublishRid = "osx-arm64"; + electronPackerPlatform = "mac"; + break; case "linux": netCorePublishRid = "linux-x64"; electronPackerPlatform = "linux"; @@ -46,12 +50,22 @@ namespace ElectronNET.CLI.Commands.Actions netCorePublishRid = $"win-x{(Environment.Is64BitOperatingSystem ? "64" : "86")}"; electronPackerPlatform = "win"; } - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) + else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) { - netCorePublishRid = "osx-x64"; - electronPackerPlatform = "mac"; + if (RuntimeInformation.OSArchitecture.Equals(Architecture.Arm64)) + { + //Apple Silicon Mac: + netCorePublishRid = "osx-arm64"; + electronPackerPlatform = "mac"; + } + else + { + //Intel Mac: + netCorePublishRid = "osx-x64"; + electronPackerPlatform = "mac"; + } } - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) { netCorePublishRid = "linux-x64"; electronPackerPlatform = "linux"; diff --git a/ElectronNET.CLI/Commands/BuildCommand.cs b/ElectronNET.CLI/Commands/BuildCommand.cs index b03aa18..6fef4ca 100644 --- a/ElectronNET.CLI/Commands/BuildCommand.cs +++ b/ElectronNET.CLI/Commands/BuildCommand.cs @@ -178,6 +178,12 @@ Full example for a 32bit debug build with electron prune: build /target custom w Console.WriteLine("Executing electron magic in this directory: " + buildPath); string electronArch = "x64"; + + if (platformInfo.NetCorePublishRid == "osx-arm64") //Apple Silicon Mac + { + electronArch = "arm64"; + } + if (parser.Arguments.ContainsKey(_paramElectronArch)) { electronArch = parser.Arguments[_paramElectronArch][0]; diff --git a/README.md b/README.md index e6e1533..55cf1bd 100644 --- a/README.md +++ b/README.md @@ -137,10 +137,11 @@ There are additional platforms available: ``` electronize build /target win electronize build /target osx +electronize build /target osx-arm64 electronize build /target linux ``` -Those three "default" targets will produce x64 packages for those platforms. +Those four "default" targets will produce packages for those platforms. Note that the `osx-arm64` is for Apple Silicon Macs. For certain NuGet packages or certain scenarios you may want to build a pure x86 application. To support those things you can define the desired [.NET Core runtime](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog), the [electron platform](https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#platform) and [electron architecture](https://github.com/electron-userland/electron-packager/blob/master/docs/api.md#arch) like this: