there are some questions about this around here, but none has a valid (for me) answer. The question is:
Is there a way to determine the location of mstest.exe from within a msbuild project, without hardcoding either the path or using the $(VSxxComnTools) or $(VSINSTALLDIR) variables?
Reason for the latter is, because this needs to run on a build server (non-TFS but Bamboo or TeamCity) that only has the VS Test Agents installed and not a full VS.
Additional Info: Of course, this must also work on every other machine that has msbuild, the c# compiler and mstest installed, because everybody should be able to check out the project from github, call the msbuild and everything should run just smoothly.
You could use
This assumes you are working with the same version ie 2012 of the skus on all your assets. Ofcourse you can easily create fallbacks to other versions in your project itself.
Refer Use 32bit "Program Files" directory in msbuild.