One could always use a CustomAction invoking C# code which does similar
to RemoveFolderEx (though I would suggest logging an enhancement request
for RemoveFolderEx to support a child conditions).

Ex:
        const string REMOVEFILES_VIEW = @"SELECT `FileKey`,
`Component_`, `FileName`, `DirProperty`, `InstallMode` FROM
`RemoveFile`";

        /// <summary>
        /// This CA will add all the files in the DATAFOLDER storage to
the RemoveFiles table
        /// to be cleaned up on uninstall.
        /// </summary>
        /// <param name="session"></param>
        /// <returns></returns>
        [CustomAction]
        public static ActionResult AddDataFilesToBeRemoved(Session
session)
        {
            session.Log(@"Begin AddDataFilesToBeRemoved");
            ActionResult result = ActionResult.Success;

            string dataFolder = session.GetTargetPath(@"DATAFOLDER");
            session.Log(string.Format(@"DATAFOLDER = {0}", dataFolder));
            var foldersToRemove = Directory.GetDirectories(dataFolder,
@"*", SearchOption.AllDirectories);

            var view = session.Database.OpenView(REMOVEFILES_VIEW,
null);
            view.Execute();

            foreach (var folderToRemove in foldersToRemove)
            {
                
                var guid = Guid.NewGuid();
                string folderProperty = string.Format(@"dir_{0}",
guid.ToString(@"N"));
                string fileKey = string.Format(@"file_{0}",
guid.ToString(@"N"));
                string folderKey = string.Format(@"folder_{0}",
guid.ToString(@"N"));

                session[folderProperty] = folderToRemove + @"\";

                // Remove all the files
                var record = session.Database.CreateRecord(5);
                session.Log(@"FileKey= " + fileKey);
                record.SetString(1, fileKey);
                record.SetString(2,
"AComponentIdThatWillAlwaysBeInstalledAndRemoved ");
                record.SetString(3, "*.*");
                record.SetString(4, folderProperty);
                record.SetInteger(5,
(int)eInstalMode.msidbRemoveFileInstallModeOnRemove);
    
                view.Modify(ViewModifyMode.InsertTemporary, record);

                // and remove the folder
                record = session.Database.CreateRecord(5);
                record.SetString(1, folderKey);
                record.SetString(2,
"AComponentIdThatWillAlwaysBeInstalledAndRemoved");
                record.SetString(3, null);
                record.SetString(4, folderProperty);
                record.SetInteger(5,
(int)eInstalMode.msidbRemoveFileInstallModeOnRemove);
    
                view.Modify(ViewModifyMode.InsertTemporary, record);
                
            }
            view.Close();

            session.Log(@"End AddDataFilesToBeRemoved");
            return result;
        }


-----Original Message-----
From: Blair [mailto:os...@live.com] 
Sent: Tuesday, November 15, 2011 8:01 PM
To: 'General discussion for Windows Installer XML toolset.'
Subject: Re: [WiX-users] util:RemoveFolderEx with condition?

The only clean ways I am coming up with involve various schemes to force
the
component containing that RemoveFolderEx element to remain "installed"
(and
presumably orphaned) when the product containing it is removed. Does
anyone
else want to weigh in with ideas on that theme?

Blair

-----Original Message-----
From: thomas.debo...@rohde-schwarz.com
[mailto:thomas.debo...@rohde-schwarz.com] 
Sent: Tuesday, November 15, 2011 7:10 AM
To: General discussion for Windows Installer XML toolset.
Subject: [WiX-users] util:RemoveFolderEx with condition?

Hi,

I'm just working on a task where I have to cleanup a folder where the
application will create files and folders during runtime.

There for I've added a RemoveFolderEx element. <util:RemoveFolderEx On="
uninstall" Property="AppDataCommonFolder"/> This works fine so far, but
for
one folder the user should be able to set in a dialog if this folder
should
be deleted or not.
For this I set a property based on a checkbox.

Now I can't find a way how to set a condition based on my property to
the
RemoveFolderEx element.

Is it possible or do I work into the wrong way?

Cheers,
  Thomas
------------------------------------------------------------------------
----
--
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users


------------------------------------------------------------------------
------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to