Skip to content

Commit

Permalink
chore: use discovered DOTNET_ROOT instead of "dotnet" found in PATH i…
Browse files Browse the repository at this point in the history
…n uno templates checkup
  • Loading branch information
ramezgerges committed Dec 7, 2023
1 parent 0923ca8 commit a60d63b
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions UnoCheck/Checkups/DotNetNewUnoTemplatesCheckup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -31,7 +32,7 @@ internal class DotNetNewUnoTemplatesCheckup : Checkup

public override async Task<DiagnosticResult> Examine(SharedState history)
{
var dotnetOutput = GetDotNetNewInstalledList();
var dotnetOutput = GetDotNetNewInstalledList(history);

var legacyVersion = GetInstalledVersion(dotnetOutput, _unoLegacyTemplatesOutputRegex);
var version = GetInstalledVersion(dotnetOutput, _unoTemplatesOutputRegex);
Expand Down Expand Up @@ -63,11 +64,17 @@ public override async Task<DiagnosticResult> 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;

Expand Down

0 comments on commit a60d63b

Please sign in to comment.