Вопрос

I want to build an Installer with Microsoft Wix 3.8 that actually just registers some COM-components and creates some shortcuts to a program on a server share. Just to point that out in advance: This program is a legacy tool and the way it's launched or used won't be changed, unfortunately. So I need my installer to ask for three paths: The server installation path (as unc), and two additional paths, also on the server (also as unc).

I'm already struggling with the first path. As soon as I add it it seems to be hard wired to some directory I have to specify in my product.wxs.

That's how my product.wxs looks like:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension">
  <Product Id="613A5421-BF59-46DD-B363-05E55587B89F" Name="Test Client" Language="1033" Version="1.0.0" Manufacturer="Blub AG" UpgradeCode="A451E5EB-4AED-4A8A-ACBC-F65A34E86D45">
    <Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <MediaTemplate />
    <WixVariable Id="WixUIDialogBmp" Value="images\background.bmp" />    
    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />    
    <UIRef Id="WixUI_InstallDir" />
    <Feature Id='Complete' Title='Foobar 1.0' Description='The complete package.'>
      <Feature Id='TestClient' Title='Test Client' Description='Test Client' Level='1'>
        <ComponentGroupRef Id='ProductComponents' />
      </Feature>
    </Feature>
  </Product>

  <Fragment>
    <PropertyRef Id="NETFRAMEWORK20"/>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="ExpoWin" />
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER" >
      <Component Id="ProductComponent">
        <File Source="Blub.txt" />
      </Component>
    </ComponentGroup>
  </Fragment>
</Wix>

(In my original code I replaced the WixUI_InstallDir with my own version so that I can modify it to ask for three paths. But to point out my problem the code above should suffice) I don't want the "INSTALLFOLDER" to be linked to any Directory. But as soon as I change

<Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER" />

to

<Property Id="WIXUI_INSTALLDIR" Value="SERVERPATH" />
<Property Id="INSTALLFOLDER" Value="c:\program files (x86)\TestClient" />

and run the installer I get a "2343 error":

DEBUG: Error 2343: Specified path is empty. The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2343. The arguments are: , ,

Well hopefully this question is easy to answer. I've been searching the web for hours. Probably I haven't understood the concept of properties entirely. Can someone shed some light on this?

Это было полезно?

Решение

The following explanation might not be valid 100%, it's the way that I explain it to myself ;-).
WiX takes the value of a property and uses it to resolve the path. In the first case it finds the property in the directory structure, so the path can be resolved. In the second example SERVERPATH is just the string SERVERPATH, so it can't find anything. You have to either set it using a registry search or to a concrete path or by a custom action.
What worked great for me in the UI and custom dialogs (I had a similar requirement with the installation folder and an additional path) was the answer to a similar question.

Here is an example for setting it via a custom action (INSTALLLOCATION in my case was read from the registry, but it can be any path; INSTALLDIR is defined by the directory structure in the WiX source file):

<CustomAction Id="SetINSTALLDIR"  Property="INSTALLDIR" Value="[INSTALLLOCATION]" Execute="firstSequence" />
<InstallExecuteSequence>
        <Custom Action="SetINSTALLDIR" After="AppSearch">INSTALLLOCATION</Custom>
</InstallExecuteSequence>
<InstallUISequence>
        <Custom Action="SetINSTALLDIR" After="AppSearch">INSTALLLOCATION</Custom>
</InstallUISequence>

Using the method described in the answer above I have the following in my WiX source file:

<Directory Id="LUCENEFOLDER" SourceName="LuceneIndex" />

The path is then set in the UI on a custom dialog by the following snippet:

<Control Id="LuceneFolderLabel" Type="Text" X="5" Y="155" Width="200" Height="10" Text="Folder containing Multiindex.config of Lucene:" TabSkip="yes" />
<Control Type="PathEdit" Id="LuceneFolder" Width="200" Height="17" X="5" Y="165" Property="LUCENEFOLDER"/>
<Control Id="LuceneFolderBrwsButton" Type="PushButton" Width="56" Height="17" X="210" Y="164" Text="Change..." >
  <Publish Property="_BrowseProperty" Value="LUCENEFOLDER" Order="1">1</Publish>
  <Publish Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
</Control>
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top