Skip to content

Commit

Permalink
Merge pull request #342 from unoplatform/dev/jela/relax-dotnet-check
Browse files Browse the repository at this point in the history
fix: Don't require sudo for dotnet workloads validation
  • Loading branch information
jeromelaban authored Feb 18, 2025
2 parents 3e6e39b + 851fb1f commit 9882aef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/UnoCheck/bin/Debug/netcoreapp3.1/UnoCheck.dll",
"args":["-v", "--manifest", "https://raw.githubusercontent.com/unoplatform/uno.check/bf3684e2ad725baa66da3573759129d6bb1d8817/manifests/uno.ui.manifest.json"],
"args":["-v", "--non-interactive", "--manifest", "${workspaceFolder}/manifests/uno.ui.manifest.json"],
"cwd": "${workspaceFolder}/UnoCheck",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
Expand Down
4 changes: 2 additions & 2 deletions UnoCheck/DotNet/DotNetWorkloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public async Task<string[]> GetInstalledWorkloads()
"--machine-readable"
};

var r = await Util.WrapShellCommandWithSudo(dotnetExe, DotNetCliWorkingDir, Util.Verbose, args.ToArray());
var r = await Util.ShellCommand(dotnetExe, DotNetCliWorkingDir, Util.Verbose, args.ToArray());

// Throw if this failed with a bad exit code
if (r.ExitCode != 0)
Expand All @@ -127,7 +127,7 @@ public async Task<string[]> GetInstalledWorkloads()
"--print-rollback"
};

var r = await Util.WrapShellCommandWithSudo(dotnetExe, DotNetCliWorkingDir, Util.Verbose, args.ToArray());
var r = await Util.ShellCommand(dotnetExe, DotNetCliWorkingDir, Util.Verbose, args.ToArray());

// Throw if this failed with a bad exit code
if (r.ExitCode != 0)
Expand Down
6 changes: 6 additions & 0 deletions UnoCheck/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,12 @@ public static bool Delete(string path, bool isFile)
return false;
}

public static Task<ShellProcessRunner.ShellProcessResult> ShellCommand(string cmd, string workingDir, bool verbose, string[] args)
{
var cli = new ShellProcessRunner(new ShellProcessRunnerOptions(cmd, string.Join(" ", args)) { WorkingDirectory = workingDir, Verbose = verbose } );
return Task.FromResult(cli.WaitForExit());
}

public static Task<ShellProcessRunner.ShellProcessResult> WrapShellCommandWithSudo(string cmd, string[] args)
=> WrapShellCommandWithSudo(cmd, null, false, args);

Expand Down

0 comments on commit 9882aef

Please sign in to comment.