0

I want to add feature if setup run second time it will remove existing product first. without version feature. kindly guide me how i make sure if product already exist. setup will remove it first and install it again and after installation launch application. OR if product with same version already exist setup launch the Application. its good if having sample code please share that too. Thanks advance.

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define EmbeddApp_TargetDir=$(var.EmbeddApp.TargetDir)?>
  <Product Id="*" Name="Troytec_TestEngine" Language="1033" Version="1.0.0.0" Manufacturer="TroyTec" UpgradeCode="c28ad43a-4fe4-4d14-ba4f-6422c00b13c2">
    <Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <!--<MajorUpgrade AllowDowngrades="yes" />-->
    <MediaTemplate />

    <Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" />
<Upgrade Id="a61287ef-e184-421b-ac76-d8b91e489a6d">  
   <UpgradeVersion
      Minimum="1.0.0.0" Maximum="99.0.0.0"
      Property="PREVIOUSVERSIONSINSTALLED"
      IncludeMinimum="yes" IncludeMaximum="no" />
</Upgrade>

    <Feature Id="ProductFeature" Title="Troytec_TestEngine" Level="1">
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="ApplicationShortcut" />
      <ComponentRef Id="ApplicationShortcutDesktop" />
      <ComponentRef Id="CMP_MyEmptyDir" />
      <ComponentRef Id="CMP_MyEmptyDir2" />
      <ComponentRef Id="CMP_MyEmptyDir3" />
    </Feature>


     <!--Step 2: Add UI to your installer / Step 4: Trigger the custom action--> 
    <!--<UI>
      <UIRef Id="WixUI_Minimal" />
      <Publish Dialog="ExitDialog"
          Control="Finish"
          Event="DoAction"
          Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
    </UI>-->
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch My Application Name" />

     <!--Step 3: Include the custom action--> 
    <!--<Property Id="WixShellExecTarget" Value="[EmbeddApp.exe]" />-->
    <CustomAction Id="LaunchApplication"
        BinaryKey="WixCA"
        DllEntry="WixShellExec"
        Impersonate="yes" />




  </Product>
  <!--<Fragment>
    <InstallExecuteSequence>
      <Custom Action='902bc339-5cef-4f74-9d04-07941afa8ba1' Before='6d48fcc2-99cb-4ab6-867a-79f0484db05c'>
        (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
      </Custom>
    </InstallExecuteSequence>
  </Fragment>-->






  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="Troytec_TestEngine" >
          <Directory Id="FOLDER1" Name="GPUCache">
          </Directory>
            <Directory Id="FOLDER2" Name="locales">
              </Directory>
          <Directory Id="FOLDER3" Name="swiftshader">
            </Directory>
      </Directory>
    </Directory>
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="Troytec_TestEngine" />
      </Directory>
      <Directory Id="DesktopFolder" Name="Desktop"/>

    </Directory>
  </Fragment>

  <Fragment>
    <Icon Id="City.ico" SourceFile="letter-t-24.ico" />
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="9bd13330-6540-406f-a3a8-d7f7c69ae7f9">
        <Shortcut Id="ApplicationStartMenuShortcut" Name="Troytec_TestEngine" Description="MyWpfApplication" Target="[INSTALLFOLDER]EmbeddApp.exe" WorkingDirectory="INSTALLFOLDER" Icon ="City.ico" />
        <RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\MyWpfApplication" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesktop" Guid="cde1e030-eb64-49a5-b7b8-400b379c2d1a">
        <Shortcut Id="ApplicationDesktopShortcut" Name="Troytec_TestEngine" Description="MyWpfApplication" Target="[INSTALLFOLDER]EmbeddApp.exe" WorkingDirectory="INSTALLFOLDER" Icon ="City.ico" />
        <RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\Troytec_TestEngine" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>
  </Fragment>


  <Fragment>



</Fragment>




  <Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
      <!-- 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="EmbeddApp.exe" Guid="85c6f764-7517-4bc6-8e5a-ec52ae6ece1e">
        <File Id="EmbeddApp.exe" Name="EmbeddApp.exe" Source="$(var.EmbeddApp_TargetDir)EmbeddApp.exe" />
      </Component>
      <Component Id="EmbeddApp.exe.config" Guid="8ee125d7-7043-498a-ad65-24055252218a">
        <File Id="EmbeddApp.exe.config" Name="EmbeddApp.exe.config" Source="$(var.EmbeddApp_TargetDir)EmbeddApp.exe.config" />
      </Component>
      <Component Id="CefSharp.WinForms.dll" Guid="9fdb1c25-2275-4a14-8f4f-6832b7a617dc">
        <File Id="CefSharp.WinForms.dll" Name="CefSharp.WinForms.dll" Source="$(var.EmbeddApp_TargetDir)CefSharp.WinForms.dll" />
      </Component>
      <Component Id="CefSharp.dll" Guid="9bdbc9cc-52a6-4213-b941-0248e995aa71">
        <File Id="CefSharp.dll" Name="CefSharp.dll" Source="$(var.EmbeddApp_TargetDir)CefSharp.dll" />
      </Component>
      <Component Id="CefSharp.Core.dll" Guid="0e058c32-f73b-4b3f-acbd-b0c29c019297">
        <File Id="CefSharp.Core.dll" Name="CefSharp.Core.dll" Source="$(var.EmbeddApp_TargetDir)CefSharp.Core.dll" />
      </Component>

      <!--other files-->

      <Component Id="cef.pak" Guid="283c053a-c66e-4889-9c6b-2884b50b8cbb">
        <File Id="cef.pak" Name="cef.pak" Source="$(var.EmbeddApp_TargetDir)cef.pak" />
      </Component>
      <Component Id="cef_100_percent.pak" Guid="12342b21-68e4-4874-ac3f-87ac8a9f40c2">
        <File Id="cef_100_percent.pak" Name="cef_100_percent.pak" Source="$(var.EmbeddApp_TargetDir)cef_100_percent.pak" />
      </Component>
      <Component Id="cef_200_percent.pak" Guid="b261180b-0fa2-41ea-ba8d-63d329f2d047">
        <File Id="cef_200_percent.pak" Name="cef_200_percent.pak" Source="$(var.EmbeddApp_TargetDir)cef_200_percent.pak" />
      </Component>
      <Component Id="cef_extensions.pak" Guid="a4a0a9d0-0308-46be-b24a-7de985018039">
        <File Id="cef_extensions.pak" Name="cef_extensions.pak" Source="$(var.EmbeddApp_TargetDir)cef_extensions.pak" />
      </Component>
      <Component Id="CefSharp.BrowserSubprocess.Core.dll" Guid="f3e2f9bc-066a-43f0-9e14-445d7af00243">
        <File Id="CefSharp.BrowserSubprocess.Core.dll" Name="CefSharp.BrowserSubprocess.Core.dll" Source="$(var.EmbeddApp_TargetDir)CefSharp.BrowserSubprocess.Core.dll" />
      </Component>
      <Component Id="CefSharp.BrowserSubprocess.Core.pdb" Guid="6127f13d-4b77-4a7f-992d-5b49abb2dfee">
        <File Id="CefSharp.BrowserSubprocess.Core.pdb" Name="CefSharp.BrowserSubprocess.Core.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.BrowserSubprocess.Core.pdb" />
      </Component>
      <Component Id="CefSharp.BrowserSubprocess.exe" Guid="4b029801-a97e-47a0-8f37-0a0540bed89e">
        <File Id="CefSharp.BrowserSubprocess.exe" Name="CefSharp.BrowserSubprocess.exe" Source="$(var.EmbeddApp_TargetDir)CefSharp.BrowserSubprocess.exe" />
      </Component>
      <Component Id="CefSharp.BrowserSubprocess.pdb" Guid="d47f6d16-c6f5-4cf3-98a8-a342444e225f">
        <File Id="CefSharp.BrowserSubprocess.pdb" Name="CefSharp.BrowserSubprocess.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.BrowserSubprocess.pdb" />
      </Component>
      <Component Id="CefSharp.Core.pdb" Guid="f9ae3c06-3c49-40af-8047-da555d43304b">
        <File Id="CefSharp.Core.pdb" Name="CefSharp.Core.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.Core.pdb" />
      </Component>
      <Component Id="CefSharp.Core.xml" Guid="71e6a1c8-e1c2-4f41-bf09-c664cd62b0a7">
        <File Id="CefSharp.Core.xml" Name="CefSharp.Core.xml" Source="$(var.EmbeddApp_TargetDir)CefSharp.Core.xml" />
      </Component>
      <Component Id="CefSharp.pdb" Guid="1f6df66a-972c-4945-a675-ab7f6bff3207">
        <File Id="CefSharp.pdb" Name="CefSharp.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.pdb" />
      </Component>
      <Component Id="CefSharp.WinForms.pdb" Guid="9f9aa753-8be7-4349-bf90-3799c9cb8560">
        <File Id="CefSharp.WinForms.pdb" Name="CefSharp.WinForms.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.WinForms.pdb" />
      </Component>
      <Component Id="CefSharp.WinForms.xml" Guid="56dc62fa-e64e-4f92-a8df-3415423e65cd">
        <File Id="CefSharp.WinForms.xml" Name="CefSharp.WinForms.xml" Source="$(var.EmbeddApp_TargetDir)CefSharp.WinForms.xml" />
      </Component>
      <Component Id="CefSharp.xml" Guid="c567fe97-a411-477d-8f5b-82432593c090">
        <File Id="CefSharp.xml" Name="CefSharp.xml" Source="$(var.EmbeddApp_TargetDir)CefSharp.xml" />
      </Component>
      <Component Id="chrome_elf.dll" Guid="8272cf27-65c6-499e-b503-b56ed9f80db1">
        <File Id="chrome_elf.dll" Name="chrome_elf.dll" Source="$(var.EmbeddApp_TargetDir)chrome_elf.dll" />
      </Component>
      <Component Id="d3dcompiler_47.dll" Guid="3405163c-2405-41e7-aeef-3f4f65df1dd2">
        <File Id="d3dcompiler_47.dll" Name="d3dcompiler_47.dll" Source="$(var.EmbeddApp_TargetDir)d3dcompiler_47.dll" />
      </Component>
      <Component Id="devtools_resources.pak" Guid="e2ffd1f6-9283-442f-b83f-fde86ddf1553">
        <File Id="devtools_resources.pak" Name="devtools_resources.pak" Source="$(var.EmbeddApp_TargetDir)devtools_resources.pak" />
      </Component>
      <Component Id="EmbeddApp.pdb" Guid="e040e421-d4b4-4916-9089-f2efb1459594">
        <File Id="EmbeddApp.pdb" Name="EmbeddApp.pdb" Source="$(var.EmbeddApp_TargetDir)EmbeddApp.pdb" />
      </Component>
      <Component Id="icudtl.dat" Guid="a14f1e18-8813-42c1-bad6-f40ad21d1b25">
        <File Id="icudtl.dat" Name="icudtl.dat" Source="$(var.EmbeddApp_TargetDir)icudtl.dat" />
      </Component>
      <Component Id="libcef.dll" Guid="22493d08-ed8f-4bf3-9708-ace297e0d2d7">
        <File Id="libcef.dll" Name="libcef.dll" Source="$(var.EmbeddApp_TargetDir)libcef.dll" />
      </Component>
      <Component Id="libEGL.dll" Guid="8ffc6d72-f929-4162-b7d4-49b8229aeb32">
        <File Id="libEGL.dll" Name="libEGL.dll" Source="$(var.EmbeddApp_TargetDir)libEGL.dll" />
      </Component>
      <Component Id="libGLESv2.dll" Guid="8e759d91-3e4c-4a02-9ba7-6dfaf4c0fa7e">
        <File Id="libGLESv2.dll" Name="libGLESv2.dll" Source="$(var.EmbeddApp_TargetDir)libGLESv2.dll" />
      </Component>
      <Component Id="natives_blob.bin" Guid="15c51480-6cf0-4127-a949-d899ba5a3422">
        <File Id="natives_blob.bin" Name="natives_blob.bin" Source="$(var.EmbeddApp_TargetDir)natives_blob.bin" />
      </Component>
      <Component Id="snapshot_blob.bin" Guid="50f987cb-551e-4734-9d15-b59e0fa7f868">
        <File Id="snapshot_blob.bin" Name="snapshot_blob.bin" Source="$(var.EmbeddApp_TargetDir)snapshot_blob.bin" />
      </Component>
      <Component Id="v8_context_snapshot.bin" Guid="492bb45e-1cdf-4ee1-992f-5479edff99e9">
        <File Id="v8_context_snapshot.bin" Name="v8_context_snapshot.bin" Source="$(var.EmbeddApp_TargetDir)v8_context_snapshot.bin" />
      </Component>
    <!--<Component Id="data_0" Guid="b2f7d81e-587b-4e5e-835a-e29b394ae574">
        <File Id="data_0" Name="data_0" Source="$(var.EmbeddApp_TargetDir)GPUCache\data_0" />
      </Component>-->

    </ComponentGroup>


  <CustomAction Id="EXECUTE_AFTER_FINALIZE"                  
              Execute="immediate" 
              Impersonate="no"
              Return="asyncNoWait"
              FileKey="EmbeddApp.exe"
              ExeCommand="" />

<InstallExecuteSequence>

  <RemoveExistingProducts Before="InstallInitialize" Overridable="yes" />
  <Custom Action="EXECUTE_AFTER_FINALIZE" After="InstallFinalize">NOT Installed</Custom>
<!--<RemoveExistingProducts Overridable="yes" Sequence="1" />
  <Custom Action="EXECUTE_AFTER_FINALIZE" After="InstallFinalize">NOT Installed</Custom>-->
</InstallExecuteSequence>


  </Fragment>





  <!--<Fragment>
    <ComponentGroup Id="ProductSubComponents" Directory="FOLDER1">
      <Component Id="data_0" Guid="b2f7d81e-587b-4e5e-835a-e29b394ae574">
        <File Id="data_0" Name="data_0" Source="$(var.EmbeddApp_TargetDir)GPUCache\data_0" />
      </Component>
    </ComponentGroup>
  </Fragment>-->


</Wix>
  • Limited time, but here are some links: [Major Upgrade & Problems](https://stackoverflow.com/a/56991527/129130). [Major Upgrade Element and old style elements combined](https://stackoverflow.com/a/51803320/129130). The issue of ["SameVersionUpgrades"](https://stackoverflow.com/a/57809491/129130). And [even more major upgrade info](https://stackoverflow.com/a/48761048/129130). – Stein Åsmul Nov 05 '19 at 03:05
  • Thanks. but i am little bit confuse i just want to allow the same version to uninstall itself and re-install? can you share me example code or the link that have example code – Mohsin Nawaz Nov 05 '19 at 06:08

0 Answers0