The posts I see for setting up MSBuild on the tool menu in Visual Studio assume that you want to build the current project. If you’re working with custom msbuild files, this will not be the case. Here’s how you can set up MSBuild in Visual Studio 2010 to compile the currently selected build script and output it to the Output window.
In my situation, I have multiple build scripts for demonstration purposes.
Then open the Tools menu and select “External Tools…” A dialog will appear. Click the ‘Add’ button, and type MSBuild in the name text box. Browse for MSBuild.exe in the command text box, my copy was C:\Windows\Microsoft.NET\Framework64\v4.0.30128\MSBuild.exe. For the Arguments text box, type $(ItemPath). Check “Use Output window.” Your window should look like mine below.
The key here is using the ItemPath property as the argument. This uses the full path and filename of the selected item in Solution Explorer