Create a folder this is where you will treat as your workspace for your project as shown in Figure 1
Create a batch file in as shows in Figure 2
Save that batch file in your workspace folder
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
If Windows does not see an executable file named, "Program.exe", it will create the file and name it "Program.exe"
Find the csc compiler (this is where the compiler is usually located), and run it with the following libraries listed after the "/r:", (the libraries are found different directories mentioned later)
Compile "Program.exe" using the Program.c file (This is what is after the "/out:")
Tell the user on the terminal its progress with "ECHO"
Make sure that "Program.exe" exists, then run it
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.