Example #1
0
 /// <summary>
 /// Creates the new custom action with the given parameters
 /// </summary>
 public override void Execute()
 {
     try
     {
         IVsdDeployable         deployable         = (IVsdDeployable)SetupProject.Object;
         IVsdCollectionSubset   plugins            = deployable.GetPlugIns();
         IVsdCustomActionPlugIn customActionPlugin = plugins.Item("CustomAction") as IVsdCustomActionPlugIn;
         if (customActionPlugin != null)
         {
             customAction =
                 (IVsdCustomAction)DteHelper.CoCreateInstance(
                     this.Site,
                     typeof(VsdCustomActionClass),
                     typeof(IVsdCustomAction));
             customAction.Name           = this.ActionName;
             customAction.InstallerClass = true;
             customAction.Object         = this.Assembly;
             customAction.FileType       = vsdCustomActionFileTypes.vsdcaDll;
             if (InstallAction.Equals("Install"))
             {
                 customAction.InstallAction = vsdCustomActionInstallActions.vsdcaInstall;
             }
             else if (InstallAction.Equals("Uninstall"))
             {
                 customAction.InstallAction = vsdCustomActionInstallActions.vsdcaUninstall;
             }
             else if (InstallAction.Equals("Commit"))
             {
                 customAction.InstallAction = vsdCustomActionInstallActions.vsdcaCommit;
             }
             else if (InstallAction.Equals("Rollback"))
             {
                 customAction.InstallAction = vsdCustomActionInstallActions.vsdcaRollback;
             }
             else
             {
                 throw new InvalidOperationException(
                           String.Format(CultureInfo.CurrentCulture, Properties.Resources.AddCustomAction_InvalidInstallAction,
                                         InstallAction));
             }
             customAction.CustomActionData = this.CustomActionData;
             customActionPlugin.Items.Add(customAction);
         }
     }
     catch (Exception)
     {
         if (CustomAction != null)
         {
             CustomAction = null;
         }
         throw;
     }
 }