Ich brauche Hilfe bei der Synchronisierung von Perforce auf einer Remote -Maschine mit C#

StackOverflow https://stackoverflow.com/questions/2366059

  •  23-09-2019
  •  | 
  •  

Frage

Hallo, ich möchte in der Lage sein, Perforce auf meinem Build -Server von einem anderen Server programmgesteuert mit C# zu synchronisieren. Server A hat die Exe drauf. Server B hat Perforce.

Ich habe Administratorrechte auf beiden Maschinen.

Ich würde gerne so etwas verwenden

System.Diagnostics.Process.Start("p4 sync", "\"" + path + @""" -f //release/production/...")

Ich habe die Computerverbindung

ManagementScope scope = new ManagementScope("\\\\" + computer_name + "\\root\\cimv2");

scope.Connect();

Ich kann nicht herausfinden, wie ich alles zusammenstellen soll. Jede Hilfe wäre sehr geschätzt. Vielen Dank

War es hilfreich?

Lösung

Ich konnte es herausfinden:

public static void perforce_sync()
    {

        string computer_name = @"server_name";
        ManagementScope scope = new ManagementScope("\\\\" + computer_name + "\\root\\cimv2");
        scope.Connect();
        ObjectGetOptions object_get_options = new ObjectGetOptions();
        ManagementPath management_path = new ManagementPath("Win32_Process");
        ManagementClass process_class = new ManagementClass(scope, management_path, object_get_options);
        ManagementBaseObject inparams = process_class.GetMethodParameters("create");
        inparams["CommandLine"] = @"p4 sync -f //release/...";
        ManagementBaseObject outparams = process_class.InvokeMethod("Create", inparams, null);
        Console.WriteLine("Creation of the process returned: " + outparams["returnValue"]);
        Console.WriteLine("Process ID: " + outparams["processId"]);

    }
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top