Skip to content

Add DotNet-First packaging layout support and build extensibility - #1106

Open
DYH1319 wants to merge 1 commit into
ElectronNET:developfrom
DYH1319:main
Open

Add DotNet-First packaging layout support and build extensibility#1106
DYH1319 wants to merge 1 commit into
ElectronNET:developfrom
DYH1319:main

Conversation

@DYH1319

@DYH1319 DYH1319 commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR makes the Electron.NET runtime and MSBuild targets support an additional "DotNet-First" packaged app layout and gives packaging builds a few more escape hatches.

Motivation

Today the runtime probes for the packaged layout resources/bin/<app> (Electron-first). When the .NET publish output is the app root and the Electron host is placed under an electron subdirectory (DotNet-First), UnpackagedDetector mis-identifies the app as unpackaged and ElectronProcessActive cannot find the Electron binary.

In addition, ElectronPackageId, Title, the intermediate PublishDir, and the npm/npx exec steps are hard-coded, which makes it harder to plug Electron.NET into custom packaging pipelines or CI.

Changes

  • DotNet-First layout detection in UnpackagedDetector.CheckUnpackaged2:

    • If the base directory contains an electron subdirectory, treat the app as packaged.
    • Existing resources/bin (Electron-first) and .electron (development) checks are preserved.
  • DotNet-First binary startup in ElectronProcessActive.StartCore:

    • When dir/electron exists, start electron from that directory and use it as the working directory.
    • Falls back to the existing dir.Parent.Parent logic for the Electron-first layout.
  • Overridable build properties in ElectronNET.Core.props:

    • ElectronPackageId and Title only default from MSBuildProjectName when the properties are not already set.
  • Configurable publish/exec targets in ElectronNET.LateImport.targets:

    • ElectronPublishDir can override the intermediate PublishDir.
    • ElectronSkipExecCommands (default false) can suppress npm/npx execution steps.
    • All Exec tasks for npm/npx now respect ElectronSkipExecCommands.

Files changed

  • src/ElectronNET.API/Runtime/Helpers/UnpackagedDetector.cs
  • src/ElectronNET.API/Runtime/Services/ElectronProcess/ElectronProcessActive.cs
  • src/ElectronNET/build/ElectronNET.Core.props
  • src/ElectronNET/build/ElectronNET.LateImport.targets

@DYH1319
DYH1319 changed the base branch from main to develop August 24, 2026 09:02
@github-actions

github-actions Bot commented Aug 24, 2026

Copy link
Copy Markdown

pr-comment: Run #137

Tests 📝 Passed ✅ Failed ❌ Skipped ⏭️ Pending ⏳ Other ❓ Flaky 🍂 Duration ⏱️
1568 1406 0 0 0 162 0 2m 37s

🎉 All tests passed!

Github Test Reporter by CTRF 💚

🔄 This comment has been updated

- Detect and launch the Electron host from an electron/ subdirectory
  when using a DotNet-First packaged app layout.
- Make ElectronPackageId and Title overridable from MSBuild properties.
- Allow overriding the intermediate PublishDir via ElectronPublishDir.
- Add ElectronSkipExecCommands to suppress npm/npx build steps.

Co-Authored-By: Mark Deng <1245687900@qq.com>
@DYH1319
DYH1319 marked this pull request as ready for review August 24, 2026 10:50
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.

1 participant