Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreOlivierBrillant committed Oct 17, 2024
2 parents b839b50 + 9429055 commit 6e978b0
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
5 changes: 3 additions & 2 deletions scriptsharp/ScriptSharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ static class Program

private static async Task Main()
{
//LogSingleton.Get.LogAndWriteLine("yo");
//TestDebug();
Directory.SetCurrentDirectory(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
//clear the log file
LogSingleton.Get.LogAndWriteLine("Bienvenue dans l'installeur pour les cours de mobile");
Expand Down Expand Up @@ -115,8 +117,7 @@ private static async Task Main()

private static void TestDebug()
{
Utils.CreateDesktopShortcut("gna", "C:\\Program Files\\7-Zip\\7z.exe");
Utils.CreateDesktopShortcut("gni", "C:\\Program Files\\7-Zip\\plop.exe");
UtilsFirebase.InstallFirebase();
}


Expand Down
48 changes: 27 additions & 21 deletions scriptsharp/ScriptSharp/Utils/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,35 +93,41 @@ public static void RunCommand(string command)
LogSingleton.Get.LogAndWriteLine("Execution de la commande: " + command);
try
{
// Récupérer la variable d'environnement PATH
//string pathVariable = Environment.GetEnvironmentVariable("PATH");
//Console.WriteLine("La variable d'environnement PATH est:");
//Console.WriteLine(pathVariable);

// Configuration de ProcessStartInfo
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = "C:\\Windows\\System32\\cmd.exe",
FileName = "C:\\Windows\\system32\\cmd.exe",
Arguments = $"/c {command}",
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
CreateNoWindow = true,
WorkingDirectory = Environment.CurrentDirectory
CreateNoWindow = true
};
processStartInfo.EnvironmentVariables["PATH"] = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User);

using Process process = Process.Start(processStartInfo);

string currentTime = DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss");
string outputFilePath = Path.Combine(Config.LogPath, $"Commande-{currentTime}.txt");

using (StreamWriter writer = new StreamWriter(outputFilePath))
{
writer.WriteLine("Trace de l'exeuction de la commande:");
writer.WriteLine(command);
writer.WriteLine(process.StandardOutput.ReadToEnd());
writer.WriteLine(process.StandardError.ReadToEnd());
writer.Close();
}
process.WaitForExit();
if (process.ExitCode != 0)
// Exécution du processus
using (Process process = new Process { StartInfo = processStartInfo })
{
throw new Exception($"Command exited with code {process.ExitCode}");
process.Start();
string output = process.StandardOutput.ReadToEnd();
string error = process.StandardError.ReadToEnd();
process.WaitForExit();

// Afficher les résultats de la commande exécutée
if (string.IsNullOrEmpty(error))
{
LogSingleton.Get.LogAndWriteLine(" FAIT Sortie pour : " + command);
LogSingleton.Get.LogAndWriteLine(output);
}
else
{
LogSingleton.Get.LogAndWriteLine(" ERREUR Sortie pour : " + command);
LogSingleton.Get.LogAndWriteLine(error);
}
}
}
catch (Exception ex)
Expand Down Expand Up @@ -187,7 +193,7 @@ public static async Task Unzip7ZFileAsync(string sourceFile, string destinationF
LogSingleton.Get.LogAndWriteLine($"Une erreur est survenue: {ex.Message}");
}

LogSingleton.Get.LogAndWriteLine("Dézippage avec 7z fini pour " + sourceFile);
LogSingleton.Get.LogAndWriteLine(" FAIT Dézippage 7z fini pour " + sourceFile);
}

public static async Task CopyFileFromNetworkShareAsync(string networkFilePath, string localFilePath)
Expand Down
6 changes: 0 additions & 6 deletions scriptsharp/ScriptSharp/Utils/UtilsFlutter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,9 @@ await Utils.CopyFileFromNetworkShareAsync(
await Utils.Unzip7ZFileAsync(
Path.Combine(Config.LocalTemp, "flutter.7z"),
Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
// execute "flutter doctor --android-licenses"
Utils.RunCommand(PathToFlutter() +" config --android-sdk "+Utils.GetSdkPath());
Utils.RunCommand(PathToFlutter() +" config --android-studio-dir "+Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "android-studio"));
Utils.RunCommand(PathToFlutter() +" doctor --android-licenses");
Utils.RunCommand(PathToFlutter() +" doctor --verbose");
Utils.RunCommand(PathToFlutter() +" precache");
// Utils.RunCommand(Program.PathToFlutter() +" pub global activate devtools"); Obsolete depuis nouvelles version flutter
// create a fake project to initialize flutter
Utils.RunCommand(PathToFlutter() +" create fake_start;cd fake_start;flutter run");
LogSingleton.Get.LogAndWriteLine(" FAIT Installation Flutter complet");
}
public static string PathToFlutter()
Expand Down

0 comments on commit 6e978b0

Please sign in to comment.