Hi Sayed
Great article, although I can't quite get what I want to work. Instead
working with a .sln file I tried it linking in another .csproj file to try
and override the BuildDependson property as described in your artical.
Below is the .proj if you can give it a quick scan with an experts eye (
it's a cut down version of my original .sln version).
As you can see am trying to override the build properties and call a custom
before build target- but it don't work...
I really appreciate your help thanks.
Dan
<!--=============== =============== =============== =============== =============== ============
MSBuild file which can be used to inject steps into the building of solution
files
=============== =============== =============== =============== =============== =============== =-->
<Project DefaultTargets= "BuildSolut ion"
xmlns="http://schemas.microso ft.com/developer/msbuild/2003">
<PropertyGrou p>
<BuildSolutionD ir>c:\devtest\</BuildSolutionDi r>
</PropertyGroup>
<ItemGroup>
<!-- Item for solutions file(s) -->
<SlnFiles Include="$(Buil dSolutionDir)*. csproj"/>
</ItemGroup>
<Target Name="BuildSolu tion" >
<!-- Have MSBuild emit the solution -->
<!-- Create a new item to pick up the newly generated file -->
<CreateItem Include="$(Buil dSolutionDir)*. csproj">
<Output TaskParameter=" Include" ItemName="Solut ionMSBuildFiles "/>
</CreateItem>
<!--
Call MSBuild for each solution file. Pass the property:
theSolution=SOL UTION_FILE_TO_B UILD.
In the DoBuildSolution we use this to determine which file to build.
-->
<MSBuild Projects="$(MSB uildProjectFile ) "
Targets="DoBuil dSolution"
Properties="@(S olutionMSBuildF iles->'theSolution=$ (BuildSolutionD ir)%(Filename)% (Extension)')"/>
</Target>
<PropertyGrou p>
<DoBuildSolutio nDependsOn>
BeforeDoBuildSo lution;
CoreBuildSoluti on;
AfterDoBuildSol ution
</DoBuildSolution DependsOn>
</PropertyGroup>
<Target Name="DoBuildSo lution"
DependsOnTarget s="$(DoBuildSol utionDependsOn) " />
<Target Name="BeforeDoB uildSolution">
<Message Text="********* *****Before building your solution******* **********"
Importance="hig h"/>
</Target>
<!--
Here is where we actually build the solution passed to us.
-->
<Target Name="AfterDoBu ildSolution">
<Message Text="######### #####After building your solution####### ###########"
Importance="hig h"/>
</Target>
<PropertyGrou p>
<BuildDependsOn >
CustomBeforeBui ld;
$(BuildDependsO n);
</BuildDependsOn>
</PropertyGroup>
<Target Name="CustomBef oreBuild">
<Message
Text="!!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!!!!! !!!!!!!!!!!!!Cu stomBeforeBuild !!"
Importance="hig h"></Message>
</Target>
<Target Name="CoreBuild Solution" >
<MSBuild Projects="$(the Solution)" Targets="Build"/>
</Target>
</Project>
"Sayed Ibrahim Hashimi" <Sa************ *****@discussio ns.microsoft.co m>
wrote in message news:DE******** *************** ***********@mic rosoft.com...
Have a look at my MSDN article Inside MSBuild at
http://msdn.microsoft.com/msdnmag/is...d/default.aspx
I think what you're looking for is in the section "Extending the Build
Processes"
Hope that helps
Sayed Ibrahim Hashimi
http://www.sedodream.com
"Danny" wrote:
>Hi
I trying to master msBuild but have a problem. I have a solution that I
wish to build using msbuild but want to override BeforeBuild/AfterBuild
targets for each of the projects. I trying to avoid modifying the
common.targe ts etc and the individual project .sln files and just do it
within a solution proj.
One method I've tried, is to create the .proj file from the .sln file
using
the msbuildemitsolu tion enviroment flag- base upon
http://www.sedodream.com/PermaLink,g...aa24bc7da.aspx
but I still cannot get the targets to be called when the
individual projects are built - I think is is because the projects are
not
imported but are run via a <MSBuild Projects task
does anyone have an example how to do this? or point me in the right
direction
thanks
dan