Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mastersign committed Apr 12, 2024
2 parents 9b875ce + 2705400 commit fb3cfc7
Show file tree
Hide file tree
Showing 29 changed files with 808 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/archive
/release
/applibs
/res/setup

/docs

Expand Down
4 changes: 2 additions & 2 deletions BenchManager/BenchCLI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.22.6.0")]
[assembly: AssemblyFileVersion("0.22.6.0")]
[assembly: AssemblyVersion("0.23.0.0")]
[assembly: AssemblyFileVersion("0.23.0.0")]
50 changes: 25 additions & 25 deletions BenchManager/BenchDashboard/ExportForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion BenchManager/BenchDashboard/ExportForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void BrowseForTargetFile()
OverwritePrompt = true,
CheckPathExists = true,
AddExtension = true,
Filter = "SFX Archive (*.exe)|*.exe|7-Zip Archive (*.7z)|*.7z|ZIP Archive (*.zip)|*.zip",
Filter = "Setup Program (*.exe)|*.exe|7-Zip Archive (*.7z)|*.7z|ZIP Archive (*.zip)|*.zip",
FilterIndex = 0,
ValidateNames = true,
FileName = txtTarget.Text,
Expand Down
4 changes: 2 additions & 2 deletions BenchManager/BenchDashboard/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.22.6.0")]
[assembly: AssemblyFileVersion("0.22.6.0")]
[assembly: AssemblyVersion("0.23.0.0")]
[assembly: AssemblyFileVersion("0.23.0.0")]
119 changes: 87 additions & 32 deletions BenchManager/BenchLib/BenchTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2308,6 +2308,7 @@ private static void InstallPythonPackage(BenchConfiguration config, IProcessExec
}
var argList = new List<string>();
argList.Add("install");
argList.Add("--no-warn-script-location");
if (app.IsInstalled) argList.Add("--upgrade");
//argList.Add("--quiet");
if (!app.IsManagedPackageFromRemoteRepo) // python wheel file
Expand Down Expand Up @@ -3008,7 +3009,7 @@ private static void ExportBenchEnvironment(IBenchManager man,
}
var sfxArchive = extension == ".exe";
if (sfxArchive)
ExportBenchEnvironmentSfx(man, notify, targetFile, paths);
ExportBenchEnvironmentSetupProgram(man, notify, targetFile, paths);
else
ExportBenchEnvironmentArchive(man, notify, targetFile, paths);
}
Expand All @@ -3031,58 +3032,113 @@ private static void CopyFileToStream(string file, Stream trg, int bufferSize = 6
}
}

private static TextWriter WriteSfxConfig(BenchConfiguration cfg, Stream trg, bool withInfoText, bool userProfileChangeWarning)
private static void WriteSetupText(string targetDir, string title, bool preConfigured, bool userProfileChangeWarning)
{
var enc = new UTF8Encoding(false);
var w = new StreamWriter(trg, enc, 1024);
w.WriteLine(";!@Install@!UTF-8!");
if (withInfoText)
File.WriteAllText(Path.Combine(targetDir, "Title.txt"), title, enc);
using (var w = new StreamWriter(Path.Combine(targetDir, "Info.txt"), append: false, encoding: enc))
{
w.WriteLine("Title=\"Bench Transfer Package\"");
w.Write("BeginPrompt=\"This is a pre - configured Bench environment. If you proceed, you will be asked for a target directory to extract and setup the Bench environment.\n\n");
if (userProfileChangeWarning)
if (preConfigured)
{
w.Write("Warning: Because this bench environment is configured to register in the user profile, the environment variables and possibly some registry keys of your user profile will be modified during setup.\n\n");
w.WriteLine("This is a pre-configured Bench environment.");
w.WriteLine();
if (userProfileChangeWarning)
{
w.WriteLine("Warning: Because this bench environment is configured to register in the user profile, the environment variables and possibly some registry keys of your user profile will be modified during setup.");
w.WriteLine();
}
w.WriteLine("See https://winbench.org/ for more info.");
}
else
{
w.WriteLine("This is the standard Bench setup package with the default environment.");
}
w.WriteLine("See https://winbench.org/ for more info.\n\nAre you sure you want to extract and setup this Bench environment?\"");
}
w.WriteLine(@"RunProgram="".\\auto\\bin\\bench.exe --verbose transfer install""");
w.Write(";!@InstallEnd@!");
w.Flush();
return w;
}

private static bool ExportBenchEnvironmentSfx(IBenchManager man, Action<TaskInfo> notify, string targetFile, string[] paths)
private static bool ExportBenchEnvironmentSetupProgram(IBenchManager man, Action<TaskInfo> notify, string targetFile, string[] paths)
{
var tmpArchive = Path.Combine(
var msbuild = Environment.ExpandEnvironmentVariables("%SystemRoot%\\Microsoft.NET\\Framework64\\v4.0.30319\\msbuild.exe");
if (!File.Exists(msbuild))
{
msbuild = Environment.ExpandEnvironmentVariables("%SystemRoot%\\Microsoft.NET\\Framework\\v4.0.30319\\msbuild.exe");
}
if (!File.Exists(msbuild))
{
notify(new TaskError("Can not find the MSBuild CLI as part of the .NET Framework 4"));
return false;
}

var tmpDir = Path.Combine(
man.Config.GetStringValue(ConfigPropertyKeys.TempDir),
"bench_export_" + Path.ChangeExtension(Path.GetRandomFileName(), ".7z"));
"bench_setup_" + Path.GetRandomFileName().Replace(".", ""));

if (!ExportBenchEnvironmentArchive(man, notify, tmpArchive, paths)) return false;
Directory.CreateDirectory(tmpDir);
var cleanup = true;

var sfxPath = Path.Combine(Path.Combine(man.Config.BenchRootDir, "res"), "bench.sfx");
try
{
using (var s = File.Open(targetFile, FileMode.Create, FileAccess.Write))
var setupProjectDir = Path.Combine(Path.Combine(man.Config.BenchRootDir, "res"), "setup");
var fileList = File.ReadAllLines(Path.Combine(setupProjectDir, "files.txt"));
foreach (var file in fileList)
{
CopyFileToStream(sfxPath, s);
var userConfigDir = man.Config.GetStringValue(ConfigPropertyKeys.UserConfigDir);
var includeUserConfig = Seq(paths).Any(p => string.Equals(userConfigDir,
Path.Combine(man.Config.BenchRootDir, p), StringComparison.InvariantCultureIgnoreCase));
WriteSfxConfig(man.Config, s,
withInfoText: includeUserConfig,
userProfileChangeWarning: man.Config.GetBooleanValue(ConfigPropertyKeys.RegisterInUserProfile));
CopyFileToStream(tmpArchive, s);
if (string.IsNullOrWhiteSpace(file)) continue;
File.Copy(Path.Combine(setupProjectDir, file), Path.Combine(tmpDir, file));
}
File.Delete(tmpArchive);

var userConfigDir = man.Config.GetStringValue(ConfigPropertyKeys.UserConfigDir);
var includeUserConfig = Seq(paths).Any(p => string.Equals(userConfigDir,
Path.Combine(man.Config.BenchRootDir, p), StringComparison.InvariantCultureIgnoreCase));

WriteSetupText(tmpDir, "Bench Setup",
preConfigured: includeUserConfig,
userProfileChangeWarning: man.Config.GetBooleanValue(ConfigPropertyKeys.RegisterInUserProfile));
var tmpArchive = Path.Combine(tmpDir, "Bench.zip");

if (!ExportBenchEnvironmentArchive(man, notify, tmpArchive, paths)) return false;

if (File.Exists(targetFile)) File.Delete(targetFile);

var execHost = man.ProcessExecutionHost;
var result = execHost.RunProcess(man.Env, tmpDir, msbuild,
string.Join(" ",
"-nologo",
"-verbosity:normal",
"-t:Clean;PrepareResources;Compile",
"-p:Configuration=Release",
"-fileLogger",
"-fileLoggerParameters:logfile=build.log;verbosity=detailed",
"BenchSetup.csproj"),
ProcessMonitoring.ExitCode);
if (result.ExitCode != 0)
{
notify(new TaskError("MSBuild exited with error. Exit status: " + result.ExitCode));
return false;
}

var setupExe = Path.Combine(tmpDir, "obj", "Release", "BenchSetup.exe");
if (!File.Exists(setupExe))
{
cleanup = false;
notify(new TaskError("Compiling the transfer package failed."));
return false;
}
File.Move(setupExe, targetFile);
}
catch (Exception e)
{
notify(new TaskError(
"Failed to export the Bench environment.",
notify(new TaskError("Failed to export the Bench environment.",
exception: e));
return false;
}
finally
{
if (cleanup)
{
Directory.Delete(tmpDir, true);
}
}

return true;
}

Expand All @@ -3109,7 +3165,6 @@ private static bool ExportBenchEnvironmentArchive(IBenchManager man, Action<Task
ProcessMonitoring.ExitCode);
if (result.ExitCode != 0)
{

notify(new TaskError($"Creating export archive with 7zip failed with exit code {result.ExitCode}."));
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions BenchManager/BenchLib/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.22.6.0")]
[assembly: AssemblyFileVersion("0.22.6.0")]
[assembly: AssemblyVersion("0.23.0.0")]
[assembly: AssemblyFileVersion("0.23.0.0")]
9 changes: 9 additions & 0 deletions BenchSetup/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
obj
bin
.vs/
*.suo
*.user
*.cache
*.exe

/packages
17 changes: 17 additions & 0 deletions BenchSetup/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.Reflection;
using System.Runtime.InteropServices;

[assembly: AssemblyTitle("benchSetup")]
[assembly: AssemblyDescription("Setup application for Bench")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Tobias Kiertscher")]
[assembly: AssemblyProduct("Bench")]
[assembly: AssemblyCopyright("Copyright © Tobias Kiertscher 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: ComVisible(false)]
[assembly: Guid("da29f93f-382f-46fd-93dd-aa0ef6d87bd5")]

[assembly: AssemblyVersion("0.1.0.0")]
[assembly: AssemblyFileVersion("0.1.0.0")]
Binary file added BenchSetup/Bench.zip
Binary file not shown.
Loading

0 comments on commit fb3cfc7

Please sign in to comment.