|
4 | 4 | <PropertyGroup> |
5 | 5 | <ElectronMigrationChecksDependsOn> |
6 | 6 | ElectronCheckNoPackageJson; |
| 7 | + ElectronCheckRootPackageJsonNoElectron; |
| 8 | + ElectronCheckRootPackageJsonNotCopied; |
7 | 9 | ElectronCheckNoManifestJson; |
8 | 10 | ElectronCheckElectronBuilderJson; |
9 | 11 | ElectronCheckNoParentPaths; |
|
19 | 21 | </Target> |
20 | 22 |
|
21 | 23 | <!-- |
22 | | - Check 1: No package.json must be present in the project (except ElectronHostHook folder) |
| 24 | + Check 1: No package.json/package-lock.json must be present in the project (except ElectronHostHook folder) |
| 25 | +
|
| 26 | + NOTE: Root package.json is excluded from ELECTRON001 and checked by separate targets. |
23 | 27 | --> |
24 | 28 | <Target Name="ElectronCheckNoPackageJson"> |
25 | 29 |
|
26 | | - <!-- Find all package.json files, excluding ElectronHostHook folder and output directories --> |
| 30 | + <!-- Find all package.json files, excluding ElectronHostHook folder, root, and output directories --> |
27 | 31 | <ItemGroup> |
28 | 32 | <_InvalidPackageJson Include="$(MSBuildProjectDirectory)\**\package.json" |
29 | | - Exclude="$(MSBuildProjectDirectory)\ElectronHostHook\**\package.json; |
| 33 | + Exclude="$(MSBuildProjectDirectory)\package.json; |
| 34 | + $(MSBuildProjectDirectory)\ElectronHostHook\**\package.json; |
30 | 35 | $(MSBuildProjectDirectory)\bin\**\package.json; |
31 | 36 | $(MSBuildProjectDirectory)\obj\**\package.json; |
32 | 37 | $(MSBuildProjectDirectory)\publish\**\package.json; |
|
46 | 51 |
|
47 | 52 | <Warning Condition="'$(_HasInvalidPackageJson)' == 'true'" |
48 | 53 | Code="ELECTRON001" |
49 | | - Text="Found package.json or package-lock.json file(s) in the project root or subdirectories. These files are no longer supported in this location. |
| 54 | + Text="Found package.json or package-lock.json file(s) in unsupported location(s). These files are no longer supported in this location. |
50 | 55 |
|
51 | 56 | Files found: |
52 | 57 | @(_InvalidPackageJson, '%0A')@(_InvalidPackageLockJson, '%0A') |
53 | 58 |
|
54 | 59 | MIGRATION REQUIRED: |
55 | | -All properties from an existing package.json file must now be specified as MSBuild properties in the project file. |
| 60 | +All Electron.NET-related properties from an existing package.json must now be specified as MSBuild properties in the project file. |
56 | 61 |
|
57 | 62 | For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#1-packagejson-not-allowed |
58 | 63 |
|
59 | | -EXCEPTION: package.json and package-lock.json files ARE allowed in the 'ElectronHostHook' folder for custom host hook implementations." /> |
| 64 | +EXCEPTION: |
| 65 | +- package.json and package-lock.json files ARE allowed in the 'ElectronHostHook' folder for custom host hook implementations. |
| 66 | +- A package.json in the project root is handled by separate migration checks." /> |
| 67 | + |
| 68 | + </Target> |
| 69 | + |
| 70 | + <!-- |
| 71 | + Check 1b: Root package.json must not contain Electron-related configuration |
| 72 | + --> |
| 73 | + <Target Name="ElectronCheckRootPackageJsonNoElectron" |
| 74 | + Condition="Exists('$(MSBuildProjectDirectory)\package.json')"> |
| 75 | + |
| 76 | + <ItemGroup> |
| 77 | + <_RootPackageJsonLines Include="$([System.IO.File]::ReadAllLines('$(MSBuildProjectDirectory)\package.json'))" /> |
| 78 | + </ItemGroup> |
| 79 | + |
| 80 | + <PropertyGroup> |
| 81 | + <_RootPackageJsonContent>@(_RootPackageJsonLines, ' ')</_RootPackageJsonContent> |
| 82 | + <_RootPackageJsonHasElectron>false</_RootPackageJsonHasElectron> |
| 83 | + <_RootPackageJsonHasElectron Condition="$([System.Text.RegularExpressions.Regex]::IsMatch('$(_RootPackageJsonContent)', 'electron', System.Text.RegularExpressions.RegexOptions.IgnoreCase))">true</_RootPackageJsonHasElectron> |
| 84 | + </PropertyGroup> |
| 85 | + |
| 86 | + <Warning |
| 87 | + Condition="'$(_RootPackageJsonHasElectron)' == 'true'" |
| 88 | + Code="ELECTRON008" |
| 89 | + Text="The project contains a root package.json that references 'electron' (case-insensitive). |
| 90 | +
|
| 91 | +File: |
| 92 | +$(MSBuildProjectDirectory)\package.json |
| 93 | +
|
| 94 | +MIGRATION REQUIRED: |
| 95 | +Electron.NET configuration must be defined via MSBuild properties and electron-builder.json (not via a user-provided package.json). |
| 96 | +
|
| 97 | +HOW TO FIX: |
| 98 | +- Remove Electron-related entries from the root package.json, or delete the file if it's only used for Electron configuration. |
| 99 | +
|
| 100 | +For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#1-packagejson-not-allowed" /> |
| 101 | + |
| 102 | + </Target> |
| 103 | + |
| 104 | + <!-- |
| 105 | + Check 1c: Root package.json must not be copied to output/publish |
| 106 | + --> |
| 107 | + <Target Name="ElectronCheckRootPackageJsonNotCopied" |
| 108 | + Condition="Exists('$(MSBuildProjectDirectory)\package.json')"> |
| 109 | + |
| 110 | + <ItemGroup> |
| 111 | + <_RootPackageJsonFile Include="@(Content);@(None)" |
| 112 | + Condition="'%(Identity)' == 'package.json' OR '%(Identity)' == '$(MSBuildProjectDirectory)\package.json'" /> |
| 113 | + </ItemGroup> |
| 114 | + |
| 115 | + <PropertyGroup> |
| 116 | + <_RootPackageJsonIsCopied>false</_RootPackageJsonIsCopied> |
| 117 | + <_RootPackageJsonIsCopied Condition="'@(_RootPackageJsonFile)' != '' AND ( '%(_RootPackageJsonFile.CopyToOutputDirectory)' != '' OR '%(_RootPackageJsonFile.CopyToPublishDirectory)' != '' )">true</_RootPackageJsonIsCopied> |
| 118 | + </PropertyGroup> |
| 119 | + |
| 120 | + <Warning |
| 121 | + Condition="'$(_RootPackageJsonIsCopied)' == 'true'" |
| 122 | + Code="ELECTRON009" |
| 123 | + Text="The project contains a root package.json that is configured to be copied to the output/publish directory. |
| 124 | +
|
| 125 | +File: |
| 126 | +$(MSBuildProjectDirectory)\package.json |
| 127 | +
|
| 128 | +MIGRATION REQUIRED: |
| 129 | +Root package.json must not be copied during build/publish. |
| 130 | +
|
| 131 | +HOW TO FIX: |
| 132 | +- Remove CopyToOutputDirectory / CopyToPublishDirectory metadata for package.json in your project file. |
| 133 | +
|
| 134 | +For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#1-packagejson-not-allowed" /> |
60 | 135 |
|
61 | 136 | </Target> |
62 | 137 |
|
|
0 commit comments