Using CSC Compiler to Create WPF Programs

2025-07-04

Summary

  1. Create a folder this is where you will treat as your workspace for your project as shown in Figure 1
  2. Create a batch file in as shows in Figure 2
  3. Save that batch file in your workspace folder
  4. OPTIONAL: save the dll library files in your workspace to make effort easier
Figure 1: workplace folder

The Solution

The Batch File

	
		cd /d %~dp0
		@echo on
		if not exist Program.exe (echo Compiling Program...) else (DEL Program.exe)
		C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /r:PresentationFramework.dll,WindowsBase.dll,PresentationCore.dll,System.Xaml.dll /out:Program.exe Program.cs
		ECHO Generating File...
		if not exist Program.exe (echo ERROR: PROGRAM DOES NOT EXIST OR DID NOT COMPILE) else (start "" Program.exe)
		PAUSE
	
	

Functional Description of the Batch File

Location of the dll File Libraries

		C:/Windows/Microsoft.NET/Framework/v4.0.30319/WPF
	
	

System.Xaml.dll can be found here:

		C:/Windows/Microsoft.NET/Framework/v4.0.30319
	
	

Why Compiling in this Way is Still Useful

Due to data rights, your IT department may restrict what software may be installed on your computer. However, the .NET Framework usually comes installed with every Windows PC. This means that you can conduct C#, Windows Presentation Framework (WPF) programs on any machine you like without asking for special permission.

Video Demo

You can find a video demo at the Substack page found here.