diff --git a/GitVersion.yml b/GitVersion.yml
index 9f8957b..71b10bb 100644
--- a/GitVersion.yml
+++ b/GitVersion.yml
@@ -1,5 +1,5 @@
assembly-versioning-scheme: Major
-next-version: 3.0
+next-version: 4.0
branches:
develop:
tag: beta
diff --git a/src/NServiceBus.Metrics.PerformanceCounters.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt b/src/NServiceBus.Metrics.PerformanceCounters.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt
index c251ccb..753518e 100644
--- a/src/NServiceBus.Metrics.PerformanceCounters.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt
+++ b/src/NServiceBus.Metrics.PerformanceCounters.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt
@@ -3,6 +3,9 @@
namespace NServiceBus.Metrics.PerformanceCounters
{
[System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.All)]
+ [System.ObsoleteAttribute("The NServiceBus.Metrics.PerformanceCounters.MsBuild package is deprecated. There " +
+ "is no longer any need to configure its output. To promote the script outside the" +
+ " build directory, use a post-build event. Will be removed in version 5.0.0.", true)]
public sealed class PerformanceCounterSettingsAttribute : System.Attribute
{
public PerformanceCounterSettingsAttribute() { }
diff --git a/src/NServiceBus.Metrics.PerformanceCounters.sln b/src/NServiceBus.Metrics.PerformanceCounters.sln
index e86d426..563fe62 100644
--- a/src/NServiceBus.Metrics.PerformanceCounters.sln
+++ b/src/NServiceBus.Metrics.PerformanceCounters.sln
@@ -9,8 +9,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.Metrics.Perform
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptBuilderTask", "ScriptBuilderTask\ScriptBuilderTask.csproj", "{08FD76CB-6988-485A-A535-B3129AF89C60}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScriptBuilderTask.Tests", "ScriptBuilderTask.Tests\ScriptBuilderTask.Tests.csproj", "{8174164E-52B8-4878-BFB0-34C81A31930E}"
-EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1B573EC5-07D6-4E25-9687-FB5A536B4FD9}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
@@ -35,10 +33,6 @@ Global
{08FD76CB-6988-485A-A535-B3129AF89C60}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08FD76CB-6988-485A-A535-B3129AF89C60}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08FD76CB-6988-485A-A535-B3129AF89C60}.Release|Any CPU.Build.0 = Release|Any CPU
- {8174164E-52B8-4878-BFB0-34C81A31930E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8174164E-52B8-4878-BFB0-34C81A31930E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8174164E-52B8-4878-BFB0-34C81A31930E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8174164E-52B8-4878-BFB0-34C81A31930E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/src/NServiceBus.Metrics.PerformanceCounters.sln.DotSettings b/src/NServiceBus.Metrics.PerformanceCounters.sln.DotSettings
index 611eecc..5bbdbe3 100644
--- a/src/NServiceBus.Metrics.PerformanceCounters.sln.DotSettings
+++ b/src/NServiceBus.Metrics.PerformanceCounters.sln.DotSettings
@@ -557,6 +557,9 @@ II.2.12 <HandlesEvent />
<Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
<Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" />
True
+ True
+ True
+ True
True
True
True
diff --git a/src/ScriptBuilderTask/CounterNameConventions.cs b/src/NServiceBus.Metrics.PerformanceCounters/CounterNameConventions.cs
similarity index 100%
rename from src/ScriptBuilderTask/CounterNameConventions.cs
rename to src/NServiceBus.Metrics.PerformanceCounters/CounterNameConventions.cs
diff --git a/src/NServiceBus.Metrics.PerformanceCounters/NServiceBus.Metrics.PerformanceCounters.csproj b/src/NServiceBus.Metrics.PerformanceCounters/NServiceBus.Metrics.PerformanceCounters.csproj
index f4ddb28..0a43fb8 100644
--- a/src/NServiceBus.Metrics.PerformanceCounters/NServiceBus.Metrics.PerformanceCounters.csproj
+++ b/src/NServiceBus.Metrics.PerformanceCounters/NServiceBus.Metrics.PerformanceCounters.csproj
@@ -4,10 +4,16 @@
net452
true
$(SolutionDir)NServiceBus.snk
- ..\..\binaries\
Enables access to performance counters
+
+ $(NoWarn);NU5110;NU5111
+
+
+
+
+
@@ -16,8 +22,4 @@
-
-
-
-
\ No newline at end of file
diff --git a/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCounterSettingsAttribute.cs b/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCounterSettingsAttribute.cs
index 8ef822b..0c31399 100644
--- a/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCounterSettingsAttribute.cs
+++ b/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCounterSettingsAttribute.cs
@@ -6,6 +6,8 @@
/// Configuration options that are evaluated at compile time.
///
[AttributeUsage(AttributeTargets.Assembly)]
+ [ObsoleteEx(Message = "The NServiceBus.Metrics.PerformanceCounters.MsBuild package is deprecated. There is no longer any need to configure its output. To promote the script outside the build directory, use a post-build event.",
+ RemoveInVersion = "5.0", TreatAsErrorFromVersion = "4.0")]
public sealed class PerformanceCounterSettingsAttribute : Attribute
{
///
diff --git a/src/ScriptBuilderTask.Tests/ApprovalFiles/PowershellCodeGenerationTests.Generates.approved.txt b/src/NServiceBus.Metrics.PerformanceCounters/Scripts/CreateNSBPerfCounters.ps1
similarity index 99%
rename from src/ScriptBuilderTask.Tests/ApprovalFiles/PowershellCodeGenerationTests.Generates.approved.txt
rename to src/NServiceBus.Metrics.PerformanceCounters/Scripts/CreateNSBPerfCounters.ps1
index 53d1d67..9c0c67b 100644
--- a/src/ScriptBuilderTask.Tests/ApprovalFiles/PowershellCodeGenerationTests.Generates.approved.txt
+++ b/src/NServiceBus.Metrics.PerformanceCounters/Scripts/CreateNSBPerfCounters.ps1
@@ -1,7 +1,7 @@
#requires -RunAsAdministrator
Function InstallNSBPerfCounters {
-
+
$category = @{Name="NServiceBus"; Description="NServiceBus statistics"}
$counters = New-Object System.Diagnostics.CounterCreationDataCollection
$counters.AddRange(@(
diff --git a/src/NServiceBus.Metrics.PerformanceCounters/Scripts/NServiceBus.Metrics.PerformanceCounters.props b/src/NServiceBus.Metrics.PerformanceCounters/Scripts/NServiceBus.Metrics.PerformanceCounters.props
new file mode 100644
index 0000000..4e09e3a
--- /dev/null
+++ b/src/NServiceBus.Metrics.PerformanceCounters/Scripts/NServiceBus.Metrics.PerformanceCounters.props
@@ -0,0 +1,8 @@
+
+
+
+ PreserveNewest
+ NServiceBus.Metrics.PerformanceCounters\%(Filename)%(Extension)
+
+
+
\ No newline at end of file
diff --git a/src/ScriptBuilder/CSharpCounterWriter.cs b/src/ScriptBuilder/CSharpCounterWriter.cs
deleted file mode 100644
index bc84923..0000000
--- a/src/ScriptBuilder/CSharpCounterWriter.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
-
- static class CSharpCounterWriter
- {
- public static void WriteCode(string scriptPath, IEnumerable timers, IEnumerable meters, Dictionary legacyInstanceNameMap)
- {
- var outputPath = Path.Combine(scriptPath, "Counters.g.cs");
- using (var streamWriter = File.CreateText(outputPath))
- {
- var stringBuilder = new StringBuilder();
-
- var slaCounterDefinition = @"new CounterCreationData(""SLA violation countdown"", ""Seconds until the SLA for this endpoint is breached."", PerformanceCounterType.NumberOfItems32),";
- stringBuilder.AppendLine(slaCounterDefinition.PadLeft(slaCounterDefinition.Length + 8));
-
- foreach (var timer in timers)
- {
- var timerDefinition = $@"new CounterCreationData(""{timer.Name}"", ""{timer.Description}"", PerformanceCounterType.NumberOfItems32),";
- stringBuilder.AppendLine(timerDefinition.PadLeft(timerDefinition.Length + 8));
- }
-
- foreach (var meter in meters)
- {
- string instanceName;
- legacyInstanceNameMap.TryGetValue(meter.Name, out instanceName);
-
- var meterDefinition = $@"new CounterCreationData(""{instanceName ?? meter.Name}"", ""{meter.Description}"", PerformanceCounterType.RateOfCountsPerSecond32),";
- stringBuilder.AppendLine(meterDefinition.PadLeft(meterDefinition.Length + 8));
- }
-
- streamWriter.Write(Template, stringBuilder);
- }
- }
-
- const string Template = @"using System;
-using System.Diagnostics;
-using System.Security;
-using System.Runtime.CompilerServices;
-
-[CompilerGenerated]
-public static class CounterCreator
-{{
- public static void Create()
- {{
- var counterCreationCollection = new CounterCreationDataCollection(Counters);
- try
- {{
- var categoryName = ""NServiceBus"";
-
- if (PerformanceCounterCategory.Exists(categoryName))
- {{
- foreach (CounterCreationData counter in counterCreationCollection)
- {{
- if (!PerformanceCounterCategory.CounterExists(counter.CounterName, categoryName))
- {{
- PerformanceCounterCategory.Delete(categoryName);
- break;
- }}
- }}
- }}
-
- if (PerformanceCounterCategory.Exists(categoryName) == false)
- {{
- PerformanceCounterCategory.Create(
- categoryName: categoryName,
- categoryHelp: ""NServiceBus statistics"",
- categoryType: PerformanceCounterCategoryType.MultiInstance,
- counterData: counterCreationCollection);
- }}
-
- PerformanceCounter.CloseSharedResources();
- }}
- catch (Exception ex) when (ex is SecurityException || ex is UnauthorizedAccessException)
- {{
- throw new Exception(""Execution requires elevated permissions"", ex);
- }}
- }}
-
- static CounterCreationData[] Counters = new CounterCreationData[]
- {{
-{0}
- }};
-}}";
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilder/PowerShellCounterWriter.cs b/src/ScriptBuilder/PowerShellCounterWriter.cs
deleted file mode 100644
index 7821f1a..0000000
--- a/src/ScriptBuilder/PowerShellCounterWriter.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
-
- static class PowerShellCounterWriter
- {
- public static void WriteScript(string scriptPath, IEnumerable timers, IEnumerable meters, Dictionary legacyInstanceNameMap)
- {
- var outputPath = Path.Combine(scriptPath, "CreateNSBPerfCounters.ps1");
- using (var streamWriter = File.CreateText(outputPath))
- {
- var stringBuilder = new StringBuilder();
-
- var slaCounterDefinition = @"New-Object System.Diagnostics.CounterCreationData ""SLA violation countdown"", ""Seconds until the SLA for this endpoint is breached."", NumberOfItems32";
- stringBuilder.AppendLine(slaCounterDefinition.PadLeft(slaCounterDefinition.Length + 8));
-
- foreach (var timer in timers)
- {
- var timerDefinition = $@"New-Object System.Diagnostics.CounterCreationData ""{timer.Name}"", ""{timer.Description}"", NumberOfItems32";
- stringBuilder.AppendLine(timerDefinition.PadLeft(timerDefinition.Length + 8));
- }
-
- foreach (var meter in meters)
- {
- string instanceName;
- legacyInstanceNameMap.TryGetValue(meter.Name, out instanceName);
-
- var meterDefinition = $@"New-Object System.Diagnostics.CounterCreationData ""{instanceName ?? meter.Name}"", ""{meter.Description}"", RateOfCountsPerSecond32";
- stringBuilder.AppendLine(meterDefinition.PadLeft(meterDefinition.Length + 8));
- }
-
- streamWriter.Write(Template, stringBuilder);
- }
- }
-
- const string Template = @"#requires -RunAsAdministrator
-Function InstallNSBPerfCounters {{
-
- $category = @{{Name=""NServiceBus""; Description=""NServiceBus statistics""}}
- $counters = New-Object System.Diagnostics.CounterCreationDataCollection
- $counters.AddRange(@(
-{0}
- ))
-
- if ([System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) {{
- foreach($counter in $counters){{
- $exists = [System.Diagnostics.PerformanceCounterCategory]::CounterExists($counter.CounterName, $category.Name)
- if (!$exists){{
- Write-Host ""One or more counters are missing.The performance counter category will be recreated""
- [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name)
-
- break
- }}
- }}
- }}
-
- if (![System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) {{
- Write-Host ""Creating the performance counter category""
- [void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters)
- }}
- else {{
- Write-Host ""No performance counters have to be created""
- }}
-
- [System.Diagnostics.PerformanceCounter]::CloseSharedResources()
-}}
-InstallNSBPerfCounters";
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask.Tests/ApprovalFiles/CSharpCodeGenerationTests.Generates.approved.txt b/src/ScriptBuilderTask.Tests/ApprovalFiles/CSharpCodeGenerationTests.Generates.approved.txt
deleted file mode 100644
index e22dc50..0000000
--- a/src/ScriptBuilderTask.Tests/ApprovalFiles/CSharpCodeGenerationTests.Generates.approved.txt
+++ /dev/null
@@ -1,60 +0,0 @@
-using System;
-using System.Diagnostics;
-using System.Security;
-using System.Runtime.CompilerServices;
-
-[CompilerGenerated]
-public static class CounterCreator
-{
- public static void Create()
- {
- var counterCreationCollection = new CounterCreationDataCollection(Counters);
- try
- {
- var categoryName = "NServiceBus";
-
- if (PerformanceCounterCategory.Exists(categoryName))
- {
- foreach (CounterCreationData counter in counterCreationCollection)
- {
- if (!PerformanceCounterCategory.CounterExists(counter.CounterName, categoryName))
- {
- PerformanceCounterCategory.Delete(categoryName);
- break;
- }
- }
- }
-
- if (PerformanceCounterCategory.Exists(categoryName) == false)
- {
- PerformanceCounterCategory.Create(
- categoryName: categoryName,
- categoryHelp: "NServiceBus statistics",
- categoryType: PerformanceCounterCategoryType.MultiInstance,
- counterData: counterCreationCollection);
- }
-
- PerformanceCounter.CloseSharedResources();
- }
- catch (Exception ex) when(ex is SecurityException || ex is UnauthorizedAccessException)
- {
- throw new Exception("Execution requires elevated permissions", ex);
- }
- }
-
- static CounterCreationData[] Counters = new CounterCreationData[]
- {
- new CounterCreationData("SLA violation countdown", "Seconds until the SLA for this endpoint is breached.", PerformanceCounterType.NumberOfItems32),
- new CounterCreationData("Critical Time Average", "The time it took from sending to processing the message.", PerformanceCounterType.AverageTimer32),
- new CounterCreationData("Critical Time AverageBase", "The time it took from sending to processing the message.", PerformanceCounterType.AverageBase),
- new CounterCreationData("Critical Time", "The time it took from sending to processing the message.", PerformanceCounterType.NumberOfItems32),
- new CounterCreationData("Processing Time Average", "The time it took to successfully process a message.", PerformanceCounterType.AverageTimer32),
- new CounterCreationData("Processing Time AverageBase", "The time it took to successfully process a message.", PerformanceCounterType.AverageBase),
- new CounterCreationData("Processing Time", "The time it took to successfully process a message.", PerformanceCounterType.NumberOfItems32),
- new CounterCreationData("# of msgs failures / sec", "The current number of failed processed messages by the transport per second.", PerformanceCounterType.RateOfCountsPerSecond32),
- new CounterCreationData("# of msgs successfully processed / sec", "The current number of messages processed successfully by the transport per second.", PerformanceCounterType.RateOfCountsPerSecond32),
- new CounterCreationData("# of msgs pulled from the input queue /sec", "The current number of messages pulled from the input queue by the transport per second.", PerformanceCounterType.RateOfCountsPerSecond32),
- new CounterCreationData("Retries", "A message has been scheduled for retry (FLR or SLR)", PerformanceCounterType.RateOfCountsPerSecond32),
-
- };
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask.Tests/CSharpCodeGenerationTests.cs b/src/ScriptBuilderTask.Tests/CSharpCodeGenerationTests.cs
deleted file mode 100644
index 948e3a9..0000000
--- a/src/ScriptBuilderTask.Tests/CSharpCodeGenerationTests.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-namespace ScriptBuilderTask.Tests
-{
- using System;
- using System.IO;
- using System.Linq;
- using NServiceBus.Metrics.PerformanceCounters;
- using NUnit.Framework;
- using Particular.Approvals;
-
- [TestFixture]
- public class CSharpCodeGenerationTests
- {
- InnerTask task;
- string tempPath;
-
- [SetUp]
- public void SetUp()
- {
- var testDirectory = TestContext.CurrentContext.TestDirectory;
- tempPath = testDirectory;
- var assemblyPath = Path.Combine(testDirectory, "ScriptBuilderTask.Tests.dll");
- var metricsAssemblyPath = Path.Combine(testDirectory, "NServiceBus.Metrics.dll");
- var intermediatePath = Path.Combine(tempPath, "IntermediatePath");
- var promotePath = Path.Combine(tempPath, "PromotePath");
- Directory.CreateDirectory(tempPath);
- Directory.CreateDirectory(intermediatePath);
-
- Action logError = (error, s1) => { throw new Exception(error); };
- task = new InnerTask(assemblyPath, metricsAssemblyPath, intermediatePath, "TheProjectDir", promotePath, logError);
- }
-
- [Test]
- public void Generates()
- {
- task.Execute();
-
- var cSharpCode = Directory.EnumerateFiles(tempPath, "*.g.cs", SearchOption.AllDirectories).Single();
- var content = File.ReadAllText(cSharpCode);
-
- Approver.Verify(content);
- }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.cs b/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.cs
deleted file mode 100644
index c25513b..0000000
--- a/src/ScriptBuilderTask.Tests/PowershellCodeGenerationTests.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-namespace ScriptBuilderTask.Tests
-{
- using System;
- using System.IO;
- using System.Linq;
- using NServiceBus.Metrics.PerformanceCounters;
- using NUnit.Framework;
- using Particular.Approvals;
-
- [TestFixture]
- public class PowershellCodeGenerationTests
- {
- InnerTask task;
- string tempPath;
-
- [SetUp]
- public void SetUp()
- {
- var testDirectory = TestContext.CurrentContext.TestDirectory;
- tempPath = testDirectory;
- var assemblyPath = Path.Combine(testDirectory, "ScriptBuilderTask.Tests.dll");
- var metricsAssemblyPath = Path.Combine(testDirectory, "NServiceBus.Metrics.dll");
- var intermediatePath = Path.Combine(tempPath, "IntermediatePath");
- var promotePath = Path.Combine(tempPath, "PromotePath");
- Directory.CreateDirectory(tempPath);
- Directory.CreateDirectory(intermediatePath);
-
- Action logError = (error, s1) => { throw new Exception(error); };
- task = new InnerTask(assemblyPath, metricsAssemblyPath, intermediatePath, "TheProjectDir", promotePath, logError);
- }
-
- [Test]
- public void Generates()
- {
- task.Execute();
-
- var powershell = Directory.EnumerateFiles(tempPath, "*.ps1", SearchOption.AllDirectories).Single();
- var content = File.ReadAllText(powershell);
-
- Approver.Verify(content);
- }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask.Tests/ScriptBuilderTask.Tests.csproj b/src/ScriptBuilderTask.Tests/ScriptBuilderTask.Tests.csproj
deleted file mode 100644
index 659506c..0000000
--- a/src/ScriptBuilderTask.Tests/ScriptBuilderTask.Tests.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- net452
- true
- $(SolutionDir)NServiceBus.snk
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/ScriptBuilderTask/BuildLogger.cs b/src/ScriptBuilderTask/BuildLogger.cs
deleted file mode 100644
index 054d28d..0000000
--- a/src/ScriptBuilderTask/BuildLogger.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using Microsoft.Build.Framework;
-
- class BuildLogger
- {
- public BuildLogger(IBuildEngine buildEngine)
- {
- this.buildEngine = buildEngine;
- }
-
- public void LogInfo(string message)
- {
- buildEngine.LogMessageEvent(new BuildMessageEventArgs(PrependMessage(message), "", "PerformanceCounterScriptTask", MessageImportance.Normal));
- }
-
- static string PrependMessage(string message)
- {
- return $"PerformanceCounterScriptTask: {message}";
- }
-
- public void LogError(string message, string file = null)
- {
- ErrorOccurred = true;
- buildEngine.LogErrorEvent(new BuildErrorEventArgs("", "", file, 0, 0, 0, 0, PrependMessage(message), "", "PerformanceCounterScriptTask"));
- }
-
- public bool ErrorOccurred;
-
- IBuildEngine buildEngine;
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/BuildScriptVariant.cs b/src/ScriptBuilderTask/BuildScriptVariant.cs
deleted file mode 100644
index 3f5fb8c..0000000
--- a/src/ScriptBuilderTask/BuildScriptVariant.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- public enum BuildScriptVariant
- {
- CSharp,
- Powershell
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/CSharpCounterWriter.cs b/src/ScriptBuilderTask/CSharpCounterWriter.cs
deleted file mode 100644
index 22d2459..0000000
--- a/src/ScriptBuilderTask/CSharpCounterWriter.cs
+++ /dev/null
@@ -1,99 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
-
- static class CSharpCounterWriter
- {
- public static void WriteCode(string scriptPath, IEnumerable durations, IEnumerable signals, Dictionary legacyInstanceNameMap)
- {
- var outputPath = Path.Combine(scriptPath, "Counters.g.cs");
- using (var streamWriter = File.CreateText(outputPath))
- {
- var stringBuilder = new StringBuilder();
-
- var slaCounterDefinition = @"new CounterCreationData(""SLA violation countdown"", ""Seconds until the SLA for this endpoint is breached."", PerformanceCounterType.NumberOfItems32),";
- stringBuilder.AppendLine(slaCounterDefinition.PadLeft(slaCounterDefinition.Length + 8));
-
- foreach (var duration in durations)
- {
- var averageTimerName = duration.Name.GetAverageTimerCounterName();
- var averageTimerBase = duration.Name.GetAverageTimerBaseCounterName();
-
- var durationAverageDefinition = $@"new CounterCreationData(""{averageTimerName}"", ""{duration.Description}"", PerformanceCounterType.AverageTimer32),";
- stringBuilder.AppendLine(durationAverageDefinition.PadLeft(durationAverageDefinition.Length + 8));
-
- var durationBaseDefinition = $@"new CounterCreationData(""{averageTimerBase}"", ""{duration.Description}"", PerformanceCounterType.AverageBase),";
- stringBuilder.AppendLine(durationBaseDefinition.PadLeft(durationBaseDefinition.Length + 8));
-
- if (duration.Name == CounterNameConventions.ProcessingTime || duration.Name == CounterNameConventions.CriticalTime)
- {
- var legacyTimerDefinition = $@"new CounterCreationData(""{duration.Name}"", ""{duration.Description}"", PerformanceCounterType.NumberOfItems32),";
- stringBuilder.AppendLine(legacyTimerDefinition.PadLeft(legacyTimerDefinition.Length + 8));
- }
- }
-
- foreach (var signal in signals)
- {
- legacyInstanceNameMap.TryGetValue(signal.Name, out var instanceName);
-
- var signalDefinition = $@"new CounterCreationData(""{instanceName ?? signal.Name}"", ""{signal.Description}"", PerformanceCounterType.RateOfCountsPerSecond32),";
- stringBuilder.AppendLine(signalDefinition.PadLeft(signalDefinition.Length + 8));
- }
-
- streamWriter.Write(Template, stringBuilder);
- }
- }
-
- const string Template = @"using System;
-using System.Diagnostics;
-using System.Security;
-using System.Runtime.CompilerServices;
-
-[CompilerGenerated]
-public static class CounterCreator
-{{
- public static void Create()
- {{
- var counterCreationCollection = new CounterCreationDataCollection(Counters);
- try
- {{
- var categoryName = ""NServiceBus"";
-
- if (PerformanceCounterCategory.Exists(categoryName))
- {{
- foreach (CounterCreationData counter in counterCreationCollection)
- {{
- if (!PerformanceCounterCategory.CounterExists(counter.CounterName, categoryName))
- {{
- PerformanceCounterCategory.Delete(categoryName);
- break;
- }}
- }}
- }}
-
- if (PerformanceCounterCategory.Exists(categoryName) == false)
- {{
- PerformanceCounterCategory.Create(
- categoryName: categoryName,
- categoryHelp: ""NServiceBus statistics"",
- categoryType: PerformanceCounterCategoryType.MultiInstance,
- counterData: counterCreationCollection);
- }}
-
- PerformanceCounter.CloseSharedResources();
- }}
- catch (Exception ex) when(ex is SecurityException || ex is UnauthorizedAccessException)
- {{
- throw new Exception(""Execution requires elevated permissions"", ex);
- }}
- }}
-
- static CounterCreationData[] Counters = new CounterCreationData[]
- {{
-{0}
- }};
-}}";
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/CecilExtensions.cs b/src/ScriptBuilderTask/CecilExtensions.cs
deleted file mode 100644
index 01eebd2..0000000
--- a/src/ScriptBuilderTask/CecilExtensions.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System.Collections.Generic;
- using System.Linq;
- using Mono.Cecil;
-
- static class CecilExtensions
- {
- public static CustomAttribute GetSingleAttribute(this FieldDefinition field, string attributeName)
- {
- return field.CustomAttributes.SingleOrDefault(x => x.AttributeType.FullName == attributeName);
- }
-
- public static MethodDefinition SingleConstructor(this TypeDefinition type)
- {
- return type.Methods.Single(method => method.IsConstructor && !method.IsStatic);
- }
- public static int ParameterIndex(this MethodDefinition method, string name)
- {
- return method.Parameters.Single(x=>x.Name == name).Index;
- }
-
- public static T ParameterValue(this CustomAttribute attribute, string name)
- {
- var constructor = attribute.AttributeType.Resolve().SingleConstructor();
- return (T)attribute.ConstructorArguments[constructor.ParameterIndex(name)].Value;
- }
-
- public static string GetStringProperty(this CustomAttribute attribute, string name)
- {
- return (string)attribute.Properties
- .SingleOrDefault(argument => argument.Name == name)
- .Argument.Value;
- }
-
- public static bool GetBoolProperty(this CustomAttribute attribute, string name)
- {
- var value = attribute.Properties
- .SingleOrDefault(argument => argument.Name == name)
- .Argument.Value;
- return value != null && (bool)value;
- }
-
- public static IEnumerable AllClasses(this ModuleDefinition module)
- {
- return module.GetTypes()
- .Where(x => x.IsClass);
- }
-
-
- public static string GetFileName(this TypeDefinition type)
- {
- foreach (var method in type.Methods)
- {
- var debugInformation = method.DebugInformation;
- if (debugInformation == null)
- {
- continue;
- }
- if (!debugInformation.HasSequencePoints != true)
- {
- continue;
- }
- var body = method.Body;
- if (body?.Instructions == null)
- {
- continue;
- }
- foreach (var instruction in body.Instructions)
- {
- var point = debugInformation.GetSequencePoint(instruction);
- if (point?.Document?.Url == null)
- {
- continue;
- }
- return point.Document.Url;
- }
- }
- return null;
- }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/CounterWriter.cs b/src/ScriptBuilderTask/CounterWriter.cs
deleted file mode 100644
index d3bdab2..0000000
--- a/src/ScriptBuilderTask/CounterWriter.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System;
- using System.Collections.Generic;
- using Mono.Cecil;
-
- public static class CounterWriter
- {
- public static void WriteScript(string scriptPath, BuildScriptVariant variant, ModuleDefinition module, Action logError)
- {
- var timers = AllDurationsDefinitionReader.GetDurations(module, (exception, type) =>
- {
- logError($"Error in '{type.FullName}'. Error:{exception.Message}", type.GetFileName());
- });
-
- var meters = AllSignalsDefinitionReader.GetSignals(module, (exception, type) =>
- {
- logError($"Error in '{type.FullName}'. Error:{exception.Message}", type.GetFileName());
- });
-
- switch (variant)
- {
- case BuildScriptVariant.CSharp:
- CSharpCounterWriter.WriteCode(scriptPath, timers, meters, legacyInstanceNameMap);
- break;
- case BuildScriptVariant.Powershell:
- PowerShellCounterWriter.WriteScript(scriptPath, timers, meters, legacyInstanceNameMap);
- break;
- default:
- throw new ArgumentOutOfRangeException(nameof(variant), variant, null);
- }
- }
-
- static Dictionary legacyInstanceNameMap = new Dictionary
- {
- {"# of message failures / sec", "# of msgs failures / sec"},
- {"# of messages pulled from the input queue / sec", "# of msgs pulled from the input queue /sec"},
- {"# of messages successfully processed / sec", "# of msgs successfully processed / sec"}
- };
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/DirectoryExtensions.cs b/src/ScriptBuilderTask/DirectoryExtensions.cs
deleted file mode 100644
index 38d14db..0000000
--- a/src/ScriptBuilderTask/DirectoryExtensions.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System.IO;
-
- static class DirectoryExtensions
- {
- public static void Delete(string path)
- {
- if (!Directory.Exists(path))
- {
- return;
- }
- Directory.Delete(path, true);
- }
-
- public static void DuplicateDirectory(string source, string destination)
- {
- foreach (var dirPath in Directory.GetDirectories(source, "*", SearchOption.AllDirectories))
- {
- Directory.CreateDirectory(dirPath.Replace(source, destination));
- }
-
- foreach (var newPath in Directory.GetFiles(source, "*.*", SearchOption.AllDirectories))
- {
- File.Copy(newPath, newPath.Replace(source, destination), true);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/Durations/AllDurationsDefinitionReader.cs b/src/ScriptBuilderTask/Durations/AllDurationsDefinitionReader.cs
deleted file mode 100644
index 6220f5a..0000000
--- a/src/ScriptBuilderTask/Durations/AllDurationsDefinitionReader.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System;
- using System.Collections.Generic;
- using Mono.Cecil;
-
- static class AllDurationsDefinitionReader
- {
- public static IEnumerable GetDurations(ModuleDefinition module, Action logError)
- {
- var timerDefinitions = new List();
- foreach (var type in module.AllClasses())
- {
- try
- {
- if (DurationDefinitionReader.TryGetDurationDefinition(type, out var definition))
- {
- timerDefinitions.AddRange(definition);
- }
- }
- catch (ErrorsException exception)
- {
- logError(exception, type);
- }
- }
- return timerDefinitions;
- }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/Durations/DurationDefinition.cs b/src/ScriptBuilderTask/Durations/DurationDefinition.cs
deleted file mode 100644
index 86ee1df..0000000
--- a/src/ScriptBuilderTask/Durations/DurationDefinition.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- class DurationDefinition
- {
- public DurationDefinition(string name, string description)
- {
- Name = name;
- Description = description;
- }
-
- public readonly string Description;
-
- public readonly string Name;
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/Durations/DurationDefinitionReader.cs b/src/ScriptBuilderTask/Durations/DurationDefinitionReader.cs
deleted file mode 100644
index 5a38e35..0000000
--- a/src/ScriptBuilderTask/Durations/DurationDefinitionReader.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System.Collections.Generic;
- using System.Linq;
- using Mono.Cecil;
-
- static class DurationDefinitionReader
- {
- public static bool TryGetDurationDefinition(TypeDefinition type, out List definitions)
- {
- definitions = new List();
- if (type.BaseType != null && type.BaseType.FullName == "DurationProbeBuilder")
- {
- var attributes = type.CustomAttributes.Where(a => a.AttributeType.FullName == "ProbePropertiesAttribute");
-
- foreach (var attribute in attributes)
- {
- var name = attribute.ParameterValue("name");
- var description = attribute.ParameterValue("description");
-
- definitions.Add(new DurationDefinition(name, description));
- }
- }
- return definitions.Count > 0;
- }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/ErrorsException.cs b/src/ScriptBuilderTask/ErrorsException.cs
deleted file mode 100644
index 4463714..0000000
--- a/src/ScriptBuilderTask/ErrorsException.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System;
-
- public class ErrorsException : Exception
- {
- public ErrorsException(string message) : base(message)
- {
- }
-
- public string FileName { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/ExceptionExtensions.cs b/src/ScriptBuilderTask/ExceptionExtensions.cs
deleted file mode 100644
index de0bcf6..0000000
--- a/src/ScriptBuilderTask/ExceptionExtensions.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System;
- using System.Text;
-
- static class ExceptionExtensions
- {
- public static string ToFriendlyString(this Exception exception)
- {
- var stringBuilder = new StringBuilder();
- stringBuilder.Append("An unhandled exception occurred:");
- stringBuilder.Append(Environment.NewLine);
- stringBuilder.Append("Exception:");
- stringBuilder.Append(Environment.NewLine);
- while (exception != null)
- {
- stringBuilder.Append(exception.Message);
- stringBuilder.Append(Environment.NewLine);
-
- foreach (var i in exception.Data)
- {
- stringBuilder.Append("Data :");
- stringBuilder.Append(i);
- stringBuilder.Append(Environment.NewLine);
- }
-
- if (exception.StackTrace != null)
- {
- stringBuilder.Append("StackTrace:");
- stringBuilder.Append(Environment.NewLine);
- stringBuilder.Append(exception.StackTrace);
- stringBuilder.Append(Environment.NewLine);
- }
-
- if (exception.Source != null)
- {
- stringBuilder.Append("Source:");
- stringBuilder.Append(Environment.NewLine);
- stringBuilder.Append(exception.Source);
- stringBuilder.Append(Environment.NewLine);
- }
-
- exception = exception.InnerException;
- }
-
- return stringBuilder.ToString();
- }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/InnerTask.cs b/src/ScriptBuilderTask/InnerTask.cs
deleted file mode 100644
index 62e83aa..0000000
--- a/src/ScriptBuilderTask/InnerTask.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System;
- using System.IO;
- using Mono.Cecil;
-
- public class InnerTask
- {
- public InnerTask(string assemblyPath, string metricsAssemblyPath, string intermediateDirectory, string projectDirectory, string solutionDirectory, Action logError)
- {
- this.metricsAssemblyPath = metricsAssemblyPath;
- this.assemblyPath = assemblyPath;
- this.intermediateDirectory = intermediateDirectory;
- this.projectDirectory = projectDirectory;
- this.solutionDirectory = solutionDirectory;
- this.logError = logError;
- }
-
- public void Execute()
- {
- var scriptPath = Path.Combine(intermediateDirectory, "NServiceBus.Metrics.PerformanceCounters");
- DirectoryExtensions.Delete(scriptPath);
- Directory.CreateDirectory(scriptPath);
-
- var assemblyModuleDefinition = ModuleDefinition.ReadModule(assemblyPath, new ReaderParameters(ReadingMode.Deferred));
- var metricsAssemblyModuleDefinition = ModuleDefinition.ReadModule(metricsAssemblyPath, new ReaderParameters(ReadingMode.Deferred));
-
- foreach (var variant in ScriptVariantReader.Read(assemblyModuleDefinition))
- {
- var variantPath = Path.Combine(scriptPath, variant.ToString());
- Directory.CreateDirectory(variantPath);
- CounterWriter.WriteScript(variantPath, variant, metricsAssemblyModuleDefinition, logError);
- }
-
- PromoteFiles(assemblyModuleDefinition, scriptPath);
- }
-
- void PromoteFiles(ModuleDefinition moduleDefinition, string scriptPath)
- {
- if (!ScriptPromotionPathReader.TryRead(moduleDefinition, out var customPath))
- {
- return;
- }
- var replicationPath = customPath
- .Replace("$(ProjectDir)", projectDirectory)
- .Replace("$(SolutionDir)", solutionDirectory);
- try
- {
- DirectoryExtensions.Delete(replicationPath);
- DirectoryExtensions.DuplicateDirectory(scriptPath, replicationPath);
- }
- catch (Exception exception)
- {
- throw new ErrorsException($"Failed to promote scripts to '{replicationPath}'. Error: {exception.Message}");
- }
- }
-
- string assemblyPath;
- string intermediateDirectory;
- string projectDirectory;
- string solutionDirectory;
- Action logError;
- string metricsAssemblyPath;
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/NServiceBus.Metrics.PerformanceCounters.MsBuild.nuspec b/src/ScriptBuilderTask/NServiceBus.Metrics.PerformanceCounters.MsBuild.nuspec
index b7fd5ae..cbd192c 100644
--- a/src/ScriptBuilderTask/NServiceBus.Metrics.PerformanceCounters.MsBuild.nuspec
+++ b/src/ScriptBuilderTask/NServiceBus.Metrics.PerformanceCounters.MsBuild.nuspec
@@ -18,8 +18,6 @@
-
-
diff --git a/src/ScriptBuilderTask/NServiceBus.Metrics.PerformanceCounters.MsBuild.targets b/src/ScriptBuilderTask/NServiceBus.Metrics.PerformanceCounters.MsBuild.targets
index 8bf8673..3e60d3f 100644
--- a/src/ScriptBuilderTask/NServiceBus.Metrics.PerformanceCounters.MsBuild.targets
+++ b/src/ScriptBuilderTask/NServiceBus.Metrics.PerformanceCounters.MsBuild.targets
@@ -1,57 +1,7 @@
-
-
-
-
-
- $(MSBuildThisFileDirectory)..\netstandard\NServiceBus.Metrics.PerformanceCounters.Task.dll
-
-
-
-
- $(MSBuildThisFileDirectory)..\netclassic\NServiceBus.Metrics.PerformanceCounters.Task.dll
-
-
-
+
-
-
-
-
- $(ProjectDir)$(IntermediateOutputPath)NServiceBus.Metrics.PerformanceCounters\
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/PowerShellCounterWriter.cs b/src/ScriptBuilderTask/PowerShellCounterWriter.cs
deleted file mode 100644
index 461e338..0000000
--- a/src/ScriptBuilderTask/PowerShellCounterWriter.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System.Collections.Generic;
- using System.IO;
- using System.Text;
-
- static class PowerShellCounterWriter
- {
- public static void WriteScript(string scriptPath, IEnumerable durations, IEnumerable signals, Dictionary legacyInstanceNameMap)
- {
- var outputPath = Path.Combine(scriptPath, "CreateNSBPerfCounters.ps1");
- using (var streamWriter = File.CreateText(outputPath))
- {
- var stringBuilder = new StringBuilder();
-
- var slaCounterDefinition = @"New-Object System.Diagnostics.CounterCreationData ""SLA violation countdown"", ""Seconds until the SLA for this endpoint is breached."", NumberOfItems32";
- stringBuilder.AppendLine(slaCounterDefinition.PadLeft(slaCounterDefinition.Length + 8));
-
- foreach (var duration in durations)
- {
- var averageTimerName = duration.Name.GetAverageTimerCounterName();
- var averageTimerBase = duration.Name.GetAverageTimerBaseCounterName();
-
- var durationAverageDefinition = $@"New-Object System.Diagnostics.CounterCreationData ""{averageTimerName}"", ""{duration.Description}"", AverageTimer32";
- stringBuilder.AppendLine(durationAverageDefinition.PadLeft(durationAverageDefinition.Length + 8));
-
- var durationBaseDefinition = $@"New-Object System.Diagnostics.CounterCreationData ""{averageTimerBase}"", ""{duration.Description}"", AverageBase";
- stringBuilder.AppendLine(durationBaseDefinition.PadLeft(durationBaseDefinition.Length + 8));
-
- if (duration.Name == CounterNameConventions.ProcessingTime || duration.Name == CounterNameConventions.CriticalTime)
- {
- var legacyTimerDefinition = $@"New-Object System.Diagnostics.CounterCreationData ""{duration.Name}"", ""{duration.Description}"", NumberOfItems32";
- stringBuilder.AppendLine(legacyTimerDefinition.PadLeft(legacyTimerDefinition.Length + 8));
- }
- }
-
- foreach (var signal in signals)
- {
- legacyInstanceNameMap.TryGetValue(signal.Name, out var instanceName);
-
- var signalDefinition = $@"New-Object System.Diagnostics.CounterCreationData ""{instanceName ?? signal.Name}"", ""{signal.Description}"", RateOfCountsPerSecond32";
- stringBuilder.AppendLine(signalDefinition.PadLeft(signalDefinition.Length + 8));
- }
-
- streamWriter.Write(Template, stringBuilder);
- }
- }
-
- const string Template = @"
-#requires -RunAsAdministrator
-Function InstallNSBPerfCounters {{
-
- $category = @{{Name=""NServiceBus""; Description=""NServiceBus statistics""}}
- $counters = New-Object System.Diagnostics.CounterCreationDataCollection
- $counters.AddRange(@(
-{0}
- ))
-
- if ([System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) {{
-
- foreach($counter in $counters){{
- $exists = [System.Diagnostics.PerformanceCounterCategory]::CounterExists($counter.CounterName, $category.Name)
- if (!$exists){{
- Write-Host ""One or more counters are missing.The performance counter category will be recreated""
- [System.Diagnostics.PerformanceCounterCategory]::Delete($category.Name)
-
- break
- }}
- }}
- }}
-
- if (![System.Diagnostics.PerformanceCounterCategory]::Exists($category.Name)) {{
- Write-Host ""Creating the performance counter category""
- [void] [System.Diagnostics.PerformanceCounterCategory]::Create($category.Name, $category.Description, [System.Diagnostics.PerformanceCounterCategoryType]::MultiInstance, $counters)
- }}
- else {{
- Write-Host ""No performance counters have to be created""
- }}
-
- [System.Diagnostics.PerformanceCounter]::CloseSharedResources()
-}}
-InstallNSBPerfCounters
-";
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/ScriptBuilderTask.cs b/src/ScriptBuilderTask/ScriptBuilderTask.cs
deleted file mode 100644
index 215a37c..0000000
--- a/src/ScriptBuilderTask/ScriptBuilderTask.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using Microsoft.Build.Framework;
- using Microsoft.Build.Utilities;
-
- public class ScriptBuilderTask : Task
- {
- [Required]
- public string AssemblyPath { get; set; }
-
- [Required]
- public string References { get; set; }
-
- [Required]
- public ITaskItem[] ReferenceCopyLocalPaths { get; set; }
-
- [Required]
- public string IntermediateDirectory { get; set; }
-
- [Required]
- public string ProjectDirectory { get; set; }
-
- [Required]
- public string SolutionDirectory { get; set; }
-
- public Dictionary ReferenceDictionary { get; } = new Dictionary(StringComparer.OrdinalIgnoreCase);
-
- public override bool Execute()
- {
- logger = new BuildLogger(BuildEngine);
- logger.LogInfo($"ScriptBuilderTask (version {typeof(ScriptBuilderTask).GetTypeInfo().Assembly.GetName().Version}) Executing");
-
- var stopwatch = Stopwatch.StartNew();
-
- var referenceCopyLocalPaths = ReferenceCopyLocalPaths.Select(x => x.ItemSpec);
- var splitReferences = References.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Union(referenceCopyLocalPaths, StringComparer.OrdinalIgnoreCase);
- foreach (var filePath in splitReferences)
- {
- var fileNameWithExtension = Path.GetFileName(filePath);
- ReferenceDictionary[fileNameWithExtension] = filePath;
-
- logger.LogInfo($"ScriptBuilderTask (Reference {fileNameWithExtension} located at {filePath})");
- }
-
- try
- {
- ValidateInputs();
- Action logError = (error, file) => { logger.LogError(error, file); };
- var innerTask = new InnerTask(AssemblyPath, ReferenceDictionary["NServiceBus.Metrics.dll"], IntermediateDirectory, ProjectDirectory, SolutionDirectory, logError);
- innerTask.Execute();
- }
- catch (ErrorsException exception)
- {
- logger.LogError(exception.Message, exception.FileName);
- }
- catch (Exception exception)
- {
- logger.LogError(exception.ToFriendlyString());
- }
- finally
- {
- logger.LogInfo($" Finished ScriptBuilderTask {stopwatch.ElapsedMilliseconds}ms.");
- }
- return !logger.ErrorOccurred;
- }
-
-
- void ValidateInputs()
- {
- if (!File.Exists(AssemblyPath))
- {
- throw new ErrorsException($"AssemblyPath '{AssemblyPath}' does not exist.");
- }
-
- if (!Directory.Exists(IntermediateDirectory))
- {
- throw new ErrorsException($"IntermediateDirectory '{IntermediateDirectory}' does not exist.");
- }
-
- if (!Directory.Exists(ProjectDirectory))
- {
- throw new ErrorsException($"ProjectDirectory '{ProjectDirectory}' does not exist.");
- }
-
- if (!Directory.Exists(SolutionDirectory))
- {
- throw new ErrorsException($"SolutionDirectory '{SolutionDirectory}' does not exist.");
- }
-
- if (!ReferenceDictionary.TryGetValue("NServiceBus.Metrics.dll", out _))
- {
- throw new ErrorsException("NServiceBus.Metrics.dll is not referenced in this assembly.");
- }
- }
-
- BuildLogger logger;
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/ScriptBuilderTask.csproj b/src/ScriptBuilderTask/ScriptBuilderTask.csproj
index 6881c22..ae083b1 100644
--- a/src/ScriptBuilderTask/ScriptBuilderTask.csproj
+++ b/src/ScriptBuilderTask/ScriptBuilderTask.csproj
@@ -1,65 +1,22 @@
- net452;netstandard1.5
- true
- NServiceBus.Metrics.PerformanceCounters.Task
- $(SolutionDir)NServiceBus.snk
- ..\..\binaries\
- $(NoWarn);CS1591
+ net452
+ NServiceBus.Metrics.PerformanceCounters.MsBuild
+ This package is deprecated and should no longer be referenced. The functionality was merged into the NServiceBus.Metrics.PerformanceCounters package.
+ $(MSBuildThisFileDirectory)$(PackageId).nuspec
+ true
+ false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- NServiceBus.Metrics.PerformanceCounters.MsBuild
- MsBuild Task for building deployment scripts for the NServiceBus.Metrics.PerformanceCounters package.
- $(MSBuildThisFileDirectory)$(PackageId).nuspec
- true
-
-
id=$(PackageId);version=$(PackageVersion);authors=$(Authors);owners=$(Authors);licenseUrl=$(PackageLicenseUrl);requireLicenseAcceptance=$(PackageRequireLicenseAcceptance);iconUrl=$(PackageIconUrl);projectUrl=$(PackageProjectUrl);description=$(Description);copyright=$(Copyright);tags=$(PackageTags)
-
-
- true
-
-
-
-
- $(ProjectDir)$(OutputPath)temp
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/ScriptPromotionPathReader.cs b/src/ScriptBuilderTask/ScriptPromotionPathReader.cs
deleted file mode 100644
index 8fde430..0000000
--- a/src/ScriptBuilderTask/ScriptPromotionPathReader.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System.Linq;
- using Mono.Cecil;
-
- public static class ScriptPromotionPathReader
- {
- public static bool TryRead(ModuleDefinition moduleDefinition, out string target)
- {
- var customAttribute = moduleDefinition.Assembly.CustomAttributes
- .FirstOrDefault(x => x.AttributeType.FullName == "NServiceBus.Metrics.PerformanceCounters.PerformanceCounterSettingsAttribute");
- if (customAttribute == null)
- {
- target = null;
- return false;
- }
-
- target = customAttribute.GetStringProperty("ScriptPromotionPath");
- if (target == null)
- {
- return false;
- }
- if (!string.IsNullOrWhiteSpace(target))
- {
- return true;
- }
- throw new ErrorsException("PerformanceCounterSettingsAttribute contains an empty ScriptPromotionPath.");
- }
-
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/ScriptVariantReader.cs b/src/ScriptBuilderTask/ScriptVariantReader.cs
deleted file mode 100644
index d1a3171..0000000
--- a/src/ScriptBuilderTask/ScriptVariantReader.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Mono.Cecil;
-
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- public static class ScriptVariantReader
- {
- public static IEnumerable Read(ModuleDefinition moduleDefinition)
- {
- var attribute = moduleDefinition.Assembly.CustomAttributes
- .FirstOrDefault(x => x.AttributeType.FullName == "NServiceBus.Metrics.PerformanceCounters.PerformanceCounterSettingsAttribute");
- if (attribute == null)
- {
- yield return BuildScriptVariant.CSharp;
- yield return BuildScriptVariant.Powershell;
- yield break;
- }
-
- var csharpScripts = attribute.GetBoolProperty("CSharp");
- if (csharpScripts)
- {
- yield return BuildScriptVariant.CSharp;
- }
-
- var powerShellScripts = attribute.GetBoolProperty("Powershell");
- if (powerShellScripts)
- {
- yield return BuildScriptVariant.Powershell;
- }
-
- if (!csharpScripts && !powerShellScripts)
- {
- throw new ErrorsException("Must define either CSharpScripts, PowershellScripts, or both. Add a [PerformanceCounterSettingsAttribute] to the assembly.");
- }
- }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/Signals/AllSignalsDefinitionReader.cs b/src/ScriptBuilderTask/Signals/AllSignalsDefinitionReader.cs
deleted file mode 100644
index 6b1be48..0000000
--- a/src/ScriptBuilderTask/Signals/AllSignalsDefinitionReader.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System;
- using System.Collections.Generic;
- using Mono.Cecil;
-
- static class AllSignalsDefinitionReader
- {
- public static IEnumerable GetSignals(ModuleDefinition module, Action logError)
- {
- var timerDefinitions = new List();
- foreach (var type in module.AllClasses())
- {
- try
- {
- if (SignalDefinitionReader.TryGetSignalDefinition(type, out var definition))
- {
- timerDefinitions.AddRange(definition);
- }
- }
- catch (ErrorsException exception)
- {
- logError(exception, type);
- }
- }
- return timerDefinitions;
- }
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/Signals/SignalDefinition.cs b/src/ScriptBuilderTask/Signals/SignalDefinition.cs
deleted file mode 100644
index 4a8ee3c..0000000
--- a/src/ScriptBuilderTask/Signals/SignalDefinition.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- class SignalDefinition
- {
- public SignalDefinition(string name, string description)
- {
- Name = name;
- Description = description;
- }
-
- public readonly string Description;
-
- public readonly string Name;
- }
-}
\ No newline at end of file
diff --git a/src/ScriptBuilderTask/Signals/SignalDefinitionReader.cs b/src/ScriptBuilderTask/Signals/SignalDefinitionReader.cs
deleted file mode 100644
index 76e7693..0000000
--- a/src/ScriptBuilderTask/Signals/SignalDefinitionReader.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-namespace NServiceBus.Metrics.PerformanceCounters
-{
- using System.Collections.Generic;
- using System.Linq;
- using Mono.Cecil;
-
- static class SignalDefinitionReader
- {
- public static bool TryGetSignalDefinition(TypeDefinition type, out List definitions)
- {
- definitions = new List();
- if (type.BaseType != null && type.BaseType.FullName == "SignalProbeBuilder")
- {
- var attributes = type.CustomAttributes.Where(a => a.AttributeType.FullName == "ProbePropertiesAttribute");
-
- foreach (var attribute in attributes)
- {
- var name = attribute.ParameterValue("name");
- var description = attribute.ParameterValue("description");
- definitions.Add(new SignalDefinition(name, description));
- }
- }
- return definitions.Count > 0;
- }
- }
-}
\ No newline at end of file