-1

People in my office often ask me 'how do I run those tests?'. I tell them, browse to the Build folder, open a command prompt, and run msbuild /t:Tests.

That works for me, because msbuild is in my path

> where msbuild.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

However it doesn't work for everyone else, because they might not have that folder in their path. Explaining how to change that is tedious.

Is it possible to make the command work for everyone, even if they don't have the folder in their path?

I'm imagining a file msbuild.cmd in the Build folder that fixes the problem. It would run the real msbuild.exe with the same arguments (it's not always /t:Tests). It would first look in the path for msbuild.exe, then in C:\Windows\Microsoft.NET\Framework\v4.0.30319.

1
  • Sure...Just tell them the full path of the exe and include that in the command you tell them. Infact forget about the path file if you simply did C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /t:Tests it does what you want.
    – Ramhound
    May 31, 2013 at 15:38

1 Answer 1

0

Went with

@echo off
REM This shim helps anyone who doesn't have msbuild in their path.

for %%X in (msbuild.exe) do (
    msbuild.exe %*
    exit /b
)

echo "You should probably add msbuild to your path."

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" %*
exit /b
1
  • if the last part relays the arguments to the exe file, what does the for %%X part do ?
    – beppe9000
    Jan 14, 2021 at 17:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .