My solution was something like that. So I could do all with required permissions and refs and even track the status (this topic was helpfull):
Actions:
Custom actions looks something like this:
does project.DefaultUsesProperties can send assembly even to default events like BeforeInstall ?
Actions:
var runTaskSchedulerAction = new ElevatedManagedAction("InstallRunTaskAction", Return.check, When.Before, Step.InstallFinalize, Condition.NOT_Installed) { UsesProperties = "Installed, REMOVE, REINSTALL", // send this values to session to get it like session.CustomActionData["Installed"] RefAssemblies = new[] { Path.Combine(pathToSetupProjectBinDirectory, AssebmlyFileName) } }; var stopTaskAndUninstallCertsCustomAction = new ElevatedManagedAction("RepairRunTaskAction", Return.check, When.Before, Step.InstallFinalize, Condition.NOT_BeingRemoved) { //Condition = new Condition("REINSTALL=ALL"), //somehow it with this option it doesnt appear UsesProperties = "Installed, REMOVE, REINSTALL", , RefAssemblies = new[] { Path.Combine(PathToSetupProjectBinDirectory, .AssebmlyFileName) } };
[CustomAction] publicstatic ActionResult InstallRunTaskAction(Session session) { var installDir = session.Property("INSTALLDIR"); ActionResult resultOfOpeartion = MyInstallLogic(installDir); if (resultOfOpeartion != ActionResult.Success) { // NOTE: rollback doesn't call unsintall custom action. Need to remove all manually // ... my remove logicreturn ActionResult.Failure; } return ActionResult.Success; } [CustomAction] publicstatic ActionResult RepairRunTaskAction(Session session) { var statusService = new InstallationStatusService(session.CustomActionData); // service read data from passed propeties added to CustomActionData// where we do check like CustomActionData["REINSTALL"] == "ALL"if (!statusService.IsRepairing) // and here it checks the status of installationreturn ActionResult.Success; //... other logicreturn ActionResult.Success; }