Thank you so much for your help! Although I have not fully tested it, I think 
everything is working. I learned quite a lot in the process. In the hopes that 
this effort might be useful to others as they search the archives, I am posting 
my working wxs files below. (Working wixlib examples and documentation are 
rather scarce, I have found!) If anyone has any comments, warnings, or 
suggestions, I'd love to hear them!

The files below are built using the following powershell script:
param(
  [string]$checkoutPath = "trunk", 
  [string]$wixPath = "C:\Program Files\Windows Installer XML v3\bin",
  [string]$msbuildPath = "C:\Windows\Microsoft.NET\Framework\v3.5"
  )

# Clear out any previous directories, or create them if they do not exist.
if (test-path checkout -pathtype container){Remove-Item checkout\* 
-recurse}else{New-Item checkout -type directory}
if (test-path wixobj   -pathtype container){Remove-Item wixobj\*   
-recurse}else{New-Item wixobj   -type directory}
if (test-path msi      -pathtype container){Remove-Item msi\*      
-recurse}else{New-Item msi      -type directory}

# Get the latest code from subversion.
&"..\lib\svn\svn.exe" export 
svn://path-to-svn-repos/$checkoutPath/src/ClassLibrary 
checkout\src\ClassLibrary --force
&"..\lib\svn\svn.exe" export 
svn://path-to-svn-repos/$checkoutPath/src/UserInterface 
checkout\src\UserInterface --force
&"..\lib\svn\svn.exe" export 
svn://path-to-svn-repos/$checkoutPath/lib/Ntfmo.Utility 
checkout\lib\Ntfmo.Utility --force

# Build the project in Release mode.
&"$msbuildPath\msbuild.exe" checkout\src\UserInterface\UserInterface.csproj 
/t:Rebuild /p:Configuration=Release

# Build the installer using WiX.

# First, build the common components
&"$wixPath\candle.exe" -out wixobj\literacy_common.wixobj literacy_common.wxs
&"$wixPath\lit.exe" -out wixobj\literacy_common.wixlib 
wixobj\literacy_common.wixobj

# Next, build the MSI for the stand-alone application.
&"$wixPath\candle.exe" -out wixobj\literacy_standalone.wixobj 
literacy_standalone.wxs
&"$wixPath\light.exe" -out msi\LiteracyHelper.msi 
wixobj\literacy_standalone.wixobj wixobj\literacy_common.wixlib

# Last, build the merge module for the components
&"$wixPath\candle.exe" -out wixobj\literacy_mergemodule.wixobj 
literacy_mergemodule.wxs
&"$wixPath\light.exe" -out msi\LiteracyHelper.msm 
wixobj\literacy_mergemodule.wixobj wixobj\literacy_common.wixlib

-------------------
literacy_common.wxs
-------------------
<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>

  <Fragment Id='LiteracyCommonFragment'>

    <DirectoryRef Id='LITERACYINSTALLDIR'>
      
      <Component Id='MainExecutable' 
Guid='{0E72681F-6244-4A29-9C0C-9E488A72F722}'>
        <File Id='NtfmoLiteracyUiExe' Name='Literacy Helper.exe' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Literacy.UI.exe' />
        <File Id='NtfmoLiteracyUiPdb' Name='Literacy Helper.pdb' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Literacy.UI.pdb' />
      </Component>

      <Component Id='ClassLibrary' 
Guid='{4E676A1E-7180-4321-99AC-F6D61152A848}'>
        <File Id='NtfmoLiteracyDll' Name='Ntfmo.Literacy.dll' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Literacy.dll' />
        <File Id='NtfmoLiteracyPdb' Name='Ntfmo.Literacy.pdb' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Literacy.pdb' />
      </Component>

      <Component Id='BackgroundProcessForm' 
Guid='{F3FBB0CA-3D6E-46CA-8FE4-5879AC80EC0D}'>
        <File Id='NtfmoBackgroundProcessFormDll' 
Name='Ntfmo.Utility.BackgroundProcessForm.dll' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Utility.BackgroundProcessForm.dll'
 />
        <File Id='NtfmoBackgroundProcessFormPdb' 
Name='Ntfmo.Utility.BackgroundProcessForm.pdb' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Utility.BackgroundProcessForm.pdb'
 />
      </Component>

      <Component Id='TunneledCommands' 
Guid='{51FC70AB-CB1F-4299-9508-F2FED259715B}'>
        <File Id='NtfmoTunneledCommandsDll' 
Name='Ntfmo.Utility.TunneledCommands.dll' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Utility.TunneledCommands.dll'
 />
        <File Id='NtfmoTunneledCommandsPdb' 
Name='Ntfmo.Utility.TunneledCommands.pdb' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Utility.TunneledCommands.pdb'
 />
      </Component>

      <Component Id='AssemblyInformation' 
Guid='{B78AA719-B362-4D27-9594-BBD9ABF85CD9}'>
        <File Id='NtfmoUtilityAssemblyInformationDll' 
Name='Ntfmo.Utility.AssemblyInformation.dll' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Utility.AssemblyInformation.dll'
 />
        <File Id='NtfmoUtilityAssemblyInformationPdb' 
Name='Ntfmo.Utility.AssemblyInformation.pdb' DiskId='1' 
Source='checkout\src\UserInterface\bin\Release\Ntfmo.Utility.AssemblyInformation.pdb'
 />
      </Component>

    </DirectoryRef>

    <ComponentGroup Id='LiteracyCommonGroup'>
      <ComponentRef Id='MainExecutable'/>
      <ComponentRef Id='ClassLibrary'/>
      <ComponentRef Id='BackgroundProcessForm'/>
      <ComponentRef Id='TunneledCommands'/>
      <ComponentRef Id='AssemblyInformation'/>
    </ComponentGroup>

  </Fragment>

</Wix>

-----------------------
literacy_standalone.wxs
-----------------------
<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>

  <?define ThisVersion = "0.9.7" ?>
  
  <Product Name='Literacy Helper' Id='*' 
UpgradeCode='{A0EC30AF-8094-41EF-AC3F-2CBBD6976C01}' 
Version='$(var.ThisVersion)' Language='1033' Manufacturer='Ntfmo'>
    
    <Package Id='*' Description="Literacy Helper Installer" 
Manufacturer='Ntfmo' InstallerVersion='200' Languages='1033' Compressed='yes' />

    <Upgrade Id="{A0EC30AF-8094-41EF-AC3F-2CBBD6976C01}">
      <UpgradeVersion Minimum="0.9.0" IncludeMinimum="yes" 
Maximum="$(var.ThisVersion)" Property="OLDERVERSIONBEINGUPGRADED" />
      <UpgradeVersion Minimum="$(var.ThisVersion)" IncludeMinimum="no" 
OnlyDetect="yes" Property="NEWERVERSIONDETECTED" />
    </Upgrade>

    <InstallExecuteSequence>
      <RemoveExistingProducts After="InstallInitialize"/>
    </InstallExecuteSequence>

    <Condition Message="A later version of [ProductName] is already installed. 
Setup will now exit.">
      NOT NEWERVERSIONDETECTED OR Installed
    </Condition>
    
    <Media Id='1' Cabinet='Literacy.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" 
/>
    
    <Property Id='DiskPrompt' Value="Literacy Helper Installation [1]" />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      
      <Directory Id='ProgramFilesFolder' Name='PFiles'>
        <Directory Id='Ntfmo' Name='Ntfmo'>
          <Directory Id='LITERACYINSTALLDIR' Name='Literacy' />
        </Directory>
      </Directory>

      <Directory Id="DesktopFolder" Name="Desktop" />

    </Directory>

    <DirectoryRef Id="DesktopFolder">
      <Component Id='MainExecutableShortcut' 
Guid='{E6ACC5F7-0244-4E8E-AAB7-41DF652B78FE}'>
        <Shortcut Id='DesktopShortcut' Target='[LITERACYINSTALLDIR]Literacy 
Helper.exe' Name='Literacy Helper (Beta)' WorkingDirectory='LITERACYINSTALLDIR' 
Advertise='no' Icon='LiteracyHelperIcon.exe'>
          <Icon Id="LiteracyHelperIcon.exe" 
SourceFile='checkout\src\UserInterface\bin\Release\Ntfmo.Literacy.UI.exe' />
        </Shortcut>
        <RegistryValue Root="HKCU" Key="Software\Ntfmo\Literacy" 
Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>

    <Feature Id='Complete' Level='1'>
      <ComponentRef Id='MainExecutableShortcut' />
      <ComponentGroupRef Id='LiteracyCommonGroup' />
    </Feature>

  </Product>
  
</Wix>

------------------------
literacy_mergemodule.wxs
------------------------
<?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>

  <?define ThisVersion = "0.9.7" ?>

  <Module Id='LiteracyHelperMergeModule' Version='$(var.ThisVersion)' 
Language='1033'>

    <Package Id='{E7D68DFC-1261-405B-897F-B8E7AFB6D0C4}' Description="Literacy 
Helper Installer" Manufacturer='Ntfmo' InstallerVersion='200' Languages='1033' 
/>

    <ComponentGroupRef Id='LiteracyCommonGroup' />

    <Directory Id='TARGETDIR' Name='SourceDir'>
      <Directory Id='LITERACYINSTALLDIR' Name='.' />
    </Directory>
    
  </Module>

</Wix>

----------------------------------------------------------------------

Message: 1
Date: Tue, 13 Oct 2009 15:25:36 -0700
From: "Blair" <os...@live.com>
Subject: Re: [WiX-users] Create shortcut for file in merge module
To: "'General discussion for Windows Installer XML toolset.'"
        <wix-users@lists.sourceforge.net>
Message-ID: <bay122-ds7582077df26937dfb4067cd...@phx.gbl>
Content-Type: text/plain; charset="us-ascii"

In your wixlib, use only DirectoryRef elements as needed. Under your Product
and Module elements for each of the two packages supply the appropriate
directory tree.

-----Original Message-----
From: Dave Mateer [mailto:dave_mat...@ntm.org] 
Sent: Tuesday, October 13, 2009 7:30 AM
To: wix-users@lists.sourceforge.net
Subject: Re: [WiX-users] Create shortcut for file in merge module

The wixlib looks like exactly what I need--thank you for pointing me in that
direction. I *almost* have it working, except I can't figure out what to use
for the Directory elements in the "common" wxs file. The components in the
wxs file will be installed in different locations in the stand-alone
application vs. the larger application. My stand-alone wxs Directory
elements look like this:

<Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id='ProgramFilesFolder' Name='PFiles'>
    <Directory Id='Ntfmo' Name='Ntfmo'>
      <Directory Id='INSTALLDIR' Name='Literacy'>

Right now, my common wxs Directory elements are:

<Directory Id='TARGETDIR' Name='SourceDir'>
  <Directory Id='INSTALLDIR' Name='.'>

But, of course, light.exe gives me "error LGHT0130 : The primary key
'INSTALLDIR' is duplicated in table 'Directory'.  Please remove one of the
entries or rename a part of the primary key to avoid the collision."

What do I use here? In the standalone app, the installation path is
%ProgramFiles%\Ntfmo\Literacy, but in the larger application it should be
the installation path of that application.

Thanks for your help!

----------------------------------------------------------------------

Message: 1
Date: Fri, 9 Oct 2009 01:28:28 -0700
From: "Blair" <os...@live.com>
Subject: Re: [WiX-users] Create shortcut for file in merge module
To: "'General discussion for Windows Installer XML toolset.'"
        <wix-users@lists.sourceforge.net>
Message-ID: <bay122-ds48fd29104433ba618c98acd...@phx.gbl>
Content-Type: text/plain; charset="us-ascii"

If you wish to retain the advertised nature of the shortcut, you will have a
harder time because the shortcut has to live in the same component as the
eventual target (which means you have to have the same component with
different resources based on whether the component lives in the stand-alone
application or the integrated application, which is a violation of the
component rules. Violating it could possibly cause the shortcut to be
orphaned depending on the installation/upgrade/removal sequences between the
stand-alone and integrated products.

If you wish to target a file from a merge module in a shortcut, you have to
assemble the target like this: "[#fileid.mergemoduleguid]". If you are
autogenerating the MSM's package guid, that value might be hard to
anticipate, depending on your build environment.

Instead, think of the situation this way: Component GUIDS are used to
identify components universally in the Windows Installer universe. Component
Ids, File Ids, etc. are used to identify those elements WITHIN any arbitrary
package. Thus, you don't have to use the same merge module in both
installation packages, you just have to use the same merge module content
you care about between both packages. And the easiest way to do that would
be to use wixlibs, which are wix-toolset-specific "libraries" of compiled
wix code, analogous to merge modules in the larger Windows Installer world
but without several of the problems associated with merge modules.

Here's how this can work in practice:

You generate a wixlib (compile with candle, link with lit) the code
containing the shared components and their resources. That code consists of
.wxs files containing only Fragments as direct children of the root Wix
elements.

You reference that wixlib in your standalone application, which will include
the appropriate ~Ref elements required to eventually include all your
fragments in your wixlib. Your standalone app is now built and can easily
create a non-advertised shortcut that targets any file (using simple
"[#fileid]" syntax) in your wixlib.

You generate an MSM that has a similarly small wxs file as your standalone
app, except it uses the Module element instead of the Product element and
doesn't include the shortcut. You reference the resulting MSM file in your
integrated package.

The result is that the shared components are the same (have the same GUIDS
and the same contained resources) even though the IDs differ (the integrated
product has those IDs with the appended ".GUID" on them). They act as you
expect them to act in scenarios where the standalone app and the integrated
app are both installed and removed in all combinations of ordering/version
differing/etc. as if the merge module had been used in building both
packages. And, when you finally move away from non-wix toolsets, you can
simply drop the wrapping MSM and directly link the wixlibs (remembering to
replace the Merge elements with appropriate ~Ref elements to pull in the
fragments from the wixlibs), so you have your migration story.

Let us know how that works for you.


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to