我将Wix Toolset用于安装软件包。我希望用户选择安装路径,然后将我的应用程序安装到该目录,但是我无法做到这一点。我已经尝试了一些方法,但是没有解决。我将分享一些wix项目代码并写下我尝试过的内容。首先是我的代码:
<wix>
<Property Id="WIXUI_INSTALLDIR" Value="APPROOTFOLDER" />
<UIRef Id="WixUI_InstallDir" />
<UIRef Id="WixUI_ErrorProgressText" />
</wix>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="APPROOTFOLDER" Name="MyApp">
.
.
.
<SetDirectory Id="APPROOTFOLDER" Value="[WindowsVolume]MyApp\[ProductName]"/>
</Fragment>
我不共享整个项目,因为我认为其余部分与本部分无关。现在,通过此设置,我可以向用户C:\ MyApp \ test显示为默认路径,并且用户可以通过单击浏览来更改它。但是由于我使用<SetDirectory Id="APPROOTFOLDER" Value="[WindowsVolume]MyApp\[ProductName]"/>
这行设置目录,因此当用户更改路径时,安装程序仍在使用C:\ MyApp \ test。我试图删除该行,并且该行起作用了,我能够将其安装到浏览的任何位置,但是安装程序会选择一个随机的默认路径。基本上,我只想提供一个默认路径作为[WindowsVolume] MyApp [ProductName],并且还允许用户更改该路径并安装到该路径。
我该如何实现?
答案 0 :(得分:0)
我找到了解决方案,我将其写下来而不是删除问题,也许有人会遇到我现在的情况。
我已经更改了
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:shimmer="http://schemas.android.com/apk/res-auto"
android:background="@color/darkgrey"
tools:context=".ui.ProductList.ProductListFragment">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="@dimen/padding_10"
android:text=" Select an item closest to your desired search"
android:textSize="16sp"
android:textColor="@color/black"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="@+id/product_list_recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginBottom="60dp"
android:scrollbars="vertical" />
</LinearLayout>
</ScrollView>
<android.support.v4.view.ViewPager
android:id="@+id/list_pager"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentBottom="true"
android:layout_gravity="end"
android:visibility="invisible"
android:background="@color/white"
android:gravity="bottom|center"
/>
</RelativeLayout>
<Property Id="WIXUI_INSTALLDIR" Value="APPROOTFOLDER" />
,而不是设置APPROOTFOLDER的目录,而是设置TARGETDIR。 所以代替这个:
<Property Id="WIXUI_INSTALLDIR" Value="TARGETDIR" />
我这样做:
<SetDirectory Id="APPROOTFOLDER" Value="[WindowsVolume]MyApp\[ProductName]"/>
我不是100%知道这里是什么问题tbh,我认为问题是我没有同时在WIXUI_INSTALLDIR属性和SetDirectory中使用根目录ID,我在根目录中使用了子目录,所以可能问题。因此,如果您遇到类似的问题,请确保您使用根目录。