Wix错误未定义的预处理器变量(错误CNDL0150)

问题描述 投票:1回答:1

我正在尝试使用WIX构建我的第一个安装程序。我没有使用visual studio而是使用命令行。我有一个wxs文件,我也为Headers创建了一个.wxi文件,我已经定义了它们当我运行candle.exe“未定义的预处理器变量'$(var.ProjectDir)'”时,我得到以下错误

这是.wxs和.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代码

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

关于萨格尔

wix wix3.5 wix3
1个回答
2
投票

您需要在每个wxs文件中包含您的wxi文件,您希望在<Wix>标记之前使用文件顶部的属性

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

This page将解释预处理器的一些可用变量,如“SOURCEFILEDIR”。

© www.soinside.com 2019 - 2024. All rights reserved.