Skip to content

Commit

Permalink
Build Layout PerfView Command (#2099)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brianrob authored Aug 22, 2024
1 parent 18fa52b commit e12a1e4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/PerfView/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -394,6 +413,11 @@ public static ConfigData AppConfigData
}
}

public static void WriteDefaultAppConfigDataFile(string directoryPath)
{
string defaultConfig = "<ConfigData>\r\n <SupportFilesDir>.\\</SupportFilesDir>\r\n</ConfigData>";
File.WriteAllText(Path.Combine(directoryPath, "AppConfig.xml"), defaultConfig);
}

// Logfile
/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions src/PerfView/Utilities/SupportFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit e12a1e4

Please sign in to comment.