Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. executing rake from C# app

executing rake from C# app

Scheduled Pinned Locked Moved C#
csharpc++help
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    lune12
    wrote on last edited by
    #1

    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

    P B 2 Replies Last reply
    0
    • L lune12

      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

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      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 have

      p.StartInfo.FileName = Path.Combine(my_dir, "rake.exe");

      Have a look here[^] to understand what's happening with your code.

      L 1 Reply Last reply
      0
      • P Pete OHanlon

        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 have

        p.StartInfo.FileName = Path.Combine(my_dir, "rake.exe");

        Have a look here[^] to understand what's happening with your code.

        L Offline
        L Offline
        lune12
        wrote on last edited by
        #3

        Thanks, I tried to do as you said but still getting the same error. what can be the problem?

        P 1 Reply Last reply
        0
        • L lune12

          Thanks, I tried to do as you said but still getting the same error. what can be the problem?

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          What does your code look like now?

          L 1 Reply Last reply
          0
          • P Pete OHanlon

            What does your code look like now?

            L Offline
            L Offline
            lune12
            wrote on last edited by
            #5

            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();

            P 1 Reply Last reply
            0
            • L lune12

              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();

              P Offline
              P Offline
              Pete OHanlon
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • L lune12

                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

                B Offline
                B Offline
                Bernhard Hiller
                wrote on last edited by
                #7

                replace "rake" with the full path and the full filename including its extension of that executable.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups