0

I have a post build app that takes a long time to execute. So I need to execute it only when I really need it. Is there a way to execute such an app only when I've pressed a key (eg. SHIFT) and built the project at the same time?

Robin Rodricks
  • 110,798
  • 141
  • 398
  • 607

1 Answers1

2

That's going to be a bit difficult, build events execute in a hidden console mode app, started by msbuild.exe. Directly interacting with the user is not an option.

One thing you can do is write a little program that calls/pinvokes GetAsyncKeyState() to check if VK_SHIFT is down. And set the process exit code accordingly. Which you can then call in your post build event and use if %ERRORLEVEL% to check that return value.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536