visual-studio-2012
  • wix
  • windows-installer
  • wix3
  • 2014-09-22 64 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> 
    
    相關問題