From a60d63b64c369eb68468f4ca07b2caa063f061d8 Mon Sep 17 00:00:00 2001 From: Ramez Ragaa Date: Thu, 7 Dec 2023 11:52:14 +0200 Subject: [PATCH] chore: use discovered DOTNET_ROOT instead of "dotnet" found in PATH in uno templates checkup --- UnoCheck/Checkups/DotNetNewUnoTemplatesCheckup.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/UnoCheck/Checkups/DotNetNewUnoTemplatesCheckup.cs b/UnoCheck/Checkups/DotNetNewUnoTemplatesCheckup.cs index df5cf4fd..c8298567 100644 --- a/UnoCheck/Checkups/DotNetNewUnoTemplatesCheckup.cs +++ b/UnoCheck/Checkups/DotNetNewUnoTemplatesCheckup.cs @@ -4,6 +4,7 @@ using DotNetCheck.Models; using System.Diagnostics; using System; +using System.IO; using System.Threading.Tasks; using System.Text.RegularExpressions; using NuGet.Versioning; @@ -31,7 +32,7 @@ internal class DotNetNewUnoTemplatesCheckup : Checkup public override async Task Examine(SharedState history) { - var dotnetOutput = GetDotNetNewInstalledList(); + var dotnetOutput = GetDotNetNewInstalledList(history); var legacyVersion = GetInstalledVersion(dotnetOutput, _unoLegacyTemplatesOutputRegex); var version = GetInstalledVersion(dotnetOutput, _unoTemplatesOutputRegex); @@ -63,11 +64,17 @@ public override async Task Examine(SharedState history) return DiagnosticResult.Ok(this); } - private string GetDotNetNewInstalledList() + private string GetDotNetNewInstalledList(SharedState? history) { + var binaryLocation = new DotNetSdk(history).DotNetExeLocation; + var dotnetCommand = + binaryLocation.Exists + ? binaryLocation.FullName + : "dotnet"; // fallback to the dotnet binary found in PATH + // Running 'dotnet new uninstall' without any package ID will list all installed // dotnet new templates along with their versions. - var processInfo = new ProcessStartInfo("dotnet", "new uninstall"); + var processInfo = new ProcessStartInfo(dotnetCommand, "new uninstall"); processInfo.RedirectStandardOutput = true; processInfo.UseShellExecute = false;