How can I run specific post build events in visual studio based on a compiler condition? I know I can do it based on the configuration name such as Debug/Release but that isn't quite what I want. I have say a compiler condition called "ENABLE_XX" and I want to perform some xcopy commands based on this.
Asked
Active
Viewed 28 times
0
-
Take a look at the accepted answer to https://stackoverflow.com/questions/12200301/is-it-possible-to-use-conditional-compilation-symbols-in-vs-build-events. It's important to realize that the script in the pre- and post-build event boxes is simply executed by CMD.exe - quirks and all. But you also get some VS-provided magic like "$(DefineConstants.Contains('ENABLE_XX'))". It's also important to remember that when you get to a build box, MS_BUILD will do the same thing (more or less - be sure to test) that VS does with the pre- and post-build scripts – Flydog57 Sep 15 '21 at 01:40
-
I couldn't get this is work, does this still work in VS 2019? if "$(DefineConstants.Contains('XXX_ENABLE'))" == "True" xcopy /y /d /s "$(SolutionDir)XXX\bin\$(ConfigurationName)" "$(ProjectDir)$(OutDir)\XXX\" Doesn't seem to actually copy althought XXX_ENABLED is defined in the conditional compilation symbols. – rukiman Sep 15 '21 at 07:05
-
I tested it out with `echo` statements and it worked like a charm on VS 2019 (the echoed stuff shows up in the build spew). I've done this before, and it's real finicky (it's the CMD language and it's in VS). Using `echo` is your friend for ringing it out – Flydog57 Sep 15 '21 at 11:34