executing rake from C# app
-
Hi, I have a rakefile that compile a C++ code. now I have a C# app that change something in the C++ code and I want to recompile it automatically. I did:
Process p = new Process();
p.StartInfo.FileName = "rake";
p.StartInfo.Arguments = my_expected_args;
p.StartInfo.WorkingDirectory = my_dir;
p.StartInfo.UseShellExecute = false;
p.start();I'm getting error: The system canot find the file specified. Let say that if I open a cmd prompt and do: > cd my_dir > rake my_expected_args this is fine. Thanks for any solution
-
Hi, I have a rakefile that compile a C++ code. now I have a C# app that change something in the C++ code and I want to recompile it automatically. I did:
Process p = new Process();
p.StartInfo.FileName = "rake";
p.StartInfo.Arguments = my_expected_args;
p.StartInfo.WorkingDirectory = my_dir;
p.StartInfo.UseShellExecute = false;
p.start();I'm getting error: The system canot find the file specified. Let say that if I open a cmd prompt and do: > cd my_dir > rake my_expected_args this is fine. Thanks for any solution
It looks like you are getting confused about what WorkingDirectory is used for. It is not a path to the file when you set
UseShellExecute=false;
- if the executable doesn't exist somewhere in the PATH settings, you need to specify a directory as part of the filename, so you would havep.StartInfo.FileName = Path.Combine(my_dir, "rake.exe");
Have a look here[^] to understand what's happening with your code.
-
It looks like you are getting confused about what WorkingDirectory is used for. It is not a path to the file when you set
UseShellExecute=false;
- if the executable doesn't exist somewhere in the PATH settings, you need to specify a directory as part of the filename, so you would havep.StartInfo.FileName = Path.Combine(my_dir, "rake.exe");
Have a look here[^] to understand what's happening with your code.
-
Thanks, I tried to do as you said but still getting the same error. what can be the problem?
What does your code look like now?
-
What does your code look like now?
Process p = new Process();
p.StartInfo.FileName = Path.Combine(my_dir, "rake.exe");
p.StartInfo.Arguments = my_expected_args;
p.StartInfo.UseShellExecute = false;
p.start();I Also tried the following :
Directory.SetCurrentDirectory(my_dir);
Process p = new Process();
p.StartInfo.FileName = "rake.exe";
p.StartInfo.Arguments = my_expected_args;
p.StartInfo.UseShellExecute = false;
p.start(); -
Process p = new Process();
p.StartInfo.FileName = Path.Combine(my_dir, "rake.exe");
p.StartInfo.Arguments = my_expected_args;
p.StartInfo.UseShellExecute = false;
p.start();I Also tried the following :
Directory.SetCurrentDirectory(my_dir);
Process p = new Process();
p.StartInfo.FileName = "rake.exe";
p.StartInfo.Arguments = my_expected_args;
p.StartInfo.UseShellExecute = false;
p.start();Either of those should have worked. Have you verified that my_dir actually points to the directory that contains rake? Put a break point on
Process p = new Process();
and see what's in my_dir. -
Hi, I have a rakefile that compile a C++ code. now I have a C# app that change something in the C++ code and I want to recompile it automatically. I did:
Process p = new Process();
p.StartInfo.FileName = "rake";
p.StartInfo.Arguments = my_expected_args;
p.StartInfo.WorkingDirectory = my_dir;
p.StartInfo.UseShellExecute = false;
p.start();I'm getting error: The system canot find the file specified. Let say that if I open a cmd prompt and do: > cd my_dir > rake my_expected_args this is fine. Thanks for any solution
replace "rake" with the full path and the full filename including its extension of that executable.