wpfvisual-studiomanifestpost-build

Compile application twice with different manifest files


Is there a way to compile a WPF application twice in Visual Studio (version 2015/2017) with different manifest files? On the one hand I need the application to require administrator permissions, on the other hand the same application without administrator permissions (means: without or another manifest file).

With compile constants I'm able to do something like this:

<?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>

but this doesn't seem to work like expected. A solution where I only need to click the build button once and receive two applications would be perfect.

Another possible solution is to use post-build commands, but I'm not sure if this will work.


Solution

  • There is an option in Visual Studio 2017 (and maybe earlier versions, I cannot confirm) that allows you to build multiple configurations in a single run.

    Look at the toolbar menu: "Build" > "Batch Build"