diff --git a/src/ElectronNET/ElectronNET.csproj b/src/ElectronNET/ElectronNET.csproj new file mode 100644 index 0000000..c0a909e --- /dev/null +++ b/src/ElectronNET/ElectronNET.csproj @@ -0,0 +1,47 @@ + + + + + + net6.0;net8.0 + ..\..\artifacts + $(PackageNamePrefix) + $(PackageId) + $(DescriptionFirstPart) This package contains the ElectronNET project system. + false + false + + + + + + + + + + .electron\%(RecursiveDir)%(FileName)%(Extension) + Never + true + .electron\ + + + + + true + build\ + + + + + True + + + + + MSBuild:Compile + + + MSBuild:Compile + + + \ No newline at end of file diff --git a/src/ElectronNET.CLI/PackageIcon.png b/src/ElectronNET/PackageIcon.png similarity index 100% rename from src/ElectronNET.CLI/PackageIcon.png rename to src/ElectronNET/PackageIcon.png diff --git a/src/ElectronNET/build/ElectronNET.Build.dll b/src/ElectronNET/build/ElectronNET.Build.dll new file mode 100644 index 0000000..b3794d9 Binary files /dev/null and b/src/ElectronNET/build/ElectronNET.Build.dll differ diff --git a/src/ElectronNET/build/ElectronNET.Core.props b/src/ElectronNET/build/ElectronNET.Core.props new file mode 100644 index 0000000..c9e1eed --- /dev/null +++ b/src/ElectronNET/build/ElectronNET.Core.props @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/ElectronNET/build/ElectronNET.Core.targets b/src/ElectronNET/build/ElectronNET.Core.targets new file mode 100644 index 0000000..4bee510 --- /dev/null +++ b/src/ElectronNET/build/ElectronNET.Core.targets @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/ElectronNET/build/ElectronNET.DesignTime.targets b/src/ElectronNET/build/ElectronNET.DesignTime.targets new file mode 100644 index 0000000..6f6adba --- /dev/null +++ b/src/ElectronNET/build/ElectronNET.DesignTime.targets @@ -0,0 +1,129 @@ + + + + + True + + + + + + Project + + + + + + Project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(ElectronSplashScreen.Replace('$(MSBuildProjectDirectory)', '').TrimStart('\')) + + + + + + + + + + + + + + $(ElectronIcon.Replace('$(MSBuildProjectDirectory)', '').TrimStart('\')) + + + + + + + + + + + + + <_ProjectDir>$([System.IO.Path]::GetFullPath('$(MSBuildProjectDirectory)'))\ + + $([System.String]::Substring($(ElectronSplashScreen), + $([System.String]::Length($(_ProjectDir))))) + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ElectronNET/build/ElectronNET.LateImport.targets b/src/ElectronNET/build/ElectronNET.LateImport.targets new file mode 100644 index 0000000..892f764 --- /dev/null +++ b/src/ElectronNET/build/ElectronNET.LateImport.targets @@ -0,0 +1,480 @@ + + + + + + + + + + + + + + + + Never + Never + + + Never + Never + + + Never + Never + + + + + + + + + + + + + + + + + $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\..\xxxxElectronNET.Host')) + $([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)\..\.electron')) + .electron + $([System.IO.Path]::GetFileName($(ElectronSplashScreen))) + $([System.IO.Path]::GetFileName($(ElectronIcon))) + + + + + + + + + + + + + + + + + + + + + + + $(OutDir)$(ElectronDirName)\ + $(TargetDir)$(ElectronDirName)\ + $(IntermediateOutputPath)$(ElectronDirName)\ + $(ElectronIntermediateOutputPath)package.json + + + + + + + + <_ProjectPropertiesFolder>$(MSBuildProjectDirectory)\Properties\ + <_ElectronBuilderExpectedPath>$(_ProjectPropertiesFolder)$(ElectronBuilderJson) + <_NeedCopyElectronBuilderFile>True + <_NeedCopyElectronBuilderFile Condition="Exists($(_ElectronBuilderExpectedPath))">False + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + $(TargetName) + + + + + $([System.Text.RegularExpressions.Regex]::Replace('$(Version)', '^(\d+\.\d+\.\d+)(?:\.\d+)?(.*)$', '$1$2')) + + linux + $(Title) + $(Title.Replace(' ', '-')) + + + + + + + + + + + + + + + + + + + + + + + + + + + <_NonIntermediatePublishDir>$(PublishDir) + $(PublishDir) + $(IntermediateOutputPath)PubTmp\ + + + + + + + + + + + + + + + + false + true + + + + + + + + + + + + + $(ElectronDirName)\%(RecursiveDir)%(FileName)%(Extension) + PreserveNewest + + + + + + + + + + + + + + + + + + + + $(ElectronDirName)\%(RelativeDir)%(FileName)%(Extension) + + + + + + + + + + $(ElectronDirName)\%(FileName)%(Extension) + + + + + + + + + + + + + + + + + $(ElectronDirName)\%(DestinationRelativePath) + $(ElectronDirName)\%(DestinationRelativePath) + PreserveNewest + + + + + + + + + + <_ElectronFiles Include="$(ElectronSplashScreen)" Condition="'$(ElectronSplashScreen)'!=''" /> + <_ElectronFiles Include="$(ElectronIcon)" Condition="'$(ElectronIcon)'!=''" /> + + + + <_ElectronFiles Update="**"> + PreserveNewest + + + + + + + <_ElectronFilesToCopy Include="@(_ElectronFiles->'%(FullPath)')" /> + + + + + + <_ElectronFilesToCopyWithTargetPath Include="@(_ElectronFilesToCopy)"> + $(ElectronDirName)\%(FileName)%(Extension) + + + + + + + + + + + <_SourceItemsToCopyToOutputDirectoryIfDifferent Include="@(_ElectronFilesToCopyWithTargetPath)"/> + + + + + + + + $(OutDir)$(ElectronDirName)\node_modules\electron-host-hook + + + + + + + + + + + + + + + + + + $([System.IO.Path]::GetFullPath('$(ElectronOutDir)')) + linux + false + true + <_NpmCmd>npm install --no-bin-links + <_NpmCmd Condition="'$(IsLinuxWsl)' == 'true'">wsl bash -ic '$(_NpmCmd)' + + + + + + + + + + + + + + + + + + + + + + <_OriginalPublishDir>$(PublishDir) + $(_OriginalPublishDir)bin\ + true + + + + + + + + + + + + + + <_PublishIntermediateOutputPathFiles Remove="@(_PublishIntermediateOutputPathFiles)"> + + + + + <_ElectronPublishAppAfterTarget Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true'">AfterPublish + <_ElectronPublishAppAfterTarget Condition="'$(UsingMicrosoftNETSdkWeb)' != 'true'">Publish + + + + + + $(_OriginalPublishDir) + $(_NonIntermediatePublishDir) + $(_OriginalPublishDir) + + + + + + x64 + ia32 + arm64 + x64 + armv7l + arm64 + x64 + arm64 + + win + linux + mac + + + + + + + + + + + + + + + + + + + + + + + + + + + $(ElectronPublishDir)%(RecursiveDir)%(FileName)%(Extension) + + + + + + + + + $([System.IO.Path]::GetFullPath('$(ElectronPublishDir)')) + $([System.IO.Path]::GetFullPath('$(PublishUrl.TrimEnd("\"))')) + + + + false + true + <_NpmCmd>npm install electron-builder@$(ElectronBuilderVersion) --save-dev + <_NpmCmd Condition="'$(IsLinuxWsl)' == 'true'">wsl bash -ic '$(_NpmCmd)' + + + + + + + + + + + + + + + + + + $(ElectronPaParams) -c.appId "$(PackageId)" + $(ElectronPaParams) -c.buildVersion "$(Version)" + $(ElectronPaParams) -c.copyright "$(Copyright)" + $(ElectronPaParams) -c.extraResources "bin/**/*" + + + + <_NpxCmd>npx electron-builder --config=./$(ElectronBuilderJson) --$(ElectronPlatform) --$(ElectronArch) -c.electronVersion=$(ElectronVersion) -c.directories.output "$(ElectronPublishUrlFullPath)" $(ElectronPaParams) + <_NpxCmd Condition="'$(IsLinuxWsl)' == 'true'">wsl bash -ic '$(_NpxCmd)' + + + + + + + + + + + + + + + + diff --git a/src/ElectronNET/build/ElectronNET.props b/src/ElectronNET/build/ElectronNET.props new file mode 100644 index 0000000..f616fbb --- /dev/null +++ b/src/ElectronNET/build/ElectronNET.props @@ -0,0 +1,32 @@ + + + + + 30.4.0 + 26.0 + win-x64 + true + + + + $(MSBuildProjectName.Replace(".", "-").ToLower()) + electron-builder.json + $(MSBuildProjectName) + + + + false + false + false + + + + $(MSBuildThisFileDirectory)ElectronNET.LateImport.targets + + + + $(CollectUpToDateCheckBuiltDesignTimeDependsOn);ElectronCollectUpToDateCheckBuiltDesignTime + $(FileSystemPublishDependsOn);ElectronFileSystemPublishClearItems + + + diff --git a/src/ElectronNET/build/ElectronNET.targets b/src/ElectronNET/build/ElectronNET.targets new file mode 100644 index 0000000..40c5872 --- /dev/null +++ b/src/ElectronNET/build/ElectronNET.targets @@ -0,0 +1,26 @@ + + + + + win + $(Title) + $(PackageId) + + + + <_IsMsAspNetProject>False + <_IsMsAspNetProject Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true'">True + + + + + + + + + + + + + + diff --git a/src/ElectronNET/build/ElectronNETRules.Project.xaml b/src/ElectronNET/build/ElectronNETRules.Project.xaml new file mode 100644 index 0000000..62fcb82 --- /dev/null +++ b/src/ElectronNET/build/ElectronNETRules.Project.xaml @@ -0,0 +1,566 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ElectronNET/build/ElectronNETRules.Project2.xaml b/src/ElectronNET/build/ElectronNETRules.Project2.xaml new file mode 100644 index 0000000..3a4d2f5 --- /dev/null +++ b/src/ElectronNET/build/ElectronNETRules.Project2.xaml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ElectronNET/build/electron-builder.json b/src/ElectronNET/build/electron-builder.json new file mode 100644 index 0000000..41f483c --- /dev/null +++ b/src/ElectronNET/build/electron-builder.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://raw.githubusercontent.com/electron-userland/electron-builder/refs/heads/master/packages/app-builder-lib/scheme.json", + "compression": "maximum", + "linux": { + "target": [ + "tar.xz" + ], + "executableArgs": [ "--no-sandbox" ], + "artifactName": "${name}-${arch}-${version}.${ext}" + }, + "win": { + "target": [ + { + "target": "portable", + "arch": "x64" + } + ] + } +} \ No newline at end of file diff --git a/src/ElectronNET/build/package.template.json b/src/ElectronNET/build/package.template.json new file mode 100644 index 0000000..156fab2 --- /dev/null +++ b/src/ElectronNET/build/package.template.json @@ -0,0 +1,48 @@ +{ + "name": "$(PackageId)", + "productName": "$(ElectronTitle)", + "build": { + "appId": "$(PackageId)", + "linux": { + "desktop": { + "entry": { "Name": "$(Title)" } + }, + "executableName": "$(PackageId)" + }, + "deb": { + "desktop": { + "entry": { "Name": "$(Title)" } + } + } + }, + "description": "$(Description)", + "version": "$(Version)", + "main": "main.js", + "author": { + "name": "$(Company)" + }, + "license": "$(License)", + "executable": "$(TargetName)", + "singleInstance": "$(ElectronSingleInstance)", + "homepage": "$(ProjectUrl)", + "splashscreen": { + "imageFile": "$(ElectronSplashScreen)" + }, + "scripts": { + "start": "tsc -p ." + }, + "dependencies": { + "dasherize": "^2.0.0", + "electron-updater": "^6.6.2", + "image-size": "^1.2.1", + "portscanner": "^2.2.0", + "socket.io": "^4.8.1", + "electron-host-hook": "file:./ElectronHostHook" + }, + "devDependencies": { + "@types/node": "^22.18", + "electron": "$(ElectronVersion)", + "eslint": "^9.37.0", + "typescript": "^5.9.3" + } +} \ No newline at end of file diff --git a/src/ElectronNET/build/update_electron_versions.py b/src/ElectronNET/build/update_electron_versions.py new file mode 100644 index 0000000..beeee44 --- /dev/null +++ b/src/ElectronNET/build/update_electron_versions.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 +""" +Update Electron version list in ElectronNETRules.Project.xaml + +This script: +1. Downloads the Electron releases feed from GitHub +2. Filters for stable releases >= 23.0.0 +3. Generates the ElectronVersion enum XML +4. Updates the XAML file with the new version list +""" + +import json +import re +import urllib.request +from pathlib import Path + + +def download_releases(): + """Download Electron releases JSON from GitHub.""" + url = "https://releases.electronjs.org/releases.json" + print(f"Downloading releases from {url}...") + + with urllib.request.urlopen(url) as response: + data = response.read() + + print(f"Downloaded {len(data)} bytes") + return json.loads(data) + + +def filter_versions(releases, min_version="23.0.0"): + """Filter and sort stable Electron versions.""" + print(f"Filtering versions >= {min_version}...") + + # Regular expression for stable versions (major.minor.patch) + stable_pattern = re.compile(r'^\d+\.\d+\.\d+$') + + # Parse minimum version + min_parts = tuple(map(int, min_version.split('.'))) + + # Filter and collect versions + versions = set() + for release in releases: + version = release.get('version', '') + if stable_pattern.match(version): + parts = tuple(map(int, version.split('.'))) + if parts >= min_parts: + versions.add(version) + + # Sort versions + sorted_versions = sorted(versions, key=lambda v: tuple(map(int, v.split('.')))) + + print(f"Found {len(sorted_versions)} stable versions") + return sorted_versions + + +def generate_enum_xml(versions): + """Generate the ElectronVersion enum property XML.""" + lines = [ + ' ', + ' ', + ] + + for version in versions: + lines.append(f' ') + + lines.append(' ') + + return '\n'.join(lines) + + +def update_xaml_file(xaml_path, enum_xml): + """Update the XAML file with the new enum.""" + print(f"Updating {xaml_path}...") + + # Read the original file + content = Path(xaml_path).read_text(encoding='utf-8') + + # Find the ElectronVersion enum markers + start_marker = '