如何创建.csproj文件的DLL

pra*_*dha -1 c# csc

csc /target:library /out:MyMaths.dll ClassLibraryFunction.csproj
Run Code Online (Sandbox Code Playgroud)

我正在使用此代码在VS.Cmd编译器中生成一个完整解决方案的DLL.但是,我收到编译错误,并且没有生成DLL.

Mar*_*ell 6

csc不适用于.csproj文件.你有几个选择:

  1. 使用msbuild; 例如

    msbuild ClassLibraryFunction.csproj
    
    Run Code Online (Sandbox Code Playgroud)

    注意到您可能需要更改项目的输出类型(在IDE中这是项目属性,应用程序,输出类型;在csproj文件中这是<OutputType>Library</OutputType>)

  2. csc/recurse开关一起使用; 例如:

    csc /target:library /out:MyMaths.dll /recurse:*.cs
    
    Run Code Online (Sandbox Code Playgroud)

    (它将编译.cs当前文件夹或子文件夹中的所有文件)

  3. 什么也不做,只使用你已经拥有的exe; .NET exe可以像任何其他程序集一样被引用,并且public可以使用任何类型