I do not like to copy anyones work, and found out about this process myself and wanted to save myself time when releasing when tfs build succeds.
Step one:
Open visual studio command line:C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\VsDevCmd.bat""
Now you can run msbuild command.
Step two:
Create your publish.msbuild file.
Step three:
File content
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<PropertyGroup>
<PublishDestination>C:\Release\Test</PublishDestination>
<Configuration>Release</Configuration>
</PropertyGroup>
<Target Name="Build" >
<Error Condition="'$(PublishDestination)'==''" Text="The PublishDestination property must be set to the intended publishing destination." />
<MakeDir Condition="!Exists($(PublishDestination))" Directories="$(PublishDestination)" />
<MSBuild Projects="WebUi\WebUi.csproj"
Properties="Platform=AnyCPU;Configuration=Release;
DeployOnBuild=true; DeployTarget=PipelinePreDeployCopyAllFilesToOneFolder;_PackageTempDir=$(PublishDestination);" />
</Target>
</Project>