<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Sayed Ibrahim Hashimi - MSBuild, Web Deploy (MSDeploy), ASP.NET - TFS</title>
    <link>http://sedodream.com/</link>
    <description>MSBuild, C#, Visual Studio and more</description>
    <language>en-us</language>
    <copyright>Sayed Ibrahim Hashimi</copyright>
    <lastBuildDate>Fri, 27 Jun 2008 06:28:35 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.3.9074.18820</generator>
    <managingEditor>sayed.hashimi@gmail.com</managingEditor>
    <webMaster>sayed.hashimi@gmail.com</webMaster>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=a3e0f4b1-5714-4491-9134-cce95b1d6e19</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,a3e0f4b1-5714-4491-9134-cce95b1d6e19.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://sedodream.com/CommentView,guid,a3e0f4b1-5714-4491-9134-cce95b1d6e19.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a3e0f4b1-5714-4491-9134-cce95b1d6e19</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <title>MSBuild Conditions on Targets</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,a3e0f4b1-5714-4491-9134-cce95b1d6e19.aspx</guid>
      <link>http://sedodream.com/2008/06/27/MSBuildConditionsOnTargets.aspx</link>
      <pubDate>Fri, 27 Jun 2008 06:28:35 GMT</pubDate>
      <description>&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;This post is related to my&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;previous
post &lt;/font&gt;&lt;a href="http://www.sedodream.com/PermaLink,guid,096a2e3f-fcff-4715-8d00-73d8f2491a13.aspx"&gt;&lt;font face=Calibri size=3&gt;MSBuild
RE: Enforcing the Build Agent in a Team Build&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt; which
is a response on the post by Michael Ruminer at &lt;/font&gt;&lt;a href="http://manicprogrammer.com/cs/blogs/michaelruminer/archive/2008/06/19/enforcing-the-build-agent-in-a-team-build.aspx"&gt;&lt;font face=Calibri size=3&gt;http://manicprogrammer.com/cs/blogs/michaelruminer/archive/2008/06/19/enforcing-the-build-agent-in-a-team-build.aspx&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt;. &lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Basically every MSBuild element can contain
a Condtions attribute. You can read more at &lt;/font&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/7szfhaft.aspx"&gt;&lt;font face=Calibri size=3&gt;MSBuild
Conditions&lt;/font&gt;&lt;/a&gt;&lt;font face=Calibri color=#000000 size=3&gt;. So even targets can
have conditions attached to them! Despite the fact that you can do this, you should
not. I recommend that you do not use conditions on targets. Conditions on targets
seem straight forward but after you take a closer look they are more complicated.
We can take a look at some of the items that come to mind here.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font size=3&gt;&lt;font color=#000000&gt;&lt;font face=Calibri&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;Conditions
on targets and DependsOnTargets don’t play well&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri color=#000000 size=3&gt;Take a look at this simple project file&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Calibri size=3&gt;&lt;font color=#006400&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;br&gt;
&amp;lt;Project ToolsVersion="2.0" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xmlns="&lt;/font&gt;&lt;a href="http://schemas.microsoft.com/developer/msbuild/2003"&gt;&lt;font color=#006400&gt;http://schemas.microsoft.com/developer/msbuild/2003&lt;/font&gt;&lt;/a&gt;&lt;font color=#006400&gt;"&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DefaultTargets="Demo"&amp;gt;&lt;/font&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Calibri color=#006400 size=3&gt;&amp;nbsp; &amp;lt;PropertyGroup&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AllowTarget&amp;gt;true&amp;lt;/AllowTarget&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/PropertyGroup&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Calibri color=#006400 size=3&gt;&amp;nbsp; &amp;lt;Target Name="SupressTarget"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;CreateProperty Value="false"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Output PropertyName="AllowTarget" TaskParameter="Value"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/CreateProperty&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Message Text=" ==== SupressTarget ==== " Importance="high"/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Message Text="AllowTarget: $(AllowTarget)"/&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/Target&amp;gt;&lt;br&gt;
&amp;nbsp; 
&lt;br&gt;
&amp;nbsp; 
&lt;br&gt;
&amp;nbsp; &amp;lt;Target Name="Demo" Condition="'$(AllowTarget)'=='true'" 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DependsOnTargets="SupressTarget"&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Message Text=" ===== Demo ===== " Importance="high" /&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Calibri color=#006400 size=3&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Message Text="AllowTarget:
$(AllowTarget)"/&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/Target&amp;gt;&lt;br&gt;
&amp;nbsp; 
&lt;br&gt;
&amp;lt;/Project&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;In
this project the main target is Demo and it depends on a target SupressTarget which
actually disables the Demo target based on its condition. If you execute the command &lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt;msbuild
/t:Demo&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt; you
get the results shown below.&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Calibri color=#000000 size=3&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;
&lt;o:p&gt;
&lt;img alt="" hspace=0 src="http://www.sedodream.com/content/binary/20080627-01.png" align=baseline border=0&gt;
&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;font face=Calibri color=#000000&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;
&lt;o:p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;Most
users would expect that the target SupressTarget target would execute which sets the
AllowTarget value to false, and then the Demo target is skipped. But what is happening
here is that by the time DependsOnTargets is evaluated the condition has already been
evaluated and has passed! The even more interesting thing here is if you execute&lt;/span&gt;&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"&gt; msbuild
/t:SupressTarget;Demo&lt;/span&gt;&lt;/b&gt;&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt; the
results are shown below.&lt;/span&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 12pt; FONT-FAMILY: 'Times New Roman','serif'; mso-fareast-font-family: 'Times New Roman'"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;&amp;nbsp;&lt;img alt="" hspace=0 src="http://www.sedodream.com/content/binary/20080627-02.png" align=baseline border=0&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri&gt;So this time it was skipped, because SupressTarget was called before
the Demo target was invoked so the condition evaluated to false.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;b style="mso-bidi-font-weight: normal"&gt;&lt;font face=Calibri&gt;Conditions and target batching
doesn’t work well either&lt;o:p&gt;&lt;/o:p&gt;
&lt;/font&gt;&lt;/b&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri&gt;If you are batching a target and you want to execute the target
for some batches but not others, this cannot be achieved with target conditions, for
a few reasons but the simplest is: Either a target is or is not defined. When the
target is going to be executed for the first time the condition is evaluated. If the
condition is true it will exist, otherwise it will not.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri&gt;I thought of some other issues but they are not coming to me at
this time, but I think this is enough to deter you from using target dependencies.
Instead of target dependencies you should take a look at other way of achieving the
same results.&lt;/font&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;o:p&gt;
&lt;font face=Calibri&gt;&amp;nbsp;&lt;/font&gt;
&lt;/o:p&gt;
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;
&lt;font face=Calibri&gt;Sayed Ibrahim Hashimi&lt;/font&gt;
&lt;/o:p&gt;
&lt;/span&gt;&lt;/font&gt;&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,a3e0f4b1-5714-4491-9134-cce95b1d6e19.aspx</comments>
      <category>MSBuild</category>
      <category>Team Build</category>
      <category>TFS</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=aac8b927-124d-4aff-9321-6fb49ad92576</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,aac8b927-124d-4aff-9321-6fb49ad92576.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://sedodream.com/CommentView,guid,aac8b927-124d-4aff-9321-6fb49ad92576.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=aac8b927-124d-4aff-9321-6fb49ad92576</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">If you are using <a href="http://msdn.microsoft.com/vstudio/teamsystem/team/default.aspx">Team
Foundation Server</a> as your SCM tool, I hope you're taking advantage of using the <a href="http://msdn2.microsoft.com/en-us/library/ms181710%28VS.80%29.aspx">Team
Build</a> tool to create re-producable public builds for your projects. Very cool,
and very useful, especially for those Enterprise applications. As you use Team Build
you'll need to make changes to how your build process is executed. You can make the
customizations in the <font color="#006400">TFSBuild.proj</font> file. This is the
file that will drive your team build. In this file there are many properties declared
that are generated by the New Build Type Creation Wizard. These properties are contained
in the first <a href="http://msdn2.microsoft.com/en-US/library/t4w159bs%28VS.80%29.aspx">PropertyGroup </a>element
in that file. Some of these properties include; Description, DropLocation,BuildDirectoryPath,...
which are used internally by Team Build to setup the build. Of course Team Build uses
MSBuild to actually execute the build, but some things need to happen before/after
MSBuild gets involved. For instance creating the Build report, which require those
values. In the ideal world you'd expect for those values to be gathered using the <a href="http://msdn2.microsoft.com/en-us/library/ms123531%28en-US,VS.80%29.aspx">MSBuild
Object Model</a>, but this is not the case. Team Build is extracting those values
as they are declared.<br />
There has been a few posts about this particular problem on the <a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=27&amp;SiteID=1">MSBuild
MSDN Forum</a>. Those posts are at:<br /><blockquote><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=226906&amp;SiteID=1">Post:
Property Evaluation Order (beta 3)</a><br /><a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=326982&amp;SiteID=1">Properties
in properties</a><br /></blockquote>In the post Property Evaluation Order (beta 3) I provide a workaround
for most situations, but its not always perfect. Here it is for you to see:<br /><blockquote><span><p>
It seems like Team build is not using the msbuild object model to get those evaluated
properties, but instead are simply extracting the text value from those property declarations.
</p><p>
I tried to overwirte it in different places in the project file as well, with no luck.
It always took the first declaration. I'm guessing that the property is not able
to be overwritten because it is passed in as a command line parameter to msbuild.exe
by team build. But there is a workaround that solves some of the issues. In your TFSBuild.proj
file, modify the DropLocation to one that doesn't use any properties and insert the
following towards the bottom:
</p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">  </span>&lt;</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">PropertyGroup</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">&gt;</span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">    </span>&lt;</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">RootProjectFolder</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">&gt;</span><span style="font-size: 10pt; font-family: 'Courier New';">ProjectX<span style="color: blue;">&lt;/</span><span style="color: maroon;">RootProjectFolder</span><span style="color: blue;">&gt;</span></span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">    </span>&lt;</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">DropBuildDependsOn</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">&gt;</span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: 'Courier New';"><span style="">      </span>FixDropLocation;</span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; font-family: 'Courier New';"><span style="">      </span>$(DropBuildDependsOn);</span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">    </span>&lt;/</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">DropBuildDependsOn</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">&gt;</span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">  </span>&lt;/</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">PropertyGroup</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">&gt;</span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"> </span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">  </span>&lt;</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">Target</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">Name</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">=</span><span style="font-size: 10pt; font-family: 'Courier New';">"<span style="color: blue;">FixDropLocation</span>"<span style="color: blue;">&gt;</span></span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">    </span>&lt;</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">CreateProperty</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">Value</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">=</span><span style="font-size: 10pt; font-family: 'Courier New';">"<span style="color: blue;">$(DropLocation)\$(RootProjectFolder)</span>"<span style="color: blue;">&gt;</span></span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">      </span>&lt;</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">Output</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">TaskParameter</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">=</span><span style="font-size: 10pt; font-family: 'Courier New';">"<span style="color: blue;">Value</span>"<span style="color: blue;"></span><span style="color: red;">PropertyName</span><span style="color: blue;">=</span>"<span style="color: blue;">DropLocation</span>"<span style="color: blue;">/&gt;</span></span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">    </span>&lt;/</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">CreateProperty</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">&gt;</span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">    </span>&lt;</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">Message</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"></span><span style="font-size: 10pt; color: red; font-family: 'Courier New';">Text</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">=</span><span style="font-size: 10pt; font-family: 'Courier New';">"<span style="color: blue;">Drop
loc: $(DropLocation)</span>"<span style="color: blue;"></span><span style="color: red;">Importance</span><span style="color: blue;">=</span>"<span style="color: blue;">high</span>"<span style="color: blue;">/&gt;</span></span></p><p class="MsoNormal" style="margin: 0in 0in 0pt;"><span style="font-size: 10pt; color: blue; font-family: 'Courier New';"><span style="">  </span>&lt;/</span><span style="font-size: 10pt; color: maroon; font-family: 'Courier New';">Target</span><span style="font-size: 10pt; color: blue; font-family: 'Courier New';">&gt;</span></p><p>
This prepends the <font color="#339966">FixDropLocation </font>to the <font color="#339966">DropBuildDependsOn </font>list
of targets, so it will be executed before the <font color="#339966">DropBuild </font>target.
This cause your project drop files to be dropped in the location tat you want. This
is able to overwrite the DropLocation property becuase we are using the <a title="http://msdn2.microsoft.com/63ckb9s9.aspx" href="http://msdn2.microsoft.com/63ckb9s9.aspx">CreateProperty
task</a> to overwrite this instead of the normal property declaration.
</p><p>
This is not however a perfect solution, because your build log will always be located
in the <font color="#339966">DropLocation</font> that was originally declared (the
one w/o the property embedded within it). And in the Team build type history the drop
location will also have this location as well. But it does place the files where you
want them :)
</p><p>
Unfortunately it looks like the DropLocation that is given to TFS is happening outside
the scope of MSBuild so I'm not sure you have a lot of options. You can't even pass
this as a command line parameter to the tfsbuild.exe utility either. Let me know if
this  is not clear.
</p></span></blockquote><span><p><br /></p><p>
Sayed Ibrahim Hashimi
</p></span><br /><p></p></body>
      <title>Team Build + MSBuild Properties</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,aac8b927-124d-4aff-9321-6fb49ad92576.aspx</guid>
      <link>http://sedodream.com/2006/04/05/TeamBuildMSBuildProperties.aspx</link>
      <pubDate>Wed, 05 Apr 2006 07:09:52 GMT</pubDate>
      <description>If you are using &lt;a href="http://msdn.microsoft.com/vstudio/teamsystem/team/default.aspx"&gt;Team
Foundation Server&lt;/a&gt; as your SCM tool, I hope you're taking advantage of using the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms181710%28VS.80%29.aspx"&gt;Team
Build&lt;/a&gt; tool to create re-producable public builds for your projects. Very cool,
and very useful, especially for those Enterprise applications. As you use Team Build
you'll need to make changes to how your build process is executed. You can make the
customizations in the &lt;font color="#006400"&gt;TFSBuild.proj&lt;/font&gt; file. This is the
file that will drive your team build. In this file there are many properties declared
that are generated by the New Build Type Creation Wizard. These properties are contained
in the first &lt;a href="http://msdn2.microsoft.com/en-US/library/t4w159bs%28VS.80%29.aspx"&gt;PropertyGroup &lt;/a&gt;element
in that file. Some of these properties include; Description, DropLocation,BuildDirectoryPath,...
which are used internally by Team Build to setup the build. Of course Team Build uses
MSBuild to actually execute the build, but some things need to happen before/after
MSBuild gets involved. For instance creating the Build report, which require those
values. In the ideal world you'd expect for those values to be gathered using the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms123531%28en-US,VS.80%29.aspx"&gt;MSBuild
Object Model&lt;/a&gt;, but this is not the case. Team Build is extracting those values
as they are declared.&lt;br&gt;
There has been a few posts about this particular problem on the &lt;a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=27&amp;amp;SiteID=1"&gt;MSBuild
MSDN Forum&lt;/a&gt;. Those posts are at:&lt;br&gt;
&lt;blockquote&gt;&lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=226906&amp;amp;SiteID=1"&gt;Post:
Property Evaluation Order (beta 3)&lt;/a&gt;
&lt;br&gt;
&lt;a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=326982&amp;amp;SiteID=1"&gt;Properties
in properties&lt;/a&gt;
&lt;br&gt;
&lt;/blockquote&gt;In the post Property Evaluation Order (beta 3) I provide a workaround
for most situations, but its not always perfect. Here it is for you to see:&lt;br&gt;
&lt;blockquote&gt;&lt;span&gt;
&lt;p&gt;
It seems like Team build is not using the msbuild object model to get those evaluated
properties, but instead are simply extracting the text value from those property declarations.
&lt;/p&gt;
&lt;p&gt;
I tried to overwirte it in different places in the project file as well, with no luck.
It always took the first declaration.&amp;nbsp;I'm guessing that the property is not able
to be overwritten because it is passed in as a command line parameter to msbuild.exe
by team build. But there is a workaround that solves some of the issues. In your TFSBuild.proj
file, modify the DropLocation to one that doesn't use any properties and insert the
following towards the bottom:
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;PropertyGroup&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;RootProjectFolder&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;ProjectX&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;RootProjectFolder&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;DropBuildDependsOn&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;FixDropLocation;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;$(DropBuildDependsOn);&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;DropBuildDependsOn&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;PropertyGroup&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;nbsp;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;Target&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Name&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;FixDropLocation&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;CreateProperty&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Value&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;$(DropLocation)\$(RootProjectFolder)&lt;/span&gt;"&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;Output&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;TaskParameter&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;Value&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;PropertyName&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;DropLocation&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;CreateProperty&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&amp;lt;&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;Message&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt; &lt;/span&gt;&lt;span style="font-size: 10pt; color: red; font-family: 'Courier New';"&gt;Text&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;=&lt;/span&gt;&lt;span style="font-size: 10pt; font-family: 'Courier New';"&gt;"&lt;span style="color: blue;"&gt;Drop
loc: $(DropLocation)&lt;/span&gt;"&lt;span style="color: blue;"&gt; &lt;/span&gt;&lt;span style="color: red;"&gt;Importance&lt;/span&gt;&lt;span style="color: blue;"&gt;=&lt;/span&gt;"&lt;span style="color: blue;"&gt;high&lt;/span&gt;"&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p class="MsoNormal" style="margin: 0in 0in 0pt;"&gt;
&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&lt;span style=""&gt;&amp;nbsp; &lt;/span&gt;&amp;lt;/&lt;/span&gt;&lt;span style="font-size: 10pt; color: maroon; font-family: 'Courier New';"&gt;Target&lt;/span&gt;&lt;span style="font-size: 10pt; color: blue; font-family: 'Courier New';"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
This prepends the &lt;font color="#339966"&gt;FixDropLocation &lt;/font&gt;to the &lt;font color="#339966"&gt;DropBuildDependsOn &lt;/font&gt;list
of targets, so it will be executed before the &lt;font color="#339966"&gt;DropBuild &lt;/font&gt;target.
This cause your project drop files to be dropped in the location tat you want. This
is able to overwrite the DropLocation property becuase we are using the &lt;a title="http://msdn2.microsoft.com/63ckb9s9.aspx" href="http://msdn2.microsoft.com/63ckb9s9.aspx"&gt;CreateProperty
task&lt;/a&gt; to overwrite this instead of the normal property declaration.
&lt;/p&gt;
&lt;p&gt;
This is not however a perfect solution, because your build log will always be located
in the &lt;font color="#339966"&gt;DropLocation&lt;/font&gt; that was originally declared (the
one w/o the property embedded within it). And in the Team build type history the drop
location will also have this location as well. But it does place the files where you
want them :)
&lt;/p&gt;
&lt;p&gt;
Unfortunately it looks like the DropLocation that is given to TFS is happening outside
the scope of MSBuild so I'm not sure you have a lot of options. You can't even pass
this as a command line parameter to the tfsbuild.exe utility either. Let me know if
this&amp;nbsp; is not clear.
&lt;/p&gt;
&lt;/span&gt;&lt;/blockquote&gt;&lt;span&gt; 
&lt;p&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;
&lt;/span&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,aac8b927-124d-4aff-9321-6fb49ad92576.aspx</comments>
      <category>MSBuild</category>
      <category>Team Build</category>
      <category>TFS</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://sedodream.com/Trackback.aspx?guid=1264a1ec-e825-4274-85d1-3971f5909685</trackback:ping>
      <pingback:server>http://sedodream.com/pingback.aspx</pingback:server>
      <pingback:target>http://sedodream.com/PermaLink,guid,1264a1ec-e825-4274-85d1-3971f5909685.aspx</pingback:target>
      <dc:creator />
      <wfw:comment>http://sedodream.com/CommentView,guid,1264a1ec-e825-4274-85d1-3971f5909685.aspx</wfw:comment>
      <wfw:commentRss>http://sedodream.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1264a1ec-e825-4274-85d1-3971f5909685</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Lately I've been using Team Foundation Server (TFS) for my source control and Team
Build to perfom builds on a dedicated machine. Everything was working pretty good
until the other night, I created a new team project and added some projects to the
source control. Following this I created a new Team Build and tried to execute it,
but I received an error, <em>TF42053: The build machine is not configured to build
for server..." </em>I received this error when I tried to invoke Team Builds
that were previously building correctly as well, not just on the new project. The
image of the dialog box is shown below (click for larget image).
</p>
        <p>
          <a href="http://www.sedodream.com/content/binary/TF42053_Error_Web.JPG">
            <img src="http://www.sedodream.com/content/binary/TF42053_Error_Web_Small.JPG" border="0" />
          </a>
        </p>
        <p>
As instructed I opened up the TFSBuildService.exe config file which is at <em>%Program
Files%/Microsoft Visual Studio 8/Common7/IDE/PrivateAssemblies/TFSBuildService.exe.config</em>,
I opened up that file and located the <font color="#008000">AllowedTeamServer</font> key
element. Originally it looked like:
</p>
        <p>
          <font color="#008000">&lt;add key="AllowedTeamServer" value="" /&gt;</font>
        </p>
        <p>
By the way my TFS setup is on a single tier, so the application and data tier are
both on the same machine, and that is also the machine that I was trying to run the
build on. So I changed the value to:
</p>
        <p>
          <font color="#008000">&lt;add key="AllowedTeamServer" value="MACHINE_NAME"/&gt;</font>
        </p>
        <p>
Then I restarted the service and invoked the team build again, and all was fine. I'm
not sure why I was able to build previously but not now. The only things I can think
of a few changes to the envrionment:<br />
  1) a minor hardware change (I disconnected a removable hard drive from that
machine) 
<br />
  2) the IP address of that machine changed<br />
  3) machine was restarted a few times<br />
  4) new team project with its source control<br />
So I'm not quite sure why I received this error, but I'm glad it was an easy fix.
Now I can continue working on my project.
</p>
        <p>
Sayed Ibrahim Hashimi
</p>
      </body>
      <title>TFS Build Error</title>
      <guid isPermaLink="false">http://sedodream.com/PermaLink,guid,1264a1ec-e825-4274-85d1-3971f5909685.aspx</guid>
      <link>http://sedodream.com/2006/01/01/TFSBuildError.aspx</link>
      <pubDate>Sun, 01 Jan 2006 18:03:08 GMT</pubDate>
      <description>&lt;p&gt;
Lately I've been using Team Foundation Server (TFS) for my source control and Team
Build to perfom builds on a dedicated machine. Everything was working pretty good
until the other night, I created a new team project and added some projects to the
source control. Following this I created a new Team Build and tried to execute it,
but I received an error, &lt;em&gt;TF42053: The build machine is not configured to build
for server..."&amp;nbsp;&lt;/em&gt;I received this error when I tried to invoke Team Builds
that were previously building correctly as well, not just on the new project. The
image of the dialog box is shown below (click for larget image).
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.sedodream.com/content/binary/TF42053_Error_Web.JPG"&gt;&lt;img src="http://www.sedodream.com/content/binary/TF42053_Error_Web_Small.JPG" border=0&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
As instructed I opened up the TFSBuildService.exe config file which is at &lt;em&gt;%Program
Files%/Microsoft Visual Studio 8/Common7/IDE/PrivateAssemblies/TFSBuildService.exe.config&lt;/em&gt;,
I opened up that file and located the &lt;font color=#008000&gt;AllowedTeamServer&lt;/font&gt; key
element. Originally it looked like:
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#008000&gt;&amp;lt;add key="AllowedTeamServer" value="" /&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
By the way my TFS setup is on a single tier, so the application and data tier are
both on the same machine, and that is also the machine that I was trying to run the
build on. So I changed the value to:
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#008000&gt;&amp;lt;add key="AllowedTeamServer" value="MACHINE_NAME"/&amp;gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
Then I restarted the service and invoked the team build again, and all was fine. I'm
not sure why I was able to build previously but not now. The only things I can think
of a few&amp;nbsp;changes to the envrionment:&lt;br&gt;
&amp;nbsp; 1) a minor hardware change (I disconnected a removable hard drive from that
machine) 
&lt;br&gt;
&amp;nbsp; 2) the IP address of that machine changed&lt;br&gt;
&amp;nbsp; 3) machine was restarted a few times&lt;br&gt;
&amp;nbsp; 4) new team project with its source control&lt;br&gt;
So I'm not quite sure why I received this error, but I'm glad it was an easy fix.
Now I can continue working on my project.
&lt;/p&gt;
&lt;p&gt;
Sayed Ibrahim Hashimi
&lt;/p&gt;</description>
      <comments>http://sedodream.com/CommentView,guid,1264a1ec-e825-4274-85d1-3971f5909685.aspx</comments>
      <category>Team Build</category>
      <category>TFS</category>
      <category>Visual Studio</category>
    </item>
  </channel>
</rss>