From cc80a055165ffdfbe43f743ad9fac14bb3da0efd Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Sat, 7 Dec 2024 22:59:09 +0100 Subject: [PATCH 1/3] Introduce DisableLogging option in RefitterGenerateTask --- src/Refitter.MSBuild/RefitterGenerateTask.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Refitter.MSBuild/RefitterGenerateTask.cs b/src/Refitter.MSBuild/RefitterGenerateTask.cs index 9e7b729c..52e7b9f0 100644 --- a/src/Refitter.MSBuild/RefitterGenerateTask.cs +++ b/src/Refitter.MSBuild/RefitterGenerateTask.cs @@ -8,6 +8,8 @@ public class RefitterGenerateTask : MSBuildTask { public string ProjectFileDirectory { get; set; } + public bool DisableLogging { get; set; } + public override bool Execute() { TryLogCommandLine($"Starting {nameof(RefitterGenerateTask)}"); @@ -49,12 +51,18 @@ private void StartProcess(string file) var refitterDll = $"{packageFolder}{seperator}..{seperator}refitter.dll"; TryLogCommandLine("Starting " + refitterDll); + var args = $"{refitterDll} --settings-file {file}"; + if (DisableLogging) + { + args += " --no-logging"; + } + using var process = new Process { StartInfo = new ProcessStartInfo { FileName = "dotnet", - Arguments = $"{refitterDll} --settings-file {file}", + Arguments = args, WorkingDirectory = Path.GetDirectoryName(file)!, RedirectStandardOutput = true, RedirectStandardError = true, From 34957b70a4871b8b6612eb38d9058eaff1391d48 Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Sat, 7 Dec 2024 23:04:48 +0100 Subject: [PATCH 2/3] Disable logging in MSBuild test project --- src/Refitter.MSBuild/Refitter.MSBuild.targets | 3 ++- test/MSBuild/Refitter.MSBuild.Tests.csproj | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Refitter.MSBuild/Refitter.MSBuild.targets b/src/Refitter.MSBuild/Refitter.MSBuild.targets index 777951c0..53377cd3 100644 --- a/src/Refitter.MSBuild/Refitter.MSBuild.targets +++ b/src/Refitter.MSBuild/Refitter.MSBuild.targets @@ -1,7 +1,8 @@ - + diff --git a/test/MSBuild/Refitter.MSBuild.Tests.csproj b/test/MSBuild/Refitter.MSBuild.Tests.csproj index 36282569..840bcdc0 100644 --- a/test/MSBuild/Refitter.MSBuild.Tests.csproj +++ b/test/MSBuild/Refitter.MSBuild.Tests.csproj @@ -1,10 +1,11 @@ - + Exe net8.0 enable enable + true @@ -13,5 +14,5 @@ - + From 4e88391d9f1198806910efaba88a24feac622d48 Mon Sep 17 00:00:00 2001 From: Christian Helle Date: Sun, 8 Dec 2024 13:50:54 +0100 Subject: [PATCH 3/3] Output the executed command --- src/Refitter.MSBuild/RefitterGenerateTask.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Refitter.MSBuild/RefitterGenerateTask.cs b/src/Refitter.MSBuild/RefitterGenerateTask.cs index 52e7b9f0..bd1849c3 100644 --- a/src/Refitter.MSBuild/RefitterGenerateTask.cs +++ b/src/Refitter.MSBuild/RefitterGenerateTask.cs @@ -49,7 +49,6 @@ private void StartProcess(string file) var packageFolder = Path.GetDirectoryName(assembly.Location); var seperator = Path.DirectorySeparatorChar; var refitterDll = $"{packageFolder}{seperator}..{seperator}refitter.dll"; - TryLogCommandLine("Starting " + refitterDll); var args = $"{refitterDll} --settings-file {file}"; if (DisableLogging) @@ -57,6 +56,8 @@ private void StartProcess(string file) args += " --no-logging"; } + TryLogCommandLine($"Starting dotnet {args}"); + using var process = new Process { StartInfo = new ProcessStartInfo