Fix #483810: Use working directory placeholders when executing the run command
Previously the placeholders were only replaced when a target was build. This moves the placeholder replacement code into a helper function and calls it when building and running the target.