public static Assembly CreateAssembly(string name) { ICodeCompiler compiler = new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler(); string source = LoadSource(name); CompilerParameters options = new CompilerParameters(); options.GenerateExecutable = false; options.GenerateInMemory = false; options.OutputAssembly = name + ".dll"; options.ReferencedAssemblies.Add("MbUnit.Framework.dll"); CompilerResults results = compiler.CompileAssemblyFromSource(options, source); if (results.Errors.HasErrors) { CompilerAssert.DisplayErrors(results, Console.Out); } Assert.IsFalse(results.Errors.HasErrors); return(results.CompiledAssembly); }
private static string CreateAssembly(string assemblyPath) { ICodeCompiler compiler = new Microsoft.CSharp.CSharpCodeProvider().CreateCompiler(); string source = LoadSource(Path.GetFileNameWithoutExtension(assemblyPath)); CompilerParameters options = new CompilerParameters(); options.GenerateExecutable = false; options.GenerateInMemory = false; options.OutputAssembly = assemblyPath; options.ReferencedAssemblies.Add(Path.Combine(Path.GetDirectoryName(assemblyPath), "MbUnit.Framework.dll")); CompilerResults results = compiler.CompileAssemblyFromSource(options, source); if (results.Errors.HasErrors) { CompilerAssert.DisplayErrors(results, Console.Out); } Assert.IsFalse(results.Errors.HasErrors); return(results.PathToAssembly); }