Thursday, January 03, 2008

Using Volta from the Command Line

While it’s unlikely that you would ever want to invoke the Volta compiler directly, using it does provide some insight into how Volta works.

Let’s say that you have an existing assembly named BoringObjects.dll.  BoringObjects.dll contains one class named Person.



To do a Volta conversion of this assembly from MSIL to JavaScript execute the following command from the console window. NOTE: you will need "C:\Program Files\Microsoft Live Labs Volta" in your path.

> volta BoringObjects.dll /out:JSOutput

The only argument of interest is /out:JSOutput.  This is the directory that the Volta compiler will write the JavaScript files to.

If we look under our specified output directory we notice that Volta has created a directory that corresponds to the assembly name.  Under that directory there are three items:

[Types] (directory)
assembly.js
typeMapping.js

Under the Types directory there is one file "tA.js" which corresponds to the lone Person class in our original assembly.  If you use /d (debug) option the file will be named "type_0__Person.js" and the JavaScript code will be nicely formatted.

It’s interesting to note that this same structure is seen in "C:\Program Files\Microsoft Live Labs Volta\Cache".  In that directory you will find that some core .NET assemblies and the Volta libraries have been converted to JavaScript. This step is apparently part of the installation process.

#    Comments [0] |