G+_Joe Maruschek Posted August 24, 2014 Share Posted August 24, 2014 For the adventurous Coding 101 viewers out there, it is possible to use Notepad or your favorite editor to write your C# programs, and then compile them on the command line. Visual Studio installs an item on the start menu under Visual Studio 2013, Visual Studio Tools, called "Developer Command Prompt for VS2013". Double-clicking that shortcut starts a command window with all the environment variables set up to run the C# compiler: csc.exe. You can run "csc" from any folder, so change to one your folders where you have created your C# source code files with whatever editor you like. For simple one-file console apps, you can compile them by typing "csc sourcefile.cs". If there are no compile errors, a file called "sourcefile.exe" will be created in the same folder. That's the file you run. If you create more complex programs with multiple source files, or if you build WPF programs, you will likely need to use some of the command-line options for csc. Check the docs on MSDN for a list of all the options. http://msdn.microsoft.com/en-us/library/78f4aasd.aspx Link to comment Share on other sites More sharing options...
G+_Nate Follmer Posted August 24, 2014 Share Posted August 24, 2014 Good tip - Nice to use when you don't feel like opening VS ;) Link to comment Share on other sites More sharing options...
G+_Irene Smith Posted August 25, 2014 Share Posted August 25, 2014 Can you give me a good reason for using the command line compiler instead of the IDE? If it cost money, I could see your reasoning, but it is free. I'm not arguing for the sake of arguing, I'd like to understand your logic. Link to comment Share on other sites More sharing options...
G+_Nate Follmer Posted August 26, 2014 Share Posted August 26, 2014 Irene Smith I mostly use it when I want to make a small change in code and then quickly recompile. It's usually faster to change a couple lines of code and compile via command line than it is to wait for VS to start up and do it's thing. Link to comment Share on other sites More sharing options...
G+_Joe Maruschek Posted August 26, 2014 Author Share Posted August 26, 2014 Irene Smith Some people perhaps don't like the Visual Studio editor and environment for whatever reason. Perhaps they have their own favorite editor. Padre and Snubs make it seem that you can't use notepad (or other editors) with C# like you can with Python and Perl. Being a reader of Charles Petzold's books, I knew that it was possible. Petzold himself has a love-hate relationship with Visual Studio and prefers not to have Visual Studio generate code for him. Check out this (rather long) article: http://charlespetzold.com/etc/DoesVisualStudioRotTheMind.html Link to comment Share on other sites More sharing options...
Recommended Posts