11using System ;
22using System . Collections . Generic ;
33using System . Diagnostics ;
4+ using System . IO ;
45using Semmle . Util ;
56
67namespace Semmle . Extraction . CSharp . DependencyFetching
@@ -10,12 +11,13 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
1011 /// </summary>
1112 internal class DotNet : IDotNet
1213 {
13- private const string dotnet = "dotnet" ;
1414 private readonly ProgressMonitor progressMonitor ;
15+ private readonly string dotnet ;
1516
16- public DotNet ( ProgressMonitor progressMonitor )
17+ public DotNet ( IDependencyOptions options , ProgressMonitor progressMonitor )
1718 {
1819 this . progressMonitor = progressMonitor ;
20+ this . dotnet = Path . Combine ( options . DotNetPath ?? string . Empty , "dotnet" ) ;
1921 Info ( ) ;
2022 }
2123
@@ -29,7 +31,7 @@ private void Info()
2931 }
3032 }
3133
32- private static ProcessStartInfo MakeDotnetStartInfo ( string args , bool redirectStandardOutput ) =>
34+ private ProcessStartInfo MakeDotnetStartInfo ( string args , bool redirectStandardOutput ) =>
3335 new ProcessStartInfo ( dotnet , args )
3436 {
3537 UseShellExecute = false ,
@@ -39,7 +41,7 @@ private static ProcessStartInfo MakeDotnetStartInfo(string args, bool redirectSt
3941 private bool RunCommand ( string args )
4042 {
4143 progressMonitor . RunningProcess ( $ "{ dotnet } { args } ") ;
42- using var proc = Process . Start ( MakeDotnetStartInfo ( args , redirectStandardOutput : false ) ) ;
44+ using var proc = Process . Start ( this . MakeDotnetStartInfo ( args , redirectStandardOutput : false ) ) ;
4345 proc ? . WaitForExit ( ) ;
4446 var exitCode = proc ? . ExitCode ?? - 1 ;
4547 if ( exitCode != 0 )
@@ -77,7 +79,7 @@ public bool AddPackage(string folder, string package)
7779 private IList < string > GetListed ( string args , string artifact )
7880 {
7981 progressMonitor . RunningProcess ( $ "{ dotnet } { args } ") ;
80- var pi = MakeDotnetStartInfo ( args , redirectStandardOutput : true ) ;
82+ var pi = this . MakeDotnetStartInfo ( args , redirectStandardOutput : true ) ;
8183 var exitCode = pi . ReadOutput ( out var artifacts ) ;
8284 if ( exitCode != 0 )
8385 {
0 commit comments