我在VS2010中使用WIX创建了一个安装程序。当我安装应用程序时,它正在C:\Program Files\Wixdemoapplication
下安装应用程序和应用程序相关的依赖文件。我需要对此进行自定义。我需要在Wixdemoapplication
下的C:\Wixdemoapplication
下直接安装应用程序,而不是C:\Program Files\Wixdemoapplication
。
需要帮助。
答案 0 :(得分:0)
试试这个(未经测试;但可能足以满足您的需要):
<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;
}
答案 1 :(得分:0)
将程序的<Directory>
元素嵌套在<Directory Id="WindowsVolume">
。