Getting Started
To test the software and understand how it works, open a command prompt. Change to or create a working directory, and type the following command:

scaffold Hello.csr

If Visual Studio 2008 is installed correctly, you should see it start up with a project that contains the file Hello.csr. The scaffold program should print out the actions it is taking, and exit, returning control of the console.

The VS C# project should have contents similar to the following:

  using System;
  using System.Collections.Generic;
  using System.Text;
  using System.Text.RegularExpressions;
  using System.IO;
  using Microsoft.Tools.CodeRunner;

  public class Program
    public static int Main(string[] args)
      if (args.Length == 0)
        // TODO: Fill out usage information
        Console.WriteLine("Usage: {0}", ScriptEnvironment.ScriptPath.FileAndExtension);
        return 0;

      // TODO: Script code goes here...

      return 0;

Replace the second // TODO: comment with:

Console.WriteLine("Hello {0}, this is my first C# script", args[0]);

and compile the program. Now step through it in the debugger and check that it works. You can set a command line argument in the project Properties Debug tab. All done? OK, now close Visual Studio. A background process started by the scaffold program will clean-up the temporary directory containing the project used to edit and debug the script.

Now type the following:

csr Hello.csr World

You should see the greeting message displayed. In fact, you can just type the following:

Hello World

The installation modifies necessary environment variables and registry entries to cause the command shell to automatically append the .csr extension and cause the csr.exe program to execute it.

Want to edit the script some more? Just run scaffold again, or just edit the source in notepad and save your changes. If you make a mistake any errors will be reported when the script is run, along with line number information so you can fix the problem easily.

Last edited Jan 18, 2008 at 7:17 PM by jlyonsmith, version 5


No comments yet.