• Advertisement
Sign in to follow this  

csc is not recognized

This topic is 3311 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have been using VS for compiling and running my C# programs but I decided to rally learn some coding without all the bells and whistles. I have wrote a small test program in notepad and saved it as a .cs file. The code does not contain any errors. When I try and compile in cmd I get the error message "csc is not recognized as an internal or external command, operable program or batch file." I have seen to create a bat file to somehow connect to the compiler. How do I do this, and more importantly, why does it not automatically compile without a root to where ever?

Share this post


Link to post
Share on other sites
Advertisement
csc.exe and its ilk (developer tools) are usually not added the default path during install. There is a batch file in the VS install directory that will set up paths, or you could add the path the csc.exe to your PATH yourself, or you can run the "Visual Studio Command Prompt" option under the VS start menu entry (it may be under the tools subdirectory), which will run the VS configuration batch file for you.

Share this post


Link to post
Share on other sites
csc.exe probably isn't in your PATH. Batch files (.bat) typically set up the environment to add the required directories to the path environment variable.

The simplest way to fix that problem is probably to manually add the directory containing csc.exe to your path. I don't use Windows if I can avoid it, but I see to recall one has to right click on "My Computer", go to "Properties", then "Advanced", and click on some button to edit the environment variables.

Hope this helps.

Share this post


Link to post
Share on other sites
Thanks for the replies. I got it to compile for VS cmd prompt. I have to figure out how to set up the PATH correctly but I think I can manage. Thanks

Share this post


Link to post
Share on other sites
Add %windir%\microsoft.net\framework\v3.5 to your path, replacing v3.5 with the latest version you have. The .NET compilers are part of the redistributable, so you can use them even without Visual Studio installed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement