custom event not executing while first time setup using wix installer - installation

I am trying to develop an application using SingnalR which will install into client machine and continuously give me update on a particular port. I made client setup using WIX and added a custom event to register port to the client machine. Now the issue is, while I am going to run the setup for the first time on client's machine, my custom event is not getting fired. But if I run the installer for second time, it is getting fired. I don't know what is the issue.
.wxs file is as below,
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<?define WixSetup2_TargetDir=$(var.WixSetup2.TargetDir)?>
<Product Id="*" Name="TestCompany" Language="1033" Version="1.0.0.0" Manufacturer="Test" UpgradeCode="aacb5b21-2f9c-4d93-b47c-d6ec8868dc65">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" InstallPrivileges="elevated" AdminImage="yes" />
<MajorUpgrade DowngradeErrorMessage="A newer version of Test is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="SetupProject1" Level="1">
<ComponentGroupRef Id="ProductComponents" />
<ComponentGroupRef Id="ProgramFilesFolder_files" />
</Feature>
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="WixSetup2.exe" Guid="ca9e28f3-b059-48db-ae8c-3ea39c471644">
<File Id="WixSetup2.exe" Name="WixSetup2.exe" Source="$(var.WixSetup2_TargetDir)WixSetup2.exe" />
</Component>
<Component Id="WixSetup2.exe.config" Guid="3ac3746a-c59e-450d-a575-4c137c959309">
<File Id="WixSetup2.exe.config" Name="WixSetup2.exe.config" Source="$(var.WixSetup2_TargetDir)WixSetup2.exe.config" />
</Component>
<Component Id="Owin.dll" Guid="7610272c-0faa-40b9-b633-1f251d05c360">
<File Id="Owin.dll" Name="Owin.dll" Source="$(var.WixSetup2_TargetDir)Owin.dll" />
</Component>
<Component Id="Microsoft.AspNet.SignalR.Core.dll" Guid="0bb82458-a72a-49e5-adbe-36d3521f8322">
<File Id="Microsoft.AspNet.SignalR.Core.dll" Name="Microsoft.AspNet.SignalR.Core.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.AspNet.SignalR.Core.dll" />
</Component>
<Component Id="Microsoft.AspNet.SignalR.SystemWeb.dll" Guid="8f06a4f7-93fe-45f3-a82a-ed5d5f102d17">
<File Id="Microsoft.AspNet.SignalR.SystemWeb.dll" Name="Microsoft.AspNet.SignalR.SystemWeb.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.AspNet.SignalR.SystemWeb.dll" />
</Component>
<Component Id="Microsoft.Owin.dll" Guid="98e2aa07-583d-4fe5-bf0b-04c7dd544899">
<File Id="Microsoft.Owin.dll" Name="Microsoft.Owin.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.dll" />
</Component>
<Component Id="Microsoft.Owin.Hosting.dll" Guid="8e662dd5-27ee-46fc-aa66-513e2a2620ef">
<File Id="Microsoft.Owin.Hosting.dll" Name="Microsoft.Owin.Hosting.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Hosting.dll" />
</Component>
<Component Id="Microsoft.Owin.Cors.dll" Guid="ec90a805-82c9-4293-8ef7-83b8b2675e2d">
<File Id="Microsoft.Owin.Cors.dll" Name="Microsoft.Owin.Cors.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Cors.dll" />
</Component>
<Component Id="System.Web.Cors.dll" Guid="7aa9db0e-51af-4b46-bb5d-abebc7e66285">
<File Id="System.Web.Cors.dll" Name="System.Web.Cors.dll" Source="$(var.WixSetup2_TargetDir)System.Web.Cors.dll" />
</Component>
<Component Id="Newtonsoft.Json.dll" Guid="ade7f021-743d-4d36-8fcd-c1a991f4b133">
<File Id="Newtonsoft.Json.dll" Name="Newtonsoft.Json.dll" Source="$(var.WixSetup2_TargetDir)Newtonsoft.Json.dll" />
</Component>
<Component Id="Microsoft.Owin.Host.SystemWeb.dll" Guid="38f6eaab-041a-401c-8fdb-2f841fbcea6a">
<File Id="Microsoft.Owin.Host.SystemWeb.dll" Name="Microsoft.Owin.Host.SystemWeb.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Host.SystemWeb.dll" />
</Component>
<Component Id="Microsoft.Owin.Security.dll" Guid="82ef20d9-562b-4bf4-85a0-4ea446bc5095">
<File Id="Microsoft.Owin.Security.dll" Name="Microsoft.Owin.Security.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Security.dll" />
</Component>
<Component Id="Microsoft.Owin.Host.HttpListener.dll" Guid="a00da1a6-563b-4318-8bcc-eb21c5c7d7bd">
<File Id="Microsoft.Owin.Host.HttpListener.dll" Name="Microsoft.Owin.Host.HttpListener.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Host.HttpListener.dll" />
</Component>
<Component Id="Microsoft.Owin.Diagnostics.dll" Guid="c5e44f7a-6961-4e9c-b2af-5d4a7e8d8b9d">
<File Id="Microsoft.Owin.Diagnostics.dll" Name="Microsoft.Owin.Diagnostics.dll" Source="$(var.WixSetup2_TargetDir)Microsoft.Owin.Diagnostics.dll" />
</Component>
</ComponentGroup>
<CustomAction Id="addPort" Directory="INSTALLFOLDER" Execute="immediate" Impersonate="no" ExeCommand="[SystemFolder]netsh.exe http add urlacl http://*:1919/ user=Everyone" Return="check">
</CustomAction>
<InstallExecuteSequence>
<Custom Action="addPort" Before="InstallExecute">Installed</Custom>
</InstallExecuteSequence>
</Fragment>
<Fragment>
<ComponentGroup Id="ProgramFilesFolder_files" Directory="INSTALLFOLDER">
<Component Id="Scripts_jquery_3.1.1.intellisense.js" Guid="e47264ab-facd-4c3b-9372-69e2f972fb44">
<File Id="Scripts_jquery_3.1.1.intellisense.js" Name="jquery-3.1.1.intellisense.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.intellisense.js" />
</Component>
<Component Id="Scripts_jquery_3.1.1.js" Guid="b51ca2fd-3c8a-461e-8340-e26b90dbeb4c">
<File Id="Scripts_jquery_3.1.1.js" Name="jquery-3.1.1.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.js" />
</Component>
<Component Id="Scripts_jquery_3.1.1.min.js" Guid="df63a174-bf0e-40ca-b634-aac1a9777afa">
<File Id="Scripts_jquery_3.1.1.min.js" Name="jquery-3.1.1.min.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.min.js" />
</Component>
<Component Id="Scripts_jquery_3.1.1.slim.js" Guid="63ddd1f4-b695-4441-8ce2-f81473069868">
<File Id="Scripts_jquery_3.1.1.slim.js" Name="jquery-3.1.1.slim.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.slim.js" />
</Component>
<Component Id="Scripts_jquery_3.1.1.slim.min.js" Guid="15b3bc22-b845-4d65-9c4b-baf654959531">
<File Id="Scripts_jquery_3.1.1.slim.min.js" Name="jquery-3.1.1.slim.min.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery-3.1.1.slim.min.js" />
</Component>
<Component Id="Scripts_jquery.signalR_2.2.1.js" Guid="915b874f-398a-4e9e-af24-e68045ffca71">
<File Id="Scripts_jquery.signalR_2.2.1.js" Name="jquery.signalR-2.2.1.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery.signalR-2.2.1.js" />
</Component>
<Component Id="Scripts_jquery.signalR_2.2.1.min.js" Guid="085dd028-262d-47b1-9b48-fc19d8e3db87">
<File Id="Scripts_jquery.signalR_2.2.1.min.js" Name="jquery.signalR-2.2.1.min.js" Source="$(var.WixSetup2_TargetDir)Scripts\jquery.signalR-2.2.1.min.js" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
It would be great if you can help me to get rid of this issue.

You have set the condition to run only if the product already installed.
Change the condition in the custom action to Not installed.
<Custom Action="addPort" Before="InstallExecute">NOT Installed</Custom>

Related

What is the proper way to add multiple class library projects in wix installer

I am trying to create a wix installer for window service. My service consists four class library projects. My questions is how can i add multiple class library projects in wix installer. I followed this link https://github.com/Robs79/How-to-create-a-Windows-Service-MSI-Installer-Using-WiX/blob/master/WindowsService.Installer/Product.wxs its not shows how to add multiple class library projects. Please some one help me out how can do this. or provide some reference link where i can refer.
Thanks in Advance
Product.wxs:
<?define Manufacturer = "IRIZ ID TECH" ?>
<?define VersionNumber = "1.0.0.0" ?>
<?define UpgradeCode = "{FF9D7B21-A4FE-4DEB-A2FE-E77228F95831}" ?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*"
UpgradeCode="$(var.UpgradeCode)"
Version="$(var.VersionNumber)"
Language="1033"
Name="$(var.Name)"
Manufacturer="$(var.Manufacturer)">
<Package InstallerVersion="300" Compressed="yes" InstallScope="perMachine" />
<Media Id="1" Cabinet="ESS_VillageMateIntegrtion" EmbedCab="yes"></Media>
<!-- Allow upgrades and prevent downgrades -->
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="WindowsService.Installer" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
</Product>
<Fragment>
<!-- Define the directory structure -->
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="ROOTDIRECTORY" Name="$(var.Manufacturer)">
<Directory Id="APPLICATIONROOTDIRECTORY" Name="$(var.Name)" />
</Directory>
</Directory>
</Directory>
</Fragment>
<!-- Add files to your installer package -->
<Fragment>
<DirectoryRef Id="APPLICATIONROOTDIRECTORY">
<Component Id="$(var.ESS_VillageMateIntegrtion.TargetFileName)" Guid="{F03996CC-3A49-47A7-91F1-27DBF563AE83}">
<File Id="$(var.ESS_VillageMateIntegrtion.TargetFileName)" Source="$(var.ESS_VillageMateIntegrtion.TargetPath)" KeyPath="yes" />
</Component>
<Component Id="$(var.ESS_VillageMateIntegrtionServiceConfig.TargetFileName)" Guid="{CC064C9B-298A-4D6D-AF64-40DA3657AAAB}">
<File Id="$(var.ESS_VillageMateIntegrtionServiceConfig.TargetFileName)" Source="$(var.ESS_VillageMateIntegrtionServiceConfig.TargetPath)" KeyPath="yes" />
</Component>
<Component Id="$(var.ESS_VillageMateService.TargetFileName)" Guid="{CB37D43D-BB08-4DF2-A7B0-87A819A66CED}">
<File Id="$(var.ESS_VillageMateService.TargetFileName)" Source="$(var.ESS_VillageMateService.TargetPath)" KeyPath="yes" />
</Component>
<Component Id="$(var.ESS_VillageMateIntegrationTray.TargetFileName)" Guid="{71FD65C9-A657-4093-8D5A-28743972E536}">
<File Id="$(var.ESS_VillageMateIntegrationTray.TargetFileName)" Source="$(var.ESS_VillageMateIntegrationTray.TargetPath)" KeyPath="yes" />
</Component>
<Component Id="Components">
<!-- Remove the log file on uninstall -->
<RemoveFile Id="log" Name="*.txt" On="both" />
<!-- Tell WiX to install the Service -->
<ServiceInstall Id="ServiceInstaller"
Type="ownProcess"
Vital="yes"
Name="ESS_VillageMateIntegrtion"
DisplayName="ESS_VillageMateIntegrtion Service"
Description="Write Data one DB to another DB"
Start="auto"
Account="LocalSystem"
ErrorControl="normal" />
<!-- Tell WiX to start the Service -->
<ServiceControl Id="StartService"
Start="install"
Stop="both"
Remove="uninstall"
Name="ESS_VillageMateIntegrtion"
Wait="yes" />
</Component>
</DirectoryRef>
</Fragment>
</Wix>

How to Reference a Heat Output(wxs) in Wix (Command Line)

I am using heat.exe to generate a .wxs file to include files in my main installer. I have two questions:
Which switches would I use to register a DLL?
Once I have generated the output file how do I go about adding it to my "Main.wxs" file? (Please be pretty explicit, new to this)
I have looked around a lot for an answer to the second question and I always come up with something vague or for VS, I am working from the command line. Thanks!
This is what I have tried thus far: I get the error: (LGHT0103: The system cannot find the file "file") I get this error for all of my files.
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="cmp1D2A500FA963CF9DB333FD18154B94BC" Guid="{8DE755D7-F1F9-4EC3-BCD5-B72360B8752A}">
<File Id="filCBD973AD942425DC5F533B29866FEF5A" KeyPath="yes" Source="SourceDir\DLLs\FP7000-Camera.dll" />
</Component>
<Component Id="cmp4CC93670B061A60B94C1867DCFAAAED0" Guid="{717E0819-2842-4C0D-BFAB-30E4C8C66F7E}">
<File Id="fil7CEC0F75EDE8EEF9C7F6D563E8D04EF9" KeyPath="yes" Source="SourceDir\DLLs\libmfxsw64.dll" />
</Component>
<Component Id="cmpE80ACF08DF44E67E7583F35557C8EB02" Guid="{4CAA0627-45DB-4E34-9B4C-C54B5E21346C}">
<File Id="fil1E619A89A3D0D2FDE446E60B3D3EB2AF" KeyPath="yes" Source="SourceDir\DLLs\pthreadVC2.dll" />
</Component>
</ComponentGroup>
</Fragment>
You can cut the component nodes and paste them into the correct installation directory in your main wxs file. As an example you can check out this simple mock-up:
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="put-guid-here"
Name="Example Product Name" Version="0.0.1"
Manufacturer="Example Company Name" Language="1033">
<Package InstallerVersion="200" Compressed="yes"
Comments="Windows Installer Package"/>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Example">
<Component Id="FP7000-Camera.dll" Guid="*">
<File Id="FP7000-Camera.dll" Source="replace with path to FP7000-Camera.dll"/>
</Component>
further components can be added here.
</Directory>
</Directory>
</Directory>
<Feature Id="DefaultFeature" Level="1">
<ComponentRef Id="FP7000-Camera.dll"/>
</Feature>
</Product>
</Wix>
You should extract the COM data for your COM files. Here is a sample Heat.exe command. (Note: if your dll fails to load due to missing dependencies you might need to install your sdk setup before running the extraction):
heat file MyComFile.ocx -out MyComFile.wxs
the resulting, extracted COM data in MyComFile.wxs will look something like this:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Directory Id="dirE645D1B018BB48C41BDBE188A129817F" Name="wix310-binaries" />
</DirectoryRef>
</Fragment>
<Fragment>
<DirectoryRef Id="dirE645D1B018BB48C41BDBE188A129817F">
cut from here
<Component Id="cmpD8BB195A00599F06D2FF16982DBAA523" Guid="PUT-GUID-HERE">
<File Id="filBDC3CFD8FF09857ADE9793AF172F66E6" KeyPath="yes" Source="SourceDir\wix310-binaries\ITDetector.ocx">
<TypeLib Id="{D6995525-B33A-4980-A106-9DF58570CC66}" Description="ITDetector 1.0 Type Library" HelpDirectory="dirE645D1B018BB48C41BDBE188A129817F" Language="0" MajorVersion="1" MinorVersion="0">
<Class Id="{D719897A-B07A-4C0C-AEA9-9B663A28DFCB}" Context="InprocServer32" Description="iTunesDetector Class" ThreadingModel="apartment" Programmable="yes" SafeForScripting="yes" SafeForInitializing="yes">
<ProgId Id="ITDetector.iTunesDetector.1" Description="iTunesDetector Class">
<ProgId Id="ITDetector.iTunesDetector" Description="iTunesDetector Class" />
</ProgId>
</Class>
<Interface Id="{45D2C838-0137-4E6A-AA3B-D39B4A1A1A28}" Name="IiTunesDetector" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
</TypeLib>
</File>
</Component>
to here
</DirectoryRef>
</Fragment>
</Wix>
Paste the component into your main wxs file in the appropriate Directory location. For example in INSTALLDIR as illustrated in the first WXS file above.
Finally a merged sample showing the main wxs file populated with the extracted component nodes from your heat.exe tool:
<?xml version="1.0"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" UpgradeCode="put-guid-here"
Name="Example Product Name" Version="0.0.1"
Manufacturer="Example Company Name" Language="1033">
<Package InstallerVersion="200" Compressed="yes"
Comments="Windows Installer Package"/>
<Media Id="1" Cabinet="product.cab" EmbedCab="yes"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLDIR" Name="Example">
<Component Id="FP7000-Camera.dll" Guid="*">
<File Id="FP7000-Camera.dll" Source="replace with path to FP7000-Camera.dll"/>
</Component>
<Component Id="cmpD8BB195A00599F06D2FF16982DBAA523" Guid="*">
<File Id="filBDC3CFD8FF09857ADE9793AF172F66E6" KeyPath="yes" Source="SourceDir\wix310-binaries\ITDetector.ocx">
<TypeLib Id="{D6995525-B33A-4980-A106-9DF58570CC66}" Description="ITDetector 1.0 Type Library" HelpDirectory="dirE645D1B018BB48C41BDBE188A129817F" Language="0" MajorVersion="1" MinorVersion="0">
<Class Id="{D719897A-B07A-4C0C-AEA9-9B663A28DFCB}" Context="InprocServer32" Description="iTunesDetector Class" ThreadingModel="apartment" Programmable="yes" SafeForScripting="yes" SafeForInitializing="yes">
<ProgId Id="ITDetector.iTunesDetector.1" Description="iTunesDetector Class">
<ProgId Id="ITDetector.iTunesDetector" Description="iTunesDetector Class" />
</ProgId>
</Class>
<Interface Id="{45D2C838-0137-4E6A-AA3B-D39B4A1A1A28}" Name="IiTunesDetector" ProxyStubClassId32="{00020424-0000-0000-C000-000000000046}" />
</TypeLib>
</File>
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="DefaultFeature" Level="1">
<ComponentRef Id="FP7000-Camera.dll"/>
<ComponentRef Id="cmpD8BB195A00599F06D2FF16982DBAA523"/>
</Feature>
</Product>
</Wix>
If the above is unclear, please try to read this answer: How to run heat.exe and register a dll in wix

WiX Windows service install failure

I am trying to use WiX for my service installation.
This tries to install my service but eventually fails. Do you have any idea?
My service should use a local user account. This account was added as "users which can run window services".
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Product Id="*" Name="MySvcSetup" Language="1033" Version="1.0.0.0" Manufacturer="CMPY" UpgradeCode="aae1a2bc-2ae0-409b-adc4-77cc7fc06a87">
<Package InstallerVersion="200" Compressed="yes" AdminImage="yes" InstallScope="perMachine" InstallPrivileges="elevated" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate />
<Feature Id="ProductFeature" Title="MySvcSetup" Level="1">
<ComponentGroupRef Id="ProductComponents" />
</Feature>
<Property Id="MSIUSEREALADMINDETECTION" Value="1" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="SLBFOLDER" Name="CMPY">
<Directory Id="INSTALLFOLDER" Name="My Service" />
</Directory>
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
<Component Id="ProductComponent" Guid="{15554AD5-F373-453A-88B9-BE1112A6C804}">
<!--TODO: Insert files, registry keys, and other resources here.-->
<File Id="MySvc.exe" Name="MySvc.exe" Source="..\..\..\..\Services\xxx\bin\Release\MySvc.exe" Vital="yes" KeyPath="yes" DiskId="1"/>
<File Id="Encryption.dll" Name="Encryption.dll" Source="..\..\..\..\Services\xxx\bin\Release\Encryption.dll" Vital="yes" KeyPath="no" DiskId="1"/>
<ServiceInstall
Id="MySvc.exe"
Type="ownProcess"
Vital="yes"
Name="MySvc"
DisplayName="My service"
Description="...."
Start="auto"
Account=".\MySvcUser"
Password="CN9P4CvTRo"
ErrorControl="ignore"
Interactive="no">
<util:PermissionEx
ChangePermission="yes"
Delete="yes"
GenericAll="yes"
ReadPermission="yes"
ServiceChangeConfig="yes"
ServiceEnumerateDependents="yes"
ServiceInterrogate="yes"
ServicePauseContinue="yes"
ServiceQueryConfig="yes"
ServiceQueryStatus="yes"
ServiceStart="yes"
ServiceStop="yes"
ServiceUserDefinedControl="yes"
Synchronize="yes"
TakeOwnership="no"
User=".\MySvcUser"
/>
<util:ServiceConfig
FirstFailureActionType="restart"
SecondFailureActionType="restart"
ThirdFailureActionType="restart"
RestartServiceDelayInSeconds="60"
ResetPeriodInDays="0" />
</ServiceInstall>
<ServiceControl Id="MySvc.exe" Start="install" Stop="both" Remove="uninstall" Name="GTCollector" Wait="yes" />
</Component>
</ComponentGroup>
</Fragment>
Try
Account="LocalSystem"
instead of
Account=".\MySvcUser"

WiX not embedding binaries

I'm using WiX to create my products installer. For some reason it's no longer embedding the .exes and .dlls inside the installer. So I have this:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="USERSPECIFIEDDIR" Name="My-app-name" />
</Directory>
and it creates a .msi alongside a folder called My-app-name that contains all .exe and dll files required for the application. if i run the installer from there, it's alright, but if i move the msi elsewhere (without the subdirectory), it errors out because it can't find the files. how can i tell WiX to embed all binaries inside the installer??
in case it helps, here are some other snippets from my wxs. let me know if you need any other information. oh, and i'm using wix directly from visual studio 2008.
<DirectoryRef Id="USERSPECIFIEDDIR">
<Component Id="MainExe" Guid="580F8F15-C06C-49A7-ADDC-56C96580DC0D">
<File Id="MainExe" Name="OrderMonkey.exe" KeyPath="yes" />
</Component>
<Component Id="OMEmailerExe" Guid="3B0AECC3-67E5-40B3-83CB-9B84FE965ED8">
<File Id="OMEmailerExe" Name="OMEmailer.exe" />
</Component>
<Component Id="migradomDLL" Guid="37E1BCAE-EB39-4DF5-88C7-AE74CA5EA171">
<File Id="migradom" Name="MigraDoc.DocumentObjectModel.dll" />
</Component>
<Component Id="migrarenderDLL" Guid="C2910B9E-0B06-467A-853C-7651BE7BD9E4">
<File Id="migrarender" Name="MigraDoc.Rendering.dll" />
</Component>
<Component Id="migrartfDLL" Guid="CEBE4DE9-7CA0-4F48-A8B1-1D46E4E48B66">
<File Id="migrartf" Name="MigraDoc.RtfRendering.dll" />
</Component>
<Component Id="mysqldataDLL" Guid="2E474737-474C-4146-8E67-D3837B5DB862">
<File Id="mysqldata" Name="MySql.Data.dll" />
</Component>
<Component Id="pdfchartingDLL" Guid="7467B6C2-BE38-4283-B179-9FA94C4A087F">
<File Id="pdfcharting" Name="PdfSharp.Charting.dll" />
</Component>
<Component Id="pdfsharpDLL" Guid="39F23E36-BF9C-40C1-8190-6A3554B879BC">
<File Id="pdfsharp" Name="PdfSharp.dll" />
</Component>
<Component Id="sqliteDLL" Guid="B043CF20-8DC2-4A10-AE4B-4721263A111E">
<File Id="sqlite" Name="System.Data.SQLite.dll" KeyPath="yes" />
</Component>
</DirectoryRef>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="414E91FD-7410-492C-9D48-8125C6ECCF0B">
<Shortcut Id="ApplicationStartMenuShortcut"
Name="Order Monkey"
Description="Order Monkey Orders and Quotes"
Target="[USERSPECIFIEDDIR]OrderMonkey.exe"
WorkingDirectory="USERSPECIFIEDDIR" />
<Shortcut Id="ApplicationOfflineStartMenuShortcut"
Name="Order Monkey Offline"
Description="Order Monkey Orders and Quotes"
Target="[USERSPECIFIEDDIR]OrderMonkey.exe"
WorkingDirectory="USERSPECIFIEDDIR"
Arguments="-offline" />
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\OrderMonkey" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<Feature Id='Complete' Level='1' Title='Order Monkey Complete' Description='The complete package' ConfigurableDirectory='TARGETDIR' Display='expand'>
<ComponentRef Id='MainExe' />
<ComponentRef Id='OMEmailerExe' />
<ComponentRef Id='migradomDLL' />
<ComponentRef Id='migrarenderDLL' />
<ComponentRef Id='migrartfDLL' />
<ComponentRef Id='mysqldataDLL' />
<ComponentRef Id='pdfchartingDLL' />
<ComponentRef Id='pdfsharpDLL' />
<ComponentRef Id='sqliteDLL' />
<ComponentRef Id='ApplicationShortcut' />
<ComponentRef Id='AppData' />
</Feature>
Use these elements:
<Package Compressed="yes" InstallScope="perMachine" />
<MediaTemplate EmbedCab="yes" />
Package/#Compressed="yes" creates cabinets instead of loose files. MediaTemplate/#EmbedCab="yes" embeds the default cabinets into the .msi.

Wix Directory Problems

I have two questions about the directories with using fragments in Windows Installer XML.
I got this fragment file from the heat.exe:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="TARGETDIR">
<Directory Id="dir08A07F5561FBEB6B9772467C730F6445" Name="Test" />
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="InstallationFiles">
<Component Id="cmp071F7F8F6B6027C8D2841272FE526A2B" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{CCCB70AC-29F5-4DAA-B03E-1A2266649AB6}">
<File Id="fil63087E96FFB31F9E39B642CE8914F48B" KeyPath="yes" Source="SourceDir\dmedv.jpg" />
</Component>
<Component Id="cmpAE6CBEDA75641CF25BA9996AEB74A0DE" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{F5DABCAB-95D1-4197-A49F-E5F052A8E7EF}">
<File Id="filD27F2F6B26F5C14563865FE6C2AD5D50" KeyPath="yes" Source="SourceDir\Files.txt" />
</Component>
<Component Id="cmp25C5EADB5C0A9E779D20EC7B77BD42B0" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{E301B04A-6EA5-496B-A58A-8898110BE57C}">
<File Id="fil7C91C48D9AA0F2FE0EB37A21F108037F" KeyPath="yes" Source="SourceDir\readme.txt" />
</Component>
<Component Id="cmpD387AB4B40EDF14BF271ADDA7B71D2B7" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{6AF61DF4-32D0-4E7C-95B8-1DB9E7409029}">
<File Id="fil966691BA382AFC9343430FE162643432" KeyPath="yes" Source="SourceDir\readme1.txt" />
</Component>
<Component Id="cmpB86212407C1BEA12838C8C7B20495E9F" Directory="dir08A07F5561FBEB6B9772467C730F6445" Guid="{921E971E-E224-464C-9FBC-FBC5F78B3E5B}">
<File Id="fil61CD8EF43EA29DF58454E9A19F8C1EF9" KeyPath="yes" Source="SourceDir\readme2.txt" />
</Component>
<Component Id="cmpE4143B48FF854AE84F6054D4636FDE81" Directory="dir0ADF7E89B935DD39670130B4DC1D670E" Guid="{6F248718-93DD-4850-A18E-BD7079F738D5}">
<File Id="fil03847B355B6AADE5E4E04D143C92BC67" KeyPath="yes" Source="SourceDir\Test2\dmedv2.jpg" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<DirectoryRef Id="dir08A07F5561FBEB6B9772467C730F6445" />
</Fragment>
<Fragment>
<DirectoryRef Id="dir0ADF7E89B935DD39670130B4DC1D670E" />
</Fragment>
<Fragment>
<DirectoryRef Id="dir08A07F5561FBEB6B9772467C730F6445">
<Directory Id="dir0ADF7E89B935DD39670130B4DC1D670E" Name="Test2" />
</DirectoryRef>
</Fragment>
</Wix>
and I have this wix installer file:
<?xml version='1.0' encoding='windows-1252'?>
<?define ProductVersion="1.0.0.0"?>
<?define ProductName="DMServices Installer"?>
<?define Manufacturer="DM EDV- und Bürosysteme GmbH"?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:iis='http://schemas.microsoft.com/wix/IIsExtension'>
<Product Name="$(var.ProductName)" Id='BB7FBBE4-0A25-4cc7-A39C-AC916B665220' UpgradeCode='8A5311DE-A125-418f-B0E1-5A30B9C667BD'
Language='1033' Codepage='1252' Version="$(var.ProductVersion)" Manufacturer="$(var.Manufacturer)">
<Package Id='*' Keywords='Installer'
Description="DMService Installer Setup"
Manufacturer='DM EDV- und Bürosysteme GmbH'
InstallerVersion='100' Languages='1033' Compressed='yes' SummaryCodepage='1252' />
<Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
<Property Id='DiskPrompt' Value="the man" />
<PropertyRef Id="NETFRAMEWORK35"/>
<Condition Message='This setup requires the .NET Framework 3.5.'>
<![CDATA[Installed OR (NETFRAMEWORK35)]]>
</Condition>
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder'>
<Directory Id='DM' Name='DM EDV'>
<Directory Id='INSTALLDIR' Name='DMServices'>
</Directory>
</Directory>
</Directory>
</Directory>
<Feature Id='InstallationFiles' Title='InstallationFiles' Level='1'>
<ComponentGroupRef Id='InstallationFiles' />
</Feature>
</Product>
</Wix>
So far.
Now when i generate this files to wixobj, the compiler shows errors because the files can't be found. The files are in a directory called "Test". And in the file it's named SourceDir.
For a lil workaround i can copy the test directory and call it SourceDir ;-). So my Setup will be created.
How can I do it without a second directory?
EDIT: Problem is done.
Now i install my package. But whatever i do, the files will be installed to C:\Test.
But I want it to be installed in my Program Files Directory.
In many examples i can do it, like in the file, but i have to know the guids.
But we do wix for getting all files from one directory, without to put our hands on.
So how to install the files into the program files directory?
Take a closer look at -dr switch of heat.exe. You can put the necessary directory reference there. So, define your directory structure in the main file as you do now, and provide correct directory ID to heat.exe.
UPDATE:
Ok, the following works for me. The main directory structure:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INSTALLLOCATION" Name="My folder">
<Directory Id="WebsiteFolder" Name="Website">
...
</Directory>
</Directory>
</Directory>
The Feature references the ComponentGroup:
<Feature Id="ProductFeature" Title="!(loc.ProductFeature.Title)" Level="100">
...
<ComponentGroupRef Id="WebsiteFolderComponentGroup"/>
...
</Feature>
The heat.exe generates the following fragment:
<Fragment>
<DirectoryRef Id="WebsiteFolder">
<Component Id="cmp1" Guid="GUID-GOES-HERE">
<File Id="fil1" KeyPath="yes" Source="$(var.WebsiteFolderSource)\Default.aspx" />
</Component>
<Component Id="cmp2" Guid="GUID-GOES-HERE">
<File Id="fil2" KeyPath="yes" Source="$(var.WebsiteFolderSource)\default.css" />
</Component>
<Directory Id="dir1" Name="App_Browsers">
<Component Id="cmp3" Guid="GUID-GOES-HERE">
<File Id="fil3" KeyPath="yes" Source="$(var.WebsiteFolderSource)\App_Browsers\Form.browser" />
</Component>
</Directory>
<Directory Id="App_Config" Name="App_Config">
<Component Id="cmp4" Guid="GUID-GOES-HERE">
<File Id="fil4" KeyPath="yes" Source="$(var.WebsiteFolderSource)\App_Config\ConnectionStrings.config" />
</Component>
</Directory>
<Directory Id="bin" Name="bin">
<Component Id="cmp5" Guid="GUID-GOES-HERE">
<File Id="fil5" KeyPath="yes" Source="$(var.WebsiteFolderSource)\bin\MySystem.Web.UI.dll" />
</Component>
<Component Id="cmp6" Guid="GUID-GOES-HERE">
<File Id="fil6" KeyPath="yes" Source="$(var.WebsiteFolderSource)\bin\Another.dll" />
</Component>
...
</Directory>
...
</Directory>
...
<ComponentGroup Id="WebsiteFolderComponentGroup">
<ComponentRef Id="cmp1" />
<ComponentRef Id="cmp2" />
<ComponentRef Id="cmp3" />
<ComponentRef Id="cmp4" />
...
</ComponentGroup>
And finally, the heat command which generates necessary output looks like this (Nant sample):
<exec program="heat.exe" verbose="true" basedir="${paths.source}">
<arg line='dir "${paths.dist.website}"'/><!-- Notice the quotes inside the attributes -->
<arg line='-srd'/>
<arg line='-dr WebsiteFolder'/>
<arg line='-cg WebsiteFolderComponentGroup'/>
<arg line='-out "${paths.harvest}\website.wxs"'/>
<arg line='-ke -sfrag -scom -sreg -gg'/>
<arg line='-var var.WebsiteFolderSource'/>
</exec>
These snippets contain enough information to understand how it all works. Play with heat.exe switches to find out the combination you need. Good luck!
In case people like me still looking for clarification: The <DirectoryRef Id="WebsiteFolder"> in the heat fragment is important, it is the reference to where the fragment files should be installed. If you have multiple fragments and want to place it in different locations, the DirectoryRef is the key.

Resources