Wix Toolset - Conditional installation based on TargetDir - installation

I have to install an application with several folders. If my Targetdir is not a default path, say [ProgramFilesFolder]\[Manufacturer]\[ProductName], all the folders can be installed in that Targetdir. Otherwise, some folders, say "Bin" and "AddIns", should be installed in a different path, say [CommonAppDataFolder]\[Manufacturer]\[ProductName].
I would like to avoid a C# or C++ custom action. Instead, I would try to use something like a Type51 CA. Is it possible?
I wrote the following code:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="CommonAppDataFolder">
<Directory Id="dir_B1AA3D43_E9A6_4283_81B7_D24FDA02FEC4" Name="List SpA">
<Component Id="comp_dir_B1AA3D43_E9A6_4283_81B7_D24FDA02FEC4" Guid="AB641867-3F7A-4A74-9923-03E71FC6851C" KeyPath="yes" Transitive="yes">
<Condition><![CDATA[TARGETDIR = "[ProgramFilesFolder][Manufacturer]\[ProductName]"]]></Condition>
</Component>
<Directory Id="dir_9D19AF5A_89F2_498D_AC25_B48F2C16BFF5" Name="TestApplication">
<Directory Id="dir_BinID2" Name="Bin">
<Component Id="comp_dir_BinID2" Guid="2E369F78-D321-4828-A2A8-E958E57B910B" KeyPath="yes">
<Condition><![CDATA[TARGETDIR = "[ProgramFilesFolder][Manufacturer]\[ProductName]"]]></Condition>
</Component>
<Component Id="comp_38B4C656_8291_4C45_98D5_A46908E33723" Guid="61DB01E5-6D6B-48AE-862A-3E2C18D546E7" Permanent="no" SharedDllRefCount="no" Transitive="no">
<File Id="_14E547A6_A0C5_441E_A294_59AD578B99DF" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="TestApplication.exe" Source="..\Debug\TestApplication.exe" KeyPath="yes" />
</Component>
</Directory>
<Directory Id="dir_AddInsID2" Name="AddIns">
<Component Id="comp_dir_AddInsID2" Guid="0CA9B394-77E5-48A9-85A8-F6FF0737C499" KeyPath="yes" Transitive="yes">
<Condition><![CDATA[TARGETDIR = "[ProgramFilesFolder][Manufacturer]\[ProductName]"]]></Condition>
</Component>
<Component Id="comp_6DCECE0A_AE42_49F1_BA42_B23EF2A50E44" Guid="216B87DA-4F28-4DC9-85AA-E3801E2C0A8B" Permanent="no" SharedDllRefCount="no" Transitive="no">
<File Id="_D271147D_4984_4C55_9660_33F4617957F5" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="ClosePromptCA.CA.dll" Source="..\ClosePromptCA\bin\Debug\ClosePromptCA.CA.dll" KeyPath="yes" />
</Component>
<Component Id="comp_98FCDB58_9307_44D7_9CFE_3F1DB41BD779" Guid="B8368238-B1B6-4D78-BC21-0D26B84E4938" Permanent="no" SharedDllRefCount="no" Transitive="no">
<File Id="_75368244_3285_47FD_BBC8_60CEC98755B4" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="Microsoft.Deployment.WindowsInstaller.dll" Source="..\ClosePromptCA\bin\Debug\Microsoft.Deployment.WindowsInstaller.dll" KeyPath="yes" />
</Component>
</Directory>
</Directory>
</Directory>
</Directory>
<Directory Id="dir_AddInsID" Name="AddIns">
<Component Id="comp_dir_AddInsID" Guid="0219CA84-4787-4737-99E7-95ACD8E0846D" KeyPath="yes" Transitive="yes">
<Condition><![CDATA[TARGETDIR <> "[ProgramFilesFolder][Manufacturer]\[ProductName]"]]></Condition>
</Component>
<Component Id="comp_23612F37_B27B_49E2_9FB6_9D2FA3654FB1" Guid="290915D5-38E9-4540-B7B7-7BBC27D96CA0" Permanent="no" SharedDllRefCount="no" Transitive="no">
<File Id="_0193CC70_4486_4226_BE10_4F9C927DD5F2" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="ClosePromptCA.CA.dll" Source="..\ClosePromptCA\bin\Debug\ClosePromptCA.CA.dll" KeyPath="yes" />
</Component>
<Component Id="comp_41AA7508_C12C_46CC_A383_7088A8500898" Guid="5CACA050-A59C-44DF-BF5A-8694D547D937" Permanent="no" SharedDllRefCount="no" Transitive="no">
<File Id="_362C000D_A631_4E5D_9288_FB623CD999E3" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="ClosePromptCA.XML" Source="..\ClosePromptCA\bin\Debug\ClosePromptCA.XML" KeyPath="yes" />
</Component>
</Directory>
<Directory Id="dir_BinID" Name="Bin">
<Component Id="comp_dir_BinID" Guid="99ADE113-162C-4299-8A3E-EDCE1FB838DE" KeyPath="yes" Transitive="yes">
<Condition><![CDATA[TARGETDIR <> "[ProgramFilesFolder][Manufacturer]\[ProductName]"]]></Condition>
</Component>
<Component Id="comp_FD9AB046_9110_4BFD_865F_D919F02D7B2B" Guid="5690A672-809F-47D1-938E-EAC0E18A0685" Permanent="no" SharedDllRefCount="no" Transitive="no">
<File Id="_89CFA2F5_2ED8_43C8_890E_A791BF9E16BB" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="TestApplication.exe" Source="..\Debug\TestApplication.exe" KeyPath="yes" />
</Component>
</Directory>
<Directory Id="dir_DocsID" Name="Docs">
<Component Id="comp_ECF1F68E_B9B8_49DD_9631_88E0722F8FCC" Guid="CB3861D1-6101-4F3C-94DD-AEE3EE74C217" Permanent="no" SharedDllRefCount="no" Transitive="no">
<File Id="_9CE2FA29_27F8_4C00_B22D_A99AA59E5B2D" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="ReadMe.txt" Source="..\TestApplication\ReadMe.txt" KeyPath="yes" />
</Component>
</Directory>
<Directory Id="dir_LogsID" Name="Logs">
<Component Id="comp_B81BDCFD_B947_49C0_A07F_C1546D02E7AF" Guid="CE5206CE-E651-42C6-88AF-B7D83A9318C2" Permanent="no" SharedDllRefCount="no" Transitive="no">
<File Id="_FF44C1E7_C235_47B9_BA01_C797D13EBA7D" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="trace.log" Source="bin\Debug\trace.log" KeyPath="yes" />
</Component>
</Directory>
<Directory Id="dir_TemplateID" Name="Template">
<Component Id="comp_8F946A00_3D1E_44C5_A288_E0662FFE253D" Guid="8C0A501B-15D4-46B1-91C3-23E5035CB145" Permanent="no" SharedDllRefCount="no" Transitive="no">
<File Id="_39F2BD37_C7FE_4CF1_98C7_1E7BFC1B4873" DiskId="1" Hidden="no" ReadOnly="no" TrueType="no" System="no" Vital="yes" Name="ReadMe.txt" Source="..\..\CrashReportManager\ReadMe.txt" KeyPath="yes" />
</Component>
</Directory>
</Directory>
Everything looks like right, but Wix ignore the Conditions. Wix installs my components even if the conditions are false!
What is the reason?

You can automatically harvest the both locations and set each location to different directory path.
Heat - http://wixtoolset.org/documentation/manual/v3/msbuild/task_reference/heatdirectory.html
Directory flag is the harvesting directory.
DirectoryRefId is where to deploy on target machine.
This is the most common way to do that.

You can address the special folder by using its special folders ID, a list of possible IDs can be found at msdn "System Folder Properties".
The following code sample will show you how the directory structure for your case could look like:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="MyProgramFilesFolder" Name="Manufacturer">
<Directory Id="INSTALLLOCATION" Name="InstallLocation">
<!-- Your "all the folders can be installed in that Targetdir"
can be inserted here -->
</Directory>
</Directory>
</Directory>
<Directory Id="CommonAppDataFolder">
<Directory Id="ProgramFileFolder" Name="Manufacturer">
<!--Your " 'Bin' and 'AddIns' Folders"-->
<Directory Id="AddinFolder" Name="AddIns">
<Component Id="YourFile" Guid="{SOME GUID}">
<!-- Just a file below your folder -->
<File Id="YourFile"
Name="FileName"
Source="Source of the file"/>
</Component>
</Directory>
</Directory>
</Directory>
The Code above could be used without a condition.
If you really like to install them to different folders based on Conditions, You need to duplicate your Components.
Here is a sample Condition below one of the Components:
<Component Id="YourFile" Guid="{SOME GUID}">
<Condition>YourCondition</Condition>
<!-- Just a file below your folder -->
<File Id="YourFile"
Name="FileName"
Source="Source of the file"/>
</Component>

Related

Wix Toolset - how to install a file to a completely different directory and not as a root subdirectory?

For my application, most of the files need to be installed to a directory in ProgramFiles, and one other file needs to be installed in a directory in AppData/Local.
Here is an example of what I have so far:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="Folder1" />
</Directory>
</Directory>
</Fragment>
<Fragment>
<ComponentGroup Id="AppID" Directory="INSTALLFOLDER">
<Component Id="AppID">
<File Source="$(var.myApp.TargetPath)" />
</Component>
<Component Id="OtherFile" Guid="INSERT-GUID_HERE">
<File Id='OtherFile' Name='OtherFile' Source="otherfile" KeyPath='yes' />
</Component>
<Component Id="CopyId">
<CopyFile Id="CopyId" FileId="OtherFile"
DestinationDirectory="LocalAppDataFolder" />
</Component>
</Fragment>
I've tried to copy the other file to AppData/Local but this won't compile and gives the error:
Unresolved reference to symbol 'Directory:LocalAppDataFolder' in section 'Fragment:'
Ideally, I want the other file to be in directory in AppData/Local, and not in ProgramFiles at all.
Application Launch: Consider doing file-copying on application launch instead of as part of the setup. Easier to implement, debug and change as you need to.
Fix: Try just adding this directly under the TARGETDIR element. This ensures that the standard directory LocalAppDataFolder is part of the compiled MSI file's Directory table:
<Directory Id="LocalAppDataFolder" Name="AppData">
Alternatively, here is a larger mock-up:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="SetupProject2" />
</Directory>
<Directory Id="LocalAppDataFolder" Name="AppData">
<Directory Id="AppRootDirectory" Name="MyApplication">
<Component Id="Test" Feature="ProductFeature" Guid="{11111111-1111-1111-1111-A73067A1AE95}">
<RemoveFolder Id="AppRootDirectory" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\Something" Name="Flag" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</Directory>
</Directory>
</Directory>

ICE91 Wix in perMachine Installer

I am trying to make a perMachine Installer that is able to create files and folders in the PersonalFolder and LocalAppDataFolder of each user. I am getting always the warning message "warning LGHT1076: ICE91: ..." as listed below. When I install as an Administrator the file and folder is created despite the warning, but when I try the installer as standard user no file and no folder is created on the user profile. What could be the solution?
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="PFInstallDir" Name="Example">
<Component Id="ApplicationFiles" Guid="12345678-1234-1234-1234-222222222222">
<File Id="ApplicationFile1" Source="notepad.exe"/>
</Component>
</Directory>
</Directory>
<Directory Id="CommonFilesFolder">
<Directory Id="CFInstallDir" Name="Example">
<Component Id="CommonApplicationFiles" Guid="12345678-1234-1234-1234-222222222223">
<File Id="ApplicationFile2" Source="notepad.exe"/>
</Component>
</Directory>
</Directory>
<Directory Id="CommonAppDataFolder">
<Directory Id="CAInstallDir" Name="Example">
<Component Id="CommonAppDataApplicationFiles" Guid="12345678-1234-1234-1234-222222222224">
<File Id="ApplicationFile3" Source="notepad.exe"/>
</Component>
</Directory>
</Directory>
<Directory Id="PersonalFolder">
<Directory Id="InstallDirPersonal" Name="ExampleDocs">
<Component Id="ApplicationPersonalFiles" Guid="12345678-1234-1234-1234-222222222225">
<CreateFolder />
<RemoveFolder Id="RemoveMyExampleDir1" On="uninstall" Directory="InstallDirPersonal"/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\Documents">
<RegistryValue Name="MainExe" Value="1" KeyPath="yes" Type="integer" />
</RegistryKey>
<File Id="Notepad.MyExe"
Source="notepad.exe" DiskId="1" Checksum="yes">
</File>
</Component>
</Directory>
</Directory>
<Directory Id="LocalAppDataFolder" Name="AppData">
<Directory Id="InstallDirAppDataPersonal" Name="ExampleLocals">
<Component Id="ApplicationPersonalDataFiles" Guid="12345678-1234-1234-1234-222222222226">
<CreateFolder />
<RemoveFolder Id="RemoveMyExampleDir" On="uninstall" Directory="InstallDirAppDataPersonal"/>
<RegistryKey Root="HKCU" Key="Software\MyCompany\Example">
<RegistryValue Name="MainExe" Value="1" KeyPath="yes" Type="integer" />
</RegistryKey>
<File Id="Notepad.MyExe1"
Source="notepad.exe" DiskId="1" Checksum="yes">
</File>
</Component>
</Directory>
</Directory>
</Directory>
<Feature Id="DefaultFeature" Level="1">
<ComponentRef Id="ApplicationFiles"/>
<ComponentRef Id="CommonApplicationFiles"/>
<ComponentRef Id="CommonAppDataApplicationFiles"/>
<ComponentRef Id="ApplicationPersonalDataFiles"/>
<ComponentRef Id="ApplicationPersonalFiles"/>
</Feature>
</Product>
-- Build started: Project: SetupProjectPerUsrMachine, Configuration: Debug x86 --
warning LGHT1076: ICE91: The file 'Notepad.MyExe' will be installed to the per user directory 'InstallDirPersonal' that doesn't vary based on ALLUSERS value. This file won't be copied to each user's profile even if a per machine installation is desired.
warning LGHT1076: ICE91: The file 'Notepad.MyExe1' will be installed to the per user directory 'InstallDirAppDataPersonal' that doesn't vary based on ALLUSERS value. This file won't be copied to each user's profile even if a per machine installation is desired.
Problem solved!
http://www.installworld.com/index.php?option=com_content&do_pdf=1&id=146
"If the resource must be copied to each user’s profile, then add functionality to your package to do this. To achieve this, add a current user registry key (i.e., just a dummy registry key) and make this registry key the key path of the component which contains the resource. This means that the resource will be copied to the next user’s profile as part of the MSI self healing mechanism, provided that advertised entry points exist for the product."
http://blog.bittercoder.com/2007/02/28/wix-shortcuts/
<Component Id="StandAloneApplication" Guid="C8D5DB05-2D68-40e8-88D1-EF5BEA18DBE1">
<File Id="SomeCompanySomeProductHostApp"
Name="SomeCompany.SomeProduct.HostApp.exe"
DiskId="1"
Source="....buildSomeCompany.SomeProduct.HostApp.exe"
Vital="yes">
<Shortcut Advertise="yes"
Id="SomeCompanySomeProductHostAppShortcut"
Directory="ProgramMenuDir"
Name="My Product"
WorkingDirectory="INSTALLDIR"
Description="SomeProduct Application"
Icon="HostAppShortcutIcon.exe">
<Icon Id="HostAppShortcutIcon.exe"
SourceFile="....buildSomeCompany.SomeProduct.HostApp.exe" />
</Shortcut>
</File>
</Component>

custom event not executing while first time setup using wix installer

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>

How to add to PATH variable with a WIX for everyone: admin and standard users?

I'm trying to set a global PATH environment variable along with my custom variable using WIX installer. I do the following:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="COMPANYFOLDER" Name="my company">
<Directory Id="INSTALLFOLDER" Name="app name">
<!-- blah blah -->
</Directory>
</Directory>
</Directory>
</Directory>
<DirectoryRef Id="TARGETDIR">
<!-- Add environment variables -->
<Component Id="idPathEnvSys" Guid=".....">
<Environment Id="idEnvPathSys" Name="PATH" Action="set" Part="last" System="yes" Value="[INSTALLFOLDER]" Permanent="no"/>
</Component>
<Component Id="idPathEnvUsr" Guid=".....">
<Environment Id="idEnvPathUsr" Name="PATH" Action="set" Part="last" System="no" Value="[INSTALLFOLDER]" Permanent="no"/>
</Component>
<Component Id="EnvVarsSys" Guid=".....">
<Environment Id="idEnvMyPathSys" Name="MYPATH" Value="[INSTALLFOLDER]" Part="all" System="yes" Action="set" Permanent="no" />
</Component>
<Component Id="EnvVarsUsr" Guid="....">
<Environment Id="idEnvMyPathUsr" Name="MYPATH" Value="[INSTALLFOLDER]" Part="all" System="no" Action="set" Permanent="no" />
</Component>
</DirectoryRef>
<Feature Id="ProductFeature" Title="!(loc.ProductName)" Level="1">
<!-- main components first -->
<ComponentRef Id='idPathEnvSys' />
<ComponentRef Id='idPathEnvUsr' />
<ComponentRef Id='EnvVarsSys' />
<ComponentRef Id='EnvVarsUsr' />
</Feature>
It compiles just fine but when I install it, for some reason it only adds the system variable. So in other words, if I run a command prompt as admin and do set path it shows my PATH addition. But when I do the same from a regular user account, it is not there.
What am I missing?

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