I don't want VS to assume it is all one executable that needs a specific entry point. It is so easy to do with javac. How do I do it with csc?
First misconception to fix is that it is VS doing the compilation. CSC.exe and Visual Studio are different entities. You can install just the .NET Framework SDK and get csc.exe but not have Visual Studio, and still be able to compile assemblies into executables, libraries, and modules. (Visual Studio can only compile assemblies into executables and libraries.)
Next, MSBuild.exe is essentially Microsoft's analog to Ant. (Inside Microsoft there was a short war between internal groups using NAnt -- an Ant like build system for .NET Framework vs. MSBuild.exe. You can see the results of who one that war.
) As your projects get more complex, putting in the build information into a .CSPROJ file which MSBuild can use is going to be the best way to contain that complexity. (Part of the reason MSBuild won because it supported doing other builds other than just C# projects, and so you get the various .*PROJ file extensions.) When you use the VS Solution Explorer, it goes and edits the .*PROJ files under the covers. The sad part though is that that we you build in Visual Studio, VS actually has it's own internal port version of the MSBuild engine that sometimes acts a little bit different from how the command line MSBuild.exe works. Over the past years, the delta between the two behaviors has become smaller and smaller due to the increased use of CI/DC systems where the build machine is using MSBuild.exe while developers are using VS on their desktops.
Anyway, I went into that diversion about MSBuild because of the documentation links I provided above tended to look more at MSBuild directives because as I previously said, more likely than not, you'll end up doing builds using a .*PROJ file to build your code instead of building at the command-line invoking csc.exe directly, or putting that command-line into a batch script or makefile.
Next, javac by default compiles each .java file into a .class file. Later you can group these .class files into modules or packages. This much like the way most professional C/C++ programmers will tell their compiler to build .c/.cpp files into .obj files which will later be linked together. They then later link the .obj files into a single executable or library. Csc.exe on the other hand compiles the .cs files into an assembly that might be an executable, library, or module. Executables need a single entry point because you can run these directly (as long as the .NET Framework is installed on the machine) by running typing in
filename.exe
, or by double clicking in the File Explorer without a requirement of a file association to be configured. The java .class files cannot be run directly just by typing
filename.class
, you'll need to type in
java filename.class
, or ensure that .class files associated with Java before being able to double click on them in the File Explorer.
If you want to do a build where each .cs file produces it's own executable, you'll need to script it using CMD batch script, PowerShell, makefiles. Alternatively you can also use MSBuild by using
transforms.