MSBuild

MSBuild enables developers to orchestrate and build products in build lab environments where Visual Studio is not installed.

The MSBuild project file format enables developers to fully describe what items need to be built as well as how they need to be built with different platforms and configurations. In addition, the project file format enables developers to author re-usable build rules that can be factored into separate files so that builds can be performed consistently across different projects within their product.

How to publish one web project from a solution

You may run into the issue from the command line by passing the following properties to MSBuild.exe. /p:DeployOnBuild=true
/p:PublishProfile=MyWeb
/p:Password=%password%

When you pass these properties to msbuild.exe they are known as global properties. These properties are passed to every project that is built. Because of this if you have a solution with multiple web projects, when each web project is built it is passed in the same set of properties. Because of this when each project is built the publish process for that project will start and it will expect to find a file named PublishWeb.pubxml in the folder Properties\PublishProfiles\. If the projct file doesn’t exist the operation will fail.

Add the following property group before the Import statements in the .csproj file.

	<PropertyGroup>
		<DeployOnBuild Condition="'$(DeployProjWeb)'!=''">$(DeployProjWeb)</DeployOnBuild>
	</PropertyGroup>  

Instead of passing DeployOnBuild, you may pass in DeployProjWeb which will then set DeployOnBuild. Since DeployOnBuild wasn’t passed to other projects it will not attempt to publish.

if "%1" == "" goto usage

rd /s /q C:\www\MyWeb

"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" MyWeb.csproj
/p:Configuration=Release 
/p:DeployProjWeb=true 
/p:PublishProfile=MyWeb 
/p:WarningLevel=0 
/fl /flp:logfile=msbuild_MyWeb.log;verbosity=diagnostic

goto end

:usage

echo run_msbuild_MyWeb -

:end

Inside the Microsoft Build Engine: Using MSBuild and Team Foundation Build