Skip to content

Commit

Permalink
chore: use the dotnet executable from SharedState not PATH
Browse files Browse the repository at this point in the history
  • Loading branch information
ramezgerges committed Jan 31, 2024
1 parent 109a2d6 commit ce75b8b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions UnoCheck/Solutions/DotNetNewTemplatesInstallSolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,28 @@ public DotNetNewTemplatesInstallSolution(

public override async Task Implement(SharedState sharedState, CancellationToken cancellationToken)
{
var binaryLocation = new DotNetSdk(sharedState).DotNetExeLocation;
var dotnetCommand =
binaryLocation.Exists
? binaryLocation.FullName
: "dotnet"; // fallback to the dotnet binary found in PATH

var version = _requestedVersion ??
await NuGetHelper.GetLatestPackageVersionAsync(UnoTemplatesPackageName, ToolInfo.CurrentVersion.IsPrerelease);

if (_uninstallLegacy)
{
var uninstallCli = new ShellProcessRunner(new ShellProcessRunnerOptions("dotnet", $"new uninstall {UnoLegacyTemplatesPackageName}"));
var uninstallCli = new ShellProcessRunner(new ShellProcessRunnerOptions(dotnetCommand, $"new uninstall {UnoLegacyTemplatesPackageName}"));
uninstallCli.WaitForExit();
}

if (_uninstallExisting)
{
var uninstallCli = new ShellProcessRunner(new ShellProcessRunnerOptions("dotnet", $"new uninstall {UnoTemplatesPackageName}"));
var uninstallCli = new ShellProcessRunner(new ShellProcessRunnerOptions(dotnetCommand, $"new uninstall {UnoTemplatesPackageName}"));
uninstallCli.WaitForExit();
}

var cli = new ShellProcessRunner(new ShellProcessRunnerOptions("dotnet", $"new install {UnoTemplatesPackageName}::{version}") { Verbose = Util.Verbose });
var cli = new ShellProcessRunner(new ShellProcessRunnerOptions(dotnetCommand, $"new install {UnoTemplatesPackageName}::{version}") { Verbose = Util.Verbose });
cli.WaitForExit();
}
}

0 comments on commit ce75b8b

Please sign in to comment.