private IEnumerable<ManifestItemWithContext> BuildCore(List<HostService> hostServices, DocumentBuildContext context, string versionName)
{
//preparation
PrepareBuild(context, hostServices);
Action<HostService> buildSaver = null;
Action<List<HostService>> loader = null;
Action updater = null;
if (ShouldTraceIncrementalInfo)
{
var incrementalContext = context.IncrementalBuildContext;
var lbv = incrementalContext.LastBuildVersionInfo;
var cbv = incrementalContext.CurrentBuildVersionInfo;
buildSaver = h => h.SaveIntermediateModel(incrementalContext);
loader = hs =>
{
UpdateHostServices(context.IncrementalBuildContext, hostServices);
if (lbv != null)
{
foreach (var h in hs)
{
foreach (var file in from pair in incrementalContext.GetModelLoadInfo(h)
where pair.Value == BuildPhase.PostBuild
select pair.Key)
{
lbv.BuildMessage.Replay(file);
}
}
}
Logger.UnregisterListener(cbv.BuildMessage.GetListener());
};
updater = () =>
{
incrementalContext.UpdateBuildVersionInfoPerDependencyGraph();
};
}
try
{
BuildCore(hostServices, context.MaxParallelism, buildSaver, loader, updater);
}
catch (BuildCacheException e)
{
var message = $"Build cache was corrupted, please try force rebuild `build --force` or clear the cache files in the path: {IntermediateFolder}. Detail error: {e.Message}.";
Logger.LogError(message);
throw new DocfxException(message, e);
}
// export manifest
return from h in hostServices
from m in ExportManifest(h, context)
select m;
}