Getting a Target to run BEFORE anything else runs when building from Visual Studio

Posted by damageboy on Stack Overflow See other posts from Stack Overflow or by damageboy
Published on 2009-12-23T18:56:56Z Indexed on 2010/04/30 1:17 UTC
Read the original article Hit count: 298

Hi, I'm trying to get a one-time costly target to run only when building a certain top-level project (that has many dependencies).

I have no problem on getting this working from plain msbuild / command line build. I do this with setting and InitialTargets on the project, or alternatively with

< BeforeBuild />.

The tricky part is with Visual Studio. When I build the same project from VS. VS runs the dependencies before even invoking my .csproj, so my target (which affects how the other projects are built) doesn't get to run until they have already been built.

Is there someway to force VS to run a target before invoking the dependencies?

I'm currently working around this, by running the same costly target from my most low-level project (the one that get's always built...) by using:

Condition=" $(BuildingInsideVisualStudio) "

Any ideas on how to get this done "properly"? Again, I'm looking for a solution that will work FROM VS.

© Stack Overflow or respective owner

Related posts about msbuild

Related posts about visual-studio-2008