You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[ELECTRON008](#1-packagejson-rules)| root package.json contains electron | Warns when root `package.json` contains the word `electron` (case-insensitive) |
13
+
|[ELECTRON009](#1-packagejson-rules)| root package.json copied to output | Warns when root `package.json` is configured to be copied to output/publish |
12
14
|[ELECTRON002](#2-electron-manifestjson-not-allowed)| electron-manifest.json not allowed | Detects deprecated manifest files |
|[ELECTRON004](#3-electron-builderjson-location)| electron-builder.json wrong location | Warns if electron-builder.json is found in incorrect locations |
@@ -18,24 +20,38 @@ When you build an Electron.NET project, the following validation checks are perf
The build system scans for `package.json` and `package-lock.json` files in your project directory. These files should not exist in the project root or subdirectories (with one exception).
29
+
The build system scans for `package.json` and `package-lock.json` files in your project directory.
30
+
31
+
Rules:
32
+
33
+
-**ELECTRON001**: `package.json` / `package-lock.json` must not exist in the project directory or subdirectories
34
+
- Exception: `ElectronHostHook` folder is allowed
35
+
- Note: a **root**`package.json` is **excluded** from `ELECTRON001` and validated by `ELECTRON008` / `ELECTRON009`
36
+
37
+
-**ELECTRON008**: If a root `package.json` exists, it must **not** contain electron-related dependencies or configuration.
38
+
39
+
-**ELECTRON009**: If a root `package.json` exists, it must **not** be configured to be copied to output/publish (for example via `CopyToOutputDirectory` / `CopyToPublishDirectory` metadata)
28
40
29
41
### Why this matters
30
42
31
-
In previous versions of Electron.NET, a `package.json` file was required in the project. The new version generates this file automatically from MSBuild properties defined in your `.csproj` file.
43
+
Electron.NET generates its Electron-related `package.json` during publishing based on MSBuild properties. A user-maintained Electron-related `package.json` can conflict with that process.
44
+
45
+
Also, ensuring the root `package.json` is not copied prevents accidentally shipping it with the published app.
32
46
33
47
### Exception
34
48
35
-
A `package.json` file **is allowed** in the `ElectronHostHook` folder if you're using custom host hooks. This is the only valid location for a manually maintained package.json.
49
+
A `package.json`/ `package-lock.json`file **is allowed** in the `ElectronHostHook` folder if you're using custom host hooks.
36
50
37
51
### How to fix
38
52
53
+
If you have an Electron-related `package.json` from older Electron.NET versions:
54
+
39
55
1.**Open your project's `.csproj` file**
40
56
2.**Add the required properties** to a PropertyGroup with the label `ElectronNetCommon`:
41
57
@@ -51,7 +67,12 @@ A `package.json` file **is allowed** in the `ElectronHostHook` folder if you're
51
67
</PropertyGroup>
52
68
```
53
69
54
-
3.**Delete the old `package.json`** file from your project root
70
+
3.**Delete** Electron-related `package.json` / `package-lock.json` files (except those under `ElectronHostHook` if applicable)
71
+
72
+
If you keep a root `package.json` for non-Electron reasons:
73
+
74
+
- Ensure it does **not** contain electron dependencies or configuration (fixes `ELECTRON008`)
75
+
- Ensure it is **not** copied to output/publish (fixes `ELECTRON009`)
55
76
56
77
> **See also:**[Migration Guide](Migration-Guide.md) for complete migration instructions.
Copy file name to clipboardExpand all lines: docs/Using/Configuration.md
+20Lines changed: 20 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,6 +85,26 @@ BrowserWindowOptions browserWindowOptions = new BrowserWindowOptions
85
85
```
86
86
87
87
88
+
### Preload Script
89
+
90
+
If you require the use of a [preload script](https://www.electronjs.org/docs/latest/tutorial/tutorial-preload), you can specify the file path of the script when creating a new window like so:
> When using a preload script _AND_ running a Blazor app, `IsRunningBlazor` must be set to `false` (or removed) and the following lines must be added to the preload script:
0 commit comments