From 8a79c2ffd984708750f2e69454eb78a0717e53d7 Mon Sep 17 00:00:00 2001 From: deguet Date: Thu, 17 Oct 2024 13:16:08 -0400 Subject: [PATCH 1/5] Test sur 2 versions --- scriptsharp/ScriptSharp/Program.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scriptsharp/ScriptSharp/Program.cs b/scriptsharp/ScriptSharp/Program.cs index ee76894..4d43833 100644 --- a/scriptsharp/ScriptSharp/Program.cs +++ b/scriptsharp/ScriptSharp/Program.cs @@ -49,9 +49,6 @@ static class Program private static async Task Main() { - UtilsFirebase.InstallFlutterFire(); - //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"); @@ -105,6 +102,7 @@ private static async Task Main() await Script5N6.Handle5N6FlutterAsync(); break; case not null when choixChoisi.Contains("6."): + TestDebug(); await Script5N6.Handle5N6FlutterFirebaseAsync(); break; case not null when choixChoisi.Contains("7."): From 6bb27a78ea4afaede4a36d3fb6ae115b2b0b4f7e Mon Sep 17 00:00:00 2001 From: deguet Date: Thu, 17 Oct 2024 13:18:15 -0400 Subject: [PATCH 2/5] =?UTF-8?q?D=C3=A9placement=20firebase=20au=20d=C3=A9b?= =?UTF-8?q?ut?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scriptsharp/ScriptSharp/Program.cs | 1 - scriptsharp/ScriptSharp/Script5N6.cs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/scriptsharp/ScriptSharp/Program.cs b/scriptsharp/ScriptSharp/Program.cs index 4d43833..2438fb7 100644 --- a/scriptsharp/ScriptSharp/Program.cs +++ b/scriptsharp/ScriptSharp/Program.cs @@ -102,7 +102,6 @@ private static async Task Main() await Script5N6.Handle5N6FlutterAsync(); break; case not null when choixChoisi.Contains("6."): - TestDebug(); await Script5N6.Handle5N6FlutterFirebaseAsync(); break; case not null when choixChoisi.Contains("7."): diff --git a/scriptsharp/ScriptSharp/Script5N6.cs b/scriptsharp/ScriptSharp/Script5N6.cs index d93f15e..96a57b0 100644 --- a/scriptsharp/ScriptSharp/Script5N6.cs +++ b/scriptsharp/ScriptSharp/Script5N6.cs @@ -49,6 +49,7 @@ await Task.WhenAll( public static async Task Handle5N6FlutterFirebaseAsync() { LogSingleton.Get.LogAndWriteLine("Installation de 5N6 flutter + firebase ..."); + UtilsFirebase.InstallFirebase(); await Utils.CopyFileFromNetworkShareAsync( Path.Combine(Config.LocalCache, "Sdk-Android-Flutter.7z"), Path.Combine(Config.LocalTemp, "Sdk.7z") ); @@ -83,7 +84,6 @@ await Task.WhenAll( //Utils.StartKMB(); Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "Local", "Pub", "Cache", "bin")); - UtilsFirebase.InstallFirebase(); UtilsFirebase.InstallFlutterFire(); await Utils.StartAndroidStudio(); LogSingleton.Get.LogAndWriteLine(" FAIT 5N6 Flutter + firebase complet"); From 2e809e4a869b06487a5d1f750ed8f1258870e24f Mon Sep 17 00:00:00 2001 From: deguet Date: Thu, 17 Oct 2024 13:23:19 -0400 Subject: [PATCH 3/5] Refactor + sortie de RunCommand --- scriptsharp/ScriptSharp/Script3N5.cs | 2 +- scriptsharp/ScriptSharp/Script4N6.cs | 4 +-- scriptsharp/ScriptSharp/Script5N6.cs | 4 +-- scriptsharp/ScriptSharp/Utils/Utils.cs | 29 +++---------------- .../ScriptSharp/Utils/UtilsAndroidStudio.cs | 21 ++++++++++++++ 5 files changed, 30 insertions(+), 30 deletions(-) diff --git a/scriptsharp/ScriptSharp/Script3N5.cs b/scriptsharp/ScriptSharp/Script3N5.cs index 94d68f6..f6239ac 100644 --- a/scriptsharp/ScriptSharp/Script3N5.cs +++ b/scriptsharp/ScriptSharp/Script3N5.cs @@ -29,7 +29,7 @@ await Task.WhenAll( UtilsAndroidStudio.InstallAndroidStudio(), DownloadRepo3N5()); // start android studio - await Utils.StartAndroidStudio(); + await UtilsAndroidStudio.StartAndroidStudio(); LogSingleton.Get.LogAndWriteLine(" FAIT Installation pour 3N5 Android complet"); } diff --git a/scriptsharp/ScriptSharp/Script4N6.cs b/scriptsharp/ScriptSharp/Script4N6.cs index bb8c00b..f429df9 100644 --- a/scriptsharp/ScriptSharp/Script4N6.cs +++ b/scriptsharp/ScriptSharp/Script4N6.cs @@ -38,7 +38,7 @@ await Task.WhenAll( // start android studio Utils.CreateDesktopShortcut("IntelliJ", UtilsIntellij.PathToIntellij()); - await Utils.StartAndroidStudio(); + await UtilsAndroidStudio.StartAndroidStudio(); Utils.StartKmb(); LogSingleton.Get.LogAndWriteLine(" FAIT Installation 4N6 Android + serveur Spring "); } @@ -72,7 +72,7 @@ await Task.WhenAll( //Program.DownloadRepoKMB(), DownloadRepo4N6()); // start android studio - await Utils.StartAndroidStudio(); + await UtilsAndroidStudio.StartAndroidStudio(); LogSingleton.Get.LogAndWriteLine(" FAIT Installation 4N6 Android fini"); } } \ No newline at end of file diff --git a/scriptsharp/ScriptSharp/Script5N6.cs b/scriptsharp/ScriptSharp/Script5N6.cs index 96a57b0..b7ff5f6 100644 --- a/scriptsharp/ScriptSharp/Script5N6.cs +++ b/scriptsharp/ScriptSharp/Script5N6.cs @@ -41,7 +41,7 @@ await Task.WhenAll( Utils.RunCommand(UtilsAndroidStudio.PathToAndroidStudio() + " installPlugins com.localizely.flutter-intl"); await UtilsFlutter.InstallFlutter(); Utils.StartKmb(); - await Utils.StartAndroidStudio(); + await UtilsAndroidStudio.StartAndroidStudio(); Utils.CreateDesktopShortcut("IntelliJ", UtilsIntellij.PathToIntellij()); LogSingleton.Get.LogAndWriteLine(" FAIT 5N6 Flutter complet"); } @@ -85,7 +85,7 @@ await Task.WhenAll( Utils.AddToPath(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "Local", "Pub", "Cache", "bin")); UtilsFirebase.InstallFlutterFire(); - await Utils.StartAndroidStudio(); + await UtilsAndroidStudio.StartAndroidStudio(); LogSingleton.Get.LogAndWriteLine(" FAIT 5N6 Flutter + firebase complet"); } diff --git a/scriptsharp/ScriptSharp/Utils/Utils.cs b/scriptsharp/ScriptSharp/Utils/Utils.cs index 21aac08..d6052a8 100644 --- a/scriptsharp/ScriptSharp/Utils/Utils.cs +++ b/scriptsharp/ScriptSharp/Utils/Utils.cs @@ -116,18 +116,18 @@ public static void RunCommand(string command) 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)) + + if (!string.IsNullOrEmpty(output)) { LogSingleton.Get.LogAndWriteLine(" FAIT Sortie pour : " + command); LogSingleton.Get.LogAndWriteLine(output); } - else + if (!string.IsNullOrEmpty(error)) { LogSingleton.Get.LogAndWriteLine(" ERREUR Sortie pour : " + command); LogSingleton.Get.LogAndWriteLine(error); } + } } catch (Exception ex) @@ -269,27 +269,6 @@ private static void RunPowerShellCommand(string command) } } - public static Task StartAndroidStudio() - { - LogSingleton.Get.LogAndWriteLine("Lancement d'Android Studio"); - string androidStudioPath = UtilsAndroidStudio.PathToAndroidStudio(); - if (File.Exists(androidStudioPath)) - { - CreateDesktopShortcut("Android-Studio", UtilsAndroidStudio.PathToAndroidStudio()); - ProcessStartInfo processStartInfo = new ProcessStartInfo - { - FileName = androidStudioPath, - UseShellExecute = true - }; - Process.Start(processStartInfo); - } - else - { - LogSingleton.Get.LogAndWriteLine(" ERREUR Android Studio n'est pas installé"); - } - return Task.CompletedTask; - } - public static void AddToPath(string binPath) { string currentPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.User); diff --git a/scriptsharp/ScriptSharp/Utils/UtilsAndroidStudio.cs b/scriptsharp/ScriptSharp/Utils/UtilsAndroidStudio.cs index 051bd62..a2f2912 100644 --- a/scriptsharp/ScriptSharp/Utils/UtilsAndroidStudio.cs +++ b/scriptsharp/ScriptSharp/Utils/UtilsAndroidStudio.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.IO; using System.Threading.Tasks; @@ -22,4 +23,24 @@ public static async Task InstallAndroidStudio() await Utils.Unzip7ZFileAsync(Path.Combine(Config.LocalTemp, "android-studio.7z"), destinationFolder); LogSingleton.Get.LogAndWriteLine(" FAIT Installation Android Studio fini"); } + public static Task StartAndroidStudio() + { + LogSingleton.Get.LogAndWriteLine("Lancement d'Android Studio"); + string androidStudioPath = UtilsAndroidStudio.PathToAndroidStudio(); + if (File.Exists(androidStudioPath)) + { + Utils.CreateDesktopShortcut("Android-Studio", UtilsAndroidStudio.PathToAndroidStudio()); + ProcessStartInfo processStartInfo = new ProcessStartInfo + { + FileName = androidStudioPath, + UseShellExecute = true + }; + Process.Start(processStartInfo); + } + else + { + LogSingleton.Get.LogAndWriteLine(" ERREUR Android Studio n'est pas installé"); + } + return Task.CompletedTask; + } } \ No newline at end of file From 5208d8e89459810632a10bbe52bbebe7ba6c314f Mon Sep 17 00:00:00 2001 From: deguet Date: Thu, 17 Oct 2024 13:24:56 -0400 Subject: [PATCH 4/5] Better Safe than sorry --- scriptsharp/ScriptSharp/Utils/Utils.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scriptsharp/ScriptSharp/Utils/Utils.cs b/scriptsharp/ScriptSharp/Utils/Utils.cs index d6052a8..743270d 100644 --- a/scriptsharp/ScriptSharp/Utils/Utils.cs +++ b/scriptsharp/ScriptSharp/Utils/Utils.cs @@ -343,8 +343,10 @@ private static void RemoveAllEnv() public static void SetEnvVariable(string name, string value) { + Environment.SetEnvironmentVariable(name, value); Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.User); Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.Process); + Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.Machine); } private static void DeleteThis(string path) From 21f1e24833afeec5d3becf34cce1e9ba107a6942 Mon Sep 17 00:00:00 2001 From: deguet Date: Thu, 17 Oct 2024 13:51:58 -0400 Subject: [PATCH 5/5] Oups --- scriptsharp/ScriptSharp/Utils/Utils.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/scriptsharp/ScriptSharp/Utils/Utils.cs b/scriptsharp/ScriptSharp/Utils/Utils.cs index 743270d..84eec85 100644 --- a/scriptsharp/ScriptSharp/Utils/Utils.cs +++ b/scriptsharp/ScriptSharp/Utils/Utils.cs @@ -346,7 +346,6 @@ public static void SetEnvVariable(string name, string value) Environment.SetEnvironmentVariable(name, value); Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.User); Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.Process); - Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.Machine); } private static void DeleteThis(string path)