0

I am mainly a C/C++ progammer and I do not use IDE. I am used to coding in a lightweight editor and compiling and running directly from command line. Now that I am starting to learn C#. I do not understand how to achieve the same effect in this. I have added csc.exe to path and installed the Dotnet SDK. I want to know how can I code and compile directly without any sort of IDE's just using the compiler and make 'static' executable like C/C++.

Is there not any C# compiler that is similar to GCC or mingw?

note, this isn't the duplicate of the question this Question. My Question is about how to program in C# without any IDE and also how to compile a static exe that does not require any sort of libraries to work. Yes, on the .NET framework of course.

EDIT : Also, How can I compile C# exe for Windows on Linux? The way we can compile C/C++ code on Linux for Windows?

Lynx
  • 147
  • 2
  • 8
  • You can compile using [MSBuild.exe](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild-command-line-reference?view=vs-2019) – Igor Oct 03 '19 at 10:20
  • 1
    Possible duplicate of [How can I compile and run c# program without using visual studio?](https://stackoverflow.com/questions/18286855/how-can-i-compile-and-run-c-sharp-program-without-using-visual-studio) – Selvin Oct 03 '19 at 10:20
  • yes, this is duplicate ... your "question" just contains also second question ... and about second question ... define `static exe` ... did you mean stand-alone executable? then it is not possible yet... – Selvin Oct 03 '19 at 10:21
  • Try through CLI using `MSBuild.exe` as mentioned above ↑. – CodeRed Oct 03 '19 at 10:22
  • I will try MSBuild.exe. @Selvin Yes I mean stand-alone executable on the .NET framework. Is it not possible? – Lynx Oct 03 '19 at 10:25
  • AFAIK in .net framework is not possible and it will be not ... with .net core it's in alpha or beta(CoreRT) – Selvin Oct 03 '19 at 10:26
  • 1
    If it's .net core 3.0, use VisualStudio code and the CLI. With VisualStudio Code you still have code completion and Roslyn integrated. That helps to see errors while coding, just like VisualStudio would do. One of the many reasons why to use an IDE. Another one could be the debugging experience... – Daniel Schmid Oct 03 '19 at 10:26
  • I use vscode. Maybe my understanding is wrong about .NET executables. So lets say if I compile my code with MSBuild.exe. Will that binary work on other systems with .NET installed? Or I have to link libraries to it so it can run on other systems with .NET installed? – Lynx Oct 03 '19 at 10:28
  • If you program a single exe and port that to another machine that has a compatible Version of .NET installed, it will work. But often you have external dependencies like the .config file for App Settings – Daniel Schmid Oct 03 '19 at 10:31
  • @OlivierRogier I'm using .Net Core. The only thing I don't understand is how to make-it-so I can distribute my applications. See I'm from C/C++ and to distribute my C/C++ programs I compile a static executable. I am just curious how would I do the same in C#. Because it runs on .NET. Do I need to link anything or the file will work without linking.. – Lynx Oct 03 '19 at 10:32
  • @DanielSchmid Wait yes, That. So lets say I have external dependencies. How would I add them? – Lynx Oct 03 '19 at 10:33
  • 1
    "[Publishing A Single EXE File In .NET Core 3.0](https://dotnetcoretutorials.com/2019/06/20/publishing-a-single-exe-file-in-net-core-3-0/)" – Uwe Keim Oct 03 '19 at 10:35
  • @Lynx The generated executable is made to be runned as-is on any supported platform like with java. –  Oct 03 '19 at 10:39
  • What do you mean with 'adding external dependencies'? – Daniel Schmid Oct 03 '19 at 10:40
  • @OlivierRogier Wow Thanks! My first problem is now solved I think. Also, How can I compile C# exe for Windows on Linux? The way we can compile C/C++ code on Linux for Windows? – Lynx Oct 03 '19 at 10:40
  • @Lynx That does not work on Linux? [.NET Core command-line interface (CLI) tools](https://learn.microsoft.com/dotnet/core/tools/?tabs=netcore2x) –  Oct 03 '19 at 10:42
  • multi platform is supported with .net core. .net core 3.0 supports single file exe. Are you completely against reading documentation/tutorials? – Daniel Schmid Oct 03 '19 at 10:42

0 Answers0