<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: A custom task for building WiX under MSBuild (TFS)</title>
	<atom:link href="http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/feed/" rel="self" type="application/rss+xml" />
	<link>http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/</link>
	<description>Random musings from the developers at Tranxition</description>
	<lastBuildDate>Fri, 30 Oct 2009 13:52:19 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: hempelcx</title>
		<link>http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/#comment-145</link>
		<dc:creator>hempelcx</dc:creator>
		<pubDate>Wed, 26 Aug 2009 19:10:45 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/#comment-145</guid>
		<description>Hi, Sam.

Sorry you had trouble. Note that I did specify later in the post that you will need to wrap a root element around the variable definitions. MSBuild will always strip off the outer element that contains the XML document when it passes it to your custom task.
&lt;code&gt;
&lt;_VariableDefinitions&gt;
&#160;&#160;&lt;Root&gt;
&#160;&#160;&#160;&#160;&lt;VariableDefinition Name=“Var1“ NewValue=“Val1“ /&gt;
&#160;&#160;&#160;&#160;&lt;VariableDefinition Name=“Var2“ NewValue=“Val2“ /&gt;
&#160;&#160;&#160;&#160;&lt;VariableDefinition Name=“Var3“ NewValue=“Val3“ /&gt;
&#160;&#160;&lt;/Root&gt;
&lt;/_VariableDefinitions&gt;
&lt;/code&gt;
That outer &lt;code&gt;&lt;Root&gt;&lt;/code&gt; element is required for it to be a valid XML document once the &lt;code&gt;&lt;_VariableDefinitions&gt;&lt;/code&gt; element is stripped. I don&#039;t recall what MSBuild will do if it&#039;s missing - but sending an invalid document containing just VariableDefinition elements could be the result. Also note that the name of the root element is irrelevant - the XML parsing code doesn&#039;t care.</description>
		<content:encoded><![CDATA[<p>Hi, Sam.</p>
<p>Sorry you had trouble. Note that I did specify later in the post that you will need to wrap a root element around the variable definitions. MSBuild will always strip off the outer element that contains the XML document when it passes it to your custom task.<br />
<code><br />
&lt;_VariableDefinitions&gt;<br />
&nbsp;&nbsp;&lt;Root&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;VariableDefinition Name=“Var1“ NewValue=“Val1“ /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;VariableDefinition Name=“Var2“ NewValue=“Val2“ /&gt;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&lt;VariableDefinition Name=“Var3“ NewValue=“Val3“ /&gt;<br />
&nbsp;&nbsp;&lt;/Root&gt;<br />
&lt;/_VariableDefinitions&gt;<br />
</code><br />
That outer <code>&lt;Root&gt;</code> element is required for it to be a valid XML document once the <code>&lt;_VariableDefinitions&gt;</code> element is stripped. I don&#8217;t recall what MSBuild will do if it&#8217;s missing &#8211; but sending an invalid document containing just VariableDefinition elements could be the result. Also note that the name of the root element is irrelevant &#8211; the XML parsing code doesn&#8217;t care.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Shiles</title>
		<link>http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/#comment-144</link>
		<dc:creator>Sam Shiles</dc:creator>
		<pubDate>Wed, 26 Aug 2009 15:53:58 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/#comment-144</guid>
		<description>Sorry the tags got cut out:

&lt;_VariableDefinitions&gt;
  &lt;VariableDefinition/&gt;
  ..
  &lt;_VariableDefinition/&gt;
&lt;_/_VariableDefinitions&gt;

We only got
  &lt;_VariableDefinition/&gt;
   ..
  &lt;_VariableDefinition/&gt;_</description>
		<content:encoded><![CDATA[<p>Sorry the tags got cut out:</p>
<p>&lt;_VariableDefinitions&gt;<br />
  &lt;VariableDefinition/&gt;<br />
  ..<br />
  &lt;_VariableDefinition/&gt;<br />
&lt;_/_VariableDefinitions&gt;</p>
<p>We only got<br />
  &lt;_VariableDefinition/&gt;<br />
   ..<br />
  &lt;_VariableDefinition/&gt;_</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sam Shiles</title>
		<link>http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/#comment-143</link>
		<dc:creator>Sam Shiles</dc:creator>
		<pubDate>Wed, 26 Aug 2009 15:52:09 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/#comment-143</guid>
		<description>I had some trouble getting this to work as described. The problem seemed to stem from the fact that the &quot;VariableDefinitions&quot; being passed in from the msbuild file did not contain a root element. So instead of getting:


  
  ..
  


We only got
  
   ..
  

I modified the custom task with the following which solved the problem:

  private const string ROOT_ELEMENT = &quot;&quot;;
        private const string ROOT_ELEMENT_FORMAT = &quot;{0}&quot;;
        private string _variableDefinitions;
        public string VariableDefinitions {
            get { return _variableDefinitions; }
            set
            {
                value = value.Trim();
                if (!value.StartsWith(ROOT_ELEMENT))
                    value = string.Format(ROOT_ELEMENT_FORMAT, value);

                _variableDefinitions = value;
            }
        }

There is probably a way of solving this with MSBUILD but I&#039;m more comfortable with c# so that was my solution. Perhaps this is caused by differences between the versions we have so for the sake of comparisson:

TFS 2008 SP1</description>
		<content:encoded><![CDATA[<p>I had some trouble getting this to work as described. The problem seemed to stem from the fact that the &#8220;VariableDefinitions&#8221; being passed in from the msbuild file did not contain a root element. So instead of getting:</p>
<p>  ..</p>
<p>We only got</p>
<p>   ..</p>
<p>I modified the custom task with the following which solved the problem:</p>
<p>  private const string ROOT_ELEMENT = &#8220;&#8221;;<br />
        private const string ROOT_ELEMENT_FORMAT = &#8220;{0}&#8221;;<br />
        private string _variableDefinitions;<br />
        public string VariableDefinitions {<br />
            get { return _variableDefinitions; }<br />
            set<br />
            {<br />
                value = value.Trim();<br />
                if (!value.StartsWith(ROOT_ELEMENT))<br />
                    value = string.Format(ROOT_ELEMENT_FORMAT, value);</p>
<p>                _variableDefinitions = value;<br />
            }<br />
        }</p>
<p>There is probably a way of solving this with MSBUILD but I&#8217;m more comfortable with c# so that was my solution. Perhaps this is caused by differences between the versions we have so for the sake of comparisson:</p>
<p>TFS 2008 SP1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven Bone</title>
		<link>http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/#comment-128</link>
		<dc:creator>Steven Bone</dc:creator>
		<pubDate>Thu, 26 Mar 2009 14:12:55 +0000</pubDate>
		<guid isPermaLink="false">http://tranxcoder.wordpress.com/2008/07/03/a-custom-task-for-building-wix-under-msbuild-tfs/#comment-128</guid>
		<description>Thanks for the excellent article - saved me from having to write a similar task.  Your trick of passing a set of XML Properties will no doubt come in handy at some point in the future.  Perhaps you should submit this to the Wix folks!</description>
		<content:encoded><![CDATA[<p>Thanks for the excellent article &#8211; saved me from having to write a similar task.  Your trick of passing a set of XML Properties will no doubt come in handy at some point in the future.  Perhaps you should submit this to the Wix folks!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
