Whidbey (RSS)

Whidbey

Enable Intellisense for NAnt and Wix files in VS2005 Beta1

Edit: This still works for VS2005 Beta2

Since Beta 2 is still a month off or so, I think this could still be relevant :-)

This blog tells you how to enable intellisense for NAnt .build files in VS2003.
This blog does the same for Wix .wxs files.

Both should be slightly altered to work with VS2005 beta1.

1) copy the schema files (.xsd) to the following folder: C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas

2) the registry key with which Wix (.wxs) and NAnt (.build) files can be registered as being xml is now:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Editors\{412B8852-4F21-413B-9B47-0C9751D3EBFB}\Extensions]"wxs"=dword:00000029
(replace the "wxs" by "build" for NAnt)
Note the subtle difference: dword value is 0x29 and not 0x28, which is ".htm" in vs2005b1, and the guid is different.

 

Custom tool to generate code from XSD in VS2005 beta 1

Chris Sells posted a VS.NET (2002 & 2003) custom add-in to generate code (C#, VB and J#) from xsd quite some time ago. I stumbled upon it while looking for a way to do this in VS2005B1.

With minor changes, the add-in works in VS2005B1 as well. The only thing that stumped me for a while there is that in VS2005B1 the generated code is created as 'dependent' upon the xsd, and is thus hidden until you enable 'Show all files' on the project and you click on the little '+' sign next to your xsd. I can't seem to remember if this happens in previous versions of VS as well.

You can find the changed file here.

Creating GUIDs in VS 2005 B1

In VS.NET 2003 there is an external tool called 'GuidGen' to generate GUIDs. I can't seem to find this in VS 2005 so I made my own:

class Program
{
    public const string ARG_BYTES = "/b";
    public const string ARG_CSHARP = "/cs";
    public const string ARG_HELP = "/?";

    static void Main(string[] args)
    {
        StringBuilder builder = new StringBuilder();

        if (args.Length > 0)
        {
            switch (args[0])
            {
                case ARG_BYTES:
                    foreach (byte b in Guid.NewGuid().ToByteArray())
                    {
                        builder.Append(b.ToString("X2"));
                        builder.Append(" ");
                    }
                    break;
                case ARG_CSHARP:
                    builder.Append("new byte [] { ");
                    foreach (byte b in Guid.NewGuid().ToByteArray())
                    {
                        builder.Append("0x");
                        builder.Append(b.ToString("X2"));
                        builder.Append(", ");
                    }
                    builder.Remove(builder.Length - 2, 2);
                    builder.Append(" }");
                    break;
                case ARG_HELP:
                default:
                    builder.Append(string.Format("Usage: no arguments for a hexString representation, {0} for a byteArray representation, {1} for a C# byte array, {2} for this help message", ARG_BYTES, ARG_CSHARP, ARG_HELP));
                    break;
            }
           
        }
        else
        {
            builder.Append(Guid.NewGuid().ToString());
        }

        Console.Write(builder.ToString());
    }
}

 

At the command line type:

"GuidGen" for output like "ab04c0a1-ebb7-4996-914f-2a16ca9212f4"

"GuidGen /b" for output like: "31 34 37 18 5F 5B 2A 45 BC 8C 32 06 37 BF E9 B6"

"GuidGen /cs" for output like "new byte [] { 0x38, 0x39, 0xC0, 0xBD, 0xCE, 0xD4, 0xEC, 0x41, 0x8C, 0x90, 0x7C, 0x96, 0x37, 0x35, 0x83, 0x1C }"