WIX 在 x86/x64 输出目录中找不到 app.exe

WIX cannot find app.exe in x86/x64 output directory

我有一个 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),我找不到其他变量。

也许试试这个:

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

    <Fragment>
      <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
       <Component>
        <File Source="$(var.TestConsoleApplication.TargetPath)" />
       </Component>
      </ComponentGroup>
    </Fragment>
    
  5. 全部重建。
  6. 切换发布和调试构建,然后再次全部重建。

链接:

实际上我通过将整个路径放在我的 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 ?>