Compilation errors in Unity build automation script

I am using Unity 4.0 Pro trial version on Windows-7 and I am trying to automate the build process.

I have a javascript under Editor folder, with only following 5 lines :


static void PerformBuild ()
    string[] scenes = { "Assets/Scenes/my_scene" };
    BuildPipeline.BuildPlayer(scenes, 'TestMyScene',BuildTarget.Android, BuildOptions.None);

The problem is that the script is throwing compilation errors:

  1. Assets/Common/Editor/BuildAutomation.js(3,8): BCE0043: Unexpected token: void.

  2. Assets/Common/Editor/BuildAutomation.js(3,28): UCE0001: ‘;’ expected. Insert a semicolon at the end.

  3. Assets/Common/Editor/BuildAutomation.js(5,11): BCE0044: expecting :, found ‘[’.

I copied javascript from CommandLineArguments

And I am referring to the following docs:

I am new to Unity and the above errors look pretty basic. I am sure I am missing something very obvious. I have tried searching google, and I am unable to find the cause.

Kindly assist. Any pointers, links, docs, suggestion will be helpful.

Thanks for attention.

There is a good example in the unity documentation on how to use the build player function.

// Build a folder containing unity3d file and html file
	@MenuItem ("Build/BuildWebplayer")
	static function MyBuild(){
		var levels : String[] = ["Assets/Scene1.unity", "Assets/Scene2.unity"];
		BuildPipeline.BuildPlayer( levels, "WebPlayerBuild", 
					   BuildTarget.WebPlayer, BuildOptions.None); 

If you are not familiar with scripting and want to get a build automation up and running fast, you might want to have a look at uTomate. This edited extension allows you to build automation scripts completely without scripting, just by creating actions in the editor and then arranging them into automation plans. See for details.