r/code • u/Connect-Wrap-9465 • Nov 28 '23
Help Please creating an .exe using code
how to compile a .exe file.
I have pictures, some code (in c# but can be other) and Id like to compile the code + pictures into a .exe file using code. how can I do this? code sample is welcome!
3
Upvotes
View all comments
Show parent comment
1
u/JaggedMetalOs Dec 02 '23
So the users will need the .net Framework SDK installed (it's not nearly as big as Visual Studio). This gives you csc.exe and all the libraries necessary to compile C#.
Then your program would take the C# in that text box and generate a full program class file in some temporary folder with it. Not sure what to do with the image resources, you might need to generate a C# project to compile to include the images.
(I've never actually worked with images directly in C#, always used Unity for anything graphical. You can probably post a new question in the sub asking more specifically how to pack images when compiling from the command line with csc.exe)
Finally once you have the necessary class and image resource files in your temporary folder you can call csc.exe to compile it like Visual Studio would.
Here's a very brief example of the usage of csc.exe