<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Jason Prickett's Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/jpricket/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/jpricket/feed.xml</link>
    <description />
    <lastBuildDate>Tue, 16 Apr 2019 05:15:03 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>We have a new plugin for IntelliJ IDEA</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/we-have-a-new-plugin-for-intellij-idea</link>
      <pubDate>Fri, 23 Oct 2015 12:44:00 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2015/10/23/we-have-a-new-plugin-for-intellij-idea/</guid>
      <description><![CDATA[If you are using IntelliJ IDEA and you have git repositories in VSO or TFS, you need this plugin....]]></description>
      <content:encoded><![CDATA[<p>If you are using IntelliJ IDEA and you have git repositories in VSO or TFS, you need this plugin. Checkout these posts that have more information...</p>
<p><a href="http://blogs.msdn.com/b/visualstudioalm/archive/2015/10/23/team-foundation-plugin-for-intellij-idea.aspx">http://blogs.msdn.com/b/visualstudioalm/archive/2015/10/23/team-foundation-plugin-for-intellij-idea.aspx</a>&nbsp;</p>
<p>And if you aren't using VSOnline yet for your Java development, check out this site that explains how to get started...</p>
<p><a href="http://java.visualstudio.com">http://java.visualstudio.com</a></p>
<p>Calling all Java developers!!</p>]]></content:encoded>
    </item>
    <item>
      <title>A new mission - Java!</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/a-new-mission-java</link>
      <pubDate>Thu, 22 Oct 2015 09:09:51 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2015/10/22/a-new-mission-java/</guid>
      <description><![CDATA[The course of this blog will be taking a new direction. I have moved from build automation to a...]]></description>
      <content:encoded><![CDATA[<p>The course of this blog will be taking a new direction. I have moved from build automation to a focus on the Java Developer. My new team's mission is to make TFS and VSO GREAT FOR THE JAVA DEVELOPER! It won't be easy, because this means doing things not only on Windows, but also on Linux and Mac.</p>
<p>We need your help. If you are a Java developer, tell us what you want or need from Microsoft. We want the Java development experience to be great. If there is something we can change or add, we want to know.</p>
<p>Thanks,</p>
<p>Jason</p>]]></content:encoded>
    </item>
    <item>
      <title>Upgrading your build definitions from TFS2010 to TFS2012</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/upgrading-your-build-definitions-from-tfs2010-to-tfs2012</link>
      <pubDate>Wed, 24 Oct 2012 08:32:00 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2012/10/24/upgrading-your-build-definitions-from-tfs2010-to-tfs2012/</guid>
      <description><![CDATA[There have been a lot of problems with compatibility of custom builds when upgrading from TFS2010 to...]]></description>
      <content:encoded><![CDATA[<p>There have been a lot of problems with compatibility of custom builds when upgrading from TFS2010 to TFS2012. This blog post is my attempt to summarize what you have to do and how to fix some issues you might run into.</p>
<ol>
<li>The very first step is to upgrade your Server. Your build machines should match the version of your server.</li>
<li>To upgrade your build machine to TFS2012 follow the instructions on<br /><a href="http://msdn.microsoft.com/en-us/library/jj620928.aspx">http://msdn.microsoft.com/en-us/library/jj620928.aspx</a></li>
<li>If you need Visual Studio on the build machine, install VS 2012 on the build machine. You will probably want to keep VS2010 on the build machine as well. This shouldn't cause any problems.</li>
<li>The next step is to recompile any custom activity assemblies that this build machine uses to target the 4.5 .net framework and the version 11.0.0.0 Team Foundation assemblies.</li>
<ol>
<li>Open the solutions for your custom activities</li>
<li>Open Properties on each project and change the target framework to 4.5</li>
<li>Remove all TeamFoundation references and replace them with the ones that ship with Visual Studio 2012 (the version number should be 11.0.0.0 - NOT 10.0.0.0).</li>
<li>Recompile the solutions and check in the binaries to the custom assembly location</li>
<li>ALL assemblies in the custom assembly location for a 2012 controller should be compiled against the 11.0.0.0 versions of the TeamFoundation assemblies.</li>
</ol>
<li>The final step before testing your builds is to "clean up" any versioned namespaces in your Build Process Templates (XAML files)</li>
<ol>
<li>locate all of your XAML files - these are usually in $/TeamProject/BuildProcessTemplates</li>
<li>for each XAML file: check it out, clean it by removing versioned namespaces, and check it back in (see <a href="http://blogs.msdn.com/b/jpricket/archive/2012/07/17/tfs-2012-cleaning-up-workflow-xaml-files-aka-removing-versioned-namespaces.aspx">http://blogs.msdn.com/b/jpricket/archive/2012/07/17/tfs-2012-cleaning-up-workflow-xaml-files-aka-removing-versioned-namespaces.aspx)</a></li>
</ol>
<li>Finally, you should be able to test your build definitions.</li>
</ol>
<p><strong><span style="font-size: medium;">Limitations</span></strong></p>
<ul>
<li>A 2010 Build machine will NOT work with a 2012 Team Foundation Server</li>
<li>A 2012 Build machine will NOT work with a 2010 Team Foundation Server</li>
<li>A 2012 Build machine cannot build a 2010 template that contains versioned namespaces that reference 10.0.0.0 assemblies</li>
<li>A 2012 Build machine cannot build a 2010 template that calls out to custom activities that are compiled against 10.0.0.0 Team Foundation Assemblies</li>
<li>Build Definitions that reference custom types may not be editable in both Visual Studio 2010 and 2012</li>
<ul>
<li>It's hard to identify all the combinations here, but if loading your custom types causes Team Foundation assemblies of the wrong version to be loaded then the editor will not work as desired.</li>
<li>Note that in Visual Studio 2012, you should be able to edit other parts of the definition, just not the process parameters that cause errors.</li>
</ul>
</ul>
<p><strong><span style="font-size: medium;">Problems you might face and workarounds:</span></strong></p>
<ul>
<li>After upgrading your templates and custom assemblies as described above, you will only be able to edit them in Visual Studio 2012.</li>
<li>If you install both Visual Studio 2010 and 2012 on the same machine, make sure you install them in that order: 2010 and then 2012.</li>
<ul>
<li>Opening a template in the VS 2010 Worflow Designer on this machine will not work without changes to the template. It will attempt to load the 2012 Team Foundation assemblies as well as the 2010 versions which will cause errors when it tries to evaluate any types. There's really nothing wrong with the actual template.</li>
<li>If you have to have the designer working in 2010 on a machine with 2012 installed, you can change the namespaces in the XAML file to use the full assembly name including the version information. But I wouldn't recommend this, since it will have to be removed for the template to work in 2012.</li>
<li>The 2012 Workflow Designer should work fine if you followed the steps above to "clean" the XAML</li>
</ul>
<li>If you get the following error when building your definitions against a recently upgraded build machine, you should restart your build machine service from the TF Admin Console on the build machine.</li>
<ul>
<li>TF215097: An error occurred while initializing a build for build definition \Project1 (Dev10)\Simple - Manual: The values provided for the root activity's arguments did not satisfy the root activity's requirements:<br />'DynamicActivity': Expected an input parameter value of type 'Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings' for parameter named 'BuildSettings'.</li>
<li>I am not sure what caused this error when I did it, but the fix was pretty simple once I figured it out.</li>
<li><span style="background-color: #ffff00;">UPDATE: Several customers have continued to get this error after upgrading even though they restarted their build service. It turns out that these customers had fixed most of their custom assemblies but not all. If you continue to see problems like this one (even intermittently), it means that there is still a build definition that uses assemblies/activities that are compiled against the 10.0.0.0 assemblies. Once the error starts, all subsequent builds fail because the old assemblies are loaded into the build services memory. Only restarting will resolve this issue.</span></li>
</ul>
<li>If you get the following error, you didn't update ALL your custom assemblies to reference the 11.0.0.0 versions of the TF assemblies.</li>
<ul>
<li>TF215097: An error occurred while initializing a build for build definition \Project1 (Dev10)\Advanced - Manual: The root element of the build process template found at $/Project1 (Dev10)/MyActivities/MyActivities/AdvancedBuildProcessTemplate.xaml (version C42) is not valid. (The build process failed validation. Details: <br />Validation Error: The private implementation of activity '1: DynamicActivity' has the following validation error:&nbsp;&nbsp; Compiler error(s) encountered processing expression "DropBuild AndAlso BuildDetail.Reason = Microsoft.TeamFoundation.Build.Client.BuildReason.ValidateShelveset".<br />Type 'IBuildDetail' is not defined.</li>
</ul>
<li>If you get any errors like these, the XAML file probably still contains some versioned namespaces.</li>
<ul>
<li>TF215097: An error occurred while initializing a build for build definition \Project1 (Dev10)\Moderate - Manual: The root element of the build process template found at $/Project1 (Dev10)/BuildProcessTemplates/ModerateBuildProcessTemplate.xaml (version C31) is not valid. (The build process failed validation. Details: <br />Validation Error: Compiler error(s) encountered processing expression "New Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings()".<br />'BuildSettings' is ambiguous in the namespace 'Microsoft.TeamFoundation.Build.Workflow.Activities'.<br />Validation Error: Compiler error(s) encountered processing expression "Microsoft.TeamFoundation.Build.Workflow.Activities.CleanWorkspaceOption.All".<br />'CleanWorkspaceOption' is ambiguous in the namespace 'Microsoft.TeamFoundation.Build.Workflow.Activities'.</li>
</ul>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>TFS 2012 – Cleaning up Workflow XAML files (AKA removing versioned namespaces)</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/tfs-2012-cleaning-up-workflow-xaml-files-aka-removing-versioned-namespaces</link>
      <pubDate>Tue, 17 Jul 2012 08:35:00 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2012/07/17/tfs-2012-cleaning-up-workflow-xaml-files-aka-removing-versioned-namespaces/</guid>
      <description><![CDATA[If you haven&rsquo;t run into this problem in TFS Build 2012 yet, you probably...]]></description>
      <content:encoded><![CDATA[<p>If you haven&rsquo;t run into this problem in TFS Build 2012 yet, you probably will&hellip;</p>
<h4>Problem:</h4>
<p>After Upgrading your Visual Studio client or your build machine from 2010 to 2012, you start seeing errors like these&hellip;</p>
<ol>
<li><strong>Opening a XAML file in Visual Studio 2012</strong> - System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---&gt; System.Exception: The component &ldquo;Microsoft.TeamFoundation.Build.Workflow.Design.InvokeForReasonDesigner&rsquo; does not have a resource identified by the URI&hellip;</li>
<li><strong>Editing a build definition in Visual Studio 2012</strong> &ndash; Unable to cast object of type &lsquo;Microsoft.TeamFoundation.Build.Workflow.Activities.TestSpecList&rsquo; to type &lsquo;System.Collections.Generic.List`1[Microsoft.TeamFoundation.Build.Workflow.Activities.TestSpecList]&rsquo;.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li>
<li><strong>Editing a build definition in Visual Studio 2012</strong> &ndash; [A]Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings cannot be cast to [B]Microsoft.TeamFoundation.Build.Workflow.Activities.BuildSettings. Type A originates from &lsquo;Microsoft.TeamFoundation.Build.Workflow, Version=10.0.0.0, &hellip;&rsquo; in the context &rsquo;Default&rsquo; at location &hellip;. Type B originates from &lsquo;Microsoft.TeamFoundation.Build.Workflow, Version=11.0.0.0, &hellip;&rsquo; in the context &lsquo;Default&rsquo; at location &hellip;.</li>
<li><strong>Building on a TFS 2012 Build Machine</strong> - Validation Error: The private implementation of activity '1: DynamicActivity' has the following validation error: Compiler error(s) encountered processing expression "BuildDetail.BuildNumber". Type 'IBuildDetail' is not defined.</li>
</ol>
<p>&nbsp;</p>
<h4>Background:</h4>
<p>Due to a bug in one of our activities in TFS 2010, the Visual Studio Workflow Designer would add versioned namespaces to the XAML file upon saving it. They look something like this:</p>
<blockquote>
<p>xmlns:mtbw1="clr-namespace:Microsoft.TeamFoundation.Build.Workflow; assembly=Microsoft.TeamFoundation.Build.Workflow, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"</p>
</blockquote>
<p>The version number in this string forces Workflow to attempt to load the 10.0.0.0 assemblies. These assemblies contain the same types as the 11.0.0.0 assemblies and cause all kinds of problems.</p>
<h4><span style="color: #993300;">[Update: 9/27/2012]</span></h4>
<p><span style="color: #993300;">There is another cause for some of these errors. In addition to checking your XAML, you should also look for any custom assemblies in the Controller's Custom Assembly Path that are compiled against the TFS 10.0 assemblies. Most likely, you will need to recompile any custom assemblies you have against the latest released copies of the .Net&nbsp;framework and the TFS assemblies.</span></p>
<p><span style="color: #993300;"></span></p>
<h4><span style="color: #993300;">[Update: 10/24/2012]</span></h4>
<p><span style="color: #993300;">Fixed a bug in the code below that was removing too many of the namespaces. Some unused namespaces can still be required by the VisualBasic expressions.</span><span style="color: #993300;"></span></p>
<h4>Workaround:</h4>
<p>Unfortunately, there isn&rsquo;t a good way for us to fix this problem. Even if we fixed Visual Studio 2010 so that it doesn&rsquo;t cause the problem, but we can&rsquo;t prevent those who already have it. The best I could do is create a small program that will strip out all unused namespaces like these from the XAML. Here&rsquo;s the source code&hellip;</p>
<p>[UPDATE: I added some code below to leave in the namespaces listed in the mc:Ignorable attribute found at the top of the file. If you have something listed there that isn't defined, you will not be able to open the XAML in the Workflow Editor.]</p>
<pre class="csharpcode"><span class="kwrd">using</span> System;
<span class="kwrd">using</span> System.Collections.Generic;
<span class="kwrd">using</span> System.Text;
<span class="kwrd">using</span> System.IO;
<span class="kwrd">using</span> System.Xml;
<span class="kwrd">using</span> System.Text.RegularExpressions;

<span class="kwrd">namespace</span> XAMLCleaner{
    <span class="kwrd">class</span> Program
    {
        <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
        {
            <span class="kwrd">if</span> (args.Length == 2)
            {
                <span class="kwrd">if</span> (args[0].StartsWith(<span class="str">"/report"</span>, StringComparison.OrdinalIgnoreCase))
                {
                    XamlCleaner.RemoveUnusedNamespaces(args[1], args[1], <span class="kwrd">true</span>);
                }
                <span class="kwrd">else</span>
                {
                    XamlCleaner.RemoveUnusedNamespaces(args[0], args[1], <span class="kwrd">false</span>);
                }
            }
            <span class="kwrd">else</span> <span class="kwrd">if</span> (args.Length == 1)
            {
                XamlCleaner.RemoveUnusedNamespaces(args[0], args[0], <span class="kwrd">false</span>);
            }
            <span class="kwrd">else</span>
            {
                PrintUsage();
            }
        }

        <span class="kwrd">static</span> <span class="kwrd">void</span> PrintUsage()
        {
            Console.WriteLine();
            Console.WriteLine(<span class="str">"Usage:"</span>);
            Console.WriteLine(<span class="str">" XAMLCleaner.exe &lt;xaml_file&gt; [&lt;new_xaml_file&gt;]"</span>);
            Console.WriteLine(<span class="str">" - removes unused namespaces from xaml_file and"</span>);
            Console.WriteLine(<span class="str">" optionally puts the changes in new_xaml_file."</span>);
            Console.WriteLine(<span class="str">" XAMLCleaner.exe /report &lt;xaml_file&gt;"</span>);
            Console.WriteLine(<span class="str">" - prints the unused namespaces found in xaml_file."</span>);
            Console.WriteLine();
        }
    }

    <span class="kwrd">class</span> XmlNamespace 
    {
        <span class="kwrd">public</span> String Prefix { get; set; }
        <span class="kwrd">public</span> String Namespace { get; set; }
        <span class="kwrd">public</span> String Declaration { get; set; }
    }

    <span class="kwrd">static</span> <span class="kwrd">class</span> XamlCleaner
    {
        <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> RemoveUnusedNamespaces(String inputFile, String outputFile, <span class="kwrd">bool</span> reportOnly)
        {
            List&lt;XmlNamespace&gt; namespaces = <span class="kwrd">new</span> List&lt;XmlNamespace&gt;();
            List&lt;String&gt; ignoredNamespaces = new List&lt;String&gt;();
            String fileContents = File.ReadAllText(inputFile, Encoding.UTF8);
            String newFileContents = fileContents;
            Regex ignorableRegex = new Regex("(:Ignorable=\")(.*?)\"", RegexOptions.Singleline);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Regex regex = <span class="kwrd">new</span> Regex(<span class="str">"(xmlns\\:)(.*?)=\"(.*?)\""</span>, RegexOptions.Singleline);<br />
            <span class="kwrd">foreach</span>(Match m <span class="kwrd">in</span> ignorableRegex.Matches(fileContents))
            {
                ignoredNamespaces.AddRange(m.Groups[2].Value.Split(' '));
            }

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span class="kwrd">foreach</span>(Match m <span class="kwrd">in</span> regex.Matches(fileContents))<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; namespaces.Add(<span class="kwrd">new</span> XmlNamespace() { Prefix = m.Groups[2].Value, Namespace = m.Groups[3].Value, Declaration = m.Groups[0].Value });<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br /><br />            <span class="kwrd">foreach</span> (XmlNamespace ns <span class="kwrd">in</span> namespaces)
            {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Only remove namespaces that are not in the Ignore section<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // and contain version=10<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // and are not used in the file<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!ignoredNamespaces.Contains(ns.Prefix) &amp;&amp; <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ns.Namespace.IndexOf("version=10", StringComparison.OrdinalIgnoreCase) &gt;= 0 &amp;&amp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; !fileContents.Contains(ns.Prefix + ":")) <br />                {
                    Console.WriteLine(<span class="str">"Removing unused namespace: {0}"</span>, ns.Declaration);
                    newFileContents = newFileContents.Replace(ns.Declaration, String.Empty);
                }
            }

            <span class="kwrd">if</span> (!reportOnly)
            {
                File.WriteAllText(outputFile, newFileContents, Encoding.UTF8);
            }
             
        }
    }
}
</pre>
<p>&nbsp;</p>
<h5>Examples:</h5>
<p>&gt;XAMLCleaner /report DefaultTemplate.xaml</p>
<blockquote>
<p>This will list all the unused namespaces, but will not actually change the file</p>
</blockquote>
<p>&gt;XAMLCleaner DefaultTemplate.xaml</p>
<blockquote>
<p>This will remove all unused namespaces and overwrite the file that was read in.</p>
</blockquote>
<p>&gt;XAMLCleaner DefaultTemplate.xaml NewTemplate.xaml</p>
<blockquote>
<p>This will remove all unused namespaces and write a new file called NewTemplate.xaml.</p>
</blockquote>
<p>We don&rsquo;t know exactly how we will end up fixing this issue since we don&rsquo;t want to forcibly change all build process templates. So, for now you will have to fix these up yourself. I recommend a one time conversion of the files and then simply don&rsquo;t edit them in Visual Studio 2010 any more.</p>
<p>Hopefully this post will save some of you some time.</p>]]></content:encoded>
    </item>
    <item>
      <title>TFS 2012 – IBuildDetail.RequestedFor is not what it used to be!</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/tfs-2012-ibuilddetail-requestedfor-is-not-what-it-used-to-be</link>
      <pubDate>Thu, 05 Jul 2012 12:42:33 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2012/07/05/tfs-2012-ibuilddetail-requestedfor-is-not-what-it-used-to-be/</guid>
      <description><![CDATA[If you have custom build tasks or activities that rely on “build.RequestedFor” (or...]]></description>
      <content:encoded><![CDATA[<p>If you have custom build tasks or activities that rely on “build.RequestedFor” (or “build.RequestedBy”) being the account name, you may have some problems when converting those customizations over to TFS 2012 Build.</p>  <p>In TFS 2012, we have completely switched over to Display names in the UI. To make this work consistent everywhere, we repurposed the IBuildDetail fields to show Display names (“John Smith”) instead of account names (“domain\jsmith”). Unfortunately, some customizations need the account name which is unique (the display name is not necessarily unique). </p>  <p>Luckily, it is possible to get this information…</p>  <h3>Custom Activities or XAML</h3>  <p>In a custom activity (or in the XAML file), you simply need to access the IBuildDetail.Requests[0].RequestedFor field. A build request is really an IQueuedBuild. IQueuedBuild now has RequestedFor, RequestedBy, RequestedForDisplayName, and RequestedByDisplayName. It is also possible to get to the build request from the IBuildDetail object by using the new IBuildDetail.Requests property.</p>  <p><strong>NOTE:</strong> It is possible for the Requests property to be empty or to contain more than one item. It may be empty if no build request was associated with the build or if the request was somehow deleted. This situation is rare, but should be accounted for. If you use the Gated check in feature and choose to batch your builds, you can end up with multiple requests per build. This is the only reason you should have more than one request in the Requests property.</p>  <p>Here is a code snippet of how to get this new information:</p>  <p><strong>XAML example:</strong></p>  <pre class="csharpcode">    <span class="kwrd">&lt;</span><span class="html">mtbwa:WriteBuildMessage</span> <span class="attr">Message</span><span class="kwrd">=&quot;[BuildDetail.Requests(0).RequestedFor]&quot;</span> <span class="attr">Importance</span><span class="kwrd">=&quot;High&quot;</span> <span class="kwrd">/&gt;</span>
</pre>


<p><strong>CodeActivity example:</strong></p>

<pre class="csharpcode">    <span class="kwrd">public</span> <span class="kwrd">sealed</span> <span class="kwrd">class</span> GetRequestedFor: CodeActivity&lt;String&gt;
    {
        <span class="kwrd">public</span> InArgument&lt;IBuildDetail&gt; Build { get; set; }

        <span class="kwrd">protected</span> <span class="kwrd">override</span> String Execute(CodeActivityContext context)
        {
            <span class="rem">// Obtain the runtime value of the Text input argument</span>
            <span class="kwrd">string</span> requestedFor = context.GetValue(<span class="kwrd">this</span>.Build).Requests[0].RequestedFor;
            <span class="kwrd">return</span> requestedFor;
        }
    }</pre>


<h3>Custom Tasks or Targets</h3>

<p>Unfortunately, the $(RequestedFor) property has changed in the same way as described above for builds that use the UpgradeTemplate. The fix is basically the same – you need to get to the Request object and get the information from it. However, this requires a custom MSBuild Task, since you can’t get to the properties of the IBuildDetail object directly in MSBuild.</p>

<p>Using an inline Task is perfect for this. Here is an inline Task that you can include in your targets or proj files that will update $(RequestedFor) to the correct value. </p>

<p>In this example, I put this in my TfsBuild.proj file (at the bottom just before the “&lt;/Project&gt;” end element.</p>

<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">UsingTask</span>
    <span class="attr">TaskName</span><span class="kwrd">=&quot;GetRequestedFor&quot;</span>
    <span class="attr">TaskFactory</span><span class="kwrd">=&quot;CodeTaskFactory&quot;</span>
    <span class="attr">AssemblyFile</span><span class="kwrd">=&quot;$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll&quot;</span> <span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">ParameterGroup</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">TeamFoundationServerUrl</span> <span class="attr">Required</span><span class="kwrd">=&quot;True&quot;</span><span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">BuildUri</span> <span class="attr">Required</span><span class="kwrd">=&quot;True&quot;</span><span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">RequestedFor</span> <span class="attr">Output</span><span class="kwrd">=&quot;True&quot;</span><span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">ParameterGroup</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Task</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Reference</span> <span class="attr">Include</span><span class="kwrd">=&quot;mscorlib&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Reference</span> <span class="attr">Include</span><span class="kwrd">=&quot;Microsoft.TeamFoundation.Build.Client&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Reference</span> <span class="attr">Include</span><span class="kwrd">=&quot;Microsoft.TeamFoundation.Build.Common&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Reference</span> <span class="attr">Include</span><span class="kwrd">=&quot;Microsoft.TeamFoundation.Client&quot;</span> <span class="kwrd">/&gt;</span>
 
      <span class="kwrd">&lt;</span><span class="html">Using</span> <span class="attr">Namespace</span><span class="kwrd">=&quot;System&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Using</span> <span class="attr">Namespace</span><span class="kwrd">=&quot;Microsoft.TeamFoundation.Build.Client&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Using</span> <span class="attr">Namespace</span><span class="kwrd">=&quot;Microsoft.TeamFoundation.Build.Common&quot;</span> <span class="kwrd">/&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Using</span> <span class="attr">Namespace</span><span class="kwrd">=&quot;Microsoft.TeamFoundation.Client&quot;</span> <span class="kwrd">/&gt;</span>
 
      <span class="kwrd">&lt;</span><span class="html">Code</span> <span class="attr">Type</span><span class="kwrd">=&quot;Fragment&quot;</span> <span class="attr">Language</span><span class="kwrd">=&quot;cs&quot;</span><span class="kwrd">&gt;</span>
 
        <span class="kwrd">&lt;!</span>[CDATA[
           RequestedFor = String.Empty;
           if (!String.IsNullOrEmpty(TeamFoundationServerUrl))
           {
               Uri serverUri = TfsTeamProjectCollection.GetFullyQualifiedUriForName(TeamFoundationServerUrl);
               // Attempt authentication early. On failure, this is where a good error message will be logged
               TfsTeamProjectCollection collection = new TfsTeamProjectCollection(serverUri);
               collection.Authenticate();             
 
               IBuildServer buildServer = (IBuildServer)collection.GetService(typeof(IBuildServer));
               IBuildDetail buildDetail = buildServer.GetBuild(new Uri(BuildUri));
               
               String requestedFor = buildDetail.RequestedFor;
               if (buildDetail.Requests != null &amp;&amp; buildDetail.Requests.Count <span class="kwrd">&gt;</span> 0)
               {
                   requestedFor = buildDetail.Requests[0].RequestedFor;
               }


               // Assign the value to the output parameter               
               RequestedFor = requestedFor;
           }
        ]]<span class="kwrd">&gt;</span>
 
      <span class="kwrd">&lt;/</span><span class="html">Code</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">Task</span><span class="kwrd">&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">UsingTask</span><span class="kwrd">&gt;</span>


  <span class="kwrd">&lt;</span><span class="html">Target</span> <span class="attr">Name</span><span class="kwrd">=&quot;BeforeGet&quot;</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">GetRequestedFor</span> <span class="attr">TeamFoundationServerUrl</span><span class="kwrd">=&quot;$(TeamFoundationServerUrl)&quot;</span> <span class="attr">BuildUri</span><span class="kwrd">=&quot;$(BuildUri)&quot;</span><span class="kwrd">&gt;</span>
      <span class="kwrd">&lt;</span><span class="html">Output</span> <span class="attr">PropertyName</span><span class="kwrd">=&quot;RequestedFor&quot;</span> <span class="attr">TaskParameter</span><span class="kwrd">=&quot;RequestedFor&quot;</span> <span class="kwrd">/&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">GetRequestedFor</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">Message</span> <span class="attr">Text</span><span class="kwrd">=&quot;RequestedFor = $(RequestedFor)&quot;</span> <span class="kwrd">/&gt;</span>
  <span class="kwrd">&lt;/</span><span class="html">Target</span><span class="kwrd">&gt;</span></pre>


<p>I am calling the task in the BeforeGet target as an example. It could be used where ever you need it as long as you have the TFS Url and BuildUri.</p>

<p>Happy Building!</p>]]></content:encoded>
    </item>
    <item>
      <title>TFS11 RC – Simple Build Summary Customization</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/tfs11-rc-simple-build-summary-customization</link>
      <pubDate>Thu, 07 Jun 2012 06:17:21 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2012/06/07/tfs11-rc-simple-build-summary-customization/</guid>
      <description><![CDATA[So, I did a few posts when TFS 2010 released on how developers could customize the Visual Studio...]]></description>
      <content:encoded><![CDATA[<p>So, I did a few posts when TFS 2010 released on how developers could customize the Visual Studio Build Details View. However, it required creating a VS Add-In or Package and then deploying that to all your clients. Well, with the RC release of TFS 11 and Visual Studio, there is a much easier way to add simple content to your Build Details Summary view.</p>  <p>Simply add the new activity “WriteCustomSummaryInformation” to your build process template (*.XAML). It has several properties that allow you create a new Section and add text to that section…</p>  <ul>   <li>SectionKey – Specifies a unique identifier for the section.</li>    <li>SectionDisplayName – Specifies the name to display on the Build Details View.</li>    <li>SectionPriority – Specifies the relative priority of this section. </li>    <li>Message – This is the string that is displayed inside the section.</li> </ul>  <p>Here are some examples of WriteCustomSummaryInformation and what the XAML would look like in notepad…</p>  <blockquote>   <p>&lt;mtbwa:WriteCustomSummaryInformation SectionKey=&quot;NewSection&quot; SectionDisplayName=&quot;My New Section&quot; SectionPriority=&quot;75&quot; Message=&quot;This is message 1” /&gt;     <br />&lt;mtbwa:WriteCustomSummaryInformation SectionKey=&quot;NewSection&quot; SectionDisplayName=&quot;My New Section&quot; SectionPriority=&quot;75&quot; Message=&quot;This is message 2. Click [here](<a href="http://www.bing.com)">http://www.bing.com)</a> to open Bing.com” /&gt;      <br />&lt;mtbwa:WriteCustomSummaryInformation SectionKey=&quot;NewSection&quot; SectionDisplayName=&quot;My New Section&quot; SectionPriority=&quot;75&quot; Message=&quot;This is message 3. Click [here](vstfs:///WorkItemTracking/WorkItem/1) to open the first work item in this collection.” /&gt;</p> </blockquote>  <p>And here is how that would look on the Build Details View…</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/3531.image_62E5A4E6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/3531.image_5F00_62E5A4E6.png"><img style="display: inline; background-image: none;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/3527.image_thumb_21D72582.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/3527.image_5F00_thumb_5F00_21D72582.png" width="525" height="505" /></a></p>  <p>&#160;</p>  <h2>More Details….</h2>  <p><strong>Priorities:</strong> 0 is the highest priority for a section. The standard sections start at about 100 and continue in increments of 100 for the most part.</p>  <p><strong>Adding to an existing section:</strong> You can find out the Key and priority of existing sections by hovering your mouse over them. Using that Key, you can add messages to the top of existing sections. You cannot remove existing sections but they will take on the priority that you provide. Thus, you could move them to the bottom by providing a very high priority.</p>  <p><strong>Links:</strong> By using the syntax [text](link) you can embed hyperlinks into your messages. links that start with “vstfs:” are assumed to be valid TFS artifact links and will be evaluated that way. All other links will be passed to the OS for evaluation.</p>  <p><strong>Customizing the old way:</strong> The 2010 way of customizing your Build Details View still works and provides a lot more customization than we have provided in this feature.</p>  <p>I hope this makes your customizations much easier and allows you do more with Build!</p>  <p>Happy Customizing!</p>]]></content:encoded>
    </item>
    <item>
      <title>TFS11 Beta – Continuous Diagnostic Logging</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/tfs11-beta-continuous-diagnostic-logging</link>
      <pubDate>Tue, 05 Jun 2012 13:05:46 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2012/06/05/tfs11-beta-continuous-diagnostic-logging/</guid>
      <description><![CDATA[Okay, so if you are a TFS Build user, you probably are familiar with this scenario… You setup a new...]]></description>
      <content:encoded><![CDATA[<p>Okay, so if you are a TFS Build user, you probably are familiar with this scenario… You setup a new build definition and get it working. It works for days maybe weeks, then suddenly builds start failing sporadically for no apparent reason. You have several failed builds and none of them have any useful information. So, you turn the verbosity up on your build to diagnostic so you can repeat the build and get some additional information. The build is running a little slower now and instead of failing, it succeeds. Eventually, you’ll get a failed build that you have enough logging on to fix, but getting there can be a real pain. </p>  <p>Well, in TFS11 we decided to create diagnostic logs all the time. However, we don’t want to slow down the build. So, we write the diagnostic logs to files and copy them to the drop location. These logs are written in an xml format, and we provide a transform to display it nicely in a browser. </p>  <p>From the Build Details View you can click on the new Diagnostics sub menu to View the logs for a completed build. (Note this only works for builds that have a drop location – gated and private builds don’t necessarily have them.)</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/7288.image_6B108719.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/7288.image_5F00_6B108719.png"><img style="display: inline; background-image: none;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/8640.image_thumb_384080A5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/8640.image_5F00_thumb_5F00_384080A5.png" width="534" height="75" /></a></p>  <p>This menu item will open the drop folder location that contains the logs for this build. From there you can choose which file to open. We generate one file for the controller and one for each agent that was used during the build. So, if you know the error was on the agent you can jump straight there. If you aren’t sure, start in the controller log and you can click on links there that will open the agent logs.</p>  <h2>But what about hung builds…</h2>  <p>Unfortunately, a build can get stuck in many different ways even in TFS 11. Sometimes the only way to see where the build is stuck is to view the diagnostic logs. Especially since the build may just be going really slow for some reason. You don’t want to have to stop the build to see what’s wrong.</p>  <p>While a build is in progress, the Diagnostics menu contains another option to request that the logs be put on the drop location (it’s called Request Logs).</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/1212.image_7E513DB8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/1212.image_5F00_7E513DB8.png"><img style="display: inline; background-image: none;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/7266.image_thumb_28BD6ED6.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/7266.image_5F00_thumb_5F00_28BD6ED6.png" width="540" height="89" /></a></p>  <p>If you request logs during the build, they will be copied out to the drop location as they are. Once that finishes, the Diagnostics menu will contain a menu item to view the logs produced at that time. Those logs will still exist even once the build is finished. They are placed under a directory that has the date time they were requested as the name.</p>  <p>We hope this will make diagnosing strange build failures a little easier for everyone. It also allows all the paranoid build admins to speed up their builds by reducing the verbosity to Minimal (that’s our new default in TFS11).</p>  <p>Happy Building!</p>]]></content:encoded>
    </item>
    <item>
      <title>TFS11 Beta – Batching Gated Builds</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/tfs11-beta-batching-gated-builds</link>
      <pubDate>Tue, 05 Jun 2012 07:52:46 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2012/06/05/tfs11-beta-batching-gated-builds/</guid>
      <description><![CDATA[In TFS 2010, we added Gated builds. A gated build is like a pessimistic continuous integration (CI)....]]></description>
      <content:encoded><![CDATA[<p>In TFS 2010, we added Gated builds. A gated build is like a pessimistic continuous integration (CI). CI builds are started after every check-in to make sure the developer didn’t break anything. Gated builds require the developer to check-in through the build process itself. The check-in is blocked until the build succeeds. To guarantee that the build is never broken, gated definitions only allow one check-in at a time. But this leads to a problem for large builds. If your build takes 30 minutes to build, you can only get 48 check-ins thru the system in a day.</p>  <p>The solution to this problem is not to allow parallel builds and check-ins, because that may lead to broken builds. Rather the solution is to allow the build definition to build more than one queued build at a time (or to Batch the builds). By batching the queued builds, you can increase the throughput almost as much as you want (until you have a build failure – more on that below).</p>  <p>Here’s how this works in TFS11…</p>  <p>On the build definition Trigger tab, you can specify to “Merge and build” gated builds and provide the maximum size for a batch.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/5047.image_200EF3B5.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/5047.image_5F00_200EF3B5.png"><img style="display: inline; background-image: none;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/1727.image_thumb_661FB0C8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/1727.image_5F00_thumb_5F00_661FB0C8.png" width="658" height="361" /></a></p>  <p>When a build starts the TFS server will look at this setting and start the build with the next 5 queued builds from the definition’s queue. The build process has been updated to handle multiple queued builds. This is what it does with the queued builds (also called build requests)…</p>  <ol>   <li>The Sync Workspace activity unshelves the changes from each build request in the order that they were in the queue</li>    <li>If one of the shelvesets cannot be unshelved because it conflicts with another shelveset, then that build request is removed from the build and placed back into the queue.</li>    <li>All of the changes are compiled together.</li>    <li>Tests will run as normal</li>    <li>If the compilation or tests fail the build (tests don’t have to fail the build), all of the build requests are returned to the queue and marked to build independently.</li>    <li>If the compilation and tests succeed, the changes are divided back up into their appropriate groups and checked in separately on behalf of the user that submitted the gated check-in. So, 5 build requests will generate 5 changesets even though they are built with one build.</li> </ol>  <p>In the instructions above, you may notice an algorithm to handle build failures. This is how the default algorithm works:</p>  <ol>   <li>Build 1 starts with 3 build requests</li>    <li>compilation fails</li>    <li>the 3 build requests are returned to the queue to build again</li>    <li>Build 2 starts with just 1 of the build requests and succeeds</li>    <li>Build 3 starts with just 1 of the build requests and fails (this was the bad check-in)</li>    <li>Build 4 starts with just 1 of the build requests and succeeds</li>    <li>Requests 1 and 3 were eventually checked in, but 2 was rejected</li> </ol>  <p>Notice that when a batched build fails, you end up building more times than you would have if you didn’t batch at all. This means that you should keep the batch size to a small number. For our builds internally, 5 works well. If you end up with a bad check-in in every batch, you should do one of two things: 1) stop using batched builds or 2) stop letting that dev check-in.</p>  <p>Technically speaking, this algorithm could be changed, but it would be very difficult. We chose a pattern that we felt was simple, effective, and transparent.</p>  <p>Batching builds also leads to some strange relationships between builds and build requests. In the failure case, the first build has 3 build requests associated with it and by the end of the building process, each build request has 2 different builds associated with them. So, we have a many to many relationship between build requests and builds. In Visual Studio, you can see this on the build details window and in the build explorer.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/2620.image_47F1F314.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/2620.image_5F00_47F1F314.png"><img style="display: inline; background-image: none;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/3487.image_thumb_3BF002E0.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/3487.image_5F00_thumb_5F00_3BF002E0.png" width="694" height="346" /></a></p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/7181.image_5AC676BE.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/7181.image_5F00_5AC676BE.png"><img style="display: inline; background-image: none;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/7181.image_thumb_20D733D2.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/7181.image_5F00_thumb_5F00_20D733D2.png" width="699" height="464" /></a></p>  <p>And there’s a new view called the Build Request view. If you click on one of the Request links above you will get to this new view that looks a lot like the Build Details View.</p>  <p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/4861.image_388E6B38.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/4861.image_5F00_388E6B38.png"><img style="display: inline; background-image: none;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/7510.image_thumb_69ADA5D8.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/7510.image_5F00_thumb_5F00_69ADA5D8.png" width="700" height="393" /></a></p>  <p>Hopefully, this information will help you understand this new feature in TFS11. </p>  <p>Happy Building!</p>]]></content:encoded>
    </item>
    <item>
      <title>Using NuGet with TFS Build Automation</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/using-nuget-with-tfs-build-automation</link>
      <pubDate>Thu, 10 May 2012 07:27:12 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2012/05/10/using-nuget-with-tfs-build-automation/</guid>
      <description><![CDATA[In case you aren’t familiar with NuGet, check out this link: http://www.nuget.org   How does NuGet...]]></description>
      <content:encoded><![CDATA[<p>In case you aren’t familiar with NuGet, check out this link: <a href="http://www.nuget.org">http://www.nuget.org</a> </p>  <h3>How does NuGet help you with your build automation?</h3>  <p>In short, NuGet allows you not to have to check-in all those binaries that you depend on to build and deploy your application. If you use NuGet, it will simply download all the dependencies at build time.</p>  <p>From the link above or from within Visual Studio, you can install NuGet. This will install a Visual Studio plugin that does all the magic. If you want to know more about the magic of NuGet, check out <a href="http://msdn.microsoft.com/en-us/magazine/hh547106.aspx">this post by Phil Haack</a>.</p>  <h3>A Quick Example:</h3>  <p>In this example, I will simply create a project that uses a simple NuGet package (ELMAH) and builds it on a standard build machine. I already have TFS installed with a Build Controller and Agent ready to go.</p>  <p>Note: I am using TFS11 Beta, so any screen shots are subject to change before release. However, everything I am doing should work in Visual Studio 2010 as well.</p>  <h5>First, we need to create our sample application. </h5>  <p>Here are my steps:</p>  <ol>   <li>From within Visual Studio, create a new C# Windows Console Application called “SimpleLoggingExample” and add it to source control. (No NuGet stuff yet.)&#160; </li>    <li>Add the ELMAH NuGet package to our application by right clicking on the solution in Solution Explorer and choosing “Manage NuGet Packages …”. (This dialog is pretty straight forward: click on Online then use the Search box in the upper right corner to find ELMAH).<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/8004.image_55DC3D45.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/8004.image_5F00_55DC3D45.png"><img style="margin-right: auto; margin-left: auto; float: none; display: block; background-image: none;" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/00/62/56/metablogapi/7002.image_thumb_5497A466.png" original-url="http://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-00-62-56-metablogapi/7002.image_5F00_thumb_5F00_5497A466.png" width="731" height="412" /></a></li>    <li>Now simply click the Install button on the ELMAH package and close the dialog. Now, your solution has the ELMAH package installed and we can start using it.&#160;&#160; </li>    <li>Go to your Program.cs file and add this code to the Main method:     <pre class="csharpcode">        <span class="kwrd">static</span> <span class="kwrd">void</span> Main(<span class="kwrd">string</span>[] args)
        {
            Elmah.MemoryErrorLog log = <span class="kwrd">new</span> Elmah.MemoryErrorLog();
            log.Log(<span class="kwrd">new</span> Elmah.Error(<span class="kwrd">new</span> Exception(<span class="str">&quot;Hello ELMAH!&quot;</span>)));

            List&lt;Elmah.ErrorLogEntry&gt; list = <span class="kwrd">new</span> List&lt;Elmah.ErrorLogEntry&gt;();
            log.GetErrors(0, 100, list);
            <span class="kwrd">foreach</span> (Elmah.ErrorLogEntry err <span class="kwrd">in</span> list)
            {
                Console.WriteLine(err.Error.Exception.Message);
            }
        }</pre>
    </li>

  <li>Now save everything and test it, but don’t check-in yet. If you press Ctrl+F5 in Visual Studio, you should get a command window with the output “Hello ELMAH!”.</li>
</ol>

<h5>Now, we need to decide what we want to checkin.</h5>

<p>By default, NuGet will add all the files needed to build and run your program to the solution (and source control). If you were to simply check-in everything now, the build would work perfectly and your drop location would include everything you need. However, depending on the NuGet packages that you are using this could lead to a lot of extra files in Source Control that you really don’t want to version. So, how do you avoid checking in all those extra files? It is so simple…</p>

<ol>
  <li>Right click on the Solution in Solution Explorer</li>

  <li>Click on “Enable NuGet Package Restore”</li>

  <li>Click “Yes” when prompted</li>

  <li>Undo the ‘add’ on the Package folder in your solution</li>

  <ol>
    <li>Go to the Pending Changes window in Visual Studio</li>

    <li>Right click the Packages folder</li>

    <li>Select “Undo”</li>

    <li>Confirm the undo of all the files under that folder.</li>
  </ol>

  <li>Check in the solution from the Pending Changes window (make sure all files are checked/included)</li>
</ol>

<p>After you finish these steps, you have a solution that can be built on any machine. Simply do a “TF.exe Get” to get the files and then use MSBuild or Visual Studio to build it. Part of the build process will download the package and its dependencies for you!</p>

<h5>But how do we get NuGet to work on the build machine?</h5>

<p>Simple. The build machine will do the same thing that any of your developers or testers would do, get the files from source control and build them. That’s the beauty of NuGet – it is built into your build system. But, to finish the example, let’s walk through the work you have to do to get this solution to build on your build machine.</p>

<ol>
  <li>First, with the solution still open in Visual Studio, go to Team Explorer</li>

  <li>In TFS11 Beta, you have to navigate to the Builds page</li>

  <li>Then, click on the “New Build Definition” link</li>

  <li>On the build definition editor window fill in the Build Defaults –&gt; Drop Location (this should be a share usually on the Build Machine itself).</li>

  <li>All the other settings should be automatically filled in because you have the solution open.</li>

  <li>Save the definition</li>

  <li>Go back to the Builds page in Team Explorer</li>

  <li>Right click on the new definition (SimpleLoggingExample) and select “Queue New Build”</li>

  <li>On the Queue Build dialog, click Queue.</li>
</ol>

<p>This should cause a build to start on your build machine. You can watch the progress of the build from the Builds page or by opening up the build by double clicking on it.</p>

<p>You should notice that it succeeds without any errors. The build machine successfully downloaded the NuGet packages for the build. If you open the drop folder, you can see the evidence of it by the fact that the Elmah.dll assembly is there just as expected. And if you open a command window to this folder, running “SimpleLoggingExample.exe” should work as expected.</p>

<p>Well, that’s it! I was totally surprised by how easy this was to set up and get going. NuGet is definitely changing the way that .net applications are built! And if you are a producer of .net libraries, you may want to consider creating a NuGet package for your library and providing it to the world :)</p>

<p>Happy Building!</p>]]></content:encoded>
    </item>
    <item>
      <title>TFS11 Beta - TfsBuildServiceHost.2012 service stopping unexpectedly</title>
      <link>https://docs.microsoft.com/archive/blogs/jpricket/tfs11-beta-tfsbuildservicehost-2012-service-stopping-unexpectedly</link>
      <pubDate>Tue, 08 May 2012 12:55:00 GMT</pubDate>
      <dc:creator><![CDATA[Jason Prickett - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/jpricket/2012/05/08/tfs11-beta-tfsbuildservicehost-2012-service-stopping-unexpectedly/</guid>
      <description><![CDATA[We noticed several early adopters running into an issue with the build service in TFS11 Beta...]]></description>
      <content:encoded><![CDATA[<p>We noticed several early adopters running into an issue with the build service in TFS11 Beta stopping unexpectedly. There is no event log entry other than it stopped and restarting it seems to work fine. The root cause seems to be connectivity to the TFS11 application tier. If the build machine can't connect to the AT for more than the 5 minute timeout, an exception causes it to stop. It acutally stops normally, so the service failure configuration doesn't restart it. We also forgot to log the error to the event log, so there's no explanation for the stoppage.</p>
<p>The only workaround is to restart the service.</p>
<p>To make this a little easier, I wrote a simple console application that will check the service every&nbsp;five minutes and ensure that it is still running. Unfortunately, this application has to run as an administrator because of the security around services. Simply create a Windows Console Application in VS, add a reference to System.ServiceProcess for the project,<br />and replace Program.cs with this code...</p>
<pre class="scroll"><code class="csharp"> using System;<br /> using System.Collections.Generic;<br /> using System.Diagnostics;<br /> using System.Linq;<br /> using System.ServiceProcess;<br /> using System.Text;<br /> using System.Threading;<br /> using System.Threading.Tasks;<br /> <br /> namespace KeepAliveBuildService<br /> {<br /> class Program<br /> {<br /> static void Main(string[] args)<br /> {<br /> String serviceName = args.Length &gt; 0 ? args[0] : "TfsBuildServiceHost.2012";<br /> while (true)<br /> {<br /> // Make sure the service is up<br /> EnsureServiceIsStarted(serviceName);<br /> // Wait five minutes<br /> Thread.Sleep(new TimeSpan(0, 5, 0));<br /> }<br /> }<br /> <br /> static bool EnsureServiceIsStarted(String serviceName)<br /> {<br /> try<br /> {<br /> var service = new ServiceController(serviceName);<br /> LogMessage(String.Format("{0} Status {1}", serviceName, service.Status));<br /> if (service.Status != ServiceControllerStatus.Running)<br /> {<br /> LogMessage(String.Format("Starting {0}", serviceName, service.Status));<br /> service.Start();<br /> return true;<br /> }<br /> }<br /> catch (InvalidOperationException)<br /> {<br /> LogMessage(String.Format("No service with the name {0} could be found.", serviceName));<br /> }<br /> catch (Exception ex)<br /> {<br /> LogMessage(ex.ToString());<br /> }<br /> <br /> return false;<br /> }<br /> <br /> static void LogMessage(String message)<br /> {<br /> String source = "KeepAliveBuildService";<br /> String log = "Application";<br /> if (!EventLog.SourceExists(source))<br /> {<br /> EventLog.CreateEventSource(source, log);<br /> }<br /> <br /> EventLog.WriteEntry(source, message);<br /> Console.WriteLine(message);<br /> }<br /> }<br />}</code></pre>
<p>You can run the program interactively on the desktop (remember to run as Admin) or you can create a Windows Service torun the application for you.Please note that this is only a problem for the TFS11 Beta Build Service. We have since fixed the problem and it should not appear in future versions</p>
<p>Sorry about the bug :(</p>]]></content:encoded>
    </item>
  </channel>
</rss>