CSharpCodeProvider编译顺序

本文关键字:顺序 编译 CSharpCodeProvider | 更新日期: 2023-09-27 17:59:27

有没有一种方法可以按照正确的顺序自动编译文件。"CompileAssemblyFromFile"似乎不关心依赖项在编译之前。怎么了?

public bClass 
{
   public aClass FieldName; //Trows error not aClass type not found
}

编译订单

1. bClass.css
2. aClass.cs

CSharpCodeProvider编译顺序

它对我的工作顺序有两种:

var pro = new CSharpCodeProvider();
var assem = pro.CompileAssemblyFromFile(new CompilerParameters(), "path/to/bClass.cs", "path/to/aClass.cs");
// or
var assem = pro.CompileAssemblyFromFile(new CompilerParameters(), "path/to/aClass.cs", "path/to/bClass.cs");

aClass.cs:

public class aClass 
{
}

bClass.cs:

public class bClass 
{
   public aClass FieldName;
}