Using Wix to generate an MSI

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?

Upvotes: 7

Views: 2234

Answers (2)

xxsharox2
xxsharox2

Reputation: 11

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

Upvotes: 1

Andrei U
Andrei U

Reputation: 731

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>

Upvotes: 6

Related Questions