diff --git a/src/Readme.txt b/src/Readme.txt
index bd5d4ea6..203cf75a 100644
--- a/src/Readme.txt
+++ b/src/Readme.txt
@@ -67,6 +67,10 @@ For further details take a look at LICENSE.txt.
CHANGELOG
+5.2.2.0
+
+ * New: #651 Added setting to add custom prefix to generated history files
+
5.2.1.0
* New: Added 'Crap Score' metric for Coberatura coverage files (contrbuted by @rikrak)
diff --git a/src/ReportGenerator.Core/Generator.cs b/src/ReportGenerator.Core/Generator.cs
index 8cd04343..aeb72050 100644
--- a/src/ReportGenerator.Core/Generator.cs
+++ b/src/ReportGenerator.Core/Generator.cs
@@ -328,7 +328,7 @@ public void GenerateReport(
if (historyStorage != null)
{
- new HistoryReportGenerator(historyStorage)
+ new HistoryReportGenerator(historyStorage, settings.HistoryFileNamePrefix)
.CreateReport(parserResult.Assemblies, executionTime, reportConfiguration.Tag);
}
diff --git a/src/ReportGenerator.Core/Reporting/History/HistoryReportGenerator.cs b/src/ReportGenerator.Core/Reporting/History/HistoryReportGenerator.cs
index 99a6c35c..d2639c42 100644
--- a/src/ReportGenerator.Core/Reporting/History/HistoryReportGenerator.cs
+++ b/src/ReportGenerator.Core/Reporting/History/HistoryReportGenerator.cs
@@ -28,13 +28,20 @@ internal class HistoryReportGenerator
///
private readonly IHistoryStorage historyStorage;
+ ///
+ /// Optional custom file prefix.
+ ///
+ private readonly string customfilePrefix;
+
///
/// Initializes a new instance of the class.
///
/// The history storage.
- internal HistoryReportGenerator(IHistoryStorage historyStorage)
+ /// Optional custom file prefix.
+ internal HistoryReportGenerator(IHistoryStorage historyStorage, string customfilePrefix)
{
this.historyStorage = historyStorage ?? throw new ArgumentNullException(nameof(historyStorage));
+ this.customfilePrefix = string.IsNullOrWhiteSpace(customfilePrefix) ? string.Empty : "_" + customfilePrefix;
}
///
@@ -86,7 +93,7 @@ internal void CreateReport(IEnumerable assemblies, DateTime executionT
}
var document = new XDocument(new XDeclaration("1.0", "UTF-8", "yes"), rootElement);
- string fileName = date + "_CoverageHistory.xml";
+ string fileName = date + this.customfilePrefix + "_CoverageHistory.xml";
try
{
using (var stream = new MemoryStream())
diff --git a/src/ReportGenerator.Core/Settings.cs b/src/ReportGenerator.Core/Settings.cs
index c3f6b2ec..9d6ab185 100644
--- a/src/ReportGenerator.Core/Settings.cs
+++ b/src/ReportGenerator.Core/Settings.cs
@@ -75,5 +75,10 @@ public int CachingDuringOfRemoteFilesInMinutes
/// Gets or sets the maximum decimal places for coverage quotas / percentages.
///
public int MaximumDecimalPlacesForCoverageQuotas { get; set; } = 1;
+
+ ///
+ /// Gets or sets the prefix for history files.
+ ///
+ public string HistoryFileNamePrefix { get; set; }
}
}
diff --git a/src/ReportGenerator.Core/appsettings.json b/src/ReportGenerator.Core/appsettings.json
index cd4d5eed..cd0fac04 100644
--- a/src/ReportGenerator.Core/appsettings.json
+++ b/src/ReportGenerator.Core/appsettings.json
@@ -18,6 +18,8 @@
"excludeTestProjects": false,
"createSubdirectoryForAllReportTypes": false,
"customHeadersForRemoteFiles": null,
- "defaultAssemblyName": "Default"
+ "defaultAssemblyName": "Default",
+ "maximumDecimalPlacesForCoverageQuotas": 1,
+ "historyFileNamePrefix": null
}
}
\ No newline at end of file