https://blog.csdn.net/weixin_43798960/article/details/104507238
C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:library /out:g:\test.dll G:\DLLDemo\DLLDemo*.cs
具有依赖的dll的编译方式:
C:\Users\user>C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:library /out:g:\lib.dll G:\DLLDemo\Lib*.cs
csc.exe /t:library /out:g:\test.dll /r:g:\lib.dll G:\DLLDemo\DLLDemo*.cs
C:\Users\user>C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:library /out:g:\test.dll /r:g:\lib.dll G:\DLLDemo\DLLDemo*.cs
具有宏的编译:
C:\Users\user>C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:library /out:g:\test.dll /r:g:\lib.dll G:\DLLDemo\DLLDemo*.cs /unsafe /d:USE_CODE,USE_CODE,DEBUG
using Lib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DLLDemo
{
public class Class1
{
public string SayHello()
{
Util util = new Util();
string str1 = util.Nihao();
return str1 + "helloworld";
}
public string UnSafeSayHello()
{
unsafe
{
int var = 20;
int* p = &var;
}
return "unsafehello";
}
#if USE_CODE
public string MacroSayHello()
{
return "macrohello";
}
#endif
#if USE_CODE2
public string MacroSayHello2()
{
return "macrohello2";
}
#endif
#if DEBUG
public string MacroSayHello3()
{
return "macrohello3";
}
#endif
}
}