July 28, 2005

Don Box Slept Here

July 27, 2005 spout

Limiting/Monitoring my sons’ access to the ’net?

My 11-year old wants to do email and IM and he’s already surfing the web. Does anyone have any recommendations for good software to limit and monitor his internet access? Thanks!

July 22, 2005 tools

Cool Avalon Default Style Trick

Karsten shows a cool trick for pulling out the default style of an Avalon lookless control. This is super useful if you want to replace an existing control's look, but you don't want to have to start from scratch.
July 20, 2005 fun

Have Sex With Prostitutes at the PDC

At least that's the message I'm getting from the 2nd episode of the Channel 9 guy’s trip across country to the PDC (I'm not saying that's a bad message -- it sure beats the whole "ActiveX" thing...).
July 17, 2005 fun

I don’t know who has time for this stuff @ work…

but it’s fun anyway…

[Scoble]

July 16, 2005 spout

My First MsBuild Task

I wrote my first custom msbuild task this morning. I used the the Extend the MSBuild with a New Task topic from the msbuild wiki and it worked well to get me started. I started with the simplest thing that used at least an input property:

// HelloTask.cs
using System;
using Microsoft.Build.Utilities; // reference assembly of same name
using Microsoft.Build.Framework; // ditto

namespace MyFirstTask {
  public class HelloTask : Task {
    string _who;

    [Required]
    public string Who {
      get { return _who; }
      set { _who = value; }
    }

    public override bool Execute() {
      Log.LogMessage(string.Format("hello, {0}!", _who));
      return true;
    }
  }
}

My task implements the msbuild ITask interface by deriving from the Task helper base class, which provides the Log object, among other things. The only thing I have to do is implement the Execute method, which needs to return true on success. To prove that my task is called, I use the Log object to log a message (I could also log an error or a warning). The public Who property is set from the use of the task in an msbuild file. By marking the property with the Required attribute, I ensure that msbuild itself makes sure that a Who is provided.

Once I’ve compiled my task, I can use it directly from a .proj (or .csproj or .vbproj) file:

<!-- fun.proj -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="HelloTarget">
    <HelloTask Who="Joe" />
  </Target>
  <UsingTask
    TaskName="MyFirstTask.HelloTask"
    AssemblyFile="C:\MyFirstTask\bin\Release\MyFirstTask.dll" />
</Project>

Notice the HelloTask element, which creates an instance of my HelloTask class and sets the Who property. The mapping between the HelloTask and the MyFirstTask.HelloTask class in the MyFirstTask.dll assembly is in the UsingTask element. Running msbuild against fun.proj yields the following output:

C:\taskfun>msbuild fun.proj
Microsoft (R) Build Engine Version 2.0.50215.44
[Microsoft .NET Framework, Version 2.0.50215.44]
Copyright (C) Microsoft Corporation 2005. All rights reserved.

Build started 7/16/2005 7:04:09 PM.
__________________________________________________
Project "C:\taskfun\fun.proj" (default targets):

Target HelloTarget:
hello, Joe!

Build succeeded.
0 Warning(s)
0 Error(s)

Time Elapsed 00:00:00.04

Notice the “hello, Joe!” output by the task as its Execute method is called. Notice also that while the task is in its folder, the .proj file can be anywhere, so long as it has a UsingTask that maps appropriately. By convention, the UsingTask elements are kept in .targets files and put into shared folders to be used between multiple project files, e.g. Microsoft.common.targets, etc. Refactoring the UsingTask out of the .proj file and into a .targets file looks like this:

<!-- My.Fun.targets -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <UsingTask
    TaskName="MyFirstTask.HelloTask"
    AssemblyFile="C:\MyFirstTask\bin\Release\MyFirstTask.dll" />
</Project>
<!-- fun.proj -->
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="HelloTarget">
    <HelloTask Who="Joe" />
  </Target>
  <Import Project="c:\My.Fun.targets" />
</Project>

Of course, a real task does far more than this one, but it was hella easy to get started.

July 12, 2005 .net

Amazing XAML Tool: Adobe Illustrator -> XAML

Mike Swanson has posted an amazing Adobe Illustrator to XAML conversion tool. You have to check out the eye candy page to really see what Mike's been able to accomplish; it's not perfect, but it's damn good.
July 12, 2005 tools

Eric Sink: The Game is Afoot

I don’t know if Eric understands the ISV industry or not, but certainly seems to. Luckily, I’m on a real product team now, so I get to try to channel Eric into my work.

Eric’s latest writing is The Game is Afoot, in which he describes various games and then draws lessons from them for ISVs. It’s fabulous. He concludes by apologizing for the length and then teasing us with the analogies he left off. It wasn’t too long, Eric! I wanted more! (I also want your blog to have comments, but that’s another thing entirely…)

I think now I understand the public outcry when I suggested that I might cut down on the material in the Windows Forms 2.0 book…


← Newer Entries Older Entries →