From e12a1e4a375d7817155e52b481e871acfc975843 Mon Sep 17 00:00:00 2001 From: Brian Robbins Date: Thu, 22 Aug 2024 02:17:58 -0700 Subject: [PATCH] Build Layout PerfView Command (#2099) Add the ability to build a fully extracted and self-contained PerfView layout. This is designed to avoid using the user-specific %appdata% installation of PerfView for scenarios where systems need to control updates and deployment of PerfView. --- src/PerfView/App.cs | 24 ++++++++++++++++++++++++ src/PerfView/Utilities/SupportFiles.cs | 5 +++++ 2 files changed, 29 insertions(+) diff --git a/src/PerfView/App.cs b/src/PerfView/App.cs index eb109853c..204753146 100755 --- a/src/PerfView/App.cs +++ b/src/PerfView/App.cs @@ -54,6 +54,25 @@ public static int Main(string[] args) (string.Compare(args[0], "/noGui", StringComparison.OrdinalIgnoreCase) == 0 || string.Compare(args[0], 0, "/logFile", 0, 8, StringComparison.OrdinalIgnoreCase) == 0)); + // Users will need to check the return code for failure because there is no console setup yet and we can't log any status. + var buildLayout = args.Length > 1 && string.Compare(args[0], "/buildLayout", StringComparison.OrdinalIgnoreCase) == 0; + if (buildLayout) + { + string destDirectory = args[1]; + if (Directory.Exists(destDirectory)) + { + return retCode; + } + + SupportFiles.SetSupportFilesDir(destDirectory); + App.Unpack(); + App.WriteDefaultAppConfigDataFile(destDirectory); + + retCode = 0; + return retCode; + } + + // If we need to install, display the splash screen early, otherwise wait if (!Directory.Exists(SupportFiles.SupportFileDir) && !noGui) { @@ -394,6 +413,11 @@ public static ConfigData AppConfigData } } + public static void WriteDefaultAppConfigDataFile(string directoryPath) + { + string defaultConfig = "\r\n .\\\r\n"; + File.WriteAllText(Path.Combine(directoryPath, "AppConfig.xml"), defaultConfig); + } // Logfile /// diff --git a/src/PerfView/Utilities/SupportFiles.cs b/src/PerfView/Utilities/SupportFiles.cs index 89d93c300..a6de51296 100755 --- a/src/PerfView/Utilities/SupportFiles.cs +++ b/src/PerfView/Utilities/SupportFiles.cs @@ -338,6 +338,11 @@ private static void UnpackResources() } } + internal static void SetSupportFilesDir(string supportFilesDir) + { + s_supportFileDir = supportFilesDir; + } + private static void Cleanup() { string cleanupMarkerFile = Path.Combine(SupportFileDirBase, "CleanupNeeded");