5

I know this may appear to be a duplicate question, but I have been through all of the existing answers to no avail.

I have been trying to have command prompt acknowledge the command line compiler for C#, as it is neccisary for the compiler generator I am using. I am working on a fresh install of Windows 7 SP1 64bit, with Visual Studio 2012 compliments of dreamspark.

I have tried adding the "Microsoft.NET\Framework\v4.0.30319" and the "Microsoft.NET\Framework64\v4.0.30319" to the path environmental variable, tried the vsvars batch file, and still am having no luck. Command prompt simply states that "csc is not recognised as an internal or external command".

Any help would be appreciated!

Frostie
  • 211
  • 3
  • 6
  • 2
    What's the output of the `path` command exactly? – Mike Christensen Nov 21 '12 at 21:19
  • You get full versions afaik. Just use the Visual Studio Command Prompt, Start + All Programs to find it. – Hans Passant Nov 21 '12 at 21:23
  • Are you using the Developer Command Prompt for VS2012? Look in `C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\Tools` for the Bat File named `VsDevCmd.bat` – Mark Hall Nov 21 '12 at 21:24
  • The exact output of Path is: "%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\; C:\Windows\Microsoft.NET\Framework64\v4.0.30319". I am not using the developer command prompt, as CSC is called from a batch file that is part of the compiler generator I am using – Frostie Nov 21 '12 at 21:25

1 Answers1

6

There's really only two possibilities. One, your path is incorrect. Try this:

C:\Windows\Microsoft.NET>path
PATH=C:\Program Files\Common Files\Microsoft Shared\Microsoft Online Services;C:\Program Files (x86)\Common Files\Micros
oft Shared\Microsoft Online Services;c:\Program Files (x86)\AMD APP\bin\x86_64;c:\Program Files (x86)\AMD APP\bin\x86;C:
\oraclexe\app\oracle\product\11.2.0\server\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System
32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\QuickTime\QTSystem\;c:\Program Files (x86)\Microsoft SQL Server\100\To
ols\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\P
rogram Files (x86)\Java\jre6\bin;C:\Program Files (x86)\Graphviz 2.28\bin;C:\Program Files (x86)\1E\SMSNomad\;C:\Program
 Files (x86)\Git\cmd;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\IronRuby 1.1\bin;C:\Program Files\Microsoft\W
eb Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL S
erver\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\0.8.0.0\

C:\Windows\Microsoft.NET>csc
'csc' is not recognized as an internal or external command,
operable program or batch file.

C:\Windows\Microsoft.NET>set path=%path%;C:\Windows\Microsoft.NET\Framework64\v4.0.30319

C:\Windows\Microsoft.NET>csc
Microsoft (R) Visual C# Compiler version 4.0.30319.17929
for Microsoft (R) .NET Framework 4.5
Copyright (C) Microsoft Corporation. All rights reserved.

warning CS2008: No source files specified
error CS1562: Outputs without source must have the /out option specified

C:\Windows\Microsoft.NET>

If that isn't working, then verify csc.exe is indeed in the correct location:

C:\Windows\Microsoft.NET>dir C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe /b
csc.exe

If it isn't found, try doing:

C:\Windows\Microsoft.NET>dir csc.exe /s /b
C:\Windows\Microsoft.NET\Framework\v1.1.4322\csc.exe
C:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe
C:\Windows\Microsoft.NET\Framework\v3.5\csc.exe
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\csc.exe
C:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe

To see if it's in a different directory. Perhaps you have another version of the framework installed, or do not have a 64bit OS.

Mike Christensen
  • 88,082
  • 50
  • 208
  • 326
  • dir csc.exe /s /b returns the following: c:\Windows\Microsoft.NET>dir csc.exe /s /b c:\Windows\Microsoft.NET\Framework\v2.0.50727\csc.exe c:\Windows\Microsoft.NET\Framework\v3.5\csc.exe c:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe c:\Windows\Microsoft.NET\Framework64\v2.0.50727\csc.exe c:\Windows\Microsoft.NET\Framework64\v3.5\csc.exe c:\Windows\Microsoft.NET\Framework64\v4.0.30319\csc.exe That, and set path=%path%;C:\Windows\Microsoft.NET\Framework64\v4.0.30319 works as long as the command window is open, but not permanently – Frostie Nov 21 '12 at 21:33
  • Ok, seemed to have gotten it working though not entirely sure why. I removed "%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;" from the Path, and it started working. If I add it once again, it stops working. – Frostie Nov 21 '12 at 21:42
  • @FrostSA - Yea that is rather fishy. Maybe add `%SystemRoot%\Microsoft.NET\Framework64\v4.0.30319` as the very first thing in the path. – Mike Christensen Nov 21 '12 at 22:28
  • It's possible you might have hit the PATH length limit – redtuna Jan 19 '13 at 03:00