How to use properties to set the installation path?

谁说我不能喝 提交于 2019-12-12 02:50:03

问题


I want to know how to set the installation path of the copied files by using properties. So, please let anyone explain the answer.


回答1:


If You are using a bootstrapper, You can define a variable like that:

<Variable Name="INSTALLFOLDER"
          bal:Overridable="yes"
          Type="string"
          Value="[ProgramFilesFolder]"/>

This variable has the ProgramFilesFolder as default, but it can be overwritten. You can set it either in Process.Start (when the bootstrapper is called by an EXE) as parameter or - if You have programmed Your own bootstrapper-GUI - You set the variable in the GUI-code.

In the MsiPackage You must set the variable into the MsiProperty INSTALLLOCATION, which You define in the Product.wxs of the MSI-project. Hope it helps You.

        <MsiPackage Id='SetupPackage'
                    SourceFile='.\Resources\Setup.msi'
                    Permanent='no'
                    Cache='yes'
                    DisplayInternalUI='no'
                    Vital='yes'
                    Compressed='yes'
                    EnableFeatureSelection='no'
                    DisplayName='MySetup'>
            <MsiProperty Name="INSTALLLOCATION"
                         Value="[INSTALLFOLDER]" />
        </MsiPackage>



回答2:


I know this may be too late to answer, but someone may find it useful.

Every Directory element defined in your Wix project can be accessed as a property using its Id:

For example if you have:

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="My Directory" />
        </Directory>
    </Directory>
</Fragment>

You will have a property named INSTALLFOLDER and you will be able to access it from your custom actions.

Take a look to my answer here, that will give you the idea on how to pass the parameters to your custom action and use them.



来源:https://stackoverflow.com/questions/26608767/how-to-use-properties-to-set-the-installation-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!