I can build the whole project by calling MSBuild from the command line:

C:\MyProject>MSBuild MyProject.vcproj

However I didn't find any information about compiling a single file. In essence I would like to do something like

C:\MyProject>MSBuild MyProject.vcproj /t:Compile:MySourceFile.cpp

I do not want to directly use 'cl.exe' from the command line since that would force me to define all relevant command line options for cl.exe and all the environment variables, a task which MSBuild is already doing for me.

Is there any way to achieve that?

And please, do not suggest using 'make' or 'ant' or whatever, I specifically need MSBuild. Thanks

Edit
Report