1

我有一个 C# 应用程序,它的构建目标是 x86 或 x64。构建输出是(例如)ProjectDir/bin/x86|x64/Debug|Release/*

在我的*.wxs文件中,我定义了以下变量

<?define AppTargetPath = "$(var.MyApp.TargetPath)" ?>

这指向ProjectDir/bin/Debug|Release/app.exe

如果我构建安装程序,它会失败,因为它找不到我的应用程序 exe

<File Id="AppExe" Source="$(var.AppTargetPath)" KeyPath="yes"/>

如果我查看使用项目引用和变量站点(http://wixtoolset.org/documentation/manual/v3/votive/votive_project_references.html),我找不到另一个变量。

4

2 回答 2

0

也许试试这个:

  1. 注释掉您现有的定义。
  2. 将构建 EXE 的项目和您的 WiX 项目添加到同一解决方案中。
  3. 添加从 WiX 项目到 EXE / Binary 项目的引用。
  4. 试试这个标记("TestConsoleApplication"用你的替换项目名称):

    <Fragment>
      <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
       <Component>
        <File Source="$(var.TestConsoleApplication.TargetPath)" />
       </Component>
      </ComponentGroup>
    </Fragment>
    
  5. 全部重建。
  6. 切换 Release and Debug builds,然后再次 Rebuild All。

链接:

于 2019-01-21T20:07:00.940 回答
0

实际上,我通过将整个路径放在我的 wxs 文件顶部来解决它:

<?define AppTargetFileName = "$(var.myApp.TargetFileName)" ?>

<?if $(var.Platform) = x64 ?>
  <?define AppTargetPath = "$(var.myApp.ProjectDir)\bin\x64\$(var.myApp.Configuration)\$(var.AppTargetFileName)" ?>
<?elseif  $(var.Platform) = x86 ?>
  <?define AppTargetPath = "$(var.myApp.ProjectDir)\bin\x86\$(var.myApp.Configuration)\$(var.AppTargetFileName)" ?>
<?else ?>
  <?define AppTargetPath = "$(var.myApp.TargetPath)" ?>
<?endif ?>
于 2019-01-23T07:39:26.257 回答