You need to implement CustomAction and in this action return success or failure. The easiest way of doing this is to use ManagedSetup events:
project.AfterInstall += project_AfterInstall; ... staticvoid project_AfterInstall(SetupEventArgs e) { try { //do your stuff } catch (Exception ex) { e.Session.Log(ex.Message); e.Result = ActionResult.Failure; } }