Loren Halvorson's Blog

If your only tool is a hammer...
MSBuild trick for making <Exec> calls more maintainable

One of my pet peeves with MSBuild’s <Exec> task is how long the lines get when you have lots of arguments.

I ran across a trick yesterday in a blog comment made by someone named Romain and thought it was a very nice solution to this problem. When you expand items using this form @(items, ‘DELIMITER’), it allows you to specify a delimiter to use between the items. In the case of a command line, you use a space. Thanks Romain.

<ItemGroup>
  <XmlPreprocessArgs Include="/nologo"/>
  <XmlPreprocessArgs Include="/v"/>
  <XmlPreprocessArgs Include="/x:&quot;$(InstallDir)\Environments\$(ApplicationName).EnvironmentSettings.xml&quot;"/>
  <XmlPreprocessArgs Include="/i:&quot;$(InstallDir)\UI.Shell.exe.config%3B$(InstallDir)\ClientLogging.config&quot;"/>
  <XmlPreprocessArgs Include="/e:&quot;$(Environment)&quot;"/>
</ItemGroup>

<Exec Command="&quot;$(InstallDir)\Environments\XmlPreprocess.exe&quot; @(XmlPreprocessArgs,' ')"
      WorkingDirectory="$(InstallDir)\Environments" />

Posted: Dec 11 2008, 01:52 PM by lorenh | with 6 comment(s)
Filed under: ,
Comparing XML Files with Beyond Compare 3...Brilliant

I bought a new laptop and was loading it with the tools I use every day. When it came to installing one of my favorites, Beyond Compare 2, I thought I'd check the Scooter web site to see if I had the latest version. I was happy to see they now had a version 3 with plenty of new features. I immediately reached for my credit card to buy a license. Folks, this is honestly one of the tools I don't even hesitate paying for...it's that good, and that invaluable. I don't work for them, I'm just a very happy customer.

The base tool itself is great, but I was really thrilled when I followed the link on the Download page to Additional file format downloads for version 3.  There I found something I've been looking for years...and in fact a while ago had written a plug-in for BC2 to do...the ability to compare Tidied XML.

How many times have you tried to compare two dense XML files to find out their differences only to be faced with a block of differences that looks like this:

Beyond Compare notices that there are differences in there somewhere, but can't really show you where with any precision. Further inspection is going to be needed, and forget merging selected changes over from one side to the other.

If you install the XML Tidied and XML tidied with attributes sorted file formats, you can now tell Beyond Compare to tidy up your documents, putting each attribute on its own line, so the differences stand out. You can now see exactly which attributes differ. Absolutely brilliant.

This is a fantastic feature that's already saved me a bunch of time. I see there is a similar add-in for HTML tidied files that also will come in handy.

A couple of other features in Beyond Compare that I've come to rely on over the years:

  • Beyond Compare has great "low-friction" integration with Windows Explorer. For example to compare two files, you just right click on one file and choose "Select Left Side For Compare", then right click on the other file and say "Compare to {file...}".  This works for folders too.
  • Beyond Compare has great FTP integration. I use it to deploy changed files to FTP sites very painlessly.

I also see it supports doing 3-way merging from most version control systems. I haven't tried this yet, but I'm going to see how hard it is to plug into TFS.  If anyone has pointers on how to set this up, let me know.

 Update: Scooter's website shows how to set it up here

They have a 30 day trial, so if you aren't so sure, you can give it a try for a while. Highly recommended.

New Release of XmlPreprocess

I finally got around to updating the XmlPreprocess tool with some changes I'm really excited about. For those of you not familiar with XmlPreprocess, it's a command line tool I wrote many years ago that can modify specially annotated XML files much like a code preprocessor. It is useful for deploying XML configuration files to many environments. I've blogged about it in the past as have others, and it's achieved a fair amount of use (albeit hidden below the surface) in my good friend Scott Colestock's Biztalk deployment framework.

The first thing I did was move it to a CodePlex project which replaces the prior SourceForge project.

Changes in this release

  • New Codeplex home with updated documentation and samples.
  • Requires .NET 2.0 or newer runtime.
  • Adds the ability to import spreadsheets directly thanks to Tom Abraham's excellent work on the Environment Settings Manager project. This is a really nice feature, and I thank Tom for giving me permission to use his spreadsheet reading code.
  • Adds a command line switch (/f or /fixfalse) to fix the behavior of "False" values. This has been a long-standing request and tripped up many people for example here and here.  For the anguish and consternation this has caused to you all, I sincerely apologize, and hope you forgive me. If you want to explicitly undefine a property, use the value "#undef" instead.  (Note: that for backward compatibility, this behavior is off by default, and you will need to add the /f or /fixfalse switch to enable it).
  • Adds a new command line switch (/v) to validate tokens, so if any replacement tokens are missing, it will report an error message identifying the missing tokens, return a nonzero error code and not write out the file.

I left the current release as Beta 1 in case anyone finds any issues right away, but we've been using the new version on a project without any issues yet.  It should be a drop-in backward compatible replacement for the old version (except for the new dependency on .NET 2.0 instead of 1.1).

Introducing Birch Cove Software

A few days into a 3 week vacation with my family I received a call that I wasn't surprised to receive. The company where I had worked for 6 years was downsizing and my position, along with many others in our department, was eliminated. Since downsizing (or worse) was happening across the entire sector, I didn't take it personally. In fact, I took it as a sign that I should try something different. A friend recently said that "getting laid off is one of the best thing that ever happened to him", and I hope to look back and say the same some day.

So I am officially hanging out my shingle and becoming an independent contractor. I've worked as a full time employee for the entirety of my 18 years in the industry, so working for myself is going to be something completely new. So here begins a new chapter in my life: Birch Cove Software, LLC. Wish me luck, and let me know if you have any tips or resources for getting a consulting business off the ground.

Red Gate will take over development of Lutz Roeder's .NET Reflector

I just received a newsletter from Red Gate, and nestled in the headlines was this interesting tidbit. If you haven't heard of .NET Reflector, it's one of my favorites, and I encourage you to check this invaluable tool out. It's what you reach for when you have to know what's going on inside that assembly but don't have the source.

Here's the announcement on Red Gate's site: http://www.simple-talk.com/opinion/opinion-pieces/the-future-of-reflector-/

James Moore who is the general manager of .NET Developer Tools at Red Gate states:

“I think we can provide a level of resources that will move the tool forward in a big way.  The first thing we are doing is continuing to offer the software to the community for free downloading.  The second thing is giving our product management and usability teams the task of going out into the community to get suggestions on how we can make this amazing tool even better."

I'm hopeful that Red Gate won't mess anything up. I've been using their ANTS profiler for years, and more recently discovered their wonderful SQL tools, and they are all excellent. For now they've promised to continue to give it away for free, but you know there will need to be some way to make money coming.

Subversion 1.5.1 Windows install is available

I've been working on a presentation for our next User Group meeting on Continuous Integration, and wanted to set up a local Subversion server.  Of course I wanted to use the latest and greatest versions of everything. So I've been checking back daily for the appearance of the installer for Subversion 1.5.1 for Windows.  Setup-Subversion-1.5.1.en-us.msi showed up on August 15, 2008.

You can find it on the Subversion download site  When you couple this with the latest TortoiseSVN you are cookin' with gas!

I found this CoDe Magazine article by Rick Strahl very helpful for setting things up initially. Setting Up and Running Subversion and Tortoise SVN with Visual Studio and .NET

Automatic Properties Work in .NET 2.0

This was sort of an accidental discovery, I'm not the first to stumble on it, but it doesn't seem to be widely known. A colleague of mine asked me about an interesting behavior he noticed after switching to Visual Studio 2008.  He was still targeting the .NET 2.0 framework, but noticed the automatic property feature worked.

Automatic properties are where you can just say

public string SomeProperty { get; set; }

The compiler provides the backing field and implements the get and set for you. It's a very nice shorthand syntax for a common pattern. We were all under the impression that it was a new C# 3.0 language feature and could only be used if you targeted version 3.5 of the .NET Framework. After searching around for why it was still working on a .NET 2.0 app, I found many who verified what we were seeing. Indeed it does work, because it's a compiler feature, and 2008 uses the latest compiler even if you are targeting 2.0. Cool.

IE 7 and Firefox browsing tip...open links in new tab by clicking your mouse scroll wheel

This is widely known, but I still run across people who use IE 7, and/or Firefox but don't use this little trick. On most mice, the scroll wheel is a button as well as a wheel. Click on links using the scroll wheel, and the browser will open that page in a new tab in the background without taking focus away from the current page.

I find this extremely handy when browsing results from a search engine. As you visually scan through the search results, click the links that look promising using the scroll wheel. The browser will set to work to load those pages in the background as you continue to scan.  After you've got a good batch of pages loaded in your tabs, you can skip through the tabs quickly.

Posted: May 23 2008, 11:58 AM by lorenh | with 10 comment(s)
Filed under:
We're starting a .NET user group in south-central Minnesota

We are starting a .NET user group in Mankato, which is in south-central Minnesota. Hopefully we can attract developers in the area that (like me) sometimes find it hard to make the 1-1/2 hour drive to the nearest .NET user group in Minneapolis. They're doing a great job up there in the Twin Cities, and I'll still try to make it to some of their meetings, but I just have a feeling there is a community of developers here that don't get much of a chance to hang out with geeks and talk shop.

So we have set up a web site, and set the date and time for our kickoff meeting.

Mankato .NET User Group Kickoff Meeting

When: Tuesday, June 10, 7:00 - 9:00

Where: Bethany College, 700 Luther Dr, Mankato, Minnesota We'll be meeting in Meyer Hall room 130. If you park in the Meyer Hall lot, room 130 is the first door on the right when entering from the lower level entrance. Map can be found here, http://www.blc.edu/facilities/map/.

Agenda:

  • Introductions
  • Discuss regular meeting times & format
  • Discuss how to spread the word
  • Brainstorm topics and presenters
  • Presentation on new features in Visual Studio 2008 that make it a compelling upgrade

Web site: http://www.mankatodotnet.com

If you are a developer in south-central Minnesota, consider joining us. If you know a developer in our area, we'd much appreciate if you pass this on to them.

Posted: May 22 2008, 09:23 AM by lorenh | with 3 comment(s)
Filed under:
Evoluent Vertical Mouse now available in wireless model

I've praised this mouse before, but just discovered that the wireless model of the Evoluent Vertical Mouse is now available. I have the wired version, and it is without a doubt the most comfortable mouse I've ever used. I throw it in my bag and drag it back and forth between the office and home. (I wonder how long before the cord gets a short?).

The only modification I made was to physically disable the large bottom button closest to the desk by inserting a small rolled up piece of paper behind it because I kept hitting it inadvertently while just moving the mouse.

The wireless one would be nice if anyone wants to buy it for me, my birthday is coming up.  Anybody have one yet?  How does it work?  How is the battery life?

More Posts Next page »