12

In Visual Studio postbuild, I need to run a batch file. The solution is potentially on a different drive to that which Visual Studio is running from. In postbuild, how do I determine the drive letter that the solution is running from so I can change to that drive before running the batch file? At the moment, all I have is this:

CD $(ProjectDir)
$(ProjectDir)postbuild.bat

The problem is that changing directory when that directory is on a different drive does not change the current directory, as you have to manually change which drive you're on, e.g. like so:

E:\
CD $(ProjectDir)
$(ProjectDir)postbuild.bat

I can't guarantee what drive the solution is going to be on though, so I need to determine the drive via some kind of macro to ensure the postbuild.bat file will run from the currect location.

Nathan Ridley
  • 33,766
  • 35
  • 123
  • 197

1 Answers1

16
CD /D $(ProjectDir)
Roger Lipscombe
  • 89,048
  • 55
  • 235
  • 380