在C:分区而不是Program Files文件夹中安装WIX安装程序应用程序

时间:2014-11-18 15:58:53

标签: c# visual-studio-2010 visual-studio wix

我在VS2010中使用WIX创建了一个安装程序。当我安装应用程序时,它正在C:\Program Files\Wixdemoapplication下安装应用程序和应用程序相关的依赖文件。我需要对此进行自定义。我需要在Wixdemoapplication下的C:\Wixdemoapplication下直接安装应用程序,而不是C:\Program Files\Wixdemoapplication

需要帮助。

2 个答案:

答案 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&amp;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">