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

Thursday, 13 June 2013

How to add User Interface

We show in previous post how to create simple installer now we create installer with UI 
and which component are use.
There are five types of UI wizard provided by wix

 Now add UI in your installer you need to add referance "WixUIExtension"
  1. WixUI_Mondo :- It contain welcome dialog,license-agreement dialog,setup type dialog,feature selection dialog and maintenance dialog. feature selection dialog contain facility of feature tree, disk costing and browsing.
  2. WixUI_InstallDir
  3. WixUI_FeatureTree
  4. WixUI_Minimal :-  It contain single welcome dialog,license-agreement dialog and direct install no choice for user to install perticulre component. Simply add <UIRef Id="WixUI_Minimal" /> 
  5. WixUI_Advanced  :-  Its like Minimal , it provide user selection of features  via tree view and also provide choose folder or path.
Syntax :-
<UIRef: Id="WixUI_Mondo"/>  if you want WixUI_Mondo OR

<UIRef: Id="WixUI_Minimal"/> for WixUI_Minimal  OR

<UIRef: Id="WixUI_FeatureTree"/> for WixUI_FeatureTree  etc.

In your product.wxs page add any above UIReference,
1. R+cliclk on references add select Addreference 
2. Select browse tab "C:\Program Files (x86)\WiX Toolset v3.7\bin\" select
    WixUIExtension reference.


Minimal UI contain single dialog for install

In WixUI_Mondo  UI reference welcome dialog, License and Agreement  dialog , Custom setup dialog and feature tree.



Selection of feature using feature


By using this reference you can add your custom dialogs also.
Customdialogs:-
You can add in dialog tag
Text,ComboBox,CheckBox, Bitmap(image),Icon, RadioButtonGroup,Line, SelectionTree,  PushButton,PathEdit, Billboard,DirectoryCombo, DirectoryList, Edit, GroupBox, ListBox, ListView, MaskedEdit,  ProgressBar,ScrollableText,  VolumeCostList or VolumeSelectCombo

1.Add new page name like dialos.wxs
       in <fragment> add this two references
                    <UIRef Id="WixUI_FeatureTree" />
                    <UIRef Id="WixUI_ErrorProgressText" />

2. Add license dialog reference tag and give name of your dialog as id and publish in this tag your 
   dialog in the next 
here an example of custom dialog
       
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
    <UI Id="UIDialogs">
      <!-- This uses the WixUI plugin -->
      <UIRef Id="WixUI_FeatureTree" />
      <UIRef Id="WixUI_ErrorProgressText" />

      <!-- Injection of custom UI. -->

      <DialogRef Id="SetupDlg" />
      <Publish Dialog="LicenseAgreementDlg" Control="Next" Event="NewDialog" Value="SetupDlg" Order="3">LicenseAccepted = "1"</Publish>     
    </UI>   
    </Fragment>
  <Fragment>
    <UI>
      <Dialog
Id="SetupDlg" Width="370" Height="270" Title="IIS Settings - [ProductName]" NoMinimize="yes">
        <!-- Web App details prompt -->
        <Control Id="NameLabel" Type="Text" X="45" Y="53" Width="100" Height="15" TabSkip="no" Text="&amp; Name:" />
        <Control Id="NameEdit" Type="Edit" X="45" Y="65" Width="220" Height="18" Property="NAME" Text="{80}" />

        <!-- Back button -->
        <Control Id="Back" Type="PushButton" X="180" Y="243" Width="56" Height="17" Text="&amp;Back">
          <Publish Event="NewDialog" Value="LicenseAgreementDlg">1</Publish>
        </Control>
       
        <!--Next Button-->
        <Control Id="Next" Type="PushButton" X="236" Y="243" Width="56" Height="17" Default="yes" Text="&amp;Next">
          <Publish
Event="NewDialog" Value="CustomizeDlg">        
          </Publish>
        </Control>

        <Control
Id="Cancel" Type="PushButton" X="304" Y="243" Width="56" Height="17" Cancel="yes" Text="Cancel">
          <Publish
Event="SpawnDialog" Value="CancelDlg">1</Publish>
        </Control>

        <Control Id="BannerBitmap" Type="Bitmap" X="0" Y="0" Width="370" Height="44" TabSkip="no" Text="WixUI_Bmp_Banner" />
        <Control
Id="Description" Type="Text" X="25" Y="23" Width="280" Height="15" Transparent="yes" NoPrefix="yes">
          <Text>
Please enter  Configuration</Text>
        </Control>

        <Control
Id="BottomLine" Type="Line" X="0" Y="234" Width="370" Height="0" />
        <Control Id="Title" Type="Text" X="15" Y="6" Width="200" Height="15" Transparent="yes" NoPrefix="yes">
          <Text>
{\WixUI_Font_Title}IIS Settings</Text>
        </Control>


        <Control Id="BannerLine" Type="Line" X="0" Y="44" Width="370" Height="0" />
      </Dialog>
    </UI>
  </Fragment>

    </Wix>
and your new dialog look like this
    now your own dialog ready.... you can insert here combobox etc but the important part is 
'Publish event', what you want new dialog or SpawnDialog ? SpawnDialog create new confirmation dialog. and some dialogs are wix generated so you have no need to create it just add reference of it like 
      <UIRef Id="WixUI_FeatureTree" /> For feature tree and
      <UIRef Id="WixUI_ErrorProgressText" /> for progress text

so test your new lil app..... 

Wednesday, 12 June 2013

How to create .Net-based Installer Using WiX

            The Windows Installer XML (WiX) is a toolset that builds Windows installation packages from XML source code.WiX is an open source project.You can download the latest toolset from here Windows Installer XML (WiX). 

You can create .msi file, .msu file and also create .exe file using WiX project.

How to create Simple installer?

Ans:-
 Create simple setup and its functionality using visual studio 2010  Create new project of wix after install wix toolset. Then open new project, you can see here Windows Installer XML in Installed templet select setup project...and give suitable name. 


  1. And your project contain default page product.wxs you can add it contain this                            
    default code............                                       
  2.  Now add your manufacture name and build this project, you can see in your bin folder projectname.msi file is here generated...
  3. Lets add our code. first of all declare your product path and product code after this line                                                                    <?xml version="1.0" encoding="UTF-8"?> like  
     <?define PRODUCTPATH="$(var.Setupproject.TargetPath)"?> 
     <?define ProductVersion = "14.0.0.0"?>  
    <?define UpgradeCode = "{ Guid of UpgradeCode}"?> 
  4. And add in directory section a component and give its referance in feature section because it cant run without referance.                   <Directory Id="INSTALLFOLDER" Name="SetupProject1" >
              <Component Id="Setupfile" Guid="E2356FDB-A186-49FC-8FDE-0A3E618BB193" KeyPath="no">
                <File Id="SetupfileEXE" Name="Setupfile.exe" Source="$(var.PRODUCTPATH)" KeyPath="yes">  </File>                              OR                                                                                                                                                                                                                 <File Id="SetupfileEXE" Name="Setupfile.exe" Source="..\Mtproject\bin\Debug\Myproject.exe" KeyPath="yes">  </File>
              </Component>                                                                                                                                                      </Directory>  
  5. Remember that this path is your project .exe file path which having in your bin folder, not a wix project .ece file path
  6. Referance like this                                                                                                                                                                          <Feature Id="ProductFeature" Title="SetupProject1" Level="1">
          <ComponentRef Id="Setupfile"/>                                                                                                                                     </Feature>          
  7. Build Project your installer is ready but it is simple installer without UI...............
further talk about its UI in next blog