使用不同的清单文件两次编译应用程序

时间:2018-06-06 07:44:08

标签: wpf visual-studio manifest post-build

有没有办法在Visual Studio(2015/2017版)中使用不同的清单文件两次编译WPF应用程序? 一方面,我需要应用程序需要管理员权限,另一方面需要没有管理员权限的相同应用程序(意味着:没有或其他清单文件)。

使用编译常量,我可以做这样的事情:

<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
  <assemblyIdentity version="1.0.0.0" name="Update.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
#if ADMIN
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
#endif
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

但这似乎不像预期的那样有效。 我只需要单击构建按钮一次并接收两个应用程序的解决方案就是完美的。

另一种可能的解决方案是使用构建后命令,但我不确定这是否有效。

1 个答案:

答案 0 :(得分:0)

Visual Studio 2017中有一个选项(可能是早期版本,我无法确认),允许您在一次运行中构建多个配置。

查看工具栏菜单:"Build" > "Batch Build"