Skip to content

Commit dd17df5

Browse files
committed
addition of setup registrykey configuration
1 parent 94210d9 commit dd17df5

File tree

6 files changed

+83
-48
lines changed

6 files changed

+83
-48
lines changed

source/P4VFS.Console/P4VFS.Notes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ Version [1.29.0.0]
1717
to stress test a wide range of message sizes
1818
* Fixing unit tests deterministic random byte generation to more randomly include
1919
zero as randomly as possible
20+
* Support for additional registry keys to set defined in the setup application configuration
21+
file (typically named P4VFS.Setup.xml residing in the same folder as the installer).
22+
This is helpfull for setting possibly setting a version key to indicate what settings
23+
template was also installed.
2024

2125
Version [1.28.4.0]
2226
* Addition of optional service commandline argument to launch with debugger attached.

source/P4VFS.Driver/Include/DriverVersion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
#define P4VFS_VER_MAJOR 1 // Increment this number almost never
66
#define P4VFS_VER_MINOR 28 // Increment this number whenever the driver changes
7-
#define P4VFS_VER_BUILD 4 // Increment this number when a major user mode change has been made
8-
#define P4VFS_VER_REVISION 9 // Increment this number when we rebuild with any change
7+
#define P4VFS_VER_BUILD 5 // Increment this number when a major user mode change has been made
8+
#define P4VFS_VER_REVISION 0 // Increment this number when we rebuild with any change
99

1010
#define P4VFS_VER_STRINGIZE_EX(v) L#v
1111
#define P4VFS_VER_STRINGIZE(v) P4VFS_VER_STRINGIZE_EX(v)

source/P4VFS.Setup/P4VFS.Setup.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
</ItemGroup>
105105
<ItemGroup>
106106
<Compile Include="Properties\AssemblyInfo.cs" />
107-
<Compile Include="Source\Configuration.cs" />
107+
<Compile Include="Source\SetupConfiguration.cs" />
108108
<Compile Include="Source\Program.cs" />
109109
<Compile Include="Source\SetupWindow.xaml.cs">
110110
<DependentUpon>SetupWindow.xaml</DependentUpon>

source/P4VFS.Setup/Source/Configuration.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

source/P4VFS.Setup/Source/Program.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.P4VFS.Setup
1717
public class Program
1818
{
1919
public static SetupWindow _SetupWindow;
20-
public static List<string> _IncludeFiles;
20+
public static SetupConfiguration _Configuration;
2121
public static bool _Admin;
2222
public static bool _Console;
2323
public static bool _P4vfsDebug;
@@ -58,11 +58,9 @@ public static int Main(string[] args)
5858
_Admin = false;
5959
_Console = false;
6060
_P4vfsDebug = false;
61-
_IncludeFiles = new List<string>();
61+
_Configuration = new SetupConfiguration();
6262

63-
Configuration config = LoadConfiguration();
64-
if (config != null && config.IncludeFiles != null)
65-
_IncludeFiles.AddRange(config.IncludeFiles);
63+
_Configuration.Import(LoadConfiguration());
6664

6765
int argIndex = 0;
6866
for (; argIndex < args.Length; ++argIndex)
@@ -74,7 +72,7 @@ public static int Main(string[] args)
7472
else if (String.Compare(args[argIndex], "-c") == 0)
7573
_Console = true;
7674
else if (String.Compare(args[argIndex], "-i") == 0 && argIndex+1 < args.Length)
77-
_IncludeFiles.Add(args[++argIndex]);
75+
_Configuration.IncludeFiles.Add(args[++argIndex]);
7876
else if (String.Compare(args[argIndex], "-d") == 0)
7977
_P4vfsDebug = true;
8078
else
@@ -250,7 +248,7 @@ private static bool CommandInstall(string[] args)
250248
}
251249

252250
progress.WriteLine(6, String.Format("Installing application setup ..."));
253-
if (InstallAplicationSetup() == false)
251+
if (InstallApplicationSetup() == false)
254252
{
255253
WriteLine(String.Format("Failed installing requirements for application setup"));
256254
return false;
@@ -368,7 +366,9 @@ private static bool InstallEnvironment()
368366

369367
List<string> paths = new List<string>(srcPath.Split(new char[]{';'}, StringSplitOptions.RemoveEmptyEntries));
370368
if (paths.Any(s => String.Compare(InstallFolder, Regex.Replace(s, @"[\\/]+", "\\").TrimEnd('\\'), StringComparison.InvariantCultureIgnoreCase) == 0) == false)
369+
{
371370
paths.Add(InstallFolder);
371+
}
372372

373373
string dstPath = String.Join(";", paths);
374374
envKey.SetValue("PATH", dstPath, RegistryValueKind.ExpandString);
@@ -398,7 +398,7 @@ private static void RefreshEnvironmentVariables()
398398
Environment.SetEnvironmentVariable("P4VFS_INSTALL", null, EnvironmentVariableTarget.Machine);
399399
}
400400

401-
private static bool InstallAplicationSetup()
401+
private static bool InstallApplicationSetup()
402402
{
403403
try
404404
{
@@ -419,6 +419,12 @@ private static bool InstallAplicationSetup()
419419
appKey.SetValue("UninstallString", String.Format("\"{0}\" uninstall", installedSetupExe), RegistryValueKind.String);
420420
appKey.SetValue("Publisher", "Microsoft Corporation", RegistryValueKind.String);
421421
appKey.SetValue("InstallLocation", InstallFolder, RegistryValueKind.String);
422+
423+
foreach (SetupRegistryKey setupKey in _Configuration.RegistryKeys)
424+
{
425+
WriteLine(String.Format("Setting additional registry key: {0}={1}", setupKey.Name, setupKey.Value));
426+
appKey.SetValue(setupKey.Name, setupKey.Value, RegistryValueKind.String);
427+
}
422428
}
423429
}
424430
catch (Exception e)
@@ -637,13 +643,13 @@ private static string CreateStagingFolder()
637643
}
638644

639645
string[] resourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
640-
using (LogProgress progress = new LogProgress(resourceNames.Length+_IncludeFiles.Count+2))
646+
using (LogProgress progress = new LogProgress(resourceNames.Length+_Configuration.IncludeFiles.Count+2))
641647
{
642648
WriteLine(String.Format("Staging: {0}", stagingFolder));
643649
if (ExtractResourcesToFolder(resourceNames, stagingFolder, progress) == false)
644650
return null;
645651

646-
foreach (string includeFile in _IncludeFiles)
652+
foreach (string includeFile in _Configuration.IncludeFiles)
647653
{
648654
progress.Increment();
649655
string includeFilePath = ResolveIncludeFilePath(includeFile);
@@ -728,7 +734,7 @@ private static string ResolveIncludeFilePath(string filePath)
728734
return filePath;
729735
}
730736

731-
private static Configuration LoadConfiguration()
737+
private static SetupConfiguration LoadConfiguration()
732738
{
733739
string[] configFiles = new[]{
734740
"P4VFS.Setup.xml",
@@ -740,7 +746,7 @@ private static Configuration LoadConfiguration()
740746
string configFilePath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), configFile));
741747
if (File.Exists(configFilePath))
742748
{
743-
Configuration config = Configuration.LoadFromFile(configFilePath);
749+
SetupConfiguration config = SetupConfiguration.LoadFromFile(configFilePath);
744750
if (config != null)
745751
{
746752
WriteLine(String.Format("Loaded Configuration: {0}", configFilePath));
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
using System;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Collections.Generic;
7+
using System.Xml.Serialization;
8+
9+
namespace Microsoft.P4VFS.Setup
10+
{
11+
[XmlRoot("Configuration", Namespace="")]
12+
public class SetupConfiguration
13+
{
14+
[XmlArray("IncludeFiles"), XmlArrayItem("Path", typeof(string))]
15+
public List<string> IncludeFiles;
16+
17+
[XmlArray("RegistryKeys"), XmlArrayItem("Key", typeof(SetupRegistryKey))]
18+
public List<SetupRegistryKey> RegistryKeys;
19+
20+
public static SetupConfiguration LoadFromFile(string fileName)
21+
{
22+
try
23+
{
24+
using (FileStream fs = File.OpenRead(fileName))
25+
{
26+
XmlSerializer xml = new XmlSerializer(typeof(SetupConfiguration));
27+
SetupConfiguration config = xml.Deserialize(fs) as SetupConfiguration;
28+
return config;
29+
}
30+
}
31+
catch {}
32+
return null;
33+
}
34+
35+
public void Import(SetupConfiguration config)
36+
{
37+
if (IncludeFiles == null)
38+
IncludeFiles = new List<string>();
39+
if (config?.IncludeFiles != null)
40+
IncludeFiles.AddRange(config.IncludeFiles);
41+
42+
if (RegistryKeys == null)
43+
RegistryKeys = new List<SetupRegistryKey>();
44+
if (config?.RegistryKeys != null)
45+
RegistryKeys.AddRange(config.RegistryKeys);
46+
}
47+
}
48+
49+
public class SetupRegistryKey
50+
{
51+
[XmlAttribute]
52+
public string Name;
53+
54+
[XmlAttribute]
55+
public string Value;
56+
}
57+
}
58+

0 commit comments

Comments
 (0)