【发布时间】:2020-12-24 05:32:19
【问题描述】:
我最近看到使用 CSharpCodeProvider 在 .NET Core 5 中已被弃用。我想知道是否有一种聪明的方法可以将 多个文件 组合到一个 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)
【问题讨论】:
标签: c# .net-core compilation runtime roslyn