【问题标题】:How to set the variable -var defined in heat.exe to the wxs file?如何将heat.exe中定义的变量-var设置为wxs文件?
【发布时间】:2015-12-04 12:33:37
【问题描述】:

我正在运行以下命令:

heat.exe dir bin\Release -sfrag -sreg -var var.sourcebin -dr myappfolder -cg myapp_comp_group

这会生成一个不错的 wxs 文件,看起来有点像这样:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <ComponentGroup Id="myapp_comp_group">
      <ComponentRef Id="cmpE519314043C2FFE1104E067D33CBC652" />
      <ComponentRef Id="cmp0431CFEC47E793CE59C185A8BDD9D865" />
    </ComponentGroup>
  </Fragment>
  <Fragment>
    <DirectoryRef Id="myappfolder">
      <Directory Id="dir4ADCEBD4F8C9DC384017088D96B7A1C3" Name="somebinfolder">
        <Component Id="cmpE519314043C2FFE1104E067D33CBC652" Guid="EB84C1A8-7BF5-4967-878D-8DAD9DFFA0A6">
          <File Id="filD8C8D39058B0FF5C9608B1F99B0CD5BA" KeyPath="yes" Source="$(var.sourcebin)\app.config" />
        </Component>
      </Directory>
    </DirectoryRef>
  </Fragment>
</Wix>

我在我的项目中使用这个由热生成的 wxs 文件,但我收到一个错误,因为 $(var.sourcebin) 尚未设置。

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <?define sourcebin="C:\svn\myapp\bin\Release"?>

  <!-- leaving some stuff out of course -->
  <Module>
    <ComponentGroupRef Id="myapp_comp_group"/>
  </Module>
</Wix>

错误 CNDL0150:未定义的预处理器变量“$(var.sourcebin)”。

如何定义这个变量,以便它被热生成文件拾取?我不想手动更改热生成文件,因为它每次都会重新生成。

【问题讨论】:

    标签: wix heat


    【解决方案1】:

    打开项目属性,选择构建选项卡并根据需要添加预处理器变量。

    sourcebin="C:\svn\myapp\bin\Release";
    

    在定义部分使用:

    <?define sourcebin = $(var.sourcebin)?> 
    

    加热命令可以保持原样。

    当您需要将变量从 msbuild(Wixproj 文件)传递到项目中的其他文件(wxs、wxi...)时,这将是相同的。使用 TFS 时的常用用法。

    【讨论】:

    • 我可以在构建选项卡上找到预处理器变量,但找不到“定义”部分。你能详细说明它的位置吗?
    猜你喜欢
    • 1970-01-01
    • 2011-08-13
    • 2021-09-27
    • 2016-08-07
    • 1970-01-01
    • 2013-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多