Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Build MSBuild target without dependencies

Is there any way I can tell MSBuild 4.0 to build a target, but ignore any dependencies? I just want to build that target itself, nothing else.

like image 720
EMP Avatar asked Feb 28 '11 01:02

EMP


2 Answers

I would like to reiterate @EMP's solution (and I can't vote him up due to my puny reputation).

The correct way to avoid MSBuild's default behavior of rebuilding all the dependencies listed in the project file is to set the BuildProjectReferences property to false.

In his answer he invokes MSBuild from within an MSBuild script; here's an example from the command line:

MSBuild myproj.csproj /p:Configuration=Debug /p:BuildProjectReferences=false /t:Build 
like image 189
Lee K-A Avatar answered Sep 23 '22 20:09

Lee K-A


It turns out the built-in Build target checks a property named BuildProjectReferences to tell whether to build references or not. I do need to run Build on the project itself (otherwise it doesn't work), just not on its dependencies. I ended up calling:

<MSBuild Projects="MyCloudProject.ccproj" Targets="CorePublish" Properties="Configuration=$(Configuration); BuildProjectReferences=false" /> 
like image 29
EMP Avatar answered Sep 20 '22 20:09

EMP