6

I am using Wix 3.8 to create an MSI installer for a Visual Studio project I have created. I followed this simple tutorial but even with this simply Wix project I am getting errors. Here is My

I have added my VS2012 project as a reference to my Wix Installer.

Here is my Product.ws file:

<?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>

When I compile this, I get the following error:

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

I have searched the bowels of the internet for a solution to this very basic problem. Why is VS2012 not recognising the element?

John 'Mark' Smith
  • 2,564
  • 9
  • 43
  • 69
  • 5
    What happens if you uncomment the `Component` element? – Biffen Sep 22 '14 at 15:08
  • Try the [Wix Schema Reference: ComponentGroup Element](http://wixtoolset.org/documentation/manual/v3/xsd/wix/componentgroup.html) or [File Element](http://wixtoolset.org/documentation/manual/v3/xsd/wix/file.html). – Tom Blodget Sep 24 '14 at 01:57
  • 3
    I did what John did and ran into the same issue. Sure the fix is easy enough, but the point is this tutorial is wrong (this is probably the go-to tutorial for anyone using WiX in VS for the first time!). And apparently, it has been since at least 2014 when this question was asked. Using latest v3.11 / VS2017 tools. – Adam Plocher May 30 '17 at 04:03

2 Answers2

6

You should follow next hierarchy: ComponentGroup -> Component -> File and etc. In your example i suggest to you to put File element into separated component and then add this component into ComponentGroup. Try something like this:

<Component Directory="YOUR-DIRECTORY" Guid="your-guid" Id="SomeComponent">
    <File Source="$(var.MyProject.TargetPath)"/>
</Component>
<ComponentGroup Directory="INSTALLFOLDER" Id="ProductComponents">
    <ComponentRef Id="SomeComponent"/>
</ComponentGroup>
Andrew Usikov
  • 701
  • 8
  • 13
1

Read the TODO comment right above your <File Source> You need to remove the comments around <Component Id="ProductComponent"> and </Component>.

xxsharox2
  • 11
  • 1