'Error '''csc'' is not recognized as an internal or external cmd,operable program or batch file'

Consider:

class First
{
  static void Main()
  {
    System.Console.WriteLine("piyush");
  }
}

I first started the developer command prompt by start menu → Optimize ProgramsVisual Studio 2013Visual Studio ToolsDeveloper command prompt

This is shown on start:

ERROR: Cannot determine the location of the VS Common Tools folder.
C:\Program Files (x86)\Microsoft Visual Studio 12.0>

The echo command is only showing the given below:

%VS120COMNTOOLS%

After a while, it is also automatically closing itself.

The result of set VS is:

VS110COMNTOOLS=C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools\

Also, is there a way to compile and run the above program as it’s possible in Eclipse for core Java without depending on the developer command prompt?



Solution 1:[1]

As others have mentioned, you need to ensure your PATH environment variable includes the path to your installed command-line tools.

However, if you installed Visual Studio, it already includes a batch command, vcvars.bat, that does that, and includes another batch command, VsDevCmd.bat, that runs that batch command and several other ones useful for command-line development. A shortcut to that command should have been installed in your Start menu under Microsoft Visual Studio ? Visual Studio Tools. You should always run Visual Studio commands from that CLI window.

In response to the new version; if set vs shows no environment variables starting with “VS12” then either you did not run the Visual Studio 12's (Visual Studio 2013) VsDevCmd.bat command or it is not installed. Get Properties of the Developer Command Prompt shortcut you opened and tell us the value of the Shortcut/Target field.

You should have a C:\Program Files (x86)\Microsoft Visual Studio 12.0 directory.

Solution 2:[2]

Your Path environment variable should point to below path:

C:\Windows\Microsoft.NET\Framework64\vX.X.XXX

Or alternatively you can browse to the below path and run csc.exe:

csc C:/Dot.Net/First.cs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Peter Mortensen
Solution 2 Peter Mortensen