C#命令解释

时间:2013-06-19 19:39:17

标签: c#

我有2个文件 第一个:

public class Hello{ 
  public void hello(){
      System.Console.WriteLine("Hello!Hello!");
  }
}

第二个:

class App {
   public static void Main() { 
       Hello h = new Hello(); h.hello();
   }
}

我需要知道以下各行的含义和做法

1 >sn -k hello.keys
2 >csc /t:library /keyfile:hello.keys hello.cs
3 >csc /t:exe /reference:hello.dll app.cs
4 > app
5 >csc /t:library /keyfile:hello.keys hello.cs
6 >app
7 >sn -k hello.keys
8 >csc /t:library /keyfile:hello.keys hello.cs
9 > app
10 >csc /t:library  hello.cs
11 >app

特别是“app”行! 谢谢你的帮助

2 个答案:

答案 0 :(得分:3)

csc /t:library File.cs // Compiles File.cs producing File.dll

List of compiler (csc) options

sn -k outfile //Generates a new key pair and writes it to the specified file.

Overview of Strong Name Tool (sn.exe)

“app”是在行

中将其作为可执行文件后的程序名称
csc /t:exe /reference:hello.dll app.cs

答案 1 :(得分:3)

这里运行三个命令:

  • sn - 用于创建强命名的密钥(不是这么用的 不能说更多)
  • csc - C#编译器(因此是csc)。这用于将源代码编译为DLL(/ t:library)或可执行文件(/ t:exe)
  • app - 这是您刚刚创建的程序。

我不确定你从哪里得到这些,但看起来它可能是在不同阶段之间编辑源文件。只需一次性运行这些就没有意义。

无论如何,这就是命令正在做的事情。