简体   繁体   中英

COPYFILE post MSI Installation Using WIX

Please see below statements; for time being I have hard coded source and destination folders (this folders are formed during Installation process) in setup project of MSI. Note: Below file paths are the one where MSI package installation destination are and not the source location from. The question how to set the destination or source property values by hiding the hard coded values like [INSTALLLOCATION]\\App_Config\\

As of now I am passing INSTALLLOCATION (E:\\Websites\\SCBUDirect\\Website\\SCBUDirect.B2CWeb) through command line and want to set the Destination folder value as [INSTALLLOCATION]\\App_Config\\ but not sure how it can be implemented through property setting or custom actions which I tried but failed to make it work.

Below is the Snippet (from heat.exe) of component of the file which need to be copied .

<Component Id="cmp209B0DBB82F9FF15193D29F0BD337B7F" Directory="dirB0A921E55A598C65B18B4E47885629C3" Guid="{3B140259-FCC7-4D2E-8629-CBB879BBA46C}">
  <File Id="filBC5CC5B8DCC504F6DC75A7B2673E7D0D" KeyPath="yes" Source="C:\Workspaces\Chatra\Website\SCBUDirect.B2CWeb\App_Config\basic.log4net.dev" />
</Component>

Here is my part of my code in product.wxs

<Fragment>
    <Property Id="SourceFilesFolder" Value="E:\Websites\SCBUDirect\Website\SCBUDirect.B2CWeb\App_Config\basic.log4net.dev" />

    <Property Id="DestFilesFolder" Value="E:\Websites\SCBUDirect\Website\SCBUDirect.B2CWeb\App_Config\" />


  <ComponentGroup Id="CopyFiles">
         <ComponentRef Id="CMP_LOG4TXT" />
    </ComponentGroup>

      <Component Id="CMP_LOG4TXT" Guid="341BD660-7249-42DD-9744-DBEF0776AD52"  Directory="INSTALLLOCATION" KeyPath="yes">
        <CopyFile Id="Copy_LOG4TXT" 
              SourceProperty="SourceFilesFolder" 
              DestinationProperty="DestFilesFolder" 
              DestinationName="basic.log4net" />
      </Component>

</Fragment>

you can use relative path like so:

<Component Id="comp_Include_0" DiskId="1" KeyPath="yes" Guid="D026AE84-0F34-4715-810D-4EB6656DFECD">
    <File Id="file_Include_0" Source="..\Include\3rdParty\ac_types2.6\ac_complex.h" />
</Component>

the "..\\"
means for example the bin\\release folder it's declared like this :

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFiles64Folder">
      <Directory Id="INSTALLFOLDER" Name="ATE" >
      </Directory>
    </Directory>
</Directory>

you will need to declare

<DirectoryRef Id="INSTALLFOLDER">

the easiest way I have found to create wix installer is to use paraffin for full directories

[INSTALLLOCATION] File path's Pattern Saving need to be done here ,So that file path is saved during Installation and Uninstall. Otherwise we get Network Search errors.

<product>

    <Property Id="INSTALLLOCATION">
          <RegistrySearch Id="REMEMBERPROPERTY" Root="HKCU" Key="Websites\SCBUDirect" Name="Remembered" Type="raw"/> 
    </Property>

        <CustomAction Id="SAVEINSTALLDIR" Property="CMDREMEMBERPROPERTY" Value="[INSTALLLOCATION]"/>
        <CustomAction Id="SETINSTALLDIR" Property="INSTALLLOCATION" Value="[CMDREMEMBERPROPERTY]" />

        <InstallExecuteSequence>
          <Custom Action="SAVEINSTALLDIR" Before="AppSearch"></Custom>
         <Custom Action="SETINSTALLDIR" After="AppSearch">CMDREMEMBERPROPERTY</Custom>
        </InstallExecuteSequence>

        <SetProperty Id="DestFilesFolder" Value="[INSTALLLOCATION]\Website\App_Config" After="CostInitialize" />

</product>

<fragment>

  <ComponentGroup Id="CopyFiles">
         <ComponentRef Id="CMP_LOG4TXT" />
    </ComponentGroup>

      <Component Id="CMP_LOG4TXT" Guid="341BD660-7249-42DD-9744-DBEF0776AD52"  Directory="dir572C565E70B3AEE6F0C29D3EE9056E9B" KeyPath="yes">
        <CopyFile Id="Copy_LOG4TXT"         Source="E:\Websites\SCBUDirect\Website\SCBUDirect.B2CWeb\App_Config\basic.log4net.dev" DestinationProperty="DestFilesFolder" DestinationName="basic.log4net" />
      </Component>

</fragment>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM