Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS MSBuild: $(ProjectDir) blank or random

Tags:

msbuild

tfs

I have a vcproj file that includes a simple pre-build event along the lines of:

Helpertask.exe $(ProjectDir)

This works fine on developer PCs, but when the solution is built on our TFS 2008 build server under MSBuild, $(ProjectDir) is either blank or points to an unrelated folder on the server!

So far the best workaround I have managed is to hard code the developer and server paths instead:

if exist C:\DeveloperCode\MyProject   HelperTask.exe C:\DeveloperCode\MyProject
if exist D:\BuildServerCode\MyProject HelperTask.exe D:\BuildServerCode\MyProject

This hack works in post-build steps but it doesn't work for a pre-build step (the Pre-build task now does nothing at all under MSBuild!)

Do you have any ideas for a fix or workaround? I have very little hair left!

like image 909
Jason Williams Avatar asked Dec 23 '22 10:12

Jason Williams


1 Answers

$(MSBuildProjectDirectory) worked for me

like image 120
Ben Avatar answered Dec 28 '22 10:12

Ben