# rmtPocketWatcher - Windows Build Instructions

This document explains how to build rmtPocketWatcher for Windows distribution.

## Prerequisites

- Flutter SDK 3.22.3 or later
- Windows 10/11 with Visual Studio Build Tools
- PowerShell (for advanced build script)

## Quick Build (Batch Script)

For a simple build process, use the batch script:

```cmd
build_windows.bat
```

This will create:
- `build\windows\standalone\rmtpocketwatcher.exe` - Standalone executable with all dependencies
- `build\rmtPocketWatcher-Windows-Standalone.zip` - Distribution archive

## Advanced Build (PowerShell Script)

For more control and MSIX installer creation:

```powershell
# Release build (recommended for distribution)
.\build_windows.ps1 -Release

# Debug build (for development)
.\build_windows.ps1 -Debug
```

This creates:
- **Standalone Package**: Complete folder with all dependencies
- **Portable Executable**: Single-file distribution (if possible)
- **MSIX Installer**: Windows Store-style installer
- **Distribution Archive**: ZIP file ready for sharing

## Output Files

After building, you'll find:

### Standalone Distribution
- `build\windows\standalone\` - Complete application folder
- `build\windows\standalone\rmtpocketwatcher.exe` - Main executable
- `build\windows\standalone\data\` - Flutter engine and assets
- `build\windows\standalone\VERSION.txt` - Version information

### Distribution Archives
- `build\rmtPocketWatcher-Windows-v{version}.zip` - Full standalone package
- `build\rmtPocketWatcher-Windows-Portable-v{version}.zip` - Portable version (exe only)

### Installer (if created)
- `build\windows\x64\runner\Release\*.msix` - Windows installer package

## Distribution Options

### Option 1: Standalone ZIP (Recommended)
- Share the `rmtPocketWatcher-Windows-v{version}.zip` file
- Users extract and run `rmtpocketwatcher.exe`
- No installation required
- All dependencies included

### Option 2: Portable Executable
- Share the `rmtPocketWatcher-Windows-Portable-v{version}.zip` file
- Contains only the executable
- Smallest download size
- May require Visual C++ Redistributable on target machine

### Option 3: MSIX Installer
- Share the `.msix` file
- Windows Store-style installation
- Automatic updates support
- Requires Windows 10 version 1809 or later

## Testing

To test the standalone build:

```cmd
cd build\windows\standalone
rmtpocketwatcher.exe
```

## Troubleshooting

### Build Fails
- Ensure Flutter is properly installed: `flutter doctor`
- Check Windows development setup: `flutter doctor -v`
- Clean and retry: `flutter clean && flutter pub get`

### MSIX Creation Fails
- MSIX creation is optional and may fail on some systems
- The standalone executable will still be created
- Install Windows SDK if you need MSIX support

### Runtime Issues
- Ensure the `.env` file is present in the build directory
- Check that all assets are included in the `data` folder
- Verify Visual C++ Redistributable is installed on target machine

## CI/CD Integration

The build scripts are designed to work with the GitHub Actions workflow in `.gitea/workflows/release.yml`. The workflow automatically:

1. Builds both standalone and portable versions
2. Creates MSIX installer (if possible)
3. Packages everything for release
4. Uploads artifacts to the release

## Manual Flutter Commands

If you prefer manual control:

```cmd
# Basic build
flutter build windows --release

# Create MSIX (requires msix package)
flutter pub get
flutter pub run msix:create
```

Note: Manual builds won't include the packaging and organization provided by the build scripts.