Click here to Skip to main content
15,868,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am working on WIX Installer. I am trying to read Directory path from .ini file to XML. I have to red the path and get the files installed to that particular path.

localtest.ini is the .ini file. It is in the C drive
[ENVIRONMENT]
 LocalDirectory=D:\Ng


How to read the value from .ini file and make it as path to install files?

What I have tried:

XML
<Property Id="ROOTDRIVE">
       <![CDATA[*value which is read from .ini file has to be passed here*]]>
   </Property>
   <Property Id="MY_PROPERTY">
     <IniFileSearch Id="myIniSearch" Name="localtest.ini" Section="ENVIRONMENT" Key="LocalDirectory" Type="raw">
       <DirectorySearch Id="SPIniFilePath" Path="C:\">
         <FileSearch Id="SPIniFile" Name="localtest.ini"/>
       </DirectorySearch>
     </IniFileSearch> />
  </Property>

 <Fragment>
   <Directory Id="TARGETDIR" Name="SourceDir" >
     <Directory Id="myIniSearch">
       <Directory Id="INSTALLFOLDER" Name="!(bind.property.ProductName)" />
     </Directory>
  </Directory>
 </Fragment>
Posted
Updated 7-Dec-21 21:45pm
v2

1 solution

XML
<pre>	<Product Id="1A5CEB89-D455-4CA4-ADB7-29C3763D4999" Name="My WPF Application" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="3162fb54-fcac-4647-bcd5-586c6deed853">
		<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="Simple Application"/>
    <!--<UIRef Id="WixUI_Minimal"/>-->
    
		<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
		<MediaTemplate EmbedCab="yes"/>
    
    <!--Icon for the installer package-->
    <Icon Id="MyShortcutIcon" SourceFile="$(var.ProjectDir)ng.ico"/>
    <Property Id="ARPRODUCTION" Value="MyShortcutIcon"/> 
    
		<Feature Id="ProductFeature" Title="My WPF Application" Level="1">
			<ComponentGroupRef Id="ProductComponents" />
		</Feature>
    
    <Property Id="MY_PROPERTY" Secure="yes">
      <IniFileSearch Id="myIniSearch" Name="localtest.ini" Section="ENVIRONMENT" Key="LocalDirectory" Type="raw" />
    </Property>
  
    <CustomAction Id="SetMyProperty" Execute="immediate" Property="INSTALLPATH" Value="[MY_PROPERTY]" />
  
    <InstallExecuteSequence>
      <Custom Action="SetMyProperty" After="FileCost"></Custom>
    </InstallExecuteSequence>
    
    <DirectoryRef Id='INSTALLPATH'>
      <Directory Id='INSTALLDIR_SimpleWebApp' Name='SimpleWebAppa' />
    </DirectoryRef>
  </Product>
  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id='ProgramFilesFolder' Name='PFiles'>
        <Directory Id='INSTALLPATH' Name='SimpleWebApp' />
      </Directory>
    </Directory>
  </Fragment>
	<Fragment>
		<ComponentGroup Id="ProductComponents" Directory="INSTALLPATH">
			<!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
			<!-- <Component Id="ProductComponent"> -->
				<!-- TODO: Insert files, registry keys, and other resources here. -->
			<!-- </Component> -->
			<Component Id="MyWPFApplication.exe" Guid="404c2a60-daac-49b5-847e-d1478909379f">
			  <File Id="MyWPFApplication.exe" Name="MyWPFApplication.exe" Source="$(var.MyWPFApplication_TargetDir)MyWPFApplication.exe" KeyPath="yes"/>
			</Component>
			<Component Id="MyWPFApplication.exe.config" Guid="3a3addcc-1629-4a08-b4ef-f578c04421b7">
			  <File Id="MyWPFApplication.exe.config" Name="MyWPFApplication.exe.config" Source="$(var.MyWPFApplication_TargetDir)MyWPFApplication.exe.config" KeyPath="yes"/>
			</Component>
		</ComponentGroup>
	</Fragment>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900