public static void Report(ICakeContext context, ReportSettingsDelegate settingsDelegate) { try { var assemblyDirectory = AssemblyDirectory(Assembly.GetAssembly(typeof(StyleCopSettings))); var toolPath = context.File(assemblyDirectory).Path.GetDirectory(); var defaultStyleSheet = context.File(toolPath + "/StyleCopStyleSheet.xslt"); var settings = settingsDelegate(new StyleCopReportSettings()); context.Log.Information($"StyleCopReportSetting.HtmlReport: {settings.HtmlReportFile}"); context.Log.Information($"StyleCopReportSetting.ResultFiles: {settings.ResultFiles}"); // merge xml files var resultFile = MergeResultFile(context, settings.ResultFiles); var mergedResultsFile = context.File(settings.HtmlReportFile.GetDirectory() + context.File("/stylecop_merged.xml")); context.Log.Information($"Stylecop: Saving merged results xml file {mergedResultsFile.Path.FullPath}"); resultFile.Save(mergedResultsFile); // copy default resources to output folder context.CopyDirectory(context.Directory(toolPath + "/resources"), context.Directory(settings.HtmlReportFile.GetDirectory() + "/resources")); context.Log.Information($"Stylecop: Creating html report {settings.HtmlReportFile.FullPath}"); Transform(context, settings.HtmlReportFile.MakeAbsolute(context.Environment), mergedResultsFile.Path.MakeAbsolute(context.Environment), settings.StyleSheet ?? context.MakeAbsolute(defaultStyleSheet)); } catch (Exception e) { context.Log.Error(e.ToString()); } }
public static void StyleCopReport(this ICakeContext context, ReportSettingsDelegate settingsDelegate) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (settingsDelegate == null) { throw new ArgumentNullException(nameof(settingsDelegate)); } StyleCopRunner.Report(context, settingsDelegate); }