mirror of
https://github.com/ElectronNET/Electron.NET.git
synced 2026-02-04 05:34:51 +00:00
Merge pull request #966 from softworkz/submit_migrationchecks
Add migration checks
This commit is contained in:
235
docs/Core/Migration-Checks.md
Normal file
235
docs/Core/Migration-Checks.md
Normal file
@@ -0,0 +1,235 @@
|
||||
# Migration Checks
|
||||
|
||||
Electron.NET includes automatic build-time validation checks that help users migrating from previous versions avoid common configuration issues. These checks run automatically during the build process and provide helpful guidance when problems are detected.
|
||||
|
||||
## Overview
|
||||
|
||||
When you build an Electron.NET project, the following validation checks are performed:
|
||||
|
||||
| Code | Check | Description |
|
||||
|------|-------|-------------|
|
||||
| [ELECTRON001](#1-packagejson-not-allowed) | package.json not allowed | Ensures no package.json exists outside ElectronHostHook |
|
||||
| [ELECTRON002](#2-electron-manifestjson-not-allowed) | electron-manifest.json not allowed | Detects deprecated manifest files |
|
||||
| [ELECTRON003](#3-electron-builderjson-location) | electron-builder.json location | Verifies electron-builder.json exists in Properties folder |
|
||||
| [ELECTRON004](#3-electron-builderjson-location) | electron-builder.json wrong location | Warns if electron-builder.json is found in incorrect locations |
|
||||
| [ELECTRON005](#4-parent-paths-not-allowed-in-electron-builderjson) | Parent paths not allowed | Checks for `..` references in config |
|
||||
| [ELECTRON006](#5-publish-profile-validation) | ASP.NET publish profile mismatch | Warns when ASP.NET projects have console-style profiles |
|
||||
| [ELECTRON007](#5-publish-profile-validation) | Console publish profile mismatch | Warns when console projects have ASP.NET-style profiles |
|
||||
|
||||
---
|
||||
|
||||
## 1. package.json not allowed
|
||||
|
||||
**Warning Code:** `ELECTRON001`
|
||||
|
||||
### What is checked
|
||||
|
||||
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).
|
||||
|
||||
### Why this matters
|
||||
|
||||
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.
|
||||
|
||||
### Exception
|
||||
|
||||
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.
|
||||
|
||||
### How to fix
|
||||
|
||||
1. **Open your project's `.csproj` file**
|
||||
2. **Add the required properties** to a PropertyGroup with the label `ElectronNetCommon`:
|
||||
|
||||
```xml
|
||||
<PropertyGroup Label="ElectronNetCommon">
|
||||
<PackageId>my-electron-app</PackageId>
|
||||
<Title>My Electron App</Title>
|
||||
<Version>1.0.0</Version>
|
||||
<Description>My awesome Electron.NET application</Description>
|
||||
<Company>My Company</Company>
|
||||
<Copyright>Copyright © 2025</Copyright>
|
||||
<ElectronVersion>30.0.9</ElectronVersion>
|
||||
</PropertyGroup>
|
||||
```
|
||||
|
||||
3. **Delete the old `package.json`** file from your project root
|
||||
|
||||
> **See also:** [Migration Guide](Migration-Guide.md) for complete migration instructions.
|
||||
|
||||
---
|
||||
|
||||
## 2. electron-manifest.json not allowed
|
||||
|
||||
**Warning Code:** `ELECTRON002`
|
||||
|
||||
### What is checked
|
||||
|
||||
The build system checks for the presence of `electron.manifest.json` or `electron-manifest.json` files in your project.
|
||||
|
||||
### Why this matters
|
||||
|
||||
The `electron.manifest.json` file format is deprecated. All configuration should now be specified using:
|
||||
- MSBuild properties in your `.csproj` file (for application metadata)
|
||||
- The `electron-builder.json` file in the `Properties` folder (for build configuration)
|
||||
|
||||
### How to fix
|
||||
|
||||
1. **Migrate application properties** to your `.csproj` file (see [Migration Guide](Migration-Guide.md))
|
||||
2. **Move the `build` section** from `electron.manifest.json` to `Properties/electron-builder.json`
|
||||
3. **Delete the old `electron.manifest.json`** file
|
||||
|
||||
**Example electron-builder.json:**
|
||||
```json
|
||||
{
|
||||
"compression": "maximum",
|
||||
"win": {
|
||||
"icon": "Assets/app.ico",
|
||||
"target": ["nsis", "portable"]
|
||||
},
|
||||
"linux": {
|
||||
"icon": "Assets/app.png",
|
||||
"target": ["AppImage", "deb"]
|
||||
},
|
||||
"mac": {
|
||||
"icon": "Assets/app.icns",
|
||||
"target": ["dmg", "zip"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 3. electron-builder.json Location
|
||||
|
||||
**Warning Codes:** `ELECTRON003`, `ELECTRON004`
|
||||
|
||||
### What is checked
|
||||
|
||||
- `ELECTRON003`: Verifies that an `electron-builder.json` file exists in the `Properties` folder
|
||||
- `ELECTRON004`: Warns if `electron-builder.json` is found in incorrect locations
|
||||
|
||||
### Why this matters
|
||||
|
||||
The `electron-builder.json` file must be located in the `Properties` folder so it can be properly copied to the output directory during publishing.
|
||||
|
||||
### How to fix
|
||||
|
||||
1. **Create the Properties folder** if it doesn't exist
|
||||
2. **Move or create** `electron-builder.json` in `Properties/electron-builder.json`
|
||||
3. **Remove** any `electron-builder.json` files from other locations
|
||||
|
||||
**Expected structure:**
|
||||
```
|
||||
MyProject/
|
||||
├── Properties/
|
||||
│ ├── electron-builder.json ✅ Correct location
|
||||
│ ├── launchSettings.json
|
||||
│ └── PublishProfiles/
|
||||
├── MyProject.csproj
|
||||
└── Program.cs
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 4. Parent paths not allowed in electron-builder.json
|
||||
|
||||
**Warning Code:** `ELECTRON005`
|
||||
|
||||
### What is checked
|
||||
|
||||
The build system scans the `electron-builder.json` file for parent-path references (`..`).
|
||||
|
||||
### Why this matters
|
||||
|
||||
During the publish process, the `electron-builder.json` file is copied to the build output directory. Any relative paths in this file are resolved from that location, not from your project directory. Parent-path references (`../`) will not work correctly because they would point outside the published application.
|
||||
|
||||
### How to fix
|
||||
|
||||
1. **Move resource files** (icons, installers, etc.) inside your project folder structure
|
||||
2. **Configure the files** to be copied to the output directory in your `.csproj`:
|
||||
|
||||
```xml
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\**\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
```
|
||||
|
||||
3. **Update paths** in `electron-builder.json` to use relative paths without `..`:
|
||||
|
||||
**Before (incorrect):**
|
||||
```json
|
||||
{
|
||||
"win": {
|
||||
"icon": "../SharedAssets/app.ico"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**After (correct):**
|
||||
```json
|
||||
{
|
||||
"win": {
|
||||
"icon": "Assets/app.ico"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 5. Publish Profile Validation
|
||||
|
||||
**Warning Codes:** `ELECTRON006`, `ELECTRON007`
|
||||
|
||||
### What is checked
|
||||
|
||||
The build system examines `.pubxml` files in the `Properties/PublishProfiles` folder and validates that they match the project type:
|
||||
|
||||
- **ELECTRON006**: For **ASP.NET projects** (using `Microsoft.NET.Sdk.Web`), checks that publish profiles include `WebPublishMethod`. This property is required for proper ASP.NET publishing.
|
||||
|
||||
- **ELECTRON007**: For **console/other projects** (not using the Web SDK), checks that publish profiles do NOT include the `WebPublishMethod` property. These ASP.NET-specific properties are incorrect for non-web applications.
|
||||
|
||||
### Why this matters
|
||||
|
||||
Electron.NET supports both ASP.NET and console application project types, each requiring different publish profile configurations:
|
||||
|
||||
| Project Type | SDK | Expected Properties |
|
||||
|--------------|-----|---------------------|
|
||||
| ASP.NET (Razor Pages, MVC, Blazor) | `Microsoft.NET.Sdk.Web` | `WebPublishMethod`, no `PublishProtocol` |
|
||||
| Console Application | `Microsoft.NET.Sdk` | `PublishProtocol`, no `WebPublishMethod` |
|
||||
|
||||
Using the wrong publish profile type can lead to incomplete or broken builds.
|
||||
|
||||
### How to fix
|
||||
|
||||
1. **Delete existing publish profiles** from `Properties/PublishProfiles/`
|
||||
2. **Create new publish profiles** using the Visual Studio Publishing Wizard:
|
||||
- Right-click on the project in Solution Explorer
|
||||
- Select **Publish...**
|
||||
- Follow the wizard to create a **Folder** publish profile
|
||||
|
||||
For correct publish profile examples for both ASP.NET and Console applications, see **[Package Building](../Using/Package-Building.md#step-1-create-publish-profiles)**.
|
||||
|
||||
---
|
||||
|
||||
## Disabling Migration Checks
|
||||
|
||||
If you need to disable specific migration checks (not recommended), you can set the following properties in your `.csproj` file:
|
||||
|
||||
```xml
|
||||
<PropertyGroup>
|
||||
<!-- Disable all migration checks -->
|
||||
<ElectronSkipMigrationChecks>true</ElectronSkipMigrationChecks>
|
||||
</PropertyGroup>
|
||||
```
|
||||
|
||||
> ⚠️ **Warning:** Disabling migration checks may result in build or runtime errors. Only disable checks if you fully understand the implications.
|
||||
|
||||
---
|
||||
|
||||
## See Also
|
||||
|
||||
- [Migration Guide](Migration-Guide.md) - Complete step-by-step migration instructions
|
||||
- [Advanced Migration Topics](Advanced-Migration-Topics.md) - Complex migration scenarios
|
||||
- [Configuration](../Using/Configuration.md) - Project configuration options
|
||||
- [Package Building](../Using/Package-Building.md) - Building distributable packages
|
||||
@@ -26,12 +26,15 @@ Add publish profiles to `Properties/PublishProfiles/`:
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>48eff821-2f4d-60cc-aa44-be0f1d6e5f35</ProjectGuid>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
```
|
||||
@@ -46,12 +49,15 @@ Add publish profiles to `Properties/PublishProfiles/`:
|
||||
<PropertyGroup>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<PublishDir>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishDir>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<DeleteExistingFiles>true</DeleteExistingFiles>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>publish\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>48eff821-2f4d-60cc-aa44-be0f1d6e5f35</ProjectGuid>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>false</PublishSingleFile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
```
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
|
||||
- [What's new?](Core/What's-New.md)
|
||||
- [Migration Guide](Core/Migration-Guide.md)
|
||||
- [Migration Checks](Core/Migration-Checks.md)
|
||||
- [Advanced Migration](Core/Advanced-Migration-Topics.md)
|
||||
|
||||
# Getting Started
|
||||
|
||||
@@ -23,4 +23,7 @@
|
||||
<AssemblyMetadata Include="IsAspNet" Value="$(_IsMsAspNetProject)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Import migration validation checks -->
|
||||
<Import Project="$(MSBuildThisFileDirectory)ElectronNET.MigrationChecks.targets" />
|
||||
|
||||
</Project>
|
||||
280
src/ElectronNET/build/ElectronNET.MigrationChecks.targets
Normal file
280
src/ElectronNET/build/ElectronNET.MigrationChecks.targets
Normal file
@@ -0,0 +1,280 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
|
||||
<PropertyGroup>
|
||||
<ElectronMigrationChecksDependsOn>
|
||||
ElectronCheckNoPackageJson;
|
||||
ElectronCheckNoManifestJson;
|
||||
ElectronCheckElectronBuilderJson;
|
||||
ElectronCheckNoParentPaths;
|
||||
ElectronCheckPubxmlFiles
|
||||
</ElectronMigrationChecksDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Main migration checks target that runs before build -->
|
||||
<Target Name="ElectronMigrationChecks"
|
||||
BeforeTargets="BeforeBuild"
|
||||
DependsOnTargets="$(ElectronMigrationChecksDependsOn)"
|
||||
Condition="'$(ElectronSkipMigrationChecks)' != 'true'">
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Check 1: No package.json must be present in the project (except ElectronHostHook folder)
|
||||
-->
|
||||
<Target Name="ElectronCheckNoPackageJson">
|
||||
|
||||
<!-- Find all package.json files, excluding ElectronHostHook folder and output directories -->
|
||||
<ItemGroup>
|
||||
<_InvalidPackageJson Include="$(MSBuildProjectDirectory)\**\package.json"
|
||||
Exclude="$(MSBuildProjectDirectory)\ElectronHostHook\**\package.json;
|
||||
$(MSBuildProjectDirectory)\bin\**\package.json;
|
||||
$(MSBuildProjectDirectory)\obj\**\package.json;
|
||||
$(MSBuildProjectDirectory)\publish\**\package.json;
|
||||
$(MSBuildProjectDirectory)\node_modules\**\package.json" />
|
||||
<_InvalidPackageLockJson Include="$(MSBuildProjectDirectory)\**\package-lock.json"
|
||||
Exclude="$(MSBuildProjectDirectory)\ElectronHostHook\**\package-lock.json;
|
||||
$(MSBuildProjectDirectory)\bin\**\package-lock.json;
|
||||
$(MSBuildProjectDirectory)\obj\**\package-lock.json;
|
||||
$(MSBuildProjectDirectory)\publish\**\package-lock.json;
|
||||
$(MSBuildProjectDirectory)\node_modules\**\package-lock.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<_HasInvalidPackageJson>false</_HasInvalidPackageJson>
|
||||
<_HasInvalidPackageJson Condition="@(_InvalidPackageJson->Count()) > 0 OR @(_InvalidPackageLockJson->Count()) > 0">true</_HasInvalidPackageJson>
|
||||
</PropertyGroup>
|
||||
|
||||
<Warning Condition="'$(_HasInvalidPackageJson)' == 'true'"
|
||||
Code="ELECTRON001"
|
||||
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.
|
||||
|
||||
Files found:
|
||||
@(_InvalidPackageJson, '%0A')@(_InvalidPackageLockJson, '%0A')
|
||||
|
||||
MIGRATION REQUIRED:
|
||||
All properties from an existing package.json file must now be specified as MSBuild properties in the project file.
|
||||
|
||||
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#1-packagejson-not-allowed
|
||||
|
||||
EXCEPTION: package.json and package-lock.json files ARE allowed in the 'ElectronHostHook' folder for custom host hook implementations." />
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Check 2: No electron-manifest.json must be present in the project
|
||||
-->
|
||||
<Target Name="ElectronCheckNoManifestJson">
|
||||
|
||||
<ItemGroup>
|
||||
<_InvalidManifestJson Include="$(MSBuildProjectDirectory)\**\electron.manifest.json;$(MSBuildProjectDirectory)\**\electron-manifest.json"
|
||||
Exclude="$(MSBuildProjectDirectory)\bin\**\*;
|
||||
$(MSBuildProjectDirectory)\obj\**\*;
|
||||
$(MSBuildProjectDirectory)\publish\**\*;
|
||||
$(MSBuildProjectDirectory)\node_modules\**\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<_HasInvalidManifestJson>false</_HasInvalidManifestJson>
|
||||
<_HasInvalidManifestJson Condition="@(_InvalidManifestJson->Count()) > 0">true</_HasInvalidManifestJson>
|
||||
</PropertyGroup>
|
||||
|
||||
<Warning Condition="'$(_HasInvalidManifestJson)' == 'true'"
|
||||
Code="ELECTRON002"
|
||||
Text="Found electron-manifest.json file(s) in the project. This file format is no longer supported.
|
||||
|
||||
Files found:
|
||||
@(_InvalidManifestJson, '%0A')
|
||||
|
||||
MIGRATION REQUIRED:
|
||||
1. All properties from an existing electron-manifest.json file must now be specified as MSBuild properties in the project file.
|
||||
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#2-electron-manifestjson-not-allowed
|
||||
|
||||
2. The subtree from the 'build' property must be moved to the electron-builder.json file inside the './Properties' folder.
|
||||
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#3-electron-builderjson-location" />
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Check 3: Single electron-builder.json must exist in ./Properties folder
|
||||
-->
|
||||
<Target Name="ElectronCheckElectronBuilderJson">
|
||||
|
||||
<!-- Check for electron-builder.json in the Properties folder -->
|
||||
<ItemGroup>
|
||||
<_ElectronBuilderJsonInProperties Include="$(MSBuildProjectDirectory)\Properties\electron-builder.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<_HasElectronBuilderJsonInProperties>false</_HasElectronBuilderJsonInProperties>
|
||||
<_HasElectronBuilderJsonInProperties Condition="Exists('$(MSBuildProjectDirectory)\Properties\electron-builder.json')">true</_HasElectronBuilderJsonInProperties>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Check for electron-builder.json in wrong locations -->
|
||||
<ItemGroup>
|
||||
<_ElectronBuilderJsonWrongLocation Include="$(MSBuildProjectDirectory)\**\electron-builder.json"
|
||||
Exclude="$(MSBuildProjectDirectory)\Properties\electron-builder.json;
|
||||
$(MSBuildProjectDirectory)\bin\**\*;
|
||||
$(MSBuildProjectDirectory)\obj\**\*;
|
||||
$(MSBuildProjectDirectory)\publish\**\*;
|
||||
$(MSBuildProjectDirectory)\node_modules\**\*" />
|
||||
</ItemGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<_HasElectronBuilderJsonWrongLocation>false</_HasElectronBuilderJsonWrongLocation>
|
||||
<_HasElectronBuilderJsonWrongLocation Condition="@(_ElectronBuilderJsonWrongLocation->Count()) > 0">true</_HasElectronBuilderJsonWrongLocation>
|
||||
</PropertyGroup>
|
||||
|
||||
<Warning Condition="'$(_HasElectronBuilderJsonInProperties)' != 'true'"
|
||||
Code="ELECTRON003"
|
||||
Text="The project must contain an electron-builder.json file inside the './Properties' folder.
|
||||
|
||||
Expected location: $(MSBuildProjectDirectory)\Properties\electron-builder.json
|
||||
|
||||
REQUIRED ACTION:
|
||||
Create an electron-builder.json file in the Properties folder with your electron-builder configuration.
|
||||
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#3-electron-builderjson-location" />
|
||||
|
||||
<Warning Condition="'$(_HasElectronBuilderJsonWrongLocation)' == 'true'"
|
||||
Code="ELECTRON004"
|
||||
Text="Found electron-builder.json file(s) in incorrect location(s). The file must be located only in the './Properties' folder.
|
||||
|
||||
Files found in wrong locations:
|
||||
@(_ElectronBuilderJsonWrongLocation, '%0A')
|
||||
|
||||
REQUIRED ACTION:
|
||||
Move the electron-builder.json file to: $(MSBuildProjectDirectory)\Properties\electron-builder.json" />
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Check 4: No parent-path references (..) in electron-builder.json
|
||||
-->
|
||||
<Target Name="ElectronCheckNoParentPaths"
|
||||
Condition="Exists('$(MSBuildProjectDirectory)\Properties\electron-builder.json')">
|
||||
|
||||
<PropertyGroup>
|
||||
<_ElectronBuilderJsonPath>$(MSBuildProjectDirectory)\Properties\electron-builder.json</_ElectronBuilderJsonPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Read the file content -->
|
||||
<ReadLinesFromFile File="$(_ElectronBuilderJsonPath)">
|
||||
<Output TaskParameter="Lines" ItemName="_ElectronBuilderJsonLines" />
|
||||
</ReadLinesFromFile>
|
||||
|
||||
<!-- Check if any line contains parent path references -->
|
||||
<PropertyGroup>
|
||||
<_ElectronBuilderJsonContent>@(_ElectronBuilderJsonLines, ' ')</_ElectronBuilderJsonContent>
|
||||
<_HasParentPathReference>false</_HasParentPathReference>
|
||||
<_HasParentPathReference Condition="$(_ElectronBuilderJsonContent.Contains('../')) OR $(_ElectronBuilderJsonContent.Contains('..\\'))" >true</_HasParentPathReference>
|
||||
</PropertyGroup>
|
||||
|
||||
<Warning Condition="'$(_HasParentPathReference)' == 'true'"
|
||||
Code="ELECTRON005"
|
||||
Text="The electron-builder.json file contains parent-path references ('..').
|
||||
|
||||
File: $(_ElectronBuilderJsonPath)
|
||||
|
||||
MIGRATION REQUIRED:
|
||||
Parent-path references are not allowed in electron-builder.json because the file is copied to the build output directory during publishing.
|
||||
|
||||
HOW TO FIX:
|
||||
1. Place any resource files (icons, installers, etc.) inside your project folder structure
|
||||
2. Configure those files to be copied to the output directory using the project file:
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\**\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
3. Reference files using relative paths from the output directory (e.g., 'Assets/myicon.ico' instead of '../Assets/myicon.ico')
|
||||
|
||||
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#4-parent-paths-not-allowed-in-electron-builderjson" />
|
||||
|
||||
</Target>
|
||||
|
||||
<!--
|
||||
Check 5: Pubxml files match the project type
|
||||
|
||||
This check validates that publish profiles are appropriate for the project type:
|
||||
- ASP.NET projects (using Microsoft.NET.Sdk.Web) have WebPublishMethod in their pubxml files
|
||||
- Console/other projects PublishProtocol instead of WebPublishMethod
|
||||
-->
|
||||
<Target Name="ElectronCheckPubxmlFiles">
|
||||
|
||||
<!-- Find all pubxml files -->
|
||||
<ItemGroup>
|
||||
<_PubxmlFiles Include="$(MSBuildProjectDirectory)\Properties\PublishProfiles\*.pubxml" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Determine if this is an ASP.NET project (UsingMicrosoftNETSdkWeb is set by the Web SDK) -->
|
||||
<PropertyGroup>
|
||||
<_IsAspNetProject>false</_IsAspNetProject>
|
||||
<_IsAspNetProject Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true'">true</_IsAspNetProject>
|
||||
<_HasPubxmlFiles>false</_HasPubxmlFiles>
|
||||
<_HasPubxmlFiles Condition="@(_PubxmlFiles->Count()) > 0">true</_HasPubxmlFiles>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Build a combined content string for each file and check (only if files exist) -->
|
||||
<ItemGroup Condition="'$(_HasPubxmlFiles)' == 'true'">
|
||||
<_PubxmlFileInfo Include="@(_PubxmlFiles)" Condition="'%(Identity)' != ''">
|
||||
<FileContent>$([System.IO.File]::ReadAllText('%(Identity)'))</FileContent>
|
||||
</_PubxmlFileInfo>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Check each file for WebPublishMethod presence -->
|
||||
<ItemGroup Condition="'$(_HasPubxmlFiles)' == 'true'">
|
||||
<_PubxmlFileInfoWithFlags Include="@(_PubxmlFileInfo)" Condition="'%(Identity)' != ''">
|
||||
<HasWebPublishMethod>$([System.Text.RegularExpressions.Regex]::IsMatch('%(FileContent)', '<WebPublishMethod>'))</HasWebPublishMethod>
|
||||
</_PubxmlFileInfoWithFlags>
|
||||
</ItemGroup>
|
||||
|
||||
<!-- For ASP.NET projects: find pubxml files MISSING WebPublishMethod -->
|
||||
<ItemGroup>
|
||||
<_AspNetMissingWebPublishMethod Include="@(_PubxmlFileInfoWithFlags)"
|
||||
Condition="'$(_IsAspNetProject)' == 'true' AND '%(HasWebPublishMethod)' == 'False'" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- For Console/Non-ASP.NET projects: find pubxml files that HAVE WebPublishMethod -->
|
||||
<ItemGroup>
|
||||
<_ConsolePubxmlWithAspNetProperties Include="@(_PubxmlFileInfoWithFlags)"
|
||||
Condition="'$(_IsAspNetProject)' != 'true' AND '%(HasWebPublishMethod)' == 'True'" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Warning for ASP.NET projects with incorrect pubxml files -->
|
||||
<Warning
|
||||
Condition="'@(_AspNetMissingWebPublishMethod)' != ''"
|
||||
Code="ELECTRON006"
|
||||
Text="The publish profile '%(_AspNetMissingWebPublishMethod.Identity)' appears to be configured for a console application (missing WebPublishMethod property), but this is an ASP.NET project.
|
||||
|
||||
RECOMMENDED ACTION:
|
||||
1. Delete the existing publish profiles
|
||||
2. Use the Visual Studio Publishing Wizard to create a new profile:
|
||||
- Right-click on the project in Solution Explorer
|
||||
- Select 'Publish...'
|
||||
- Follow the wizard to create a Folder publish profile for ASP.NET
|
||||
|
||||
Note: ASP.NET Electron.NET projects require publish profiles with WebPublishMethod set to FileSystem.
|
||||
|
||||
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#5-publish-profile-validation" />
|
||||
|
||||
<!-- Warning for Console projects with incorrect pubxml files -->
|
||||
<Warning
|
||||
Condition="'@(_ConsolePubxmlWithAspNetProperties)' != ''"
|
||||
Code="ELECTRON007"
|
||||
Text="The publish profile '%(_ConsolePubxmlWithAspNetProperties.Identity)' appears to be configured for ASP.NET publishing (containing the WebPublishMethod property), but this is a console application project.
|
||||
|
||||
RECOMMENDED ACTION:
|
||||
1. Delete the existing publish profiles
|
||||
2. Use the Visual Studio Publishing Wizard to create a new profile:
|
||||
- Right-click on the project in Solution Explorer
|
||||
- Select 'Publish...'
|
||||
- Follow the wizard to create a Folder publish profile for console applications
|
||||
|
||||
Note: Console Electron.NET projects should not use ASP.NET-style publish profiles.
|
||||
|
||||
For more information, see: https://github.com/ElectronNET/Electron.NET/wiki/Migration-Checks#5-publish-profile-validation" />
|
||||
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user