diff --git a/src/Uno.UI.RemoteControl.Host/DevServer.Custom.Targets b/src/Uno.UI.RemoteControl.Host/DevServer.Custom.Targets new file mode 100644 index 000000000000..5acf8d3183c2 --- /dev/null +++ b/src/Uno.UI.RemoteControl.Host/DevServer.Custom.Targets @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs b/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs index bfb27344276c..1dedf795d030 100644 --- a/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs +++ b/src/Uno.UI.RemoteControl.Host/Extensibility/AddIns.cs @@ -3,6 +3,7 @@ using System.Diagnostics; using System.IO; using System.Linq; +using System.Reflection; using System.Text; using Microsoft.Extensions.Logging; using Uno.Extensions; @@ -16,9 +17,13 @@ public class AddIns public static IImmutableList Discover(string solutionFile) { + // Note: We include the targets "on the fly" so if a project uses Microsoft.NET.Sdk instead of Uno.Sdk, we will still have the targets defined. + var targetsFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "DevServer.Custom.Targets"); + var tmp = Path.GetTempFileName(); var wd = Path.GetDirectoryName(solutionFile); - var command = $"build \"{solutionFile}\" -t:UnoDumpTargetFrameworks \"-p:UnoDumpTargetFrameworksTargetFile={tmp}\" --verbosity quiet"; + string DumpTFM(string v) => $"build \"{solutionFile}\" -t:UnoDumpTargetFrameworks \"-p:UnoDumpTargetFrameworksTargetFile={tmp}\" \"-p:CustomBeforeMicrosoftCSharpTargets={targetsFile}\" --verbosity {v}"; + var command = DumpTFM("quiet"); var result = ProcessHelper.RunProcess("dotnet", command, wd); var targetFrameworks = Read(tmp); @@ -35,7 +40,10 @@ public static IImmutableList Discover(string solutionFile) } else { + result = ProcessHelper.RunProcess("dotnet", DumpTFM("diagnostic"), wd); + _log.Log(LogLevel.Warning, msg); + _log.Log(LogLevel.Debug, result.output); } } @@ -51,7 +59,7 @@ public static IImmutableList Discover(string solutionFile) foreach (var targetFramework in targetFrameworks) { tmp = Path.GetTempFileName(); - command = $"build \"{solutionFile}\" -t:UnoDumpRemoteControlAddIns \"-p:UnoDumpRemoteControlAddInsTargetFile={tmp}\" --verbosity quiet --framework \"{targetFramework}\" -nowarn:MSB4057"; + command = $"build \"{solutionFile}\" -t:UnoDumpRemoteControlAddIns \"-p:UnoDumpRemoteControlAddInsTargetFile={tmp}\" \"-p:CustomBeforeMicrosoftCSharpTargets={targetsFile}\" --verbosity quiet --framework \"{targetFramework}\" -nowarn:MSB4057"; result = ProcessHelper.RunProcess("dotnet", command, wd); if (!string.IsNullOrWhiteSpace(result.error)) { diff --git a/src/Uno.UI.RemoteControl.Host/Uno.UI.RemoteControl.Host.csproj b/src/Uno.UI.RemoteControl.Host/Uno.UI.RemoteControl.Host.csproj index 8fbf3abaa219..18f378313c54 100644 --- a/src/Uno.UI.RemoteControl.Host/Uno.UI.RemoteControl.Host.csproj +++ b/src/Uno.UI.RemoteControl.Host/Uno.UI.RemoteControl.Host.csproj @@ -49,13 +49,13 @@ - - + + Never @@ -67,7 +67,13 @@ Always global.json - + + + + + Always + + diff --git a/src/Uno.UI.RemoteControl.Server.Processors/Helpers/ProcessHelper.cs b/src/Uno.UI.RemoteControl.Server.Processors/Helpers/ProcessHelper.cs index 40ff4c45d8c0..6a1eacbf0d6e 100644 --- a/src/Uno.UI.RemoteControl.Server.Processors/Helpers/ProcessHelper.cs +++ b/src/Uno.UI.RemoteControl.Server.Processors/Helpers/ProcessHelper.cs @@ -6,11 +6,15 @@ using System.IO; using System.Runtime.InteropServices; using System.Text; +using Microsoft.Extensions.Logging; +using Uno.Extensions; namespace Uno.UI.RemoteControl.Helpers { internal class ProcessHelper { + private static readonly ILogger _log = typeof(ProcessHelper).Log(); + public static (int exitCode, string output, string error) RunProcess(string executable, string parameters, string? workingDirectory = null) { if (!OperatingSystem.IsWindows() @@ -19,6 +23,11 @@ public static (int exitCode, string output, string error) RunProcess(string exec executable = Path.GetFileNameWithoutExtension(executable); } + if (_log.IsEnabled(LogLevel.Trace)) + { + _log.LogTrace($"Executing '{executable} {parameters}' in '{workingDirectory ?? Environment.CurrentDirectory}'"); + } + var p = new Process { StartInfo =