void BuildDefaultAssembly(List <string> files, CodeCompileUnit unit)
{
AssemblyBuilder abuilder = new AssemblyBuilder(Provider);
if (unit != null)
{
abuilder.AddCodeCompileUnit(unit);
}
CompilerParameters cp = ci.CreateDefaultCompilerParameters();
cp.OutputAssembly = baseAssemblyPath;
cp.GenerateExecutable = false;
cp.TreatWarningsAsErrors = true;
cp.IncludeDebugInformation = config.Debug;
foreach (string f in files)
{
cp.EmbeddedResources.Add(f);
}
CompilerResults results = abuilder.BuildAssembly(cp);
if (results == null)
{
return;
}
if (results.NativeCompilerReturnValue == 0)
{
mainAssembly = results.CompiledAssembly;
BuildManager.TopLevelAssemblies.Add(mainAssembly);
}
else
{
if (HttpContext.Current.IsCustomErrorEnabled)
{
throw new ApplicationException("An error occurred while compiling global resources.");
}
throw new CompilationException(null, results.Errors, null);
}
HttpRuntime.WritePreservationFile(mainAssembly, canonicAssemblyName);
HttpRuntime.EnableAssemblyMapping(true);
}