-1

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.

tg24
  • 161
  • 3
  • 22
  • What about "build" > "batch build..."? it's not one click, but it seems to allow building multiple configurations in one run. This is VS 2017 by the way, I don't know if it's available in 2015 or not – musefan Jun 06 '18 at 07:47
  • That's helpful, thank you! Didn't noticed this before. If you want to write an answer for the question, I can mark it as answered. – tg24 Jun 06 '18 at 12:21
  • The IDE does nothing to make this simple to do. Creating two EXE files is however very easy, just add another project. It will be a very small one, all it needs to do is Process.Start() to start the first one. – Hans Passant Jun 06 '18 at 14:41

1 Answers1

0

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"

musefan
  • 47,875
  • 21
  • 135
  • 185