1
votes

I am trying to build my first installer using WIX. I am not using visual studio instead i am using command line. I have a wxs file and i have also created a .wxi file for the Headers and i have defined them buy i get the following error when i run the candle.exe "Undefined preprocessor variable '$(var.ProjectDir)'"

Here is the .wxs and .wxi

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="{CB06C559-BCBF-4C85-95F3-FE55F6F50463}" Name="My first msi installer" Language="1033" Version="1.0.0.0" Manufacturer="Wave-axis" UpgradeCode="9be991bb-ceb1-4320-bfc7-56738e32c99a">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <Icon Id="icon.ico" SourceFile="$(var.ProjectDir)icon.ico" />
    <Property Id="WAVEAXIS" Value="icon.ico" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />

    <UIRef Id="WixUI_Minimal" />
    <!--used for the UI for the installer-->


    <Feature Id="ProductFeature" Title="My first msi installer" Level="1">
      <!-- This includes all the feature of the installer-->
      <ComponentGroupRef Id="ProductComponents" />
      <ComponentRef Id="ApplicationShortcut" />
      <!--Used for shortcut on the start up menu-->
      <ComponentRef Id="ApplicationShortcutDesktop" />
      <!--used for desktop shortcut-->
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <!--install location of the application-->
        <Directory Id="INSTALLFOLDER" Name="My first msi installer" />
      </Directory>
      <Directory Id="ProgramMenuFolder">
        <!--install location for the startup-->
        <Directory Id="ApplicationProgramsFolder" Name="My first msi installer" />
      </Directory>
      <Directory Id="DesktopFolder" Name="Desktop" />
      <!--install loaction for the desktop-->
    </Directory>
  </Fragment>
</Wix>

.wxi code

<?xml version="1.0" encoding="utf-8"?>
<Include xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <?define firstapplication.TargetDir ?>
  <?define ProjectDir ?>
  <?define firstapplication_TargetDir ?>
  <?define ProductId=652648517 ?>

</Include>

regards Sagar

1
post your code, not images of it - Ayush Gupta
Hi sorry for that i was in a hurry and was not able to get how to share the code.. this is my first question ill do it from the new time - Sagar Hs
NP. just edit to update your post. Also for reference, Please read and follow: What kinds of questions can I ask, How to ask. Make sure to always include an Minimal, complete, Verifiable Example. Finally, check out Research. then, we can help !. All the best. - SherylHohman

1 Answers

2
votes

You need to include your wxi file in every wxs file you wish to use the properties in at the top of your file before the <Wix> tag

<?include $(sys.SOURCEFILEDIR)Path\to\InstallVars.wxi?>
<Wix xmlns="http://...">
    ...
</Wix>

This page will explain some of the available variables for the preprocessor like "SOURCEFILEDIR".