Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 537
John 'Mark' Smith Avatar asked Sep 22 '14 15:09

John 'Mark' Smith


People also ask

How do I create an MSI File with WiX?

Adding a WiX setup project In Visual Studio, open your solution, and add a WiX project to it: go to the Visual Studio main menu and click File -> Add -> New Project to open the Add New Project dialog. Choose the Setup Project item in the Windows Installer XML node, specify the project name and click OK.

How do I create a Windows Installer MSI .NET core WiX?

You just need to create a new WiX project, add your app files, and then build the project. That's it! To create a new WiX project, open Visual Studio and go to File > New > Project. In the New Project dialog, select the “WiX Toolset” template from the list of available templates.

What is WiX MSI?

Windows Installer XML Toolset (WiX, pronounced "wicks"), is a free software toolset that builds Windows Installer packages from XML. It consists of a command-line environment that developers may integrate into their build processes to build MSI and MSM packages.


1 Answers

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>
like image 186
Andrew Usikov Avatar answered Oct 17 '22 10:10

Andrew Usikov