WixUI_InstallDir dir location

May 8, 2016 at 8:39 PM
Hello, i have a setup like this
project.Dirs = new Dir[]
                new Dir(@"ADMINET")
                    Dirs = new Dir[]
                        new Dir("ServidorADMINET_X", this.ObtenerArchivos("ServidorADMINET") ),
                        new Dir("ConsolaADMINET_X", this.ObtenerArchivos("ConsolaADMINET") ),
                        new Dir("ConsolaCopiaADMINIS_X", this.ObtenerArchivos("ConsolaCopiaADMINIS") )
ADMINET is the main dir, but has no files in it, only subfolders. I set the UI to InstallDir so the user can change this folder.
project.UI = WUI.WixUI_InstallDir;
But this, emits a wxs with the property:
So when I execute the msi, the default folder is C:\ADMINET\ServidorADMINET_X

I found a workaround, by modifying the resulting xml like this:
            Compiler.WixSourceGenerated += document =>
                var product = document.Root.Select( "Product" );
                var prop = ( from el in product.Elements()
                             where el.Name.LocalName == "Property" && (string) el.Attribute( "Id" ) == "WIXUI_INSTALLDIR"
                             select el ).FirstOrDefault();
                if ( prop != null )
                    prop.SetAttributeValue( "Value", "INSTALLDIR" );
I've seen in the wixsharp code that there is a method that defines this WIXUI_INSTALLDIR as the first Dir which has some File or Shorcut elements in it. I would be nice to override this behaviour by setting some kind of property.

May 9, 2016 at 8:03 AM
Hi there,

Just before we dive in I want to let you know that you can use Wix# XML extensions for simplifying your XML manipulations. Thus your XML event can also be implemented like this:
 project.WixSourceGenerated += document =>
                    .Where(p=>p.HasAttribute("Id", "WIXUI_INSTALLDIR"))
Now about your problem. Indeed there is a logical problem with auto assigning WIXUI_INSTALLDIR. The current implementation sets it to the GetTopLevelDir() value, which is fine for all cases except yours.

Thus the proper solution would be to allow user to nominate a directory to be an InstallDir.

I have logged the issue on your behalf (https://wixsharp.codeplex.com/workitem/117).
The feature is already implemented and the binaries are available form Git. But if you have to wait until a full or a NuGet release then you will need to use your XML-based work around.
May 9, 2016 at 8:36 AM
Ok, thanks.
Meanwhile the nuget release ships I will use the xml manipulation code. Thanks for the simplified code.