2025-10-15 12:50:31 +02:00
# Migration Guide
2025-10-14 09:52:44 +02:00
Migrating from previous versions of Electron.NET to ElectronNET.Core is straightforward but requires several important changes. This guide walks you through the process step by step.
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
## 📋 Prerequisites
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
Before starting the migration:
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
- **Backup your project** - Ensure you have a working backup
- **Update development tools** - Install Node.js 22.x and .NET 8.0+
- **Review current setup** - Note your current Electron and ASP.NET versions
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
## 🚀 Migration Steps
### Step 1: Update NuGet Packages
**Uninstall old packages:**
```powershell
2025-10-15 23:04:37 +02:00
dotnet remove package ElectronNET.API
2025-10-14 09:52:44 +02:00
```
**Install new packages:**
```powershell
2025-10-15 23:04:37 +02:00
dotnet add package ElectronNET.Core
dotnet add package ElectronNET.Core.AspNet # For ASP.NET projects
2025-10-14 09:52:44 +02:00
```
2025-10-15 16:06:09 +02:00
> **Note**: The API package is automatically included as a dependency of `ElectronNET.Core`. See [Package Description](../RelInfo/Package-Description.md) for details about the package structure.
2025-10-14 09:52:44 +02:00
### Step 2: Configure Project Settings
2025-10-15 12:50:31 +02:00
2025-10-15 16:06:09 +02:00
**Auto-generated Configuration:**
2026-01-21 15:30:44 +08:00
ElectronNET.Core automatically creates `electron-builder.json` in the `Properties` folder of your project during the first build or NuGet restore. No manual configuration is needed for basic setups.
2025-10-14 09:52:44 +02:00
2025-10-15 16:06:09 +02:00
**Migrate Existing Configuration:**
2025-10-14 09:52:44 +02:00
If you have an existing `electron.manifest.json` file:
1. **Open the generated `electron-builder.json` ** file in your project
2. **Locate the 'build' section ** in your old `electron.manifest.json`
3. **Copy the contents ** of the build section (not the "build" key itself) into the new `electron-builder.json`
4. **Use Visual Studio Project Designer ** to configure Electron settings through the UI
5. **Delete the old `electron.manifest.json` ** file
**Alternative: Manual Configuration**
You can also manually edit `electron-builder.json` :
```json
{
2025-10-15 16:06:09 +02:00
"linux": {
"target": [
"tar.xz"
]
2025-10-14 09:52:44 +02:00
},
"win": {
2025-10-15 16:06:09 +02:00
"target": [
{
"target": "portable",
"arch": "x64"
}
]
2025-10-14 09:52:44 +02:00
}
}
2025-10-15 12:50:31 +02:00
```
2026-01-21 15:30:44 +08:00
**Modify Launch Settings:**
ElectronNET.Core no longer needs a separate CLI tool (electronize.exe) for launching. You should update your launch settings to use either the ASP.NET-first or Electron-first approach. See [Debugging ](../Using/Debugging.md ) for details.
2025-10-14 09:52:44 +02:00
## 🎯 Testing Migration
After completing the migration steps:
1. **Build your project ** to ensure no compilation errors
2. **Test debugging ** using the new ASP.NET-first approach
3. **Verify packaging ** works with the new configuration
4. **Check cross-platform builds ** if targeting multiple platforms
## 🚨 Common Migration Issues
### Build Errors
- **Node.js version**: Verify Node.js 22.x is installed and in PATH
- **Package conflicts**: Clean NuGet cache if needed
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
### Runtime Errors
- **Missing electron-builder.json**: Trigger rebuild or manual NuGet restore
- **Process termination**: Use .NET-first startup mode for better cleanup
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
## 🚀 Next Steps
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
- **[What's New? ](What's-New.md )** - Complete overview of ElectronNET.Core features
- **[Advanced Migration Topics ](Advanced-Migration-Topics.md )** - Handle complex scenarios
2025-10-15 16:06:09 +02:00
- **[Getting Started ](../GettingStarted/ASP.Net.md )** - Learn about new development workflows
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
## 💡 Migration Benefits
2025-10-15 12:50:31 +02:00
2025-10-15 16:06:09 +02:00
✅ **Simplified Configuration ** - No more CLI tools or JSON files
✅ **Better Debugging ** - Native Visual Studio experience with Hot Reload
✅ **Modern Architecture ** - .NET-first process lifecycle
✅ **Cross-Platform Ready ** - Build Linux apps from Windows
✅ **Future-Proof ** - Flexible Electron version selection
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
### Step 3: Update Startup Code
**Update UseElectron() calls** to include the new callback parameter. This callback executes at the right moment to initialize your Electron UI.
#### Modern ASP.NET Core (WebApplication)
```csharp
2025-10-15 12:50:31 +02:00
using ElectronNET.API;
using ElectronNET.API.Entities;
2025-10-15 16:06:09 +02:00
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
2025-10-14 09:52:44 +02:00
2025-10-15 16:06:09 +02:00
builder.UseElectron(args, ElectronAppReady);
var app = builder.Build();
app.Run();
}
2025-10-14 09:52:44 +02:00
2025-10-15 16:06:09 +02:00
public static async Task ElectronAppReady()
{
var browserWindow = await Electron.WindowManager.CreateWindowAsync(
new BrowserWindowOptions { Show = false });
2025-10-14 09:52:44 +02:00
2025-10-15 16:06:09 +02:00
browserWindow.OnReadyToShow += () => browserWindow.Show();
}
2025-10-15 12:50:31 +02:00
```
2025-10-14 09:52:44 +02:00
#### Traditional ASP.NET Core (IWebHostBuilder)
2025-10-15 12:50:31 +02:00
2025-10-15 16:06:09 +02:00
```csharp
2025-10-14 09:52:44 +02:00
using ElectronNET.API;
using ElectronNET.API.Entities;
2025-10-15 12:50:31 +02:00
2025-10-15 16:06:09 +02:00
public static void Main(string[] args)
{
WebHost.CreateDefaultBuilder(args)
.UseElectron(args, ElectronAppReady)
.UseStartup<Startup>()
.Build()
.Run();
}
public static async Task ElectronAppReady()
{
var browserWindow = await Electron.WindowManager.CreateWindowAsync(
new BrowserWindowOptions { Show = false });
browserWindow.OnReadyToShow += () => browserWindow.Show();
}
2025-10-14 09:52:44 +02:00
```
### Step 4: Update Development Tools
2025-10-15 16:06:09 +02:00
See [System Requirements ](../GettingStarted/System-Requirements.md ).
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
### Step 5: Update Debugging Setup
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
**Watch Feature Removal:**
2025-10-15 16:06:09 +02:00
2025-10-14 09:52:44 +02:00
The old 'watch' feature is no longer supported. Instead, use the new ASP.NET-first debugging with Hot Reload:
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
- **Old approach**: Manual process attachment and slow refresh
- **New approach**: Native Visual Studio debugging with Hot Reload
- **Benefits**: Faster development cycle, better debugging experience
2025-10-15 12:50:31 +02:00
2025-10-14 09:52:44 +02:00
**Update Launch Settings:**
2025-10-15 16:06:09 +02:00
Replace old watch configurations with new debugging profiles. See [Debugging ](../GettingStarted/Debugging.md ) for detailed setup instructions.