《CLR Via C#》使用CSC.exe进行单文件的编译
2016-03-21 15:18
489 查看
1、新建一个Program.cs文件,并写入代码
在目录E:\LiuSen\VS\test下,新建一个Program.cs文件,输入以下代码using System; namespace MyConsoleApp { class Program { static void Main(string[] args) { Console.WriteLine("Hello world!"); Console.ReadKey(); } } }
2、用CSC.exe对Program.cs进行编译
打开Developer Command Prompt for VS2013,并转到目录E:\LiuSen\VS\test下,并使用如下命令进行编译:csc.exe /out:Program.exe /t:exe /r:MSCorLib.dll Program.cs
3、运行Program.exe文件
程序运行界面:
4、知识总结
4.1、/r:MSCorLib.dll可以省略掉
MSCorLib.dll is a special file in that it contains all the core types: Byte, Char, String, Int32, and many more. In fact, these types are so frequently used that the C# compiler automatically references the MSCorLib.dll assembly. In other words, the following command line (with the /r switch omitted) gives the same results as the line shown earlier.【MSCorLib.dll是一个经常被引用的类库,,因此/r MSCorLib.dll参数可以省略】csc.exe /out:Program.exe /t:exe Program.cs
4.2、/out: Program.exe 和 /t:exe 也可以省略掉
Furthermore, because the /out:Program.exe and the /t:exe command-line switches also match what the C# compiler would choose as defaults, the following command line gives the same results too.csc.exe Program.cs
4.3、如果不想让MSCorLib.exe参与编译,可以使用/nostdlib
If, for some reason, you really don't want the C# compiler to reference the MSCorLib.dll assembly, you can use the /nostdlib switch. Microsoft uses this switch when building the MSCorLib.dll assembly itself. For example, the following command line will generate an error when CSC.exe attempts to compile the Program.cs file because the System.Console type is defined in MSCorLib.dll.【如果不想让c# compiler引用MSCore.dll文件,可以加上 /nostdlib参数】4.4、Windows支持的三种Application类型
Windows supports three types of applications. To build a console user interface (CUI) application, specify the /t:exe switch; to build a graphical user interface (GUI) application, specify the /t:winexe switch; and to build a Windows Store app, specify the /t:appcontainerexe switch.【在这里,主要注意/t参数的三种类型】相关文章推荐
- 威金变种 rundl132.exe RichDll.dll,f1.exe,f2.exe,f3.exe,f4,exe,f5.exe,f11.exe解决方法
- 使用winrar打包air程序为exe(包含air运行环境)
- js 调用本地exe的例子(支持IE内核的浏览器)
- 使用 JScript 创建 .exe 或 .dll 文件的方法
- JS 自动安装exe程序
- JavaScript打开客户端exe文件的代码
- node-webkit打包成exe文件被360误报木马的解决方法
- Windows系统中Java调用cmd命令及执行exe程序的方法
- 手动实现把python项目发布为exe可执行程序过程分享
- Windows下用py2exe将Python程序打包成exe程序的教程
- win2003禁止web等目录执行exe,bat,com的方法
- Win32_PingStatus vs [System.Net.NetworkInformation.Ping] vs Ping.exe
- EXE导出函数给其它PE调用
- 让EXE导出函数
- txt,jpg***生成器原理--把exe***格式改为txt,jpg等
- Windows system中使用 Diskpart.exe 扩展数据卷
- Qt程序打包成exe可执行文件图文教程
- Program too big to fit into memory
- Program too big to fit into memory
- Csvde.exe 工具不如 Ldifde.exe 强大,因为 Csvde.exe 无法修改或删除现有目录对象