如何通过开发人员命令提示符添加引用

时间:2014-11-17 13:17:20

标签: c# console-application windows-applications

我在记事本中创建了一个C#程序并保存为" Program.cs"  我需要在VS2013的Developer Command Prompt中编译我的程序

但我需要添加引用一些dll文件  如何在VS2013的开发人员命令提示符中添加对我的程序的引用

2 个答案:

答案 0 :(得分:3)

  

参考:Working with the C# 2.0 Command Line Compiler和   How to: Create and Use Assemblies Using the Command Line (C# and Visual Basic)

如果您的客户端应用程序正在使用MyCodeLibrary.dll,则需要使用/reference (or simply /r) option。这个标志很灵活,你可以指定所讨论的* dll的完整路径:

csc /t:exe /r:C:\MyCSharpCode\MyCodeLibrary\MyCodeLibrary.dll *.cs

或者,如果私有程序集的副本与输入文件位于同一文件夹中,则只需指定程序集名称:

csc /t:exe /r:MyCodeLibrary.dll *.cs

答案 1 :(得分:2)

您需要使用/r开关添加dll引用,如

csc /target:library /r:Assembly_Name.dll Program.cs