使用Rosyln将多个文件动态编译为程序集

问题描述

海耶!我最近发现.NET Core 5中不使用CSharpCodeProvider。我想知道是否存在一种聪明的方法来将多个文件组合到一个dll中,我可以使用Rosyln从中加载该文件。我讨厌必须坚持使用.Net Framework 4.7,因为这是我正在开发的程序的重要组成部分。

我的代码过去几乎就是这样

string Files[] = Directory.GetFiles("xxxxx/bin/Debug/net5.0/Scripts",".cs");
Parameters = new CompilerParameters(new string[1] {"xxxxx/bin/Debug/net5.0/Program.dll"},"xxxxx/bin/Debug/net5.0/Scripts/Output/Scripts.dll");
return new CSharpCodeProvider().CompileAssemblyFromFile(Parameters,Files).CompiledAssembly;

在Rosyln中最有效的方法是什么?

参考:https://github.com/dotnet/runtime/issues/18768#issuecomment-265381303 (PlatformNotSupportedException)

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)