how to create INSTALLLOCATION folder in D drive us

2020-04-10 06:23发布

问题:

Below xml creates the specified folders under C:\Programfiles but I want to create (SomeFolder\MyApp) Folders in D:\MySetupFolder\, how can I create this using the WIX?

<Directory Id="TARGETDIR" Name="SourceDir">
**<Directory Id="$(var.PlatformProgramFilesFolder)">**      
        <Directory Id="INSTALLFOLDERLOCATION" Name="SomeFolder">
                <Directory Id="INSTALLLOCATION" Name="MyApp">
</Directory>
</Directory>
</Directory>

回答1:

Set the value of rootdrive to the drive you want

<CustomAction Id='SetRootDrive' Property='ROOTDRIVE' Value='[%SystemDrive]\'/>

System drive will be by default the default drive used by OS

Added code to call 'SetRootDrive' action: You need to call it from InstallUISequence

<InstallUISequence>
  <Show Dialog="MyWelcomeDlg" Before="CostFinalize">NOT Installed</Show>
  <!-- App search is what does FindInstallLocation, and it is dependent on FindRelatedProducts -->
  <AppSearch After="FindRelatedProducts"/>
  <Custom Action="SetRootDrive" Before="CostInitialize"></Custom>
</InstallUISequence>


标签: wix