通过命令行编译c#代码时如何使用引用 [英] How to use references when compiling c# code via command line

查看:32
本文介绍了通过命令行编译c#代码时如何使用引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我通过命令行编译一些 c# 文件?我有 4 个文件要编译,Main、Form1(使用 2.cs 文件)和项目中使用的另一个类.

Could anyone help me compile via command line some c# files? I have 4 files to compile, Main, Form1 (which uses 2.cs file) and another class used in the project.

我想在命令行中编译这个项目,这样我就可以添加/t:library 开关(就像在本教程中一样:http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx).

I would like to compile this project in command line so I could add the /t:library switch (like in this tutorial: http://dotnetslackers.com/articles/csharp/WritingAnActiveXControlInCSharp.aspx).

但是,在使用csc/t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs"后,我得到了缺少程序集引用的错误,例如:

However after using "csc /t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs" I get missing assembly reference errros such as these:

ProjectFaceRecProOVaspVerFaceRecProOVMainForm.cs(14,15): error CS0234: The type or namespace name 'Structure' does not exist
    in the namespace 'Emgu.CV' (are you missing an assembly reference?)

我确实安装了 EMGU 二进制文件.我认为我需要使用该文件夹中的一些 .dll,例如 EMGU.CV.dll?

I do have installed EMGU binaries installed. I would think I need to use some .dll's from that folder like EMGU.CV.dll?

推荐答案

要在命令行上引用库,您需要使用 /r: 编译器选项并将相对路径传递给库.假设它在同一目录中,您可以执行以下操作

To reference a library on the command line you need to use the /r: compiler option and pass the relative path to the library. Assuming it's in the same directory you can do the following

csc/r:EMGU.CV.dll/t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs

csc /r:EMGU.CV.dll /t:library Program1.cs MainForm.cs MainForm.Designer.cs EigenObjectRecognizer.cs

文档:http://msdn.microsoft.com/en-us/library/yabyz3h4.通过指定 /? 可以直接从命令行获得简短版本的文档:C:WindowsMicrosoft.NETFrameworkv4.0.30319csc/?

Documentation: http://msdn.microsoft.com/en-us/library/yabyz3h4. Short version of documentation available directly from command line by specifying /?: C:WindowsMicrosoft.NETFrameworkv4.0.30319csc /?

这篇关于通过命令行编译c#代码时如何使用引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆