You may have read my post about how you can build Silverlight Web applications with Visual Studio .NET 2005 [1] instead of using the next verison codename Orcas. Until this time I used always a Virtual PC which was sometimes a little bit slow.
Today I was thinking about how I could do this with Notepad. Of course, I will miss the great Intellisense support which you will get with Visual Studio, but sometimes I would like to do small changes i.e. directly on the Web server where I have no Visual Studio installed.
What do you need for Silverlight Notepad compile?
First of all you need the Microsoft .NET Framework 2.0 [2], which is a free download available at the Microsoft Download Center. Next we need the DLLs that are referenced by the Silverlight project. They are included in the Silverlight 1.1 Alpha plugin [3] download.
After the installation of both files you will have the C# compiler available in you local Windows folder and the Silverlight files in c:\Program Files\Microsoft Silverlight.
My Silverlight build.bat
And now we will build our Silverlight build.bat file which will compile all C# files in a folder into a Silverlight assembly. Let us start with the simple arguments for the C# compiler:
csc.exe /out:SilverlightApp.dll /t:library
The /out argument will name the assembly we get when the compile is finished. The /t will tell the compiler to create a library instead of a executable.
By default the C# compiler will include the standard libraries of the .NET Framework 2. To remove everything I use following arguments:
<pre class="csharpcode">/<span class="kwrd">nostdlib+</span> /<span class="kwrd">noconfig</span></pre>
To specifiy the Silverlight core assemblies we will need to add some reference arguments (I set the environment variable %sl% to "c:\Program Files\Microsoft Silverlight"):
/r:"%sl%\agclr.dll" /r:"%sl%\mscorlib.dll" /r:"%sl%\system.dll" /r:"%sl%\System.Core.dll" /r:"%sl%\System.Silverlight.dll" /r:"%sl%\System.Xml.Core.dll"
Ok, now we only need the C# source files and, if necessary some resources:
<pre class="csharpcode">/<font color="#0000ff">res</font>:Surface.xaml,SilverlightSurface.Surface.xaml *.cs </pre>
The full build.bat looks like this:
set sl=C:\Program Files\Microsoft Silverlight set csc=C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe %csc% /out:SilverlightApp.dll /t:library /nostdlib+ /noconfig /r:"%sl%\agclr.dll" /r:"%sl%\mscorlib.dll" /r:"%sl%\system.dll" /r:"%sl%\System.Core.dll" /r:"%sl%\System.Silverlight.dll" /r:"%sl%\System.Xml.Core.dll" /res:Surface.xaml,SilverlightSurface.Surface.xaml *.cs
I have uploaded a ZIP file containing the Silverlight Surface demo source code from my last blog [4] containing a build.bat instead of the solution and project files, you can download it here [5].