I want to know how to set the installation path of the copied files by using properties. So, please let anyone explain the answer.
If You are using a bootstrapper, You can define a variable like that:
<Variable Name="INSTALLFOLDER"
bal:Overridable="yes"
Type="string"
Value="[ProgramFilesFolder]"/>
This variable has the ProgramFilesFolder as default, but it can be overwritten.
You can set it either in Process.Start (when the bootstrapper is called by an EXE) as parameter or - if You have programmed Your own bootstrapper-GUI - You set the variable in the GUI-code.
In the MsiPackage You must set the variable into the MsiProperty INSTALLLOCATION, which You define in the Product.wxs of the MSI-project.
Hope it helps You.
<MsiPackage Id='SetupPackage'
SourceFile='.\Resources\Setup.msi'
Permanent='no'
Cache='yes'
DisplayInternalUI='no'
Vital='yes'
Compressed='yes'
EnableFeatureSelection='no'
DisplayName='MySetup'>
<MsiProperty Name="INSTALLLOCATION"
Value="[INSTALLFOLDER]" />
</MsiPackage>
I know this may be too late to answer, but someone may find it useful.
Every Directory element defined in your Wix project can be accessed as a property using its Id:
For example if you have:
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="INSTALLFOLDER" Name="My Directory" />
</Directory>
</Directory>
</Fragment>
You will have a property named INSTALLFOLDER and you will be able to access it from your custom actions.
Take a look to my answer here, that will give you the idea on how to pass the parameters to your custom action and use them.
Related
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.
I am using customized UI which works in a flow of different views like installview, progressview, finishview, uninstallview etc. In the custom installer there is two options, One is to change the install directory and other to change the database directory. My custom installer contains two msi. whenever I tried to pass the database directory to the msi it will not overide. It always taking the default path.
my custom installer contains a variable for database which is overidable, and passing the value to the msi.
<Variable Name="DatabaseFolder" bal:Overridable="yes" Type="string" Value="[CommonAppDataFolder]$(var.ManufacturerName)\$(var.ProductName)" />
<MsiPackage Id="StorageApp"
DisplayInternalUI="no"
DisplayName="$(var.StorageApp)"
Permanent="no"
Visible="yes"
Vital="yes"
SourceFile="$(var.StorageAppExe)"
Compressed="yes">
<MsiProperty Name="DATABASEAPPDATAFOLDER" Value="[DatabaseFolder]" />
</MsiPackage>
By default it takes the DatabaseProductName as the directory name. But if i changed the directory it always taking the default path. Why i couldn't overide the default value. Is there anything missing in my code?
<DirectoryRef Id="TARGETDIR">
<Directory Id="CommonAppDataFolder">
<Directory Id="CompanyAppDataFolder" Name="$(var.DatabaseManufacturerName)">
<Directory Id="DATABASEAPPDATAFOLDER" Name="$(var.DatabaseProductName)">
</Directory>
</Directory>
</Directory>
</DirectoryRef>
Not sure what you mean with "But if I changed the directory...". Did you change the value of $(var.DatabaseProductName) or just the Directory Id?
Make sure you verify your directory structure by setting a directory name directly in the "Name=" attribute instead of passing a value through $(var.DatabaseProductName)
Example:
<DirectoryRef Id="TARGETDIR">
<Directory Id="CommonAppDataFolder">
<Directory Id="CompanyAppDataFolder" Name="Folder1">
<Directory Id="DATABASEAPPDATAFOLDER" Name="SubFolder1">
</Directory>
</Directory>
</Directory>
</DirectoryRef>
Just a reminder. The Directory Id is just for you to reference your folder elsewhere in your .wxs file. The string that you fill in for the "Name=" attribute will be the actual name of your folder when you ultimately install your application.
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
I'm creating a program which is being installed by Wix, using VS 2010 and I've already got the product.wxs ready.
In my wxs file, I've got directory definitions which looks like this:
<SetDirectory Id="INSTALLFOLDER" Value="[WindowsVolume]Myapp" />
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INSTALLFOLDER" Name="Myapp">
<Directory Id="Myapp_Installer_Dir" Name="Myapp">
<Directory Id="BIN" Name="Bin" />
<Directory Id="ICONS" Name="Icons" />
</Directory>
</Directory>
</Directory>
And then I got these file installation definitions:
<DirectoryRef Id="Myapp_Installer_Dir">
<Component Id="INSTALLER_Myapp" Guid="{94F18477-8562-4004-BC6F-5629CC19E4CB}" >
<File Source="$(var.Myapp.TargetPath)" KeyPath="yes"/>
</Component>
</DirectoryRef>
<DirectoryRef Id="BIN">
<Component Id="INSTALLER_Data" Guid="{545FB5DD-8A52-44D7-898E-7316E70A93F5}" >
<File Source="$(var.Data.TargetPath)" KeyPath="yes"/>
</Component>
...
And it continues in that manner. The files for the "ICONS" directory are defined as well.
I am also using the WixUI_InstallDir dialog set and I got these lines present as well:
<Property Id="WIXUI_INSTALLDIR" Value="Myapp_Installer_Dir" />
<UIRef Id="WixUI_InstallDir" />
The problem is when the user installs the program and changes the value of the installation folder, the files of the "Bin" and "Icons" are installed to their correct path, but the Myapp target is installed to a fix location which was defined at the start as the default installation path.
Why do only the bin and icon files installed to the correct folder the user wanted, but the myapp target does not?
I have finally figured out the problem.
After searching for a while, I came across this document:
WixUI_InstallDir Dialog Set
The relevant part: "The directory ID must be all uppercase characters because it must be passed from the UI to the execute sequence to take effect."
And as you can see in my code: "Myapp_Installer_Dir" does not meet this criteria.
After changing it to "MYAPPINSTALLERDIR", everything worked.
I'm not quite sure, but this is what I think has happened.
When you author a SetDirectory element, you basically add a custom action which sets a directory to the MSI database. As long as you do not specify the sequence it is executed in, it defaults to both, which means execute in both InstallUISequence and InstallExecuteSequence.
Now, when a user changes the installation directory in the wizard, this happens in the UI sequence. Obviously, when the installation enters the execute sequence, the value of INSTALLFOLDER is set to [WindowsVolume]Myapp as it was instructed.
So, you have to rework this somehow. Keep in mind the silent installation as well - there's only execute sequence there.
UPDATE instead of what you have, try something like this:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="WindowsVolume">
<Directory Id="INSTALLFOLDER" Name="Myapp">
<Directory Id="BIN" Name="Bin" />
<Directory Id="ICONS" Name="Icons" />
</Directory>
</Directory>
</Directory>
And let the user optionally change the INSTALLFOLDER as you do now.
Additionally to the pitfall with capital letters there is also an other one:
You have to mark the ID of the changeable directory as secure. (At least when the setup runs with admin rights.)
Related to Yonatan's answer with the directory ID MYAPPINSTALLERDIR you have to add this:
<Property Id="MYAPPINSTALLERDIR" Secure="yes" />
Related to the example WixUI_InstallDir in the WiX documentation you have to add this:
<Property Id="TESTFILEPRODUCTDIR" Secure="yes" />
Unfortunately this important fact is not mentioned in the WiX example.
I have a default directory for installation:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFiles64Folder">
<Directory Id="INSTALLFOLDER" Name="$(var.Manufacturer) $(var.ProductName)"></Directory>
</Directory>
</Directory>
During installation, I allow users to change directory. If a user does change directory during major upgrade, do I have to retrieve the directory manually and set INSTALLFOLDER with actual path or is there a way to detect it automatically somehow?
This is not supported by Windows Installer directly; I think you're looking for the "remember property" pattern. The strategy is:
On initial installation, save the value of INSTALLFOLDER to the registry in a well-known location.
When starting an upgrade, retrieve the value from the registry and use it.
The authoring looks like this:
<!-- Retrieve the property from the registry during AppSearch -->
<Property Id='REMEMBERME'>
<RegistrySearch Id='RememberProperty'
Root='HKCU'
Key='SOFTWARE\My Company\My App'
Name='Remembered'
Type='raw' />
</Property>
<!-- Save the value in the registry for future upgrades -->
<Component Directory='INSTALLFOLDER'>
<RegistryValue Root='HKCU'
Key='SOFTWARE\My Company\My App'
Name='Remembered'
Value='[REMEMBERME]'
Type='string' />
</Component>
Rob Mensching's blog post describes this in much more detail.