How can I execute programs in my %PATH% with MSBuild?

馋奶兔 提交于 2019-12-06 02:16:34

Have you tried this extension pack for mercurial/msbuild? http://msbuildhg.codeplex.com/documentation

Seems to have a task for returning revision id, which is what your trying to achieve no?

<HgVersion LocalPath="$(MSBuildProjectDirectory)" Timeout="5000">
     <Output TaskParameter="Revision" PropertyName="AssemblyRevision" />
</HgVersion>

Okay, I found the solution.
I have to admit, it was a classic case of PEBKAC :-)

I'll explain it anyway, maybe it will help someone who made the same mistake:

Basically everything I have tried (plus what James Woolfenden suggested in his answer) would have been worked...if only the batch file that I use to run the build script wouldn't have looked like this:

path="%windir%\Microsoft.net\Framework\v4.0.30319"

msbuild build.proj

Yes, exactly.
I'm editing the %PATH% variable for the duration of this batch file, and I'm overwriting it with the path to MSBuild instead of just appending it.

So when my build script tries to call Mercurial, it can't find it anymore because its location is not in the %PATH% variable anymore.
No idea why I didn't see this before.

The correct way would be to append the MSBuild path, leaving the other paths intact:

path=%path%;%windir%\Microsoft.net\Framework\v4.0.30319
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!