Electron.NET icon indicating copy to clipboard operation
Electron.NET copied to clipboard

When building osx-arm64, the build is performed in the win-x64 folder.

Open Tartilla-TAIGO opened this issue 1 month ago • 7 comments

  • Version: 0.3.0-pre.336
  • Target: osx-arm64

OutDir: bin/Debug/net10.0/osx-arm64/ EnsureElectronBuilderJson: /Users/Test/Projects/Test/Test/Properties/ EnsureElectronBuilderJson: /Users/Test/Projects/Test/Test/Properties/electron-builder.json EnsureElectronBuilderJson: False _ElectronFiles: _ElectronFilesToCopy: Test -> /Users/Test/Projects/Test/Test/bin/Debug/net10.0/osx-arm64/Test.dll BeforePublishElectronApp PublishDir: publish/Debug/net10.0/win-x64/ BeforePublishElectronApp PublishDir: publish/Debug/net10.0/win-x64/bin/ /usr/local/share/dotnet/dotnet "/usr/local/share/dotnet/sdk/10.0.101/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/../tools/net10.0/Microsoft.NET.Sdk.StaticWebAssets.Tool.dll" brotli

Test -> /Users/Test/Projects/Test/Test/publish/Debug/net10.0/win-x64/bin/ _ElectronFilesToCopyWithTargetPath: CopiedFiles: publish/Debug/net10.0/win-x64/bin/.electron/package.json ElectronPublishFilesToMove: publish/Debug/net10.0/win-x64/bin/.electron/api/app.js;publish/Debug/net10.0/win-x64/bin/.electron/api/autoUpdater.js;publish/Debug/net10.0/win-x64/bin/.electron/api/browserView.js;publish/Debug/net10.0/win-x64/bin/.electron/api/browserWindows.js;publish/Debug/net10.0/win-x64/bin/.electron/api/clipboard.js;publish/Debug/net10.0/win-x64/bin/.electron/api/commandLine.js;publish/Debug/net10.0/win-x64/bin/.electron/api/dialog.js;publish/Debug/net10.0/win-x64/bin/.electron/api/dock.js;publish/Debug/net10.0/win-x64/bin/.electron/api/globalShortcut.js;publish/Debug/net10.0/win-x64/bin/.electron/api/ipc.js;publish/Debug/net10.0/win-x64/bin/.electron/api/menu.js;publish/Debug/net10.0/win-x64/bin/.electron/api/nativeTheme.js;publish/Debug/net10.0/win-x64/bin/.electron/api/notification.js;publish/Debug/net10.0/win-x64/bin/.electron/api/powerMonitor.js;publish/Debug/net10.0/win-x64/bin/.electron/api/process.js;publish/Debug/net10.0/win-x64/bin/.electron/api/screen.js;publish/Debug/net10.0/win-x64/bin/.electron/api/shell.js;publish/Debug/net10.0/win-x64/bin/.electron/api/tray.js;publish/Debug/net10.0/win-x64/bin/.electron/api/webContents.js;publish/Debug/net10.0/win-x64/bin/.electron/ElectronHostHook/connector.js;publish/Debug/net10.0/win-x64/bin/.electron/ElectronHostHook/index.js;publish/Debug/net10.0/win-x64/bin/.electron/eslint.config.js;publish/Debug/net10.0/win-x64/bin/.electron/main.js;publish/Debug/net10.0/win-x64/bin/.electron/package.json;publish/Debug/net10.0/win-x64/bin/.electron/scripts/blazor-preload.js;publish/Debug/net10.0/win-x64/bin/.electron/splashscreen/index.html

My pubxml:

<?xml version="1.0" encoding="utf-8"?>
<Project>
    <PropertyGroup>
        <Configuration>Release</Configuration>
        <Platform>Any CPU</Platform>
        <PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
        <PublishProtocol>FileSystem</PublishProtocol>
        <TargetFramework>net10.0</TargetFramework>
        <RuntimeIdentifier>osx-arm64</RuntimeIdentifier>
        <SelfContained>true</SelfContained>
        <PublishSingleFile>false</PublishSingleFile>
    </PropertyGroup>
</Project>

Tartilla-TAIGO avatar Dec 10 '25 15:12 Tartilla-TAIGO

This may be due to the fact that the main win-x64 framework is specified in csproj, but it works strangely.

<PropertyGroup Label="ElectronNetCommon">
    <ElectronVersion>30.4.0</ElectronVersion>
    <ElectronBuilderVersion>26.0</ElectronBuilderVersion>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <ElectronSingleInstance>true</ElectronSingleInstance>
    <ElectronSplashScreen></ElectronSplashScreen>
    <ElectronIcon></ElectronIcon>
    <PackageId>$(MSBuildProjectName.Replace(".", "-").ToLower())</PackageId>
    <ElectronBuilderJson>electron-builder.json</ElectronBuilderJson>
    <Title>$(MSBuildProjectName)</Title>
</PropertyGroup>

Tartilla-TAIGO avatar Dec 10 '25 16:12 Tartilla-TAIGO

What command are you running? I am asking because I also see Debug appearing in the output paths, while it should be Release according to your config. So in general it seems like this one is not following the publish definition, hence the question.

Can you provide a repo with a reproducible?

FlorianRappl avatar Dec 10 '25 16:12 FlorianRappl

I'll look at everything again tomorrow, maybe I did something wrong. If I don't find the reason for the error in my actions, then tomorrow I will create a test repository.

Tartilla-TAIGO avatar Dec 10 '25 16:12 Tartilla-TAIGO

I had a similar issue with a project that has other project references; I had to explicitly specify the target framework in the publish command for it to build properly: dotnet publish -p:PublishProfile=osx-arm64 -r osx-arm64 Looks redundant, but I wasn't able to get it to work otherwise.

AeonSake avatar Dec 10 '25 16:12 AeonSake

Hi,

what you are encountering here is in fact a tiny ugliness, essentially the price that had to be paid for some of the major benefits over earlier Electron.NET.

Here's why:

In most .NET scenarios the builds are platform-independent - especially those that you do during development and for debugging. The platform-specifity only plays a role when publishin.

But for Electron.NET, that's different: We have a .net side and an electron side - and the electron side is always platform-specific. When you don't build the electron side alongside, you have nothing: you cannot test, you debug, you cannot recognize any errors. That means: the target platform (=> runtime identifier) needs to be known before creating any useful output.

And that leaves two options for dealing with it:

  1. Legacy Electron.NET RuntimeIdentifiers remain to be a sole matter of publishing (like in most other .net projects) With the following consequences:
  • Regular builds are pointless (merely useful as syntax check)
  • You do not build - you always have to publish instead
  • And publishing takes several minutes each time
  1. Electron.NET Core Here we go in the other direction: We define the RID in the project And that allows to:
  • Just build - which gives you a working result without publishing
  • It's much faster on the .NET side, because it's incremental and a lot less processing (no platform-specific treatment
  • I't much faster on the electron side, because there is no package building - it's just a "restore" (= npm install) which is again incremental and most of the time doesn't need any action (=no changes on that side)
  • You can launch to debug (incl. update-build) within a few seconds only and you get hot-reload + edit&continue
  • You can easily switch between Windows and Linux/WSL on Windows (or Linux remote debugging)
  • etc.

Of course, this could be more elegant: You could create multiple solution configurations (like Release-Win, Debug-Win, Release-Linux, Debug-Linux) or even redefine the platforms to switch more easily. But the bottom line here: There are many different ways and there is no standard pattern for such cases, i.e. everybody may want a different way. If I would have done something like that, it would be incompatible with people's setups and possibly difficult ot understand - so I kept it as a kind of "loose parameter" which makes it up to everyone's self for adapting it to their needs.

softworkz avatar Dec 10 '25 20:12 softworkz

; I had to explicitly specify the target framework in the publish command for it to build properly: dotnet publish -p:PublishProfile=osx-arm64 -r osx-arm64

That's a bit unfortunate, yea. I'm doing it the same way and quickly forgot about it, so I didn't write about it in the docs either.

Another solution would be doing like this:

  <PropertyGroup>
    <_RidCopy>$(RuntimeIdentifier)'</_RidCopy>
  </PropertyGroup>

  <PropertyGroup Label="ElectronNetCommon">
    <ElectronVersion>30.4.0</ElectronVersion>
    <ElectronBuilderVersion>26.0</ElectronBuilderVersion>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>
    <ElectronSingleInstance>true</ElectronSingleInstance>
    <ElectronSplashScreen></ElectronSplashScreen>
    <ElectronIcon></ElectronIcon>
    <PackageIcon></PackageIcon>
    <PackageId>$(MSBuildProjectName.Replace(".", "-").ToLower())</PackageId>
    <ElectronBuilderJson>electron-builder.json</ElectronBuilderJson>
    <Title>$(MSBuildProjectName)</Title>
  </PropertyGroup>

  <PropertyGroup>
    <RuntimeIdentifier Condition="'$(_RidCopy)' != ''">$(_RidCopy)</RuntimeIdentifier>
  </PropertyGroup>

Means to add the two property groups, one before and one after. This should preserve and pre-existing values, so that the project-defined value no longer overrides the value form the pubxml file.

softworkz avatar Dec 10 '25 20:12 softworkz

Hi, I have created a test repository. In the new project, I set up everything using the wiki, but the build continues to build in the Debug folder. In addition, an error occurs when trying to make a build. CONSOLE: Use build tool: /usr/local/share/dotnet/sdk/10.0.101/MSBuild.dll 10:07:23 Building /Users/semennoskov/Projects/Test/Test/Test.csproj Creating package.json from template... OutDir: bin/Debug/net10.0/osx-arm64/ EnsureElectronBuilderJson: /Users/semennoskov/Projects/Test/Test/Properties/ EnsureElectronBuilderJson: /Users/semennoskov/Projects/Test/Test/Properties/electron-builder.json EnsureElectronBuilderJson: False _ElectronFiles: _ElectronFilesToCopy: Test -> /Users/semennoskov/Projects/Test/Test/bin/Debug/net10.0/osx-arm64/Test.dll BeforePublishElectronApp PublishDir: publish/Debug/net10.0/osx-arm64/ BeforePublishElectronApp PublishDir: publish/Debug/net10.0/osx-arm64/bin/ /usr/local/share/dotnet/dotnet "/usr/local/share/dotnet/sdk/10.0.101/Sdks/Microsoft.NET.Sdk.StaticWebAssets/targets/../tools/net10.0/Microsoft.NET.Sdk.StaticWebAssets.Tool.dll" brotli

Test -> /Users/semennoskov/Projects/Test/Test/publish/Debug/net10.0/osx-arm64/bin/ _ElectronFilesToCopyWithTargetPath: CopiedFiles: publish/Debug/net10.0/osx-arm64/bin/.electron/package.json ElectronPublishFilesToMove: publish/Debug/net10.0/osx-arm64/bin/.electron/api/app.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/autoUpdater.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/browserView.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/browserWindows.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/clipboard.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/commandLine.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/dialog.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/dock.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/globalShortcut.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/ipc.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/menu.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/nativeTheme.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/notification.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/powerMonitor.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/process.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/screen.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/shell.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/tray.js;publish/Debug/net10.0/osx-arm64/bin/.electron/api/webContents.js;publish/Debug/net10.0/osx-arm64/bin/.electron/ElectronHostHook/connector.js;publish/Debug/net10.0/osx-arm64/bin/.electron/ElectronHostHook/index.js;publish/Debug/net10.0/osx-arm64/bin/.electron/eslint.config.js;publish/Debug/net10.0/osx-arm64/bin/.electron/main.js;publish/Debug/net10.0/osx-arm64/bin/.electron/package.json;publish/Debug/net10.0/osx-arm64/bin/.electron/scripts/blazor-preload.js;publish/Debug/net10.0/osx-arm64/bin/.electron/splashscreen/index.html 0>ElectronNET.LateImport.targets(430,7): Error MSB4184 : The expression cannot be calculated "[System.IO.Path]::GetFullPath('')". The value cannot be an empty string. (Parameter 'path')

Important points:

  • I am using Rider 2025.3.0.3
  • ElectronVersion: 39.2.6
  • ElectronBuilderVersion: 26.3.5
  • CETCompat is false, because some users on Windows 10 crash Dotnet applications due to not having Windows updates installed.
  • PublishSingleFile is true
  • The resulting error was translated from my system language into English for ease of reading.

My repository: https://github.com/Tartilla-TAIGO/Test

Tartilla-TAIGO avatar Dec 11 '25 04:12 Tartilla-TAIGO