viraptor
viraptor

Reputation: 34145

How to specify source location in wix

How do I make the sources specified in a heat generated file visible to the build?

I've got a project named Foo and a project named FooSetup. They have the same parent directory. To generate the list of files to install I ran in FooSetup:

heat dir "..\Foo\bin\Release" -cg "SomeGroupName" -ag -template:fragment -out heat.wxs

Now when I try to build the installer, I get:

The system cannot find the file 'SourceDir\Foo.dll'.

(that file does exist in the Release directory)

The path to Foo\bin\Release is specified in include paths in the FooSetup project properties.

What am I missing here - why is none of the listed files found?

Upvotes: 1

Views: 892

Answers (1)

Stein Åsmul
Stein Åsmul

Reputation: 42126

WiX Learning Resources: A couple of links to resources on WiX:


WiX Preprocessor Variables: What is SourceDir? Rob Mensching (WiX creator) on SourceDir.

As explained here you can change SourceDir to a compiler variable:

Heat.exe: Something like this:

"%WIX%bin\heat.exe" dir . -sfrag -suid -ag -var MyReleasePath -out MySource.wxs

You will get something like this:

<!-- Extract -->

  <Component Id="MyFile.exe" Guid="*">
     <File Id="MyFile.exe" KeyPath="yes" Source="$(MyReleasePath)\MyFile.exe" />
  </Component>

<!-- End of Extract -->

WiX Sample: Then you insert this into your source. Something like this:

<!-- START OF COMPILER VARIABLES: -->
<?define MyVersion = "1.0.0.0" ?>
<?define MyReleasePath = "C:\My Releases\Wix Testing\" ?>
<!-- END OF COMPILER VARIABLES: -->

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <Product Id="*" Name="WiX Testing" Language="1033" Version="$(var.MyVersion)"
           Manufacturer="WiX Testing" UpgradeCode="PUT-GUID-HERE">

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

    <!-- Enable line below for GUI in MSI -->
    <!-- <UIRef Id="WixUI_Mondo" /> -->
    
    <MediaTemplate EmbedCab="yes" />
    <Feature Id="Main" Title="Main Feature" Level="1" />

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="WiX Testing">

         <!-- Essential part follows: -->

          <Component Feature="Main">
            <File Source="$(var.MyReleasePath)MyFile.exe"></File>
          </Component>

         <!-- End of Essential part -->

        </Directory>
      </Directory>
    </Directory>
  </Product>

</Wix>

Batch File Compile: Visual Studio takes care of most of the build issues once you have defined the variables. If you want to compile "manually", here is a quick sample:

"%WIX%bin\candle.exe" MySource.wxs -ext WixUIExtension >> Build.log
"%WIX%bin\light.exe" -out Test.msi MySource.wixobj -ext WixUIExtension >> Build.log

Links:

Upvotes: 1

Related Questions