[英]How to install application in custom folder using wix installer,other than Program Files folder
[英]install WIX installer application in C: partition instead of Program Files folder
我已經在VS2010中使用WIX創建了一個安裝程序。當前,當我安裝該應用程序時,它將在C:\\Program Files\\Wixdemoapplication
下安裝該應用程序和與應用程序相關的依賴文件。 我需要對此進行自定義。我需要將應用程序直接安裝在C:\\Wixdemoapplication
下的Wixdemoapplication
下,而不是C:\\Program Files\\Wixdemoapplication
。
需要幫忙。
嘗試以下操作(未經測試;但可能足以滿足您的需要):
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="INSTALLFOLDER" Name="Wixdemoapplication" />
</Directory>
否則,可以做一些其他有趣的事情,例如:
將此自定義操作添加到Product.wxs:
<CustomAction Id="SpawnBrowseFolderDialog" BinaryKey="CustomActions" DllEntry="SpawnBrowseFolderDialog" Return="check" />
將此添加到Product.wxs中某些對話框的按鈕中:
<Control Id="BrowseButton" Type="PushButton" X="276" Y="126" Width="90" Height="18" Text="{\VSI_MS_Sans_Serif13.0_0_0}B&rowse..." TabSkip="no">
<Publish Event="DoAction" Value="SpawnBrowseFolderDialog"><![CDATA[1]]></Publish>
<Publish Property="INSTALLFOLDER" Value="[INSTALLFOLDER]"><![CDATA[1]]></Publish>
</Control>
在以下位置添加此自定義操作(右鍵單擊解決方案,添加新項目,C#自定義操作項目):
[CustomAction]
public static ActionResult SpawnBrowseFolderDialog(Session session)
{
session.Log("Started the SpawnBrowseFolderDialog custom action.");
try
{
Thread worker = new Thread(() =>
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = "Please select an installation directory to house core files and components.";
dialog.SelectedPath = session["INSTALLFOLDER"];
DialogResult result = dialog.ShowDialog();
session["INSTALLFOLDER"] = dialog.SelectedPath;
});
worker.SetApartmentState(ApartmentState.STA);
worker.Start();
worker.Join();
}
catch (Exception exception)
{
session.Log("Exception while trying to spawn the browse folder dialog. {0}", exception.ToString());
}
session.Log("Finished the SpawnBrowseFolderDialog custom action.");
return ActionResult.Success;
}
將您的程序的<Directory>
元素嵌套在<Directory Id="WindowsVolume">
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.