c# - Visual Studio 2012 命令行编译器

标签 c# command-line csc

我知道这似乎是一个重复的问题,但我已经浏览了所有现有的答案,但都无济于事。

我一直在尝试让命令提示符确认 C# 的命令行编译器,因为它是我正在使用的编译器生成器所必需的。我正在全新安装 Windows 7 SP1 64 位,带有 Visual Studio 2012 对 dreamspark 的赞美。

我尝试将“Microsoft.NET\Framework\v4.0.30319”和“Microsoft.NET\Framework64\v4.0.30319”添加到路径环境变量,尝试了 vsvars 批处理文件,但仍然没有成功.命令提示符只是指出“csc 未被识别为内部或外部命令”。

如有任何帮助,我们将不胜感激!

最佳答案

其实只有两种可能。一,你的路径不正确。试试这个:

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>

如果这不起作用,则验证 csc.exe 确实位于正确的位置:

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

如果没有找到,尝试做:

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

查看它是否在不同的目录中。也许您安装了另一个版本的框架,或者没有 64 位操作系统。

关于c# - Visual Studio 2012 命令行编译器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13502180/

相关文章:

c# - “authority”应为 Uri 格式参数名称 : authority

linux - 在不同的显示器上启动两次 firefox

MSBuild 引用程序集未包含在构建中

c# - 引用值参数VS返回值哪个好?

c# - Asp 网络成员身份提供程序中的更改密码问题

环境变量中的 Windows 控制台宽度

c# - CS1703 : In Xamarin. Droid,我应该使用位于 Mono.Framework 或 System.Runtime 中的 .Net Standard windowsruntime.dll?

visual-studio-2013 - 找不到元数据文件.dll CSC错误

c# - 裁剪图像的左侧

command-line - 将文件从一个目录剪切复制粘贴到另一个目录的命令是什么