-1

有没有办法在 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>

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

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

4

1 回答 1

0

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

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

于 2018-06-06T12:52:00.233 回答