我正在使用Wix Toolset为我的应用程序创建安装程序,我对该技术非常陌生。
我需要能够在每个用户和每个计算机基础上,每个用户安装在%LOCALAPPDATA%
文件夹中以及每个计算机在PROGRA~1
中安装。
我尝试遵循Wix Toolset的this示例,但是没有运气。
我还尝试设置自己的界面(部分内容来自this帖子),该界面不会覆盖安装文件夹:
<UI Id="UserInterface">
<Property Id="WixUI_Mode" Value="Custom" />
<TextStyle Id="WixUI_Font_Normal" FaceName="Tahoma" Size="8" />
<TextStyle Id="WixUI_Font_Bigger" FaceName="Tahoma" Size="9" Bold="yes" />
<TextStyle Id="WixUI_Font_Title" FaceName="Tahoma" Size="9" Bold="yes" />
<Property Id="DefaultUIFont" Value="WixUI_Font_Normal" />
<DialogRef Id="InstallScopeDlg"/>
<DialogRef Id="ProgressDlg" />
<DialogRef Id="ErrorDlg" />
<DialogRef Id="FilesInUse" />
<DialogRef Id="FatalError" />
<DialogRef Id="UserExit" />
<Publish Dialog="WelcomeDlg" Control="Next" Event="NewDialog" Value="InstallScopeDlg">1</Publish>
<Publish Dialog="InstallScopeDlg" Control="Back" Event="NewDialog" Value="WelcomeDlg">1</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="WixAppFolder" Value="{}" Order="2">WixAppFolder = "WixPerUserFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="WixAppFolder" Value="1" Order="3">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="ALLUSERS" Value="{}" Order="4">WixAppFolder = "WixPerUserFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="ALLUSERS" Value="1" Order="5">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="INSTALLFOLDER" Value="[WixPerUserFolder]" Order="6">WixAppFolder = "WixPerUserFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Property="INSTALLFOLDER" Value="[WixPerMachineFolder]" Order="7">WixAppFolder = "WixPerMachineFolder"</Publish>
<Publish Dialog="InstallScopeDlg" Control="Next" Event="EndDialog" Value="Return">1</Publish>
<Publish Dialog="ExitDialog" Control="Finish" Event="EndDialog" Value="Return">1</Publish>
</UI>
无论我在安装过程中选择哪个范围,安装程序都会尝试将文件写入PROGRA~1
文件夹。
我目前的猜测是<Directory Id="ProgramFiles64Folder" />
迫使安装程序使用Program Files文件夹,该文件夹需要提升的特权。我尝试使用<Directory Id="INSTALLATIONLOCATION" />
而不是将安装移至ProgramData,还尝试将ConfigurableDirectory
属性应用到我的功能上不起作用。
我的Product.wxs配置:
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="{GUID}" Name="My App" Language="1033" Version="1.0.0.0" Manufacturer="Company" UpgradeCode="{GUID}">
<Package InstallerVersion="301" Compressed="yes" InstallPrivileges=""/>
<WixVariable Id="WixUIBannerBmp" Value="Images\Banner.bmp" />
<WixVariable Id="WixUIDialogBmp" Value="Images\Dialog.bmp" />
<WixVariable Id="WixUISupportPerMachine" Value="1" />
<WixVariable Id="WixUISupportPerUser" Value="1" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." AllowSameVersionUpgrades="yes" />
<MediaTemplate EmbedCab="yes" />
<PropertyRef Id="NETFRAMEWORK45"/>
<Property Id="ARPPRODUCTICON" Value="icon.ico" />
<Property Id="ApplicationFolderName" Value="My App" />
<Property Id="WixAppFolder" Value="WixPerUserFolder" />
<Icon Id="icon.ico" SourceFile="Icon.ico"/>
<!-- Check for .NET version -->
<Condition Message="This application requires .NET Framework 4.5.2 or higher. Please install the .NET Framework then run this installer again.">
<![CDATA[Installed OR NETFRAMEWORK45]]>
</Condition>
<Directory Id="TARGETDIR" Name="SourceDir">
<Merge Id="VCRedist" SourceFile="Microsoft_VC141_CRT_x64.msm" DiskId="1" Language="0"/>
<Directory Id="ProgramFiles64Folder"> <!-- Is this the problem, how can I make this configurable depending on user selection?-->
<Directory Id="INSTALLFOLDER" Name="My App" />
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="Company"/>
</Directory>
</Directory>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="ApplicationShortcut" Guid="{GUID}">
<Shortcut Id="ApplicationStartMenuShortcut" Name="My App" Target="[#App.exe]" WorkingDirectory="INSTALLFOLDER"/>
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Company\My App" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
<Feature Id="VCRedist" Title="Visual C++ Runtime" AllowAdvertise="no" Display="hidden" Level="1" >
<MergeRef Id="VCRedist"/>
</Feature>
<Feature Id="ProductFeature" Title="My App" Level="1">
<ComponentGroupRef Id="MyFiles" />
<ComponentRef Id="ApplicationShortcut" />
</Feature>
<UI Id="UserInterface">
<!-- see above -->
</UI>
<UIRef Id="WixUI_Advanced" />
</Product>
我正在抓紧稻草,找不到任何可靠的示例或文档来解决目录。如何根据安装范围内的选择将安装文件夹设置为%LOCALAPPDATA%
或PROGRA~1
?