I've just done a msi for my app. I'am a not so new newbie but it's not trivial to do one. By the way the following explanation is doable only on VS tools I have at work and not at home. Perhaps there is a solution using sharpdevelop i don't know i'am a newbie here.
0 - create solution with few project ; app, custom installer, and msi
1- create a cab that encompass your app.exe, files etc. (the zip file that will be dezipped localy on the wm5 machine)
2- create a custominstaller project. code is provided by ms. It create a dll the msi will use to pre/post do things during installation.
example :
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.Linq;
using System.Security.Permissions;
using System.Windows.Forms;
using Microsoft.Win32;
namespace yournamespaceInstaller
[RunInstaller(true)]
public partial class CustomInstaller : Installer
{
private const string CEAPPMGR_PATH =
@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\CEAPPMGR.EXE";
private const string ACTIVESYNC_INSTALL_PATH =
@"SOFTWARE\Microsoft\Windows CE Services";
private const string INSTALLED_DIR = "InstalledDir";
private const string CEAPPMGR_EXE_FILE = @"CEAPPMGR.EXE";
private const string CEAPPMGR_INI_FILE = @"Setup.ini";
private const string APP_SUBDIR = @"\GBW";
private string TEMP_PATH =
Environment.SystemDirectory + @"\TEMP\GBW";
public CustomInstaller()
{
InitializeComponent();
this.BeforeInstall +=
new InstallEventHandler(CustomInstaller_BeforeInstall);
this.AfterInstall +=
new InstallEventHandler(CustomInstaller_AfterInstall);
this.BeforeUninstall +=
new InstallEventHandler(CustomInstaller_BeforeUninstall);
}
private string GetAppInstallDirectory()
{
// Get the ActiveSync install directory
RegistryKey keyActiveSync =
Registry.LocalMachine.OpenSubKey(ACTIVESYNC_INSTALL_PATH);
if (keyActiveSync == null)
{
throw new Exception("ActiveSync is not installed.");
}
// Build the target directory path under the ActiveSync folder
string activeSyncPath =
(string)keyActiveSync.GetValue(INSTALLED_DIR);
string installPath = activeSyncPath + APP_SUBDIR;
keyActiveSync.Close();
return installPath;
}
void CustomInstaller_BeforeInstall(object sender, InstallEventArgs e)
{
// Find the location where the application will be installed
string installPath = GetAppInstallDirectory();
// Create the target directory
Directory.CreateDirectory(installPath);
// Copy your application files to the directory
foreach (string installFile in Directory.GetFiles(TEMP_PATH))
{
File.Copy(installFile, Path.Combine(installPath,
Path.GetFileName(installFile)), true);
}
// Get the path to ceappmgr.exe
RegistryKey keyAppMgr =
Registry.LocalMachine.OpenSubKey(CEAPPMGR_PATH);
string appMgrPath = (string)keyAppMgr.GetValue(null);
keyAppMgr.Close();
// Run CeAppMgr.exe to install the files to the device
//System.Diagnostics.Process.Start(appMgrPath,
// "\"" + Path.Combine(installPath, CEAPPMGR_INI_FILE) + "\"");
System.Diagnostics.Process p =
System.Diagnostics.Process.Start(appMgrPath, "\"" + Path.Combine(installPath, CEAPPMGR_INI_FILE) + "\"");
p.WaitForExit();
}
void CustomInstaller_AfterInstall(object sender, InstallEventArgs e)
{
// Delete the temp files
foreach (string tempFile in Directory.GetFiles(TEMP_PATH))
{
File.Delete(tempFile);
}
}
void CustomInstaller_BeforeUninstall(object sender, InstallEventArgs e)
{
// Find where the application is installed
string installPath = GetAppInstallDirectory();
// Delete the files
foreach (string appFile in Directory.GetFiles(installPath))
{
File.Delete(appFile);
}
// Delete the folder
Directory.Delete(installPath, true);
}
}
}
3- create the msi using the above dll, customized that suite your needs.
this kind of msi will install the software first on your desktop with your PDA connected or not. Once connected trough activesynch, your app will
be installed according to your setup (like a professionnal app dude).
Hope it help, now my question is ; is it possible to do that using sharpdevelop ?
thx