How to create a directory in Wix on D: - wix

Using WiX 3.7, I have figured out how to create a folder in the root. This
<Directory Id="ReceivedFilesDir" Name="ReceivedFiles">
<Component Id="ReceivedFilesComponent" Guid="84A264EF-2BC5-41e3-8124-2CA10C2805DB">
<CreateFolder Directory="ReceivedFilesDir">
<Permission User="Administrators" GenericAll="yes" />
</CreateFolder>
</Component>
</Directory>
creates a folder C:\ReceivedFiles
I want it to be at D:\ReceivedFiles instead.
How do I achieve that?
I have played around with the DiskId attribute, but it did not seem to do anything.
Also, I don't want to change the whole installation folder, the ordinary part of the installation will still be below C:\Program Files (x86). I just want to create additional folders on D:.

Here's the solution we used for basically the same need:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="CROOT" Name="root">
<Directory Id="MY_CROOT" Name="PLACE_HOLDER">
<!-- Define C directory -->
</Directory>
</Directory>
<Directory Id="TROOT" Name="root">
<Directory Id="MY_TROOT" Name="PLACE_HOLDER">
<!-- Define T directory -->
</Directory>
</Directory>
</Directory>
<CustomAction Id="SetCRootDirectory" Property="CROOT" Value="C:\" />
<CustomAction Id="SetTRootDirectory" Property="TROOT" Value="T:\" />
<InstallExecuteSequence>
<Custom Action="SetCRootDirectory" Before="AppSearch" />
<Custom Action="SetTRootDirectory" Before="AppSearch" />
</InstallExecuteSequence>
You could add this to a UI sequence if your install takes advantage of that. You may need to set the Custom Action Before values to some other value given how all the rest of your sequences are defined. Hope this is useful.

Related

How to set Wix Property from UI which user can change during installation?

I have Wix Code which simply installs a txt file in the given location
The target location is enclosed in a Property THISONE
<Fragment>
<Property Id="THISONE" Value="C:\MyFolder"/>
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='APPLICATIONFOLDER' ComponentGuidGenerationSeed="{75266e3e-3781-47e3-ac29-46a2d90548f9}">
<Directory Id='MyFolder' Name='MyFolder'/>
</Directory>
</Directory>
<SetDirectory Id='APPLICATIONFOLDER' Value='[THISONE]' />
</Fragment>
<Fragment>
<Component Id="Component1" Directory="MyFolder" Win64="yes">
<File Id="FirstFile.txt"/>
</Component>
</Fragment>
I want a minimal UI with maybe just a textbox where I can edit the property value so that I can change the target installation file path.
How can I achieve that ?
Thanks in Advance
The WiXUIInstallDir may be what you want, as described in the WiX documentation.
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='APPLICATIONFOLDER' ComponentGuidGenerationSeed="{75266e3e-3781-47e3-ac29-46a2d90548f9}">
<Directory Id='MyFolder' Name='MyFolder'/>
</Directory>
</Directory>
<Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER" />
<UIRef Id="WixUI_InstallDir" />
You must set the value of the property WIXUI_INSTALLDIR to the value of the ID of the directory you want the user to be able to specify the location of, as shown above. This is then passed to the WixUI_InstallDir dialog. Note that the directory ID must all be uppercase.
If you're using Visual Studio, you'll need to add a reference to WixUIExtension to your WiX project. See here for more details.

Calling custom exe in ExitDialog

I’m beginning with WiX and I have some trouble to customize ExitDIalog.
At first what I want:
I want to create a setup for my application
After setup I want to propose 2 choices :
Launch application (application.exe newly installed)
Launch an optional setup (my application require to install some drive depending of user’s camera)
The optional setup is a .exe. It should be placed next to setup.msi but no copied in my application folder.
I created directories :
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="$(var.compagny)"/>
</Directory>
<Directory Id="DesktopFolder" SourceName="Desktop"/>
<Directory Id="ProgramFilesFolder">
<Directory Id="COMPAGNYFOLDER" Name="$(var.compagny)">
<Directory Id="INSTALLFOLDER" Name="$(var.product)">
<Directory Id="fr" Name="fr"/>
</Directory>
</Directory>
</Directory>
</Directory>
</Fragment>
How can I add a reference to my .exe ? I did :
<Component Id="ProductComponent" Guid="{2C26B191-6654-4405-8E78-F8B6EFEDC9FC}" Directory="INSTALLFOLDER">
<File Id="uEye64_47100_WHQLexe" Source="./Resources/uEye64_47100_WHQL.exe" KeyPath="yes" Checksum="yes" Compressed="no" Vital="no"/>
</Component>
But the uEye64_47100_WHQL.exe file is copied in INSTALLFOLDER (I don't want) and the setup mix the path with [application]/bin/Release (don't know with). In the log file there is :
Failed to open the file:C:\dev\MyApplication\main\SetupProject\bin\Release\MyCompagny\MyProduct\uEye64_47100_WHQL.exe for computing its hash. Error:3
And I call the .exe like this (this file require elevated privileges)
<!-- Set checkbox for launch install uEye -->
<Property Id="WIXUI_EXITDIALOGUEYECHECKBOXTEXT" Value="Launch install uEye"/>
<CustomAction Id="SetExecUEye" FileKey="uEye64_47100_WHQLexe" ExeCommand="" Return="asyncNoWait" Impersonate="no" Execute="deferred"/>
<UI>
<UIRef Id="WixUI_Custom"/>
<Publish Dialog="MyExitDialog"
Control="Finish"
Event="DoAction"
Value="SetExecUEye">WIXUI_EXITDIALOGUEYECHECKBOX = 1 and NOT Installed</Publish>
</UI>
How should I define my uEye64_47100_WHQL.exe to be called after setup but no copied in INSTALLFOLDER ?
If you don't want to copy file to install location, just run it, you can include it as Binary source instead of component. This way, it is packed in installer, but is not deployed on installation (probably to some temp folder only).
<Binary Id="uEye64_47100_WHQLexe" SourceFile="./Resources/uEye64_47100_WHQL.exe" />
<CustomAction Id="InstalluEye64exe" BinaryKey="uEye64_47100_WHQLexe" ExeCommand="" Execute="deferred" Return="ignore" Impersonate="no"/>

How can I pass an folder path to an custom action ExeCommand

We have the following folder structure in our wix declaration:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder" Name="$(var.ProgramFilesFolder)">
<Directory Id="ManufacturerFolder" Name="$(var.Manufacturer)">
<Directory Id="APPLICATIONFOLDER" Name="$(var.AppFolderName)">
// further folders or files
</Directory>
</Directory>
</Directory>
</Directory>
Target: We want to delete the APPLICATIONFOLDER on an uninstall. RemoveFolderEx and RemoveFolder will not work for this task, so we need to use a CustomAction. The CustomAction:
<CustomAction Directory="ManufacturerFolder" ExeCommand='/c rmdir /S /Q "[APPLICATIONFOLDER]"' Id="RemoveAppFolder" Execute="deferred" Impersonate="no" Return="ignore"/>
This custom action deletes nothing. What is the correct declaration?
Why Don't you do it like this?
It must work on uninstall.
For example just place it in component where you have shortcut creation.
<RemoveFolder
Id="rem_folder"
Directory="APPLICATIONFOLDER"
On="uninstall"/>
<RemoveFile Id="rem_files"
On="uninstall"
Directory="APPLICATIONFOLDER"
Name="*.*"/>

WIX Writing user data into config file

I would like to ask a WiX installer question. I created a working installer that does many things already. I still need to ask the user for some specific information (the GUI is already done), and write it into a config file.
From this snippet, I think I could use the INSTALLFOLDER global variable.
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="IISROOT" Name='WebDir'>
<Directory Id="INSTALLFOLDER" Name="IVRDesigner">
</Directory>
</Directory>
</Directory>
This is the part, when I want to use that. This code is taken from a tutorial, should work well, if the source tag is filled properly. The ..\src\Web.config is just a dummy, so the code can compile. The default installed path for the web.config file will be C:\inetpub\wwwroot\myfolder, but the user can change this during the installation.
The question is: how could I use the global variable here, or what kind of solution, do you recommend?
Thanks in advance.
<Component Id="ConfigureWebConfig" Guid="*">
<File Id="Web.config" Name="MyConfigfile" Vital="yes" KeyPath="yes"
Source="..\src\Web.config" />
<util:XmlFile Id="AppConfigSetConnStr" Action="setValue"
Permanent="yes" File="[#Web.config]"
ElementPath="/configuration/connectionStrings/add[\[]#name='GeoIVRDesignerEntities'[\]]" Name="connectionString"
Value="data source=[DBSERVER];" />
</Component>
Under the Product tag I would add the properties that I want to be able to change in the config file like this:
<Property Id="BUILDRAN" Value="INSTALLER"/>
<Property Id="EMAIL_RECEIPIANT" Value="thisisnotme#notthere.com" />
Create the Fragment for the Directory Structure
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir" >
<Directory Id="BasicDir" Name="Dev_Home">
<Directory Id="BasicDirSuite" Name="TEST">
<Directory Id="INSTALLFOLDER" Name="DesignPatterns" />
</Directory>
</Directory>
</Directory>
</Fragment>
Declare another Fragment for the transformation of the config file
<util:XmlFile Id="AppConfigSetBuildRan" Action="setValue" Permanent="yes" File="[#App.config]"
ElementPath="/configuration/applicationSettings/MyApp.Properties.Settings/setting[\[]#name='BuildRan'[\]]/value"
Value="[BUILDRAN]" />
<util:XmlFile Id="AppConfigSetEmail" Action="setValue" Permanent="yes" File="[#App.config]"
ElementPath="/configuration/applicationSettings/MyApp.Properties.Settings/setting[\[]#name='TestValue'[\]]/value"
Value="[EMAIL_RECEIPIANT]" />
If you want you can create your own custom dialog to let the End user enter values for the properties [BUILDRAN] && [EMAIL_RECEIPIANT], or you could use the command line and set the properties with parameters
msiexec /i My.msi BUILDRAN=SuperDebug EMAIL_RECEIPIANT=you#home.com

WiX installer: Installing to Appdata - Error ICE38, ICE64 & ICE91

I've been banging my head against this one for a while and I've finally caved (after a lot of searching) and have come to stack overflow for help.
As the title suggests I am trying to create an installer that can carry out a per-user install without requiring any elevated permissions.
However the following code generates a lot of ICE38 and ICE64 errors, as well as ICE91 warnings at compile time.
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="AppDataFolder">
<Directory Id="AppRootDirectory" Name="[Manufacturer]">
<Directory Id="INSTALLFOLDER" Name="[ProductName]" />
</Directory>
</Directory>
</Directory>
<Feature Id="ProductFeature" Title="ATestProject" Level="1">
<ComponentGroupRef Id="modules" />
</Feature>
"modules" refers to the contents of a heat.exe generated .wxs file whose components install directory is "INSTALLFOLDER"
The solutions available on the internet indicate a lot of editing of my modules.wxs file in order to get this to work, this is not acceptable - There are well over 1000 files in this release process and anything that cannot be automated (done on the command line at build time or with a script) is entirely out of the question.
Thanks in advance!
You can set up a per-user install that, by default on windows 7 and later, installs to %localappdata%\Programs by doing the following;
<Property Id="ALLUSERS" Secure="yes" Value="2"/>
<Property Id="MSIINSTALLPERUSER" Secure="yes" Value="1" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="AppRootDirectory" Name="Manufacturer">
<Directory Id="INSTALLFOLDER" Name="ProductName" />
</Directory>
</Directory>
</Directory>
<!-- ... -->
<!-- ... -->
<Feature Id="ProductFeature" Title="ATestProject" Level="0">
<ComponentGroupRef Id="modules" />
</Feature>
Basically Setting the two properties at the top configures the installer to a "per user" install, which is UAC friendly and does not need elevated permissions.
See This for a detailed explanation.
Please also note that ProgramFilesFolder becomes %localAppData%/programs - Microsoft's default storage place for per-user applications and installing to a users profile rather than C:\Program Files (x86)\