From 4e39f5f3779a0f1f387b67155beab6b1446da699 Mon Sep 17 00:00:00 2001 From: Florian Rappl Date: Mon, 3 Aug 2026 14:12:09 +0200 Subject: [PATCH] Added support for MacOS modern app icon #1047 --- Changelog.md | 1 + docs/Using/Configuration.md | 6 ++++++ .../build/ElectronNET.LateImport.targets | 18 +++++++++++++++++- .../build/ElectronNETRules.Project.xaml | 4 ++-- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/Changelog.md b/Changelog.md index 3873f04..2310a95 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ - Fixed bloated ASAR file (#1080) @epsnm - Improved selection of runtime identifier (#1081) @epsnm - Added more variants for `UseElectron` (#1076) @AeonSake +- Added support for modern MacOS app icon (#1047) # 0.5.1 diff --git a/docs/Using/Configuration.md b/docs/Using/Configuration.md index 55a7cd6..dd16fc5 100644 --- a/docs/Using/Configuration.md +++ b/docs/Using/Configuration.md @@ -70,6 +70,12 @@ Since electron builder still expects a `package.json` file to exist, ElectronNET } ``` +### App Icon Path + +The `ElectronIcon` property supports classic icon files (such as `.ico` and `.icns`) and modern macOS `.icon` app icon packages. + +For `.icon`, provide the folder path (for example `Assets/MyApp.icon`). During build/publish, Electron.NET copies the full directory into the Electron output so `electron-builder.json` can reference it (for example `"mac": { "icon": "MyApp.icon" }`). + ### Node.js Integration Electron.NET requires Node.js integration to be enabled for IPC to function. If you are not using the IPC functionality you can disable Node.js integration like so: diff --git a/src/ElectronNET/build/ElectronNET.LateImport.targets b/src/ElectronNET/build/ElectronNET.LateImport.targets index ebdb3ee..10185e0 100644 --- a/src/ElectronNET/build/ElectronNET.LateImport.targets +++ b/src/ElectronNET/build/ElectronNET.LateImport.targets @@ -313,7 +313,10 @@ <_ElectronFiles Include="$(ElectronSplashScreen)" Condition="'$(ElectronSplashScreen)'!=''" /> - <_ElectronFiles Include="$(ElectronIcon)" Condition="'$(ElectronIcon)'!=''" /> + <_ElectronIconDirectories Include="$(ElectronIcon)" + Condition="'$(ElectronIcon)'!='' AND Exists('$(ElectronIcon)') AND $([System.IO.Directory]::Exists('$(ElectronIcon)') )" /> + <_ElectronFiles Include="$(ElectronIcon)" + Condition="'$(ElectronIcon)'!='' AND ( !Exists('$(ElectronIcon)') OR !$([System.IO.Directory]::Exists('$(ElectronIcon)') ) )" /> @@ -328,12 +331,25 @@ <_ElectronFilesToCopy Include="@(_ElectronFiles->'%(FullPath)')" /> + + <_ElectronIconDirectoryFiles Include="@(_ElectronIconDirectories->'%(FullPath)\**\*')" /> + <_ElectronIconDirectoryFiles Remove="@(_ElectronIconDirectoryFiles)" Condition="$([System.IO.Directory]::Exists('%(Identity)'))" /> + <_ElectronIconDirectoryFiles Update="@(_ElectronIconDirectoryFiles)"> + $([System.String]::Copy('%(Identity)').Replace('$([MSBuild]::EnsureTrailingSlash(%(_ElectronIconDirectories.FullPath)))', '')) + + + + <_ElectronFilesToCopyWithTargetPath Include="@(_ElectronFilesToCopy)"> $(ElectronDirName)\%(FileName)%(Extension) + + <_ElectronFilesToCopyWithTargetPath Include="@(_ElectronIconDirectoryFiles)"> + $(ElectronDirName)\$(ElectronIconFileName)\%(ElectronIconRelativePath) + diff --git a/src/ElectronNET/build/ElectronNETRules.Project.xaml b/src/ElectronNET/build/ElectronNETRules.Project.xaml index 59b1942..0331ae8 100644 --- a/src/ElectronNET/build/ElectronNETRules.Project.xaml +++ b/src/ElectronNET/build/ElectronNETRules.Project.xaml @@ -572,7 +572,7 @@ @@ -581,7 +581,7 @@ - +