visual-studio-2012
  • wix
  • windows-installer
  • wix3
  • 2014-09-22 68 views 4 likes 
    4

    我正在使用Wix 3.8为我创建的Visual Studio项目创建MSI安装程序。我跟着this simple tutorial,但即使这个简单的Wix项目,我收到错误。这里是我的使用Wix生成MSI

    我已经添加了我的VS2012项目作为我的Wix安装程序的参考。

    这里是我的Product.ws文件:

    <?xml version="1.0" encoding="UTF-8"?> 
    <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' 
        xmlns:iis='http://schemas.microsoft.com/wix/IIsExtension'> 
        <Product Id="*" Name="MyProjectInstaller2" Language="1033" Version="2.0.0.0" Manufacturer="Company" UpgradeCode="7f5b63be-bdad-4cc9-b4df-b3f1648c0539"> 
         <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /> 
    
         <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." /> 
         <MediaTemplate /> 
    
         <Feature Id="ProductFeature" Title="MyProjectInstaller2" Level="1"> 
          <ComponentGroupRef Id="ProductComponents" /> 
         </Feature> 
        </Product> 
    
        <Fragment> 
         <Directory Id="TARGETDIR" Name="SourceDir"> 
          <Directory Id="ProgramFilesFolder"> 
           <Directory Id="INSTALLFOLDER" Name="MyProjectInstaller2" /> 
          </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"> --> 
         <File Source="$(var.MyProject.TargetPath)" /> 
          <!-- </Component> --> 
         </ComponentGroup> 
        </Fragment> 
    </Wix> 
    

    当我编译,我得到以下错误:

    The ComponentGroup element contains an unexpected child element 'File'. 
    

    我已经在网上搜索的深处为解决这一非常基本的问题。为什么VS2012不能识别元素?

    +4

    如果取消注释“Component”元素,会发生什么情况? – Biffen 2014-09-22 15:08:05

    +0

    试试[Wix Schema Reference:ComponentGroup Element](http://wixtoolset.org/documentation/manual/v3/xsd/wix/componentgroup.html)或[File Element](http://wixtoolset.org/documentation/)手动/ V3/XSD /威克斯/ file.html)。 – 2014-09-24 01:57:07

    +0

    我做了约翰所做的事,并遇到同样的问题。确定修复很容易,但是关键是这个教程是错误的(这可能是第一次在VS中使用WiX的人的教程!)。显然,自从2014年至少有人问到这个问题以来。使用最新的v3.11/VS2017工具。 – 2017-05-30 04:03:22

    回答

    5

    你应该遵循下一层次:ComponentGroup - > Component - > File等在你的例子中,我建议你把File元素放入分离的组件中,然后将这个组件添加到ComponentGroup中。尝试这样:

    <Component Directory="YOUR-DIRECTORY" Guid="your-guid" Id="SomeComponent"> 
        <File Source="$(var.MyProject.TargetPath)"/> 
    </Component> 
    <ComponentGroup Directory="INSTALLFOLDER" Id="ProductComponents"> 
        <ComponentRef Id="SomeComponent"/> 
    </ComponentGroup> 
    
    相关问题