Nov 202009

I don’t have the Visual Studio 2008 IDE at work. To get around that I write WPF entirely though code in Notepad and compile it with the command line compiler installed with the Framework. Painful, yeah, but it makes for much better learning. The IDE makes things much easier through intellisense, code generation which makes for Rapid development, but makes developers lazier. So start coding with Notepad and learn faster!!!

But the biggest headache in using the command line compiler is adding a reference to the three WPF dlls which reside in the Program Files Folder. So I wrote a small batch file to make the referencing the creating the exe easier for me. Create two folders Codebase and Executables in the same directory that your .NET 3.5 folder resides.

Just save the following text as a batch file and save it in the same directory as your .NET installation. Save the code in the codebase folder and run it from the .NET 3.5 directory. For e.g. if your code file name is SampleCode.cs and batchfile name is runcsharp, then execute the command runcsharp SampleCode form .NET 3.5 directory. The exe will be created as SampleCode.exe in the Executables directory. Simple, yet makes things a lot easier for developers who don’t have the IDE installed.

csc.exe /out:..\execut~1\%1.exe ..\codebase\%1.cs /reference:”C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\PresentationCore.dll” /reference:”C:\Program Files\Reference
Assemblies\Microsoft\Framework\v3.0\PresentationFrameWork.dll” /reference:”C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll”

Here you can see the three dlls that are must for a WPF application.

  • PresentationCore.dll
  • PresentationFramework.dll
  • WindowsBase.dll