7

我正在尝试使用 Wix 为 MVC4 应用程序创建安装程序。我在此链接找到了一个示例,该示例显示了如何为 MVC4 应用程序创建安装程序

但是当我尝试构建 Wix 设置项目时,它给了我如下错误

Error   16  Unresolved reference to symbol 'WixComponentGroup:MyWebWebComponents' 
in section 'Product:{D16E42B5-3C6F-4EE5-B2F4-727BF8B74A92}'.    
C:\Users\Baris\Desktop\New folder\WIXInstallerDemo-master\DemoWebsite.Setup\Product.wxs 15  
1   DemoWebsite.Setup

Error   17  Unresolved reference to symbol 'WixComponentGroup:DemoWebsiteIssConfiguration' 
in section 'Product:{D16E42B5-3C6F-4EE5-B2F4-727BF8B74A92}'.    
C:\Users\Baris\Desktop\New folder\WIXInstallerDemo-master\DemoWebsite.Setup\Product.wxs 16  
1   DemoWebsite.Setup`

我尝试添加 WixUIExtension 作为参考,但它不起作用。

这是 Product.wxs。并且特征节点的子节点会导致此错误

    <?xml version="1.0" encoding="UTF-8"?>
    <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Product Id="{D16E42B5-3C6F-4EE5-B2F4-727BF8B74A92}" Name="Demo website setup" Language="1033" Version="1.0.0.0" Manufacturer="Me" UpgradeCode="9279b740-8419-45c4-9538-6a45f8e949c7">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <Media Id="1" Cabinet="DemoWebsite.cab" EmbedCab="yes" />

    <Property Id="DB_USER" Value="sa"/>
    <Property Id="DB_PASSWORD" Value="sa"/>
    <Property Id="DB_SERVER" Value="LOCAL"/>
    <Property Id="DB_DATABASE" Value="DemoWebsite"/>

    <Feature Id="ProductFeature" Title="DemoWebsite.Setup" Level="1">
      <ComponentGroupRef Id="MyWebWebComponents" />
      <ComponentGroupRef Id="DemoWebsiteIssConfiguration" />
    </Feature>
    <!-- Specify UI -->
    <UIRef Id="MyUI" />
    <Property Id="WIXUI_INSTALLDIR" Value="INETPUB" />
  </Product>

  <Fragment>
    <!-- Will default to C:\ if that is the main disk-->
    <Directory Id="TARGETDIR" Name="SourceDir">
      <!-- Will reference to C:\inetpub-->
      <Directory Id="INETPUB" Name="Inetpub">
        <!-- Will reference to c:\Inetpub\Demowebsite-->
        <Directory Id="INSTALLFOLDER" Name="DemoWebsite">
        </Directory>
      </Directory>
    </Directory>
  </Fragment>
</Wix>

我究竟做错了什么?我知道它对 SO 非常具体,但我在网上找不到任何解决方案。

我正在使用 VS 2012-Wix 4.0

4

1 回答 1

6

错误消息说明了一切:它需要一个ComponentGroup包含您的组件的 -tag(例如包含文件或注册表项)。如果您查看您在问题中链接的示例项目,<ComponentGroupRef Id="DemoWebsiteIssConfiguration" />-element 会引用ComponentGroup名为 a 的DemoWebsiteIssConfiguration。您可以在文件中找到它DemoWebsite.Setup\IISConfiguration.wxs

<ComponentGroup Id="DemoWebsiteIssConfiguration">
  <ComponentRef Id="InstallWebsite" />
  <ComponentRef Id="DemoWebsiteAppPool" />
</ComponentGroup>

ComponentGroup包含两个组件,或者在这种情况下,引用两个组件。这些组件ComponentGroup在同一文件中的 - 元素上方定义。

关于另一个ComponentGroupRefid MyWebComponents:引用ComponentGroup是在构建期间动态创建的。你可以看一下文件DemoWebsite.Setup\setup.build。此文件是用于构建设置的MSBuild文件。它包含一个名为Harvest调用的目标heat,这是 WiX 工具集包中的另一个工具。heat将解析例如一个目录并收集其中包含的所有文件并将它们放在一个ComponentGroup您可以在源文件中引用的文件中。即,您定义对 a 的引用ComponentGroup,然后您可以动态创建 this 的内容。这样您就不必担心是否将文件添加到项目中或从项目中删除,因为heat将动态收集它们。

 <Target Name="Harvest">
    <!-- Harvest all content of published result -->
    <Exec
        Command='$(WixPath)heat dir $(Publish) -dr INSTALLFOLDER -ke -srd -cg MyWebWebComponents -var var.publishDir -gg -out $(WebSiteContentCode)'
        ContinueOnError="false"
        WorkingDirectory="." />
  </Target>

动态创建的名称由ComponentGroup参数定义-cg。您可以使用参数调用heat-?获取可能参数的简短描述。

于 2014-05-08T07:43:27.977 回答