Search code examples
visual-studiobuild-processbuild-automation

In a Visual Studio pre-build event how do I execute an exe in the context of its own folder instead of the bin folder?


I have a pre-build event defined like this:

$(ProjectDir)PreBuild\runthis.exe

When the runthis.exe executes, it runs in the context of the bin folder of my project instead of the PreBuild folder where it lives. How can I make the build event execute runthis.exe in the context of the PreBuild folder instead of the bin folder?


Solution

  • Add cd $(ProjectDir)PreBuild first to switch to that folder.