I am working on an operating system with Cosmos, I am wondering if there is a way to compile text from a file, for example: helloworld.cs, and then execute the file. Thanks in advance.
Asked
Active
Viewed 84 times
-1
-
I think this is already answered [here](https://stackoverflow.com/questions/553143/compiling-executing-a-c-sharp-source-file-in-command-prompt). – bdongus Apr 15 '20 at 08:51
-
@bdongus I'm not sure Pikalover is asking within the context of how to turn helloworld.cs into helloworld.exe on a *Windows* system... – Caius Jard Apr 15 '20 at 08:58
1 Answers
0
If you want to compile a c# file (.cs) like helloworld.cs
in Windows
namespace test {
class test {
static void Main(string[] args) {
System.Console.WriteLine("Hello World");
}
}
}
you can use csc.exe
to compile the file
C:\Windows\Microsoft.NET\Framework\{version}\csc.exe pathToFile

reza moradi
- 17
- 1
- 5
-
Does it exist on Cosmos OS? Just like that.. in C:\windows and all.. (seeing as Cosmos != windows) – Caius Jard Apr 15 '20 at 08:56
-
As far as I understand the OP is building an operating system with the Cosmos framework. He made no statement about his dev environment. – bdongus Apr 15 '20 at 09:02
-
I think I stated it wrong, I want to run code from a file in c#. For example inside hello.cs, there is a command to run World.cs. – Pikalover666666 Howard Apr 15 '20 at 12:05
-
maybe this can help you https://learn.microsoft.com/en-us/dotnet/api/microsoft.csharp.csharpcodeprovider – reza moradi Apr 15 '20 at 12:37