3

我想为我的应用程序创建一个安装程序。我已经下载了 WiX 3.6 并将其安装在 vs 2012 上。

  1. 创建简单的winform应用程序
  2. 将 WiX 设置项目添加到我的解决方案
  3. 右键单击参考并将我的 winform 应用程序添加到设置的参考
  4. 我构建解决方案并转到安装项目中的调试目录并运行 SetupProject1.exe.msi 它不起作用并关闭安装程序对话框而没有任何错误。

返回设置项目

  1. 右键单击设置项目并选择属性
  2. 在安装程序选项卡 > 输出类型上,将其更改为 executablefile.exe
  3. 构建它并去调试并运行 SetupProject1.exe - 仍然不起作用

怎么了?这是我的设置项目 product.wxs

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="Natiloos" UpgradeCode="cfc2f4dd-2da5-49e2-9099-96968d75aaa4">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is  already installed." />
    <MediaTemplate />

    <Feature Id="ProductFeature" Title="SetupProject1" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="SetupProject1" />
        </Directory>
    </Directory>
</Fragment>

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
        <!-- TODO: Remove the comments around this Component element and     the ComponentRef below in order to add resources to this installer. -->
        <!-- <Component Id="ProductComponent"> -->

        <!-- </Component> -->
    </ComponentGroup>
</Fragment>

如何让安装程序正确构建?

4

2 回答 2

4

问题是您的安装程序没有安装任何东西。添加您的项目作为对安装程序的引用并不意味着安装程序将包含您的项目输出。在您的设置项目中,您有:

<Fragment>
  <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
    <!-- TODO: Remove the comments around this Component element and     the ComponentRef below in order to add resources to this installer. -->
    <!-- <Component Id="ProductComponent"> -->

    <!-- </Component> -->
  </ComponentGroup>
</Fragment>

您需要添加文件...即取消注释<Component></Component>标签并手动添加文件。最好<Component>每个文件有一个标签。

例子:

 <Component Id="MyProgram.exe" Guid="PUT-GUID-HERE">
      <File Id="MyProgram.exe" KeyPath="yes" Source="Path_To_Output_Folder\MyProgram.exe" />
 </Component>
于 2012-09-27T18:18:43.807 回答
0

您描述的类型的 WiX 项目会生成 MSI 文件,扩展名为 .msi。这些安装程序不直接运行,而是使用msiexec.exe. 默认情况下,当您双击它们时,Windows 资源管理器会为您执行此操作,但是您可以msiexec使用如下命令显式调用

msiexec MyInstaller.msi

请注意,MSI 文件与可执行文件完全不同 - 将安装程序的输出名称更改为具有 .exe 扩展名,或将文件重命名为具有 .exe 扩展名将不起作用。

如果您想生成基于 .exe 的安装程序,那么您需要一个引导程序。WiX 有一个叫做 Burn,但是如果我是你,我会担心首先制作一个可以工作的 MSI,然后再担心创建一个可执行的引导程序。

于 2012-09-27T15:13:47.593 回答