<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.wintellect.com/CS/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>John Robbins' Blog</title><link>http://www.wintellect.com/CS/blogs/jrobbins/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2.1 SP2 (Build: 61129.2)</generator><item><title>Debugger Canvas 1.1 is Released</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2012/01/31/debugger-canvas-1-1-is-released.aspx</link><pubDate>Tue, 31 Jan 2012 20:48:19 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20570</guid><dc:creator>jrobbins</dc:creator><slash:comments>0</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20570.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20570</wfw:commentRss><description>&lt;p&gt;There’s a lot of UI research going on focused around better debugging. Debugger Canvas is some that you can use today and the version 1.1 was just &lt;a href="http://msdn.microsoft.com/en-us/devlabs/debuggercanvas"&gt;released&lt;/a&gt;. The speed increased in 1.1 are great and make Debugger Canvas much more usable. I’m in love with the toggle button where you can flip between Debugger Canvas and regular text file display. While I have a few feature &lt;a href="http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/06/14/debugger-canvas-tricks-and-wishes.aspx"&gt;requests&lt;/a&gt; that I’d love to see, using 1.1 made me wish for some more. My feedback’s been given to the Debugger Canvas team but I thought it might spark some discussion by mentioning my additional wishes to everyone:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;When using Debugger Canvas on a multithreaded application, I’d love to see the thread ID and/or name in the display when it’s an active call stack. It’s a little to easy to get lost in a multithreaded canvas.&lt;/li&gt;    &lt;li&gt;It would be nice to have a timestamp on a bubble. When one canvas is getting reused you can see at a glance which is the most recent chain.&lt;/li&gt;    &lt;li&gt;It would be nice to have a way to remove a whole chain at once.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Please do let the team know your feedback at the DevLabs Debugger Canvas &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/debuggercanvas/threads"&gt;forum&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20570" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>Wintellect is Hiring!!</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2012/01/24/wintellect-is-hiring.aspx</link><pubDate>Tue, 24 Jan 2012 06:33:18 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20551</guid><dc:creator>jrobbins</dc:creator><slash:comments>0</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20551.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20551</wfw:commentRss><description>&lt;p&gt;Business is good and we need YOU! Wintellect is currently seeking senior level technical development resources for both contract and permanent employment for our current client projects. If you want the challenge of keeping up with co-workers like Jeffrey Richter, Jeff Prosise, Keith Rome, or Jeremy Likness, have we got the opportunity of a lifetime. Please have lots of hands on development experience in the following technologies: C#, ASP.NET MVC, WPF, WCF, Silverlight and SQL Server. Experience with HTML5 and jQuery would be ideal also. If you can't tell, it's all cutting edge here at Wintellect so if you like doing the latest technology we'd love to talk with you. Please forward your resume and availability to Barbara Keihm, Director of Human Resources, &lt;a href="mailto:bkeihm@wintellect.com?subject=I%20want%20to%20work%20at%20Wintellect!"&gt;bkeihm@wintellect.com&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20551" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Wintellect/default.aspx">Wintellect</category></item><item><title>Paraffin 3.6–Now Keeping Custom Added Namespaces</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2012/01/19/paraffin-3-6-now-keeping-custom-added-namespaces.aspx</link><pubDate>Thu, 19 Jan 2012 23:44:35 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20541</guid><dc:creator>jrobbins</dc:creator><slash:comments>1</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20541.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20541</wfw:commentRss><description>&lt;p&gt;Paraffin 3.6 can be downloaded here: &lt;a href="http://www.wintellect.com/CS/files/folders/18310/download.aspx"&gt;http://www.wintellect.com/CS/files/folders/18310/download.aspx&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Dan Gough had an excellent &lt;a href="http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Anybody-using-Paraffin-td7172929.html"&gt;feature request&lt;/a&gt; to have Paraffin copy over any manually added namespaces to the .WXS file like the following. Previously, Paraffin ignored them, but no more.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9357e3e1-452b-41dd-b7eb-88e813a23d8c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color:#a31515;"&gt;xml&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;version&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;1.0&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;encoding&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;utf-8&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;?&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Wix&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;xmlns:util&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;http://schemas.microsoft.com/wix/UtilExtension&lt;/span&gt;&amp;quot;&lt;/li&gt; &lt;li&gt;     &lt;span style="color:#0000ff;"&gt;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;http://schemas.microsoft.com/wix/2006/wi&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;I updated Paraffin to copy over any namespaces added to the Wix element when creating the .PARAFFIN file. If you were having Paraffin inject additional elements with a .ParaffinMold file, now it’s easier than ever to keep your WiX fragments up to date.&lt;/p&gt;  &lt;p&gt;When adding custom namespaces, put them before the default xmlns=&amp;quot;http://schemas.microsoft.com/wix/2006/wi&amp;quot; as I’ve shown in the snippet above. With LINQ to XML, the xmlns attribute is special and does not show up in the Attributes collection so there’s no way I can sort it with the rest of the values. When generating the output XML file, XDocument always puts the xmlns attribute last. I tried all sorts of tricks to get it placed first but never got them to work. &lt;/p&gt;  &lt;p&gt;There’s no trouble if you place your custom namespaces after the default xmlns, but in the .PARAFFIN file they will always appear first so you’ll see more changes when you diff the .WXS and .PARAFFIN file.&lt;/p&gt;  &lt;p&gt;Please do let me know if you have feature requests! I considered adding a command line switch to allow adding custom namespaces when creating a .WXS fragment but didn’t think that would be used very much so decided against it. Of course, now that I’ve mentioned this option everyone’s going to ask for it. &amp;lt;grin!&amp;gt;&lt;/p&gt;  &lt;p&gt;If you’re not familiar with Paraffin, please read the Zen of Paraffin document in the root directory of the download.&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20541" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Windows+Installer/default.aspx">Windows Installer</category><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Wix/default.aspx">Wix</category><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Paraffin/default.aspx">Paraffin</category></item><item><title>Visual Studio 2010 Extensions Recommendations</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2012/01/16/visual-studio-2010-extensions-recommendations.aspx</link><pubDate>Mon, 16 Jan 2012 18:31:15 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20532</guid><dc:creator>jrobbins</dc:creator><slash:comments>7</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20532.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20532</wfw:commentRss><description>&lt;p&gt;The other day I was asked which extensions for Visual Studio I use so in an effort to &lt;a href="http://blog.jonudell.net/2007/04/10/too-busy-to-blog-count-your-keystrokes/"&gt;save keystrokes&lt;/a&gt;, I thought I’d list them here so I can refer people to this list. There’s no way this is a comprehensive list and I do add and remove extensions all the time. However, these are the ones that always stay installed because if they aren’t, I can’t use Visual Studio. By the way, these are all free.&lt;/p&gt;  &lt;h2&gt;&lt;a href="http://visualstudiogallery.msdn.microsoft.com/d0d33361-18e2-46c0-8ff2-4adea1e34fef/"&gt;Productivity Power Tools&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;Want a bunch of features for the next version of Visual Studio today? That’s exactly what Microsoft’s Productivity Power Tools are all about. Once you use the awesome Solution Navigator, you’ll wonder how you ever lived without it. Add in the better Tab Well UI, Quick Find, and all the other enhancements and you’re in Visual Studio heaven. This is the single most important extension available. &lt;/p&gt;  &lt;h2&gt;&lt;a href="http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c"&gt;NuGet Package Manager&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;The first time you add an open source package to your solution, you’ll thank your lucky stars for this extension. It’s quick and easy so you can focus on what you need to do instead of the integration. What I find even better than the package manager is that NuGet adds a PowerShell window to Visual Studio. I’m using that constantly these days because the $dte variable exposes the Visual Studio automation model to PowerShell. &lt;/p&gt;  &lt;h2&gt;&lt;a href="http://visualstudiogallery.msdn.microsoft.com/f4d9c2b5-d6d7-4543-a7a5-2d7ebabc2496"&gt;VS Color Output&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;This fine extension adds color-coding to output windows in Visual Studio. Seeing build breaks in red and good builds in green, as well as control over all other output, is something that should have been built into Visual Studio already. The latest version 1.1 update fixes a crashing issue people were reporting.&lt;/p&gt;  &lt;h2&gt;&lt;a href="http://visualstudiogallery.msdn.microsoft.com/0db4814c-255e-4cc6-a2c2-a428de7f8949/"&gt;HTML Spell Checker&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;I can’t spell at all and this extension keeps me from looking like moron as others look at the comments in my code.&lt;/p&gt;  &lt;h2&gt;&lt;a href="http://visualstudiogallery.msdn.microsoft.com/4b92b6ad-f563-4705-8f7b-7f85ba3cc6bb"&gt;Highlight All Occurrences of a Selected Word&lt;/a&gt;&lt;/h2&gt;  &lt;p&gt;A super simple extension that does exactly what the title says. It’s wonderful when doing presentations to highlight a word and for looking at all uses of a global variable. Note that this extension offers no customizability so you’re stuck with the lime green highlight that does not work so well with you wild kids using dark background themes.&lt;/p&gt;  &lt;p&gt;So what extensions can you not live without? I’d love to know what extensions you use so either blog about them or add them to the comments.&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20532" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Recommended/default.aspx">Recommended</category></item><item><title>Setting the Power Plan with PowerShell</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2012/01/15/setting-the-power-plan-with-powershell.aspx</link><pubDate>Sun, 15 Jan 2012 07:54:00 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20524</guid><dc:creator>jrobbins</dc:creator><slash:comments>4</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20524.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20524</wfw:commentRss><description>&lt;p&gt;Edit: Make sure to read the comments from Shay Levy and Richard on clarifying my mistaken assumptions about how things work in PowerShell. Thanks to Richard &amp;amp; Shay for the clarifications!&amp;nbsp;&lt;/p&gt;&lt;p&gt;As I’m a command line kind of guy, I look for every opportunity to stay in a PowerShell window at all times. “Why grab the mouse when you don’t have?” to is my motto! The other day I was working on my laptop and was running short of battery power so wanted to switch to the Power Saver plan. A quick search told me POWERCFG.EXE was the command line tool to use.&lt;/p&gt;  &lt;p&gt;Hold on there Flash! POWERCFG.EXE with the –S option is the command line way to change power plans, but to specify the plan you must use the GUID of the plan. While I’m a big fan of GUIDs there’s several places where GUIDs are not appropriate: command line tools, URLs, and any other place where end users could see them. Shouldn’t you just be able to set the power plan by name like “Balanced, ” “Power Saver,” or if you are feeling randy, “High Performance?” That’s an oversight that needs to be fixed so below is a PowerShell script, Set-PowerPlan.ps1, that lets you set the power plan at the command line based on the name of the plan instead of an ugly GUID.&lt;/p&gt;  &lt;p&gt;The basic idea of the script is to get the list of defined power plans from “POWERCFG.EXE –l” and parse the output with a regular expression looking for the plan name with matching GUID. With the GUID in hand calling “POWERCFG –s &amp;lt;GUID&amp;gt;” flips to the defined plan. The regular expression work was simple, but there was one thing that stumped me.&lt;/p&gt;  &lt;p&gt;In all the PowerShell work I’ve done I’ve never needed to capture the output of an old-school command line program like POWERCFG.EXE. It seemed so simple to do something like “$plans = POWERCFG –l” to get the list of plans and parse the output with “$plans –match &amp;lt;some regex&amp;gt;” to pull out the GUID. Little did I know that would definitely not be anything approaching normal. Yet again a PowerShell-ism reached up and dope slap me hard.&lt;/p&gt;  &lt;p&gt;Interactively in a PowerShell console window, I ran “$plans = POWERCFG –l” and double-checked that $plans was a string by executing “$plans | Get-Member” as piping to Get-Member will report the type of object. Sure enough I was looking at a System.String. Oddly, when I ran “$plans –match &amp;lt;regex&amp;gt;” it always returned false even though typing “$plans” definitely showed me the complete output of the “POWERCFG –l” and the exact string I was looking for was there.&lt;/p&gt;  &lt;p&gt;What totally confused me was running “$plans.Length” as that reported “7” instead of the 364 characters I counted in the string. After a bunch of reading I finally realized that $plans is really a freaking ARRAY of seven lines instead of a complete string. When PowerShell captures the output of a regular command line program as an array of strings. Whenever one is first exposed to PowerShell you invariably are taught about the Get-Member command right at the beginning to figure out the type of an object. When Get-Member lies to you it’s hard to get a clue. It’s things like this that make you understand why so few developers have switched over to PowerShell. &lt;/p&gt;  &lt;p&gt;If you want all the output of a regular command line program into an actual string you have two choices. The first is to explicitly type the receiving variable with [string] like the following: “[string]$plans = powercfg -l” The alternative is to gather the regular command output into a variable, but if you need to look across all that output pipe the variable array to Out-String surrounded by parenthesis as in “($plans | Out-String)”.&lt;/p&gt;  &lt;p&gt;I’m sure some PowerShell Ninja will jump in here and tell me how I missed the obvious, but I don’t feel I did. Hopefully, this little PowerShell gotcha will help you go down the PowerShell route with more confidence. While PowerShell has some bumps along the way the journey is totally worth it!&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6ed12321-49dd-4596-a424-ef426835a83c" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;"&gt;Set-PowerPlan.PS1&lt;/div&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;#requires -version 2.0&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;# (c) 2012 by John Robbins\Wintellect&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;lt;#.SYNOPSIS&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;Sets the current power plan.&lt;/li&gt; &lt;li&gt;.DESCRIPTION&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;The POWERCFG.EXE utility requires GUIDS when changing a power plan instead of&lt;/li&gt; &lt;li&gt;the name of the plan. That's highly inconvenient so this simple script allows &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;you to use common sense names like "Balanced" or "Power Saver" instead.&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;To get the list of power plans on your computer execute 'powercfg -l'&lt;/li&gt; &lt;li&gt;.PARAMETER Plan&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;The name of the power plan to use.&lt;/li&gt; &lt;li&gt;.EXAMPLE &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;Set-PowerPlan -Plan Balanced&lt;/li&gt; &lt;li&gt;Sets the power plan to the Balanced plan, the recommnded Microsoft plan.&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;.EXAMPLE &lt;/li&gt; &lt;li&gt;Set-PowerPlan "Power Saver"&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;Sets the power plan to the Power Saver plan to reduce battery usage.&lt;/li&gt; &lt;li&gt;.LINK&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/PowerShell/default.aspx&lt;/li&gt; &lt;li&gt;#&amp;gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;param ($Plan = $(throw 'You must specify the power plan, use "powercfg -l" for the plan names' ))&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;Set-StrictMode -Version Latest&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;# Get the list of plans on the current machine.&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;$planList = powercfg.exe -l&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;# The regular expression to pull out the GUID for the specified plan.&lt;/li&gt; &lt;li&gt;$planRegEx = "(?&amp;lt;PlanGUID&amp;gt;[A-Fa-f0-9]{8}-(?:[A-Fa-f0-9]{4}\-){3}[A-Fa-f0-9]{12})" + ("(?:\s+\({0}\))" -f $Plan)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;# If the plan appears in the list...&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;if ( ($planList | Out-String) -match $planRegEx )&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# Pull out the matching GUID and capture both stdout and stderr.&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$result = powercfg -s $matches["PlanGUID"] 2&amp;gt;&amp;amp;1&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;# If there were any problems, show the error.&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if ( $LASTEXITCODE -ne 0)&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$result&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;}&lt;/li&gt; &lt;li&gt;else&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;{&lt;/li&gt; &lt;li&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Write-Error ("The requested power scheme '{0}' does not exist on this machine" -f $Plan) &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20524" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/PowerShell/default.aspx">PowerShell</category></item><item><title>Want Source Server to Work with Managed Minidumps in Visual Studio? Here’s How!</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2012/01/06/want-source-server-to-work-with-managed-minidumps-in-visual-studio-here-s-how.aspx</link><pubDate>Fri, 06 Jan 2012 18:29:23 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20499</guid><dc:creator>jrobbins</dc:creator><slash:comments>1</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20499.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20499</wfw:commentRss><description>&lt;p&gt;So you have an awesome minidump your IT guys grabbed with &lt;a href="http://technet.microsoft.com/en-us/sysinternals/dd996900"&gt;ProcDump&lt;/a&gt;. You’ve followed all the rules and have a Symbol Server and Source Server all set up. You open that dump with Visual Studio and BOOM, none of your indexed sources show up. You pull your hair out trying to get your public build sources appear but they never do and it’s just “SRCSRV: The module ‘&amp;lt;&amp;lt;path to the exe file&amp;gt;&amp;gt;’ does not contain source server information.” for everything in the Output window.&lt;/p&gt;  &lt;p&gt;Fortunately, a smiling bald guy, &lt;a href="http://smilingbaldguy.wordpress.com/"&gt;Andy Hopper&lt;/a&gt;, figured out how to make it all &lt;a href="http://smilingbaldguy.wordpress.com/2012/01/06/managed-minidump-debugging-now-with-source-server-support/"&gt;work&lt;/a&gt;. Turns out when opening a minidump, the “managed debugging engine tries to verify that each source server enabled assembly is running as a fully trusted assembly from the CLR’s perspective.” Ahh, nothing like security to turn off a feature. The great news is that you can tell the managed debugging engine to stop doing the checks so the Source Server works with the managed minidumps. It’s as simple as setting a registry key. Swipe the registry script below and you are good to go.&lt;/p&gt;  &lt;p&gt;All credit to Andy Hopper on this one!&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:55b01d15-bc2c-439d-9916-2d0677300087" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;Windows Registry Editor Version 5.00&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;; Enables Source Server support when opening up managed minidumps in Visual Studio.&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;; All credit to Andy Hopper!&lt;/li&gt; &lt;li&gt;; http://smilingbaldguy.wordpress.com/2012/01/06/managed-minidump-debugging-now-with-source-server-support/&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;; If you&amp;#39;re on a 32-bit machine (and why would you be?) remove Wow6432Node.&lt;/li&gt; &lt;li&gt;;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;[HKEY_LOCAL_MACHINE&amp;#92;SOFTWARE&amp;#92;Wow6432Node&amp;#92;Microsoft&amp;#92;VisualStudio&amp;#92;10.0&amp;#92;AD7Metrics&amp;#92;Engine&amp;#92;{00000000-0000-0000-0000-000000000000}]&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;quot;RequireFullTrustForSourceServer&amp;quot;=dword:00000000&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20499" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Debugging/default.aspx">Debugging</category></item><item><title>Things I Am Enjoying (December, 2011)</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/12/29/things-i-am-enjoying-december-2011.aspx</link><pubDate>Thu, 29 Dec 2011 19:51:41 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20473</guid><dc:creator>jrobbins</dc:creator><slash:comments>2</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20473.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20473</wfw:commentRss><description>&lt;p&gt;In the development world, there’s a lot of things that bump, distract, and annoy you through the day. Those get a lot of attention in blogs to help others work around those issues and to document the pain. What does not get a lot of attention are those things that work well and make your life better. In this blog post I want to shout the kudos for a few things I’ve been enjoying immensely in the last month. My list will not be anything as good as &lt;a href="http://www.hanselman.com/blog/ScottHanselmans2011UltimateDeveloperAndPowerUsersToolListForWindows.aspx"&gt;&lt;b&gt;Scott Hanselman's 2011 Ultimate Developer and Power Users Tool List for Windows&lt;/b&gt;&lt;/a&gt;, but I’m sure loving what I mention below!&lt;/p&gt;  &lt;h3&gt;&lt;a href="https://agilebits.com/onepassword"&gt;1Password from Agile Bits&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;With the news the last few years talking about security breaches and research showing everyone is using the same password everywhere if you’re not using a password manager you are plain crazy. I’ve been using 1Password for a while now and it’s so well integrated in all browsers across Windows, OS X, and phones, I basically forgot I was using it. When setting up a new machine recently I was perplexed for a minute as to why I couldn’t log into various web sites and where was the password button in the web browser? 1Password does its job so well I can’t help but recommend it because I forget I’m running it.&lt;/p&gt;  &lt;p&gt;Speaking of passwords and security, all developers need to read the wonderful research paper “&lt;a href="http://research.microsoft.com/en-us/um/people/cormac/papers/2009/SoLongAndNoThanks.pdf&amp;amp;pli=1"&gt;So Long, And No Thanks for the Externalities: The Rational Rejection of Security Advice by Users&lt;/a&gt;” by Cormac Herley of Microsoft Research. It discusses why normal people always use the same password and weak ones at that. &lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.slysoft.com/en/virtual-clonedrive.html"&gt;SlySoft Virtual Clone Drive&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;Windows 8 will &lt;em&gt;finally&lt;/em&gt; have native &lt;a href="http://www.tomshardware.com/news/windows-8-iso-vhd-mounting-win8,13358.html"&gt;ISO mounting&lt;/a&gt; support built in to the OS. It’s about time. However, with Windows 8 not releasing for quite a while you need something today to mount those ISO files. Virtual Clone Drive has been around for years and works on all Windows OS. I don’t have any software on a DVD any more because either downloaded it or converted it to ISO files. When using Virtual Clone Drive, select the Virtual Sheep option so your fake DVD drive shows up with the awesome angry sheep icon. The price is awesome for Virtual Clone Drive: free.&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://eshop.macsales.com/item/OWC/DDAMBS0GB/"&gt;Other World Computing Data Doubler&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;As it was time for a laptop upgrade, I kept with my love of Apple hardware and bought a 15-inch MacBook Pro. As I’ve said many times to people: “Apple: The best Windows machines money can buy!”™® Because I don’t use DVDs any more the Apple drive is just taking up space in the machine. Fortunately, the fine folks at Other World Computing (OWC) have a great solution in Data Doubler that replaces your DVD with another hard disk. For $65 USD I slapped in the SSD I took out of my no longer needed desktop machine and instantly had another 240GB of sweet SSD speedy sexiness for my virtual machines. &lt;/p&gt;  &lt;p&gt;The prospect of cracking open a unibody MacBook sounded daunting and I thought I might kill the magic hipster fairies that live inside of all Apple products. The good news is that OWC include all the tools you need to do the conversion and have &lt;a href="http://eshop.macsales.com/installvideos/owc_datadoubler/"&gt;fantastically detailed videos&lt;/a&gt; on all the exact steps for your particular machine. What I especially liked is that the Data Doubler came with replacement Phillips head screws to replace the hard to work with Torx head screws Apple uses in manufacturing. Now if I want to throw in a much bigger disk in the future, it will be that much easier to do it. That’s attention to detail!&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://vscoloroutput.codeplex.com/"&gt;VSColorOutput Extension by Blue Onion Software&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;Wading through the build output with a large project in Visual Studio is tedious. If only there were a way to use colors to have good lines in green, errors in red, and everything else in a gray it would be much easier to see what’s going on. Fortunately, Mike Ward over at Blue Onion Software did exactly that with VSColorOutput extension and it’s on my can’t live without list. Even better is that the code is open source on CodePlex so if you have never written a Visual Studio extension, it’s a great example.&lt;/p&gt;  &lt;p&gt;Since I’m talking about Blue Onion, make sure to subscribe to Mike’s &lt;a href="http://blueonionsoftware.com/blog.aspx"&gt;blog&lt;/a&gt;. His Friday Links posts always have something in them that I didn’t know about or find really interesting. My personal favorite category is the “Stuff I Just Like” links.&lt;/p&gt;  &lt;h3&gt;Microsoft IT VPN&lt;/h3&gt;  &lt;p&gt;It’s no surprise to you but there are a lot of problems with most VPN software. We have to use many different VPN solutions with all our clients and most of them range from painful to an all out death assault on your machine. You know, small issues like you can either VPN or hit the whole Internet but not both, each requires different anti virus software some of which are not up to date, and so on. Sadly, unless you are a Microsoft Employee or approved vendor you won’t get to see VPN software done outstandingly well. Microsoft IT has this awesome solution that uses smart cards in your badges before you connect, decent connection speed, killer security when you are connected, and never interferes with anything on your machine. &lt;/p&gt;  &lt;p&gt;I really wish Microsoft would do some white papers on their IT VPN setup because it so much better than any other I’ve seen. Hopefully mentioning the internal VPN solution has won’t kill my NDA with Microsoft. I’m sure like any internal IT group, Microsoft IT only gets noticed when something isn’t working, but I just love their VPN solution and wanted to give them a solid shout out.&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.tfspreview.com"&gt;TFS Preview from Microsoft&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;Since TFS 2005 I’ve been running my own domain so I can use TFS and get experience with all of its facets. It was all a bit of overkill, because all I really need for my personal work is TFS Basics, but that wasn’t offered back in the day. TFS is an amazing product and it offers many bells and whistles that provide all the reporting and legal requirements that up to the largest organization requires. However, one thing I’ve noticed is that many teams use the same parts of TFS such as product backlog, bug tracking, version control, and build management, but never touch other pieces such as the SharePoint integration. &lt;/p&gt;  &lt;p&gt;The TFS team has certainly noticed the same phenomenon and also saw an opportunity to provide hosted TFS. While TFS Preview isn’t formally in a beta with Dev 11 yet, I feel it’s the true killer release of TFS. For many teams it will hit the 90% sweet spot of their TFS usage, most likely provide a Service Level Agreement for uptime better than many internal IT organizations can offer, and be cheaper in the long run.&lt;/p&gt;  &lt;p&gt;This last month I set up a full project with one-week sprints to work through using TFS Preview using the Scrum 2.0 template and I’m far more than impressed, I want to start throwing gobs of money at Microsoft right now! I couldn’t believe how polished the whole web experience has become and the Scrum board is my favorite Web 2.0 page ever. Other than companies with specific legal requirements for running your own TFS server, I can’t see why anyone would ever need to run their own TFS server. I wonder if there’s a business opportunity to offer automated migration of work items and check ins between your old server and the spiffy TFS Preview?&lt;/p&gt;  &lt;h3&gt;&lt;a href="http://www.parallels.com/products/desktop/"&gt;Parallels Desktop for Mac from Parallels&lt;/a&gt;&lt;/h3&gt;  &lt;p&gt;After Apple introduced Boot Camp that lets you boot the Macs into Windows, I was in all sorts of love because it is great hardware combined with zero crapware on Windows. I was more than happy to reboot between OS X and Windows whenever I needed to use one or the other. When Parallels first announced support for utilizing your Boot Camp a while ago (version 2.5), I gave it a try but quickly gave up because Windows and Office activations triggered whenever I switched between Boot Camp and Parallels. While I could have created a separate dedicated virtual machine, I didn’t want to waste the disk space for a second copy of Windows nor go through the installation hell of setting up a development machine twice and then trying to keep everything in sync between them.&lt;/p&gt;  &lt;p&gt;When I bought my new Mac Book Pro, I figured I’d give Parallels another shot because being able to utilize Windows no matter if I was running OS X or Boot Camp seems very enticing. With version 7 the Parallels team completely and totally nailed it! I installed Windows in Boot Camp and activated it. Switching back to OS X, I installed Parallels, fired up the Boot Camp partition in a VM activated Windows again and that was it. I can use Windows (and Microsoft Office) either way and &lt;em&gt;everything just works perfectly&lt;/em&gt;. &lt;/p&gt;  &lt;p&gt;Parallels made it very easy to use the Windows VM full screen so that’s how I rolled for my initial usage. I’d read about the Coherence mode that allows all Windows applications to appear like normal OS X windows, but didn’t think it would be very useful. Let’s just say I was incredibly wrong. I love how smooth and seamless having all your windows from both operating systems running side by side. My wife came into my office and looking at the monitor could not figure out which OS I was running which I thought was pretty funny.&lt;/p&gt;  &lt;p&gt;I just had a brilliant thought! With Windows 8 supporting Hyper-V on the desktop, if Microsoft would support your Apple OS X partition in Hyper-V you’d have the best of all possible worlds! Microsoft could call the feature Camp Boot just to make it even cooler. Being able to run OS X applications when you need them from Windows 8… Oh, please don’t make me wake up from this dream. &amp;lt;Grin!/&amp;gt;&lt;/p&gt;  &lt;h3&gt;Holiday Leftover Turkey Sandwiches&lt;/h3&gt;  &lt;p&gt;My wife is an amazing cook. If you ever meet me in person you will be able to tell that from my girth. Over the holidays she wanted to make a roast turkey so I certainly did not stand in the way because I love the big bird. While the turkey dinner is great, the leftovers are even better. Here’s the ultimate recipe for the food of the gods.&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Two slices of very fresh squishy white bread&lt;/li&gt;    &lt;li&gt;Spread Hellman’s mayonnaise on both internal sides of the bread (this is the secret!)&lt;/li&gt;    &lt;li&gt;Fill the bottom bread with a layer of turkey about a quarter inch thick&lt;/li&gt;    &lt;li&gt;Take a salt grinder filled with sea salt and lightly salt the layer of turkey&lt;/li&gt;    &lt;li&gt;Place a single layer of freshly chilled lettuce on the turkey before putting the top slice of bread on the sandwich&lt;/li&gt;    &lt;li&gt;Carefully mash the sandwich down until the bread conforms around the turkey&lt;/li&gt;    &lt;li&gt;DO NOT CUT THE SANDWICH IN HALF&lt;/li&gt;    &lt;li&gt;Pick up with both hands and enjoy!&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;So what have you find readers been enjoying over the last month?&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20473" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Reviews/default.aspx">Reviews</category><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Recommended/default.aspx">Recommended</category></item><item><title>Is That a WeakReference In Your Gen 2 or Are You Just Glad to See Me?</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/10/29/is-that-a-weakreference-in-your-gen-2-or-are-you-just-glad-to-see-me.aspx</link><pubDate>Sat, 29 Oct 2011 05:39:58 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20323</guid><dc:creator>jrobbins</dc:creator><slash:comments>4</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20323.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20323</wfw:commentRss><description>&lt;p&gt;Sometimes it’s easy to see why your .NET server application is using so much memory, but other times it makes no sense at all. I was at Microsoft earlier this week and someone who’d taken my &lt;a href="http://www.wintellect.com/Training/Courses/Mastering-.NET-Debugging"&gt;debugging class&lt;/a&gt; stopped me and asked an excellent question. The scenario they had was their service memory would just grow at a steady rate without ever going down. The team found a fix for the memory leak through savvy internet searching but found it frustrating they could not see the answer through SOS and &lt;a href="http://www.stevestechspot.com/default.aspx"&gt;SOSEX&lt;/a&gt;. The person gave me the dumps as they wanted to know how they could have found the issue quicker. The research was pretty interesting so I thought I’d share the results.&lt;/p&gt;  &lt;p&gt;The first command you always run after loading SOS is !dumpheap –stat so you can get a picture of the overall memory usage. On the dumps the team gave me, the result showed something very similar to the following at the end of the output:&lt;/p&gt;  &lt;p&gt;   &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9ce60acf-dcb2-40b2-8dc3-a66b78434d04" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;"&gt; &lt;li&gt;0000000000386ce0        9         7328      Free&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;000007fee1d26ac8      464        18720 System.String&lt;/li&gt; &lt;li&gt;000007fee1d2afd0       34       183560 System.Object[]&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;000007fee1d478a0    11098       355136 System.WeakReference&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;  &lt;p&gt;In the real mini dump those WeakReferences were taking up over 270MB! The weak can kill you in the .NET world.&lt;/p&gt;  &lt;p&gt;Whenever I see a &lt;a href="http://msdn.microsoft.com/en-us/library/system.weakreference.aspx"&gt;WeakReference&lt;/a&gt;, you’re looking at some form of cache because it’s a special class that you use to reference an object, but allow that object to be garbage collected. So we know someone’s caching something, but who is doing the caching?&lt;/p&gt;  &lt;p&gt;Running !dumpheap –type System.Weak yields the following output:&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ab5bd96e-c47e-4ef4-8d9d-d3aeef3d6ceb" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;0000000002603f88 000007fee1d478a0       32     &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;0000000002603fa8 000007fee1d478a0       32     &lt;/li&gt; &lt;li&gt;0000000002603fc8 000007fee1d478a0       32     &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;total 0 objects&lt;/li&gt; &lt;li&gt;Statistics:&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;              MT    Count    TotalSize Class Name&lt;/li&gt; &lt;li&gt;000007fee1d4f320        1           40 System.Collections.Generic.List`1&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                                       [[System.WeakReference, mscorlib]]&lt;/li&gt; &lt;li&gt;000007fee1d478a0    11098       355136 System.WeakReference&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;Total 11099 objects&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Yep, that List&amp;lt;WeakReference&amp;gt;, is probably the issue. So it’s time to look who created it by doing a !gcroot on it’s address.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:39efb27f-e56f-4143-9143-9fdf007dd02d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#fff;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;0:004&amp;gt; !gcroot 00000000025ad460 &lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;Note: Roots found on stacks may be false positives. Run &amp;quot;!help gcroot&amp;quot; for&lt;/li&gt; &lt;li&gt;more info.&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;Scan Thread 0 OSTHread b3c&lt;/li&gt; &lt;li&gt;Scan Thread 2 OSTHread 3dc&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;DOMAIN(0000000000399A60):HANDLE(Pinned):4c17d8:Root:  00000000125a7048(System.Object[])-&amp;gt;&lt;/li&gt; &lt;li&gt;  00000000025ad460(System.Collections.Generic.List`1[[System.WeakReference, mscorlib]])&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;    &lt;p&gt;Life just got miserable. .NET stores static fields in an Object Array for each app domain. The static array is pinned in memory so that’s the clue. Sadly, with .NET 4 SOS the only way to see which object has the List&amp;lt;WeakReference&amp;gt; as a field without manually dumping each object in the heap. Back in the .NET 1.1 days there was a way to pretty easily figure out the holding class, but Microsoft changed the implementation so it no longer works.&lt;/p&gt;  &lt;p&gt;Fortunately, there is a way to figure out those static fields. All it takes is a little investment in the Professional edition on the amazing &lt;a href="http://memprofiler.com/"&gt;.NET Memory Profiler&lt;/a&gt;. Always purchase the Professional edition because that’s the version with the advanced feature to open mini dumps. Opening large mini dumps can take a long time as .NET Memory Profiler has to build up the reference chains and other data. However, I’m more than happy to let .NET Memory Profiler take it’s time because to do all of that work manually in SOS would consume months and make me give up technology.&lt;/p&gt;  &lt;p&gt;After opening the mini dump of my sample program, which took about 60 seconds, I typed List into the Overview tab to narrow down to the List&amp;lt;WeakReference&amp;gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.wintellect.com/CS/blogs/jrobbins/image_68F31063.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://www.wintellect.com/CS/blogs/jrobbins/image_thumb_798B0B51.png" width="668" height="202" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Double clicking on the on List&amp;lt;WeakRefefence&amp;gt; takes you to the Type details tab and shows you exactly who owns that pesky static.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.wintellect.com/CS/blogs/jrobbins/image_4C95A876.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://www.wintellect.com/CS/blogs/jrobbins/image_thumb_0B1AF61D.png" width="678" height="194" /&gt;&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;It’s a &lt;a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.tracesource.aspx"&gt;TraceSource&lt;/a&gt; so we have the culprit! In fact, looking at the type instance graph shows the whole reference chain.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.wintellect.com/CS/blogs/jrobbins/image_0D084526.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://www.wintellect.com/CS/blogs/jrobbins/image_thumb_32FDF57C.png" width="211" height="285" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Looking at the TraceSource constructor in Reflector shows exactly where the WeakReference is created.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:34f5b534-78b8-4428-bea9-984d993ea3c0" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#ddd;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; TraceSource(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; name, &lt;span style="color:#2b91af;"&gt;SourceLevels&lt;/span&gt; defaultLevel)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (name == &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    }&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (name.Length == 0)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;ArgumentException&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;name&amp;quot;&lt;/span&gt;);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    }&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.sourceName = name;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.switchLevel = defaultLevel;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;lock&lt;/span&gt; (tracesources)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    {&lt;/li&gt; &lt;li&gt;        _pruneCachedTraceSources();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        tracesources.Add(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;WeakReference&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;));&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;    &lt;p&gt;The _pruneCachedTraceSources method is interesting and shows exactly why those WeakReferences are all stuck in Gen 2.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3fead42e-f6bb-4f8e-9b35-2dfd096f6d3d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; _pruneCachedTraceSources()&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;{&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;lock&lt;/span&gt; (tracesources)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    {&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (s_LastCollectionCount != &lt;span style="color:#2b91af;"&gt;GC&lt;/span&gt;.CollectionCount(2))&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        {&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;WeakReference&lt;/span&gt;&amp;gt; collection = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:#2b91af;"&gt;WeakReference&lt;/span&gt;&amp;gt;(tracesources.Count);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            &lt;span style="color:#0000ff;"&gt;for&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; i = 0; i &amp;lt; tracesources.Count; i++)&lt;/li&gt; &lt;li&gt;            {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (((&lt;span style="color:#2b91af;"&gt;TraceSource&lt;/span&gt;)tracesources[i].Target) != &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;)&lt;/li&gt; &lt;li&gt;                {&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                    collection.Add(tracesources[i]);&lt;/li&gt; &lt;li&gt;                }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;            &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (collection.Count &amp;lt; tracesources.Count)&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            {&lt;/li&gt; &lt;li&gt;                tracesources.Clear();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                tracesources.AddRange(collection);&lt;/li&gt; &lt;li&gt;                tracesources.TrimExcess();&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;            }&lt;/li&gt; &lt;li&gt;            s_LastCollectionCount = &lt;span style="color:#2b91af;"&gt;GC&lt;/span&gt;.CollectionCount(2);&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        }&lt;/li&gt; &lt;li&gt;    }&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Basically, the cache is only cleared whenever new TraceSource is added or a call to Trace.Refresh is made. In the Microsoft code they were mistakenly allocating a new TraceSource and &lt;a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.traceswitch.aspx"&gt;TraceSwitch&lt;/a&gt;, which also has the WeakReference list, every time a connection came in. How this happened is that they converted what was a singleton static object into something they allocated on each call. That meant lots of TraceSource and TraceSwitch allocations but with this magic underneath causing big memory usage. You’ve probably guessed by now that you should always make your TraceSource and TraceSwitch fields statics so you hold only the one instance and avoid this potential memory issue.&lt;/p&gt;  &lt;p&gt;Note that I’m not saying the implementation of TraceSource or TraceSwitch is wrong as it gives you the ability to refresh all your tracing in one call instead of making you manage all the individual instances yourself. That’s a nice feature of the tracing system in .NET. The implementation just doesn’t expect that you’ll be allocating hundreds of thousands.&lt;/p&gt;  &lt;p&gt;While I would love SOS to have a better way to track down these static field problems, at least we do have a solution with .NET Memory Profiler. &lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20323" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Debugging/default.aspx">Debugging</category><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/WinDBG/default.aspx">WinDBG</category></item><item><title>Installing Windows 8 on an ASUS EP121 &amp;amp; Initial Thoughts on Metro</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/09/14/installing-windows-8-on-an-asus-ep121-initial-thoughts-on-metro.aspx</link><pubDate>Wed, 14 Sep 2011 08:25:00 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20199</guid><dc:creator>jrobbins</dc:creator><slash:comments>28</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20199.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20199</wfw:commentRss><description>&lt;p&gt;So I have been installing new builds of Windows since NT 3.1 Beta 1 so I can’t help myself! After downloading Windows 8 Developer Preview I&amp;nbsp; of course had to give it a go on my &lt;a href="http://www.wintellect.com/cs/blogs/jrobbins/archive/2011/02/04/asus-eee-slate-ep121-review.aspx"&gt;ASUS EP121&lt;/a&gt;. It’s a full touch and pen slate computer that is one of the test devices in the Windows 8 &lt;a href="http://blogs.msdn.com/b/b8/archive/2011/09/13/experiencing-windows-8-touch-on-windows-7-hardware.aspx"&gt;labs&lt;/a&gt;. If it wasn’t for the Windows team admitting they were using my exact machine I would have probably been going the Hyper-V route. However, my horoscope said it was a good day so I figured what the heck, let’s go for the full install on real hardware. Below are the notes and raw feedback I took while doing the clean install. Take them as you will.&lt;/p&gt;  &lt;p&gt;After creating a &lt;a href="http://www.intowindows.com/how-to-install-windows-7vista-from-usb-drive-detailed-100-working-guide/"&gt;bootable USB&lt;/a&gt; from the Windows 8 Developer Preview ISO, I plugged my USB drive in and said “I’m feeling lucky.” After restarting the computer, the machine booted off the USB and the install started. I LOVED how the install recognized the touch and pen digitizers on the ASUS. Other than the power cord the only thing I had plugged into the system was the USB boot drive. It was pretty cool to walk through the install with my tablet pen in hand. When installing Windows 7 on this same machine I had to have a USB hub plugged in to get my mouse, keyboard, and bootable Win7 USB drive working.&lt;/p&gt;  &lt;p&gt;As per the documentation, I chose a clean install and let the installer do it’s magic. Everything worked great and I have to give major kudos to the Microsoft lawyers for letting the first sentence in the EULA say&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Make the lawyers happy by reading this carefully. (There won't be a quiz later)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The new setup experience went smooth and I loved how I could use the pen or on screen keyboard for entering the machine account as well as setting up the wireless network. All the devices on the machine were recognized and there was no need to download any drivers.&lt;/p&gt;  &lt;p&gt;Just to make my life fun, I decided to join the machine to my domain after getting the initial OS installed. The process was exactly the same as it’s been in Vista and Windows 7. The only difference is that in Windows 8, you have to click the Control Panel tile, More Settings button, in the Metro UI as it’s not available from the Start menu any more.&lt;/p&gt;  &lt;p&gt;As I still did not have a keyboard or mouse connected to the ASUS EP121, I was able to do all the operations with either the on screen keyboard or the pen. In both cases I’ve found them to be far better than I expected. When connecting to shares or entering product keys for Office the pen and onscreen keyboard worked great.&lt;/p&gt;  &lt;p&gt;My first order of business after getting the OS installed was to get my slate computer usable in my business setting. At Wintellect we use Microsoft Office Online (what is now Office 365, but we haven’t been upgraded yet). That means the first application you install is the Sign On application. What I found neat was that the Sign In application needed .NET 3.5 so that triggered Windows 8 to add a .NET 3.5 as a feature and automatically apply all updates to it. Once that was complete, I could installed the Sign In application and life was good.&lt;/p&gt;  &lt;p&gt;As Visual Studio 11 is already on the machine, the only other set of applications I need is the ubiquitous Microsoft Office 2010 so I can get email, write documents, and have access to my beloved &lt;a href="http://www.wintellect.com/CS/blogs/jrobbins/archive/2009/12/06/how-i-use-onenote.aspx"&gt;OneNote&lt;/a&gt;. That install went smooth and life is good.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;Disclaimer: The following is based off 120 minutes of using the computer. My opinion will probably change as I get more experience with the new UI.&lt;/i&gt;&lt;/p&gt;  &lt;p&gt;Once I got the machine setup and working I was looking forward to digging in and seeing the new Metro UI. However, I found no matter how I tried, I have to be missing something because the Metro apps and approach don’t seem to be making me more productive or the computer more useful. I can totally see how the Metro UI would be wonderful and useful on an ARM tablet machine that you’re sitting on the couch using the computer to browse the web. It’s wonderful for that. However, for a desktop/development computer, all I do in Metro is poke at the Desktop or Control Panel links to get at real applications or configure the computer so Metro kind of gets in the way. &lt;/p&gt;  &lt;p&gt;While they showed off a Metro mail client in the keynote, I can’t see how I would use something that limited to get real work done when I need to sit down and write a long email to a client with lots of details and screen shots. I realize this is a Developer Preview Release and I’ve been using Windows since version 2 so I may be set in my ways. I would love to be proven wrong but on first glance I’m having a hard time seeing how a tablet-like metaphor, that works fantastic for tablet mind you, extends to the desktop.&lt;/p&gt;  &lt;p&gt;After a couple of hours using the computer, I found myself moving all my productivity application to the first “tile space” in Metro so I could get to them quickly after hitting the Windows key. While I love checking my stocks as much as the next investor, it’s not something I want to be doing every time I hit the Windows key. The same goes for the weather. I’m really struggling to try and like the Metro approach but something seems off to me. I feel the OS should better conform to the usage patterns of the device, or even ask the user when the first log in. If Windows 8 is installing on a &lt;a href="http://en.wikipedia.org/wiki/System-on-a-chip"&gt;SOC&lt;/a&gt; computer, the default should be light apps with web browsing and simple games as the default. It installing on a desktop/laptop machine it should conform to general productivity applications over the fluffier stuff.&lt;/p&gt;&lt;p&gt;These are just my initial thoughts from my initial usage. Granted, I have no idea what cool Metro apps we might be getting in the future. These thoughts are my raw thoughts dumped into this blog. Judge Metro on your scale.&amp;nbsp;&lt;/p&gt;  &lt;p&gt;Please chime in with your thoughts on Windows 8 in the comments or your own blog and feel free to tell me how wrong I am about Metro.&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20199" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Tablet+PC/default.aspx">Tablet PC</category></item><item><title>Visual Studio 2010 Updates Now in Windows Update!</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/09/13/visual-studio-2010-updates-now-in-windows-update.aspx</link><pubDate>Tue, 13 Sep 2011 21:04:37 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20198</guid><dc:creator>jrobbins</dc:creator><slash:comments>1</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20198.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20198</wfw:commentRss><description>&lt;p&gt;On a mailing list I’m on &lt;a href="http://www.edsquared.com/"&gt;Ed Blankenship&lt;/a&gt; pointed out that VS updates are now coming through Windows Update. Finally! Hopefully Microsoft will keep pushing these updates for all products they ship because it’s something of a pain to keep a development box up to date.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.wintellect.com/CS/blogs/jrobbins/image_79F4F98E.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://www.wintellect.com/CS/blogs/jrobbins/image_thumb_03D9EAFA.png" width="609" height="107" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20198" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Visual+Studio/default.aspx">Visual Studio</category></item><item><title>More on TFS 2010 Build Numbers Inside Your Projects</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/09/11/more-on-tfs-2010-build-numbers-inside-your-projects.aspx</link><pubDate>Sun, 11 Sep 2011 20:44:31 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20188</guid><dc:creator>jrobbins</dc:creator><slash:comments>3</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20188.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20188</wfw:commentRss><description>&lt;p&gt;The other day I &lt;a href="http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/09/05/tfs-2010-build-numbers-file-versions-from-inside-your-c-and-c-projects.aspx"&gt;wrote&lt;/a&gt; about how to incorporate build numbers into your .CSPROJ and .VCXPROJ files. In doing some more testing I found in some edge cases where the way I was getting the current build number by including Microsoft.TeamFoundation.Build.targets could interfere with the TFS Build. That’s not good so I fixed the problem by declaring and using the &lt;a href="http://msdn.microsoft.com/en-us/library/bb399152.aspx"&gt;GetBuildProperties&lt;/a&gt; task by itself. That avoids the odd build case and makes everything work. I’ve updated the &lt;a href="http://www.wintellect.com/CS/files/folders/20166/download.aspx"&gt;sample&lt;/a&gt; with the latest Wintellect.TFSBuildNumber.targets file so grab it &lt;a href="http://www.wintellect.com/CS/files/folders/20166/download.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;In my previous post I showed the simple example of changing the one .CSPROJ or .VCXPROJ file that’s built at the beginning of your build. I was working on a large system that was broken into multiple .SLN files that could be built in any order. That meant I had to edit multiple projects and wanted to show how I simplified the integration into many projects.&lt;/p&gt;  &lt;p&gt;First I created a common ,Targets file I called VersionNumbers.Targets that included everything necessary for creating the version number files for both C# and C++ projects. The comments in the file explain what’s going on. You can use this file as the basis of all your version number files.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:2f9137c6-66a9-44a5-85a4-387e91722821" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;"&gt;Version Numbers.Targets&lt;/div&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;white-space:nowrap;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;xmlns&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;http://schemas.microsoft.com/developer/msbuild/2003&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000;"&gt; The following two properties are mandatory with &lt;/span&gt;&lt;/li&gt; &lt;li&gt;         &lt;span style="color:#008000;"&gt;Wintellect.TFSBuildNumber.targets&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TFSMajorBuildNumber&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;5&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TFSMajorBuildNumber&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TFSMinorBuildNumber&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;0&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;TFSMinorBuildNumber&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000;"&gt; Assume the shared directory but allow it to be changed before &lt;/span&gt;&lt;/li&gt; &lt;li&gt;       &lt;span style="color:#008000;"&gt;before including this file. &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Condition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt; &amp;#39;$(SharedVersionOutputDirectory)&amp;#39; == &amp;#39;&amp;#39; &lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;SharedVersionOutputDirectory&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;..&amp;#92;Shared&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;SharedVersionOutputDirectory&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000;"&gt; Include the targets that create the version number files. &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Import&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;Wintellect.TFSBuildNumber.targets&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000;"&gt; C# and VB projects are easy, I&amp;#39;ll just jam in the file creation on the included&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;      &lt;span style="color:#008000;"&gt;BeforeBuild which will get everything hooked up perfectly. &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;BeforeBuild&lt;/span&gt;&amp;quot;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;        &lt;span style="color:#0000ff;"&gt;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;DependsOnTargets&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;WriteSharedTextAssemblyVersionFile; &lt;/span&gt;&lt;/li&gt; &lt;li&gt;                          &lt;span style="color:#0000ff;"&gt;WriteSharedCSharpAssemblyVersionFile; &lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                          &lt;span style="color:#0000ff;"&gt;WriteSharedCPPAssemblyVersionFile; &lt;/span&gt;&lt;/li&gt; &lt;li&gt;                          &lt;span style="color:#0000ff;"&gt;WriteSharedWiXAssemblyVersionFile;&lt;/span&gt;&amp;quot;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;          &lt;span style="color:#0000ff;"&gt;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Condition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;(&amp;#39;$(MSBuildProjectExtension)&amp;#39; == &amp;#39;.csproj&amp;#39;) Or (&amp;#39;$(MSBuildProjectExtension)&amp;#39; == &amp;#39;.vbproj&amp;#39;)&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000;"&gt; Only use the named target if it&amp;#39;s a C++ build, otherwise you get an MSBuild &lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;       &lt;span style="color:#008000;"&gt;warning MSB4057 about an non existant target. &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Condition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt; &amp;#39;$(MSBuildProjectExtension)&amp;#39; == &amp;#39;.vcxproj&amp;#39; &lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;    &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;CppResourceCompile&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;ResourceCompile&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;CppResourceCompile&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;PropertyGroup&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;  &lt;span style="color:#0000ff;"&gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;!--&lt;/span&gt;&lt;span style="color:#008000;"&gt; For C++ projects, jam in the file creation before doing the Resource Compiler&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;       &lt;span style="color:#008000;"&gt;build. &lt;/span&gt;&lt;span style="color:#0000ff;"&gt;--&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Condition&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt; &amp;#39;$(MSBuildProjectExtension)&amp;#39; == &amp;#39;.vcxproj&amp;#39; &lt;/span&gt;&amp;quot;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;          &lt;span style="color:#0000ff;"&gt;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;BuildVersionFiles&lt;/span&gt;&amp;quot;&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#0000ff;"&gt;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;BeforeTargets&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;$(CppResourceCompile)&lt;/span&gt;&amp;quot;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;          &lt;span style="color:#0000ff;"&gt;&lt;/span&gt;&lt;span style="color:#ff0000;"&gt;DependsOnTargets&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;WriteSharedTextAssemblyVersionFile; &lt;/span&gt;&lt;/li&gt; &lt;li&gt;                            &lt;span style="color:#0000ff;"&gt;WriteSharedCSharpAssemblyVersionFile; &lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;                            &lt;span style="color:#0000ff;"&gt;WriteSharedCPPAssemblyVersionFile; &lt;/span&gt;&lt;/li&gt; &lt;li&gt;                            &lt;span style="color:#0000ff;"&gt;WriteSharedWiXAssemblyVersionFile;&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;  &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Target&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Once everything is isolated into your VersionNumber.Targets file, you can include it with the following line in your .CSPROJ or .VCXPROJ file.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:bc6d0da9-a127-49e2-a1ed-46d53ecbeb5d" class="wlWriterEditableSmartContent"&gt; &lt;div style="border:#000080 1px solid;color:#000;font-family:'Courier New', Courier, Monospace;font-size:10pt;"&gt; &lt;div style="background:#000080;color:#fff;font-family:Verdana, Tahoma, Arial, sans-serif;font-weight:bold;padding:2px 5px;"&gt;Import Example&lt;/div&gt; &lt;div style="background:#fff;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Import&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;$(MSBuildToolsPath)&amp;#92;Microsoft.CSharp.targets&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt; /&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li style="background:#f3f3f3;"&gt;&lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#a31515;"&gt;Import&lt;/span&gt;&lt;span style="color:#0000ff;"&gt; &lt;/span&gt;&lt;span style="color:#ff0000;"&gt;Project&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;..&amp;#92;Build&amp;#92;VersionNumbers.Targets&lt;/span&gt;&amp;quot;&lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20188" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/MSBuild/default.aspx">MSBuild</category><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/TFS/default.aspx">TFS</category></item><item><title>TFS 2010 Build Numbers &amp; File Versions from Inside Your C# and C++ Projects</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/09/05/tfs-2010-build-numbers-file-versions-from-inside-your-c-and-c-projects.aspx</link><pubDate>Tue, 06 Sep 2011 00:14:00 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20169</guid><dc:creator>jrobbins</dc:creator><slash:comments>2</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20169.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20169</wfw:commentRss><description>&lt;P&gt;A while ago, I &lt;A href="http://www.wintellect.com/cs/blogs/jrobbins/archive/2009/11/09/tfs-2010-build-number-and-assembly-file-versions-completely-in-sync-with-only-msbuild-4-0.aspx"&gt;showed&lt;/A&gt; using MSBuild 4.0 to create build version files with the TFS build number so that build number could be included in your binaries. While you can use Jim Lamb's excellent &lt;A href="http://blogs.msdn.com/b/jimlamb/archive/2010/02/12/how-to-create-a-custom-workflow-activity-for-tfs-build-2010.aspx"&gt;custom workflow activity&lt;/A&gt;, I liked doing the version numbers with MSBuild because you could have the same build for both the build server as well as the developer desktop. &lt;/P&gt;
&lt;P&gt;Working with a client, they like my approach, but didn't care for the fact you had to initially create the assembly version files with a command line build. Additionally, there was good security and process on TFS build servers so adding the custom workflow activity was going to take a while to get installed. They asked me to get my pure MSBuild approach working inside Visual Studio projects so they could get the benefit of the build numbers, but not change how anyone builds the code on their development box. The client was kind enough to let me blog this so everyone could benefit. That and they wanted documentation on how I got it working. &amp;lt;grin!&amp;gt; &lt;/P&gt;
&lt;P&gt;For the rest of this article, I'm assuming you've read my &lt;A href="http://www.wintellect.com/cs/blogs/jrobbins/archive/2009/11/09/tfs-2010-build-number-and-assembly-file-versions-completely-in-sync-with-only-msbuild-4-0.aspx"&gt;original blog entry&lt;/A&gt; on Wintellect.TFSBuildNumber.targets. I've put everything I discuss into a &lt;A href="http://www.wintellect.com/CS/files/folders/20166/download.aspx"&gt;sample&lt;/A&gt; project that shows how to set this up for both C#/VB projects as well as for native C++ projects. You may want to grab the &lt;A href="http://www.wintellect.com/CS/files/folders/20166/download.aspx"&gt;sample&lt;/A&gt; and look through it as you read along. &lt;/P&gt;
&lt;P&gt;The job of Wintellect.TFSBuildNumbers.targets is to create files with build number information into them. You'll include those created files into your projects in order to get the version information, be it an AssemblyFileVersion attribute or a VERSIONINFO structure. Because the files that contain the version information should never be checked in, you need to create those files first thing or your build will fail. That means you'll need to do the steps I outline below in the first .CSPROJ/.VCSPROJ file built as part of your solution. Ideally, you'll only have to update a single project that every other binary depends on as described below to create the version files for your whole application. However, if you have various solutions and you don't know the order they will be built, it won't hurt to add these steps to all your projects as Wintellect.TFSBuildNumbers.targets only creates the build version files if they do not exist. &lt;/P&gt;
&lt;P&gt;If you've got a C# .CSPROJ file as the first thing built, it's quite easy to integrate the version file creation code. To edit the .CSPROJ file by hand, click the File, Open, File, menu in Visual Studio. &lt;/P&gt;
&lt;P&gt;In the PropertyGroup element that has no conditions on it, generally the first one after the Project element. You'll add the TFSMajorBuildNumber and TFSMinorBuildNumber elements with the appropriate values. By default Wintellect.TFSBuildNumbers.targets creates the shared files in the local directory so you should probably also set the SharedVersionOutputDirectory element to a common location. The following shows the first part of the .\BuildNumbers\VerFiles\VerFiles.CSPROJ file included with the sample. &lt;/P&gt;
&lt;P style="LINE-HEIGHT:13pt;BACKGROUND-COLOR:#c6d9f1;MARGIN:0in 0in 0pt;" class=Code&gt;&lt;FONT style="FONT-SIZE:11pt;" color=#000000 face="Courier New"&gt;&lt;SPAN class=code&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;lt;Project ToolsVersion="4.0" DefaultTargets="Build" &lt;BR&gt;&amp;nbsp;&amp;nbsp; xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; &amp;lt;PropertyGroup&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Configuration Condition=" '$(Configuration)' == '' "&amp;gt;Debug&amp;lt;/Configuration&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Platform Condition=" '$(Platform)' == '' "&amp;gt;x86&amp;lt;/Platform&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ProductVersion&amp;gt;8.0.30703&amp;lt;/ProductVersion&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SchemaVersion&amp;gt;2.0&amp;lt;/SchemaVersion&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;ProjectGuid&amp;gt;{826C2BC7-70D3-4FE0-B4D8-0E1DE36E6D2E}&amp;lt;/ProjectGuid&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;OutputType&amp;gt;Exe&amp;lt;/OutputType&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AppDesignerFolder&amp;gt;Properties&amp;lt;/AppDesignerFolder&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;RootNamespace&amp;gt;VerFiles&amp;lt;/RootNamespace&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;AssemblyName&amp;gt;VerFiles&amp;lt;/AssemblyName&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TargetFrameworkVersion&amp;gt;v4.0&amp;lt;/TargetFrameworkVersion&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TargetFrameworkProfile&amp;gt;Client&amp;lt;/TargetFrameworkProfile&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;FileAlignment&amp;gt;512&amp;lt;/FileAlignment&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- The following two properties are mandatory with &lt;/EM&gt;&lt;/SPAN&gt;&lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Wintellect.TFSBuildNumber.targets--&amp;gt;&lt;/EM&gt;&lt;/SPAN&gt;&lt;EM&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TFSMajorBuildNumber&amp;gt;22&amp;lt;/TFSMajorBuildNumber&amp;gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;EM&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;TFSMinorBuildNumber&amp;gt;33&amp;lt;/TFSMinorBuildNumber&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- The following property is optional with &lt;/SPAN&gt;&lt;/EM&gt;&lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&lt;EM&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Wintellect.TFSBuildNumber.targets but you probably&lt;/EM&gt;&lt;/SPAN&gt;&lt;EM&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; should always set it.--&amp;gt;&lt;/SPAN&gt;&lt;/EM&gt;&lt;EM&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;SharedVersionOutputDirectory&amp;gt;..\Shared&amp;lt;/SharedVersionOutputDirectory&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;/EM&gt;&lt;SPAN class=code&gt;&amp;nbsp; &amp;lt;/PropertyGroup&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;. . . Rest of file here . . . &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;With the properties out of the way, you'll scroll to the bottom of the .CSPROJ file where you will import the Wintellect.TFSBuildNumber.targets file with an Import element. C# projects have a nice target, BeforeBuild which is a target the build system will call before doing the actual build. You will need to add that target at the bottom of the file and use the DependsOnTargets to specify the various files you want to Wintellect.TFSBuildNumbers.targets to create. &lt;/P&gt;
&lt;P&gt;Here the example of setting up the import and BeforeBuild target. &lt;/P&gt;
&lt;P style="LINE-HEIGHT:13pt;BACKGROUND-COLOR:#c6d9f1;MARGIN:0in 0in 0pt;" class=Code&gt;&lt;FONT style="FONT-SIZE:11pt;" color=#000000 face="Courier New"&gt;&lt;SPAN class=code&gt;&amp;nbsp; &amp;lt;Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=code&gt;&amp;nbsp; &amp;lt;!-- Include the targets that create the version number files. --&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;EM&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &amp;lt;Import Project="..\Targets\Wintellect.TFSBuildNumber.targets" /&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &amp;lt;!-- Define the BeforeBuild target, which is normally commented out, &lt;/SPAN&gt;&lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; to depend on the particular version files I need created. --&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &amp;lt;Target Name="BeforeBuild" &lt;/SPAN&gt;&lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DependsOnTargets="WriteSharedTextAssemblyVersionFile;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteSharedCSharpAssemblyVersionFile;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteSharedCPPAssemblyVersionFile;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteSharedWiXAssemblyVersionFile;"&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &amp;lt;/Target&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;/EM&gt;&lt;SPAN class=code&gt;&amp;nbsp; &amp;lt;!-- To modify your build process, add your task inside one of the targets below &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and uncomment it. &lt;/SPAN&gt;&lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Other similar extension points exist, see Microsoft.Common.targets.&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; &amp;lt;Target Name="AfterBuild"&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; &amp;lt;/Target&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; --&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;lt;/Project&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;If you open the .\BuildNumbers\VerFiles\VerFiles.SLN and build it, you'll see four new files in the .\BuildNumbers\Shared directory. You'll also notice the project has a reference to the.\Shared\SharedAssemblyFileVersion.cs that was as a linked file. As a final reminder, because you'll be including the AssemblyFileVersion from Wintellect.TFSBuildNumber.targets, you'll need to manually remove any existing AssemblyFileVersion attributes in your projects. &lt;/P&gt;
&lt;P&gt;Incorporating Wintellect.TFSBuildNumber.targets into a C++ project is similar to what you'll do for a C# project, but there's a little more fiddling going on. C++ is supposed to be harder than C#, so that's normal for the course. You can see a full example of setting up a C++ project in the .\BuildNumbers\CPPVerFiles directory in the sample download. The first step is to edit the .VCXPROJ file by hand to add the required properties with your major and minor versions. Look for the PropertyGroup element with the Label attribute set to Globals. Here's an example of setting up the properties. &lt;/P&gt;
&lt;P style="LINE-HEIGHT:13pt;BACKGROUND-COLOR:#c6d9f1;MARGIN:0in 0in 0pt;" class=Code&gt;&lt;FONT style="FONT-SIZE:11pt;" color=#000000 face="Courier New"&gt;&lt;SPAN class=code&gt;&amp;nbsp; &amp;lt;PropertyGroup Label="Globals"&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;SPAN class=code&gt;ProjectGuid&amp;gt;{B1CCCB99-E2C5-42BA-9680-8E9511CE81C7}&amp;lt;/ProjectGuid&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;SPAN class=code&gt;RootNamespace&amp;gt;CPPVerFiles&amp;lt;/RootNamespace&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Keyword&amp;gt;MFCProj&amp;lt;/Keyword&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;BR class=boldcode&gt;&lt;EM&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- The following two properties are needed by &lt;/SPAN&gt;&lt;BR class=code&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Wintellect.TFSBuildNumber.targets--&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;SPAN class=boldcode&gt;TFSMajorBuildNumber&amp;gt;22&amp;lt;/TFSMajorBuildNumber&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;SPAN class=boldcode&gt;TFSMinorBuildNumber&amp;gt;33&amp;lt;/TFSMinorBuildNumber&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;!-- The following property writes the shared files to&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A different directory.—&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &lt;/SPAN&gt;&amp;lt;&lt;SPAN class=boldcode&gt;SharedVersionOutputDirectory&amp;gt;..\Shared&amp;lt;/SharedVersionOutputDirectory&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;/EM&gt;&lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;lt;/PropertyGroup&amp;gt;&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;At the bottom of your .VCXPROJ file, you'll need to import Wintellect.TFSBuildNumber.targets and hook the build number file creation into the build. As .VCXPROJ files do not have a predefined BeforeBuild target, it took me a little bit of trial and error to find where the best place to get my build number targets injected into the normal build flow. Fortunately, MSBuild 4.0 offers the &lt;A href="http://blogs.msdn.com/b/msbuild/archive/2010/02/18/build-extensibility-with-net-framework-4.aspx"&gt;BeforeTargets attribute&lt;/A&gt; on a target. As the build number files need to be created before the resource compiler runs, I chose to set the BeforeTargets to ResourceCompile. Here's the snippet that shows you what I'm talking about. &lt;/P&gt;
&lt;P style="LINE-HEIGHT:13pt;BACKGROUND-COLOR:#c6d9f1;MARGIN:0in 0in 0pt;" class=Code&gt;&lt;FONT style="FONT-SIZE:11pt;" color=#000000 face="Courier New"&gt;&lt;EM&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &amp;lt;!-- Include the targets that create the version number files. --&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &amp;lt;Import Project="..\Targets\Wintellect.TFSBuildNumber.targets" /&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &amp;lt;!-- Here's the trick to ensure the version files get built before &lt;/SPAN&gt;&lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; they are needed by the resource compiler. --&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &amp;lt;Target Name="BuildVersionFiles"&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BeforeTargets="ResourceCompile"&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DependsOnTargets="WriteSharedTextAssemblyVersionFile;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteSharedCSharpAssemblyVersionFile;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteSharedCPPAssemblyVersionFile;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WriteSharedWiXAssemblyVersionFile;"&amp;gt;&lt;/SPAN&gt; &lt;BR class=boldcode&gt;&lt;SPAN class=boldcode&gt;&amp;nbsp; &amp;lt;/Target&amp;gt;&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;/EM&gt;&lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;lt;/Project&amp;gt; &lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;The above steps in the .VCXPROJ file take care of properly creating the files, but we need to get the version number into the binary. Because C++ code needs a VERSIONINFO structure in the resources file, you'll have to include a common one to pick up the build numbers. What I chose to do was have a common .RC file that's included in each of your project's .RC. Below is the .\CommonResources\CommonResources.RC you'll find in the sample. &lt;/P&gt;
&lt;P style="LINE-HEIGHT:13pt;BACKGROUND-COLOR:#c6d9f1;MARGIN:0in 0in 0pt;" class=Code&gt;&lt;FONT style="FONT-SIZE:11pt;" color=#000000 face="Courier New"&gt;&lt;SPAN class=code&gt;#ifndef APSTUDIO_INVOKED&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;BR class=code&gt;&lt;SPAN class=code&gt;#include "..\Shared\SharedAssemblyFileVersion.h"&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;BR class=code&gt;&lt;SPAN class=code&gt;VS_VERSION_INFO VERSIONINFO&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; FILEVERSION rcMajor,rcMinor,rcBuild,rcRevision&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; PRODUCTVERSION rcMajor,rcMinor,rcBuild,rcRevision&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; FILEFLAGSMASK 0x3fL&lt;/SPAN&gt; &lt;BR class=code&gt;#&lt;SPAN class=code&gt;ifdef _DEBUG&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; FILEFLAGS 0x1L&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;#else&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; FILEFLAGS 0x0L&lt;/SPAN&gt; &lt;BR class=code&gt;#&lt;SPAN class=code&gt;endif&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; FILEOS 0x4L&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; FILETYPE 0x2L&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; FILESUBTYPE 0x0L&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;BEGIN&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; BLOCK "StringFileInfo"&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; BEGIN&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BLOCK "040904e4"&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE "Comment", "De Oppresso Liber"&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE "CompanyName", "Wintellect"&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE "FileDescription", "Example of the common version resource file!"&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE "FileVersion", szMajorMinorBuildRevision&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE "InternalName", "SOMENAME"&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE "LegalCopyright", "Copyright (c) 2011 by Wintellect"&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE "ProductVersion", szMajorMinorBuildRevision&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; END&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; BLOCK "VarFileInfo"&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; BEGIN&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; VALUE "Translation", 0x409, 1252&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;&amp;nbsp; END&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;SPAN class=code&gt;END&lt;/SPAN&gt; &lt;BR class=code&gt;&lt;BR class=code&gt;&lt;SPAN class=code&gt;#&lt;/SPAN&gt;&lt;SPAN class=code&gt;endif&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;To get this file into your project's .RC file, you'll edit it by hand in simply use #include to include the common file.&lt;/P&gt;
&lt;P&gt;There are two key points I need to mention about getting a common resource file working. The first drove me nuts, but you want to include an actual resource, the including file must end with .RC. If you put it in a .H, the resource compiler silently ignores the contents of the file except for #define values. The second point was that I wanted to ensure that there was no way to edit the VERSIONFINO block in the Visual Studio Resource Editor. If that's allowed, the Resource Editor replaces all defines in the resource file with the current values of the build numbers. To avoid that problem, I wrap the common VERSIONINFO in #ifndef APPSTUDIO_INVOKE…#endif. The APPSTUDIO_INVOKE is the special define used to determine if the file is being edited by the Resource Editor. The old folks reading this will recall that the Resource Editor used to be called App Studio many years ago. &lt;/P&gt;
&lt;P&gt;Some of you sharp readers might be wondering how you add non-shared data to the VERSIONINFO such as "OriginalFilename" and others as you can only have one VERSIONINFO structure per binary. If that private data is a required for your environment, add a new VALUE for it and before including the common resources, ensure you declare that define. Alternatively, you could use a VERSIONINFO editing tool like the &lt;A href="http://www.codeproject.com/KB/install/VerPatch.aspx"&gt;Simple Version Resource Tool for Windows&lt;/A&gt; by ddbug as part of your build to add that information. &lt;/P&gt;
&lt;P&gt;Based on the comments to my original article, this was a popular request, but I just never got around to doing it because I'm a command line guy and it wasn't a priority. Thanks to our client for pushing me to get build number creation working in projects and allowing me to share the result with everyone. Now there's no excuse for anyone to not have the build number show up when you look at a binary's properties.&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20169" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/MSBuild/default.aspx">MSBuild</category><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/TFS/default.aspx">TFS</category></item><item><title>Windows 7 Hang with FireWire 800 Drive Fix</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/08/29/windows-7-hang-with-firewire-800-drive-fix.aspx</link><pubDate>Mon, 29 Aug 2011 06:42:15 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20148</guid><dc:creator>jrobbins</dc:creator><slash:comments>1</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20148.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20148</wfw:commentRss><description>&lt;p&gt;Recently I bought a smoking fast &lt;a href="http://eshop.macsales.com/item/Other%20World%20Computing/MS8USSD115/"&gt;external SSD enclosures&lt;/a&gt; from Other World Computing. My plan was to use the FireWire 800 connection to the drive so I can get the best portable speed possible. Alas, on all my machines as soon as I tried to do anything on the drive, Windows 7 hangs completely. That’s not good nor was the option of using that pokey USB 2 connection as that wouldn’t take advantage of the SSD drive.&lt;/p&gt;  &lt;p&gt;Before I sent the drive back, I did some hard web searching and found I was not alone in people complaining about the Windows 7 FireWire drivers. Many people reported hangs, but none seemed to have a solution. Fortunately, John Zhu came to the rescue on the &lt;a href="http://social.technet.microsoft.com/Forums/en/w7itprohardware/thread/65cb7a25-2a84-4875-aa27-b084537e8da1"&gt;Tech Net Forums&lt;/a&gt;. Microsoft rewrote the IEEE 1394 (FireWire) driver for Windows 7 and let’s just say it doesn’t seem to work that well.&lt;/p&gt;  &lt;p&gt;John pointed out that you could go into the Device Manager and change the driver to the 1394 Legacy driver. That’s worked great for me! It’s great to see those &lt;a href="http://www.barefeats.com/usb2.html"&gt;much faster speeds&lt;/a&gt; than USB 2. See John’s &lt;a href="http://social.technet.microsoft.com/Forums/en/w7itprohardware/thread/65cb7a25-2a84-4875-aa27-b084537e8da1"&gt;discussion&lt;/a&gt; for the exact steps to change the driver.&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20148" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Bugs/default.aspx">Bugs</category><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Hacks/default.aspx">Hacks</category></item><item><title>Who’s Got Their Hands on My .NET Objects?</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/07/07/who-s-got-their-hands-on-my-net-objects.aspx</link><pubDate>Thu, 07 Jul 2011 19:47:55 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20021</guid><dc:creator>jrobbins</dc:creator><slash:comments>3</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20021.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20021</wfw:commentRss><description>&lt;p&gt;Everything in .NET revolves around memory. As in who in the heck is holding on to all my objects so memory usage just keeps going up and up and up. In conjunction with the Linked In .NET Users Group, on Friday, July 22, 2011 at 10:00 AM Pacific/1 PM Eastern, I'll be doing a demo only session on how to see the different ways of looking at your memory references. You'll see everything from WinDBG and SOS, to interesting commercial tools that show you the complete graph. The session is free and all you need to do is sign up &lt;a href="http://lidnug-robbins.eventbrite.com/"&gt;here&lt;/a&gt;. If you're on Linked In, consider joining the &lt;a href="http://www.linkedin.com/groups?gid=43315"&gt;Linked In .NET User Group&lt;/a&gt; as well.
&lt;/p&gt;&lt;p&gt;If you like what I present, you can get much more at our upcoming &lt;a href="http://www.wintellect.com/Devscovery/Austin2011"&gt;Devscovery Austin&lt;/a&gt; event on October 18&lt;sup&gt;th&lt;/sup&gt;-20&lt;sup&gt;th&lt;/sup&gt;.&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20021" width="1" height="1"&gt;</description></item><item><title>DRONE Profiler: The New Old Profiler</title><link>http://www.wintellect.com/CS/blogs/jrobbins/archive/2011/06/29/drone-profiler-the-new-old-profiler.aspx</link><pubDate>Wed, 29 Jun 2011 16:29:30 GMT</pubDate><guid isPermaLink="false">c9b5046a-91b6-4822-a57a-d848b8cb6435:20000</guid><dc:creator>jrobbins</dc:creator><slash:comments>2</slash:comments><comments>http://www.wintellect.com/CS/blogs/jrobbins/comments/20000.aspx</comments><wfw:commentRss>http://www.wintellect.com/CS/blogs/jrobbins/commentrss.aspx?PostID=20000</wfw:commentRss><description>&lt;p&gt;Deep down inside every developer really wants to create developer tools. Let’s be honest, how many of you are really excited to the tips of your toes about that Line of Business application you’re working on? It pays the bills but working on a project where you completely understand the target audience and all use cases really is a heck of a lot of fun! &lt;/p&gt;  &lt;p&gt;As most developer tools are written as side work, it’s rare that on makes it to a level where they get used by anyone other than the developer themselves. The XteProfiler was one of those tools many are using. The developer,&amp;#160; Søren Skov Christensen, helped a lot of people find memory problems in their .NET application and he had a lot of fun developing XteProfiler. After a while of working on a tool, you reach a crossroads. You have a ton of ideas you want to put in the tool, but to do that you’ll have to quit your job. That’s where most tools stop and languish to everyone’s frustration and laments of “what could have been…”&lt;/p&gt;  &lt;p&gt;Søren didn’t stop! He took the scary plunge and made the decision to go commercial with the new &lt;a href="http://www.droneprofiler.com/index.aspx"&gt;DRONE Profiler&lt;/a&gt;. He’s added a ton of fantastic features and DRONE is a complete package for your memory profiling needs. It’s also super exciting to see a developer follow their passion and take the risk to going out on their own. I highly encourage you to check out the new DRONE Profiler.&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Disclosure: Even though Søren kindly gave me a license, I purchased my own license. DRONE Profiler is a damn good tool!&lt;/em&gt;&lt;/p&gt;&lt;img src="http://www.wintellect.com/CS/aggbug.aspx?PostID=20000" width="1" height="1"&gt;</description><category domain="http://www.wintellect.com/CS/blogs/jrobbins/archive/tags/Recommended/default.aspx">Recommended</category></item></channel></rss>
