Wednesday, 26 June 2013

How to add Project in Setup and dynamic config file ?

   In previous post we create just simple setup which is not contain 
any project or web site. so now we add simple project in setup
steps :-
1. Open product.wxs page and add <file> tag in component and give Id, name and Source of projects .exe file which is in your project's bin\Debug folder.
2. set key path yes;
3. as par .exe file add config file (this file generated using xml)
    before add this reference "WixUtilExtension" and in <wix > tag
 add this ref
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"  
like

 <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <Component
Id="ProductComponen1" KeyPath="yes" Guid="{1E2CF29B-1E28-43E9-B7AA-55203D187D86}">       
          <File
Id="ProjectSetupsEXE" Name="ProjectSetups.exe" Source="$(var.Insite.PrintMonitor.TargetPath)" KeyPath="yes"/>
        OR
        <File
Id="ProjectSetupsEXE" Name="ProjectSetups.exe" Source="..\ProjectSetups\bin\ProjectSetups.exe" KeyPath="yes"/>

<File Id="ProjectSetupsAppConfig" Name="app.config" Source="..\ProjectSetups\bin\ProjectSetups.exe.config"
               KeyPath="no" Vital="yes"
/>

 <util:XmlFile Id="ModifyLogDir"  Action="setValue"
 ElementPath="//configuration/appSettings/add[\[]@key='LogDir'[\]]/@value"
File="[#ProjectSetupsAppConfig]" Value="[DIRECTORYLOCATION]"/>

 <util:XmlFile Id="ModifyProjectSetupsDir" 
Action="setValue" ElementPath="//configuration/appSettings/add[\[]@key='ProjectSetupsDir'[\]]/@value"   
File="[#ProjectSetupsAppConfig]" Value="[LOCATION]"/>
      </Component>    
  </ComponentGroup>  

here i am passing two value DIRECTORYLOCATION and LOCATION which is set in config file and it change when istaller run and m passing in textbox and it get via below property.
set this property before closing product taf
       <Property Id='DIRECTORYLOCATION' />
       <Property
Id='LOCATION' />
 
</product> 

           now build setup and click on setup, include setup bin folder and open debugfolder your msi run thsi msi. see in program file folder your .config file

No comments:

Post a Comment