Index: tools/install/Installer.cs ================================================================== --- tools/install/Installer.cs +++ tools/install/Installer.cs @@ -21,10 +21,11 @@ #if NET_20 || NET_35 using System.Security.Permissions; #endif +using System.Text; using System.Threading; using System.Windows.Forms; using System.Xml; using Microsoft.Win32; @@ -769,12 +770,14 @@ get { CheckDisposed(); if (classesRoot == null) + { classesRoot = new MockRegistryKey( Registry.ClassesRoot, whatIf, readOnly, safe); + } return classesRoot; } } @@ -786,12 +789,14 @@ get { CheckDisposed(); if (currentConfig == null) + { currentConfig = new MockRegistryKey( Registry.CurrentConfig, whatIf, readOnly, safe); + } return currentConfig; } } @@ -803,12 +808,14 @@ get { CheckDisposed(); if (currentUser == null) + { currentUser = new MockRegistryKey( Registry.CurrentUser, whatIf, readOnly, safe); + } return currentUser; } } @@ -820,12 +827,14 @@ get { CheckDisposed(); if (dynData == null) + { dynData = new MockRegistryKey( Registry.DynData, whatIf, readOnly, safe); + } return dynData; } } @@ -837,12 +846,14 @@ get { CheckDisposed(); if (localMachine == null) + { localMachine = new MockRegistryKey( Registry.LocalMachine, whatIf, readOnly, safe); + } return localMachine; } } @@ -854,12 +865,14 @@ get { CheckDisposed(); if (performanceData == null) + { performanceData = new MockRegistryKey( Registry.PerformanceData, whatIf, readOnly, safe); + } return performanceData; } } @@ -871,12 +884,14 @@ get { CheckDisposed(); if (users == null) + { users = new MockRegistryKey( Registry.Users, whatIf, readOnly, safe); + } return users; } } #endregion @@ -1191,15 +1206,20 @@ // itself since no writes are allowed in "what-if" // mode anyhow. // RegistryKey subKey = key.OpenSubKey(subKeyName); - return (subKey != null) ? - new MockRegistryKey( - subKey, whatIf, readOnly, safe) : - new MockRegistryKey( - key, subKeyName, whatIf, readOnly, safe); + if (subKey != null) + { + return new MockRegistryKey( + subKey, whatIf, readOnly, safe); + } + else + { + return new MockRegistryKey( + key, subKeyName, whatIf, readOnly, safe); + } } else { return new MockRegistryKey( key.CreateSubKey(subKeyName), whatIf, readOnly, safe); @@ -1283,10 +1303,22 @@ return key.GetValue(name, defaultValue); } /////////////////////////////////////////////////////////////////// + public string[] GetValueNames() + { + CheckDisposed(); + + if (key == null) + return null; + + return key.GetValueNames(); + } + + /////////////////////////////////////////////////////////////////// + public MockRegistryKey OpenSubKey( string subKeyName ) { CheckDisposed(); @@ -1310,12 +1342,14 @@ return null; RegistryKey subKey = key.OpenSubKey( subKeyName, whatIf ? false : writable); - return (subKey != null) ? - new MockRegistryKey(subKey, whatIf, readOnly, safe) : null; + if (subKey == null) + return null; + + return new MockRegistryKey(subKey, whatIf, readOnly, safe); } /////////////////////////////////////////////////////////////////// public void SetValue( @@ -1345,11 +1379,11 @@ if (key == null) return null; return !String.IsNullOrEmpty(subKeyName) ? - String.Format("{0}\\{1}", key.Name, subKeyName) : + RegistryHelper.JoinKeyNames(key.Name, subKeyName) : key.Name; } } /////////////////////////////////////////////////////////////////// @@ -1515,14 +1549,82 @@ } #endregion /////////////////////////////////////////////////////////////////////// + #region RegistryRootKeyNames Class + private static class RegistryRootKeyNames + { + public const string HKEY_CLASSES_ROOT = "HKEY_CLASSES_ROOT"; + public const string HKCR = "HKCR"; + + /////////////////////////////////////////////////////////////////// + + public const string HKEY_CURRENT_CONFIG = "HKEY_CURRENT_CONFIG"; + public const string HKCC = "HKCC"; + + /////////////////////////////////////////////////////////////////// + + public const string HKEY_CURRENT_USER = "HKEY_CURRENT_USER"; + public const string HKCU = "HKCU"; + + /////////////////////////////////////////////////////////////////// + + public const string HKEY_DYN_DATA = "HKEY_DYN_DATA"; + public const string HKDD = "HKDD"; + + /////////////////////////////////////////////////////////////////// + + public const string HKEY_LOCAL_MACHINE = "HKEY_LOCAL_MACHINE"; + public const string HKLM = "HKLM"; + + /////////////////////////////////////////////////////////////////// + + public const string HKEY_PERFORMANCE_DATA = "HKEY_PERFORMANCE_DATA"; + public const string HKPD = "HKPD"; + + /////////////////////////////////////////////////////////////////// + + public const string HKEY_USERS = "HKEY_USERS"; + public const string HKU = "HKU"; + } + #endregion + + /////////////////////////////////////////////////////////////////////// + #region RegistryHelper Class + #region Private Constants + private const char KeyNameSeparator = '\\'; + + /////////////////////////////////////////////////////////////////////// + + private static readonly char[] KeyNameSeparators = { + KeyNameSeparator + }; + #endregion + + /////////////////////////////////////////////////////////////////////// + private static class RegistryHelper { #region Public Static Properties + private static MockRegistry readOnlyRegistry; + public static MockRegistry ReadOnlyRegistry + { + get { return readOnlyRegistry; } + } + + /////////////////////////////////////////////////////////////////// + + private static MockRegistry readWriteRegistry; + public static MockRegistry ReadWriteRegistry + { + get { return readWriteRegistry; } + } + + /////////////////////////////////////////////////////////////////// + private static int subKeysCreated; public static int SubKeysCreated { get { return subKeysCreated; } } @@ -1561,10 +1663,200 @@ #endregion /////////////////////////////////////////////////////////////////// #region Public Static Methods + public static void ReinitializeDefaultRegistries( + bool whatIf, + bool safe + ) + { + if (readOnlyRegistry != null) + { + readOnlyRegistry.Dispose(); + readOnlyRegistry = null; + } + + if (readWriteRegistry != null) + { + readWriteRegistry.Dispose(); + readWriteRegistry = null; + } + + readOnlyRegistry = new MockRegistry(whatIf, true, safe); + readWriteRegistry = new MockRegistry(whatIf, false, safe); + } + + /////////////////////////////////////////////////////////////////// + + public static MockRegistryKey GetReadOnlyRootKey( + string name + ) + { + return GetRootKey(readOnlyRegistry, name); + } + + /////////////////////////////////////////////////////////////////// + + public static MockRegistryKey GetReadWriteRootKey( + string name + ) + { + return GetRootKey(readWriteRegistry, name); + } + + /////////////////////////////////////////////////////////////////// + + public static MockRegistryKey GetRootKey( + MockRegistry registry, + string name + ) + { + if (registry == null) + return null; + + if (String.Equals( + name, RegistryRootKeyNames.HKEY_CLASSES_ROOT, + StringComparison.OrdinalIgnoreCase) || + String.Equals( + name, RegistryRootKeyNames.HKCR, + StringComparison.OrdinalIgnoreCase)) + { + return registry.ClassesRoot; + } + else if (String.Equals( + name, RegistryRootKeyNames.HKEY_CURRENT_CONFIG, + StringComparison.OrdinalIgnoreCase) || + String.Equals( + name, RegistryRootKeyNames.HKCC, + StringComparison.OrdinalIgnoreCase)) + { + return registry.CurrentConfig; + } + else if (String.Equals( + name, RegistryRootKeyNames.HKEY_CURRENT_USER, + StringComparison.OrdinalIgnoreCase) || + String.Equals( + name, RegistryRootKeyNames.HKCU, + StringComparison.OrdinalIgnoreCase)) + { + return registry.CurrentUser; + } + else if (String.Equals( + name, RegistryRootKeyNames.HKEY_DYN_DATA, + StringComparison.OrdinalIgnoreCase) || + String.Equals( + name, RegistryRootKeyNames.HKDD, + StringComparison.OrdinalIgnoreCase)) + { + return registry.DynData; + } + else if (String.Equals( + name, RegistryRootKeyNames.HKEY_LOCAL_MACHINE, + StringComparison.OrdinalIgnoreCase) || + String.Equals( + name, RegistryRootKeyNames.HKLM, + StringComparison.OrdinalIgnoreCase)) + { + return registry.LocalMachine; + } + else if (String.Equals( + name, RegistryRootKeyNames.HKEY_PERFORMANCE_DATA, + StringComparison.OrdinalIgnoreCase) || + String.Equals( + name, RegistryRootKeyNames.HKPD, + StringComparison.OrdinalIgnoreCase)) + { + return registry.PerformanceData; + } + else if (String.Equals( + name, RegistryRootKeyNames.HKEY_USERS, + StringComparison.OrdinalIgnoreCase) || + String.Equals( + name, RegistryRootKeyNames.HKU, + StringComparison.OrdinalIgnoreCase)) + { + return registry.Users; + } + + return null; + } + + /////////////////////////////////////////////////////////////////// + + public static string JoinKeyNames( + params string[] names + ) + { + if ((names == null) || (names.Length == 0)) + return null; + + StringBuilder builder = new StringBuilder(); + + foreach (string name in names) + { + if (name == null) + continue; + + string newName = name.Trim(KeyNameSeparator); + + if (String.IsNullOrEmpty(newName)) + continue; + + if (builder.Length > 0) + builder.Append(KeyNameSeparator); + + builder.Append(newName); + } + + return builder.ToString(); + } + + /////////////////////////////////////////////////////////////////// + + public static string JoinKeyNames( + MockRegistryKey key, + params string[] names + ) + { + string result = JoinKeyNames(names); + + if (key != null) + result = JoinKeyNames(key.Name, result); + + return result; + } + + /////////////////////////////////////////////////////////////////// + + public static string[] SplitKeyName( + string keyName + ) + { + if (keyName == null) + return null; + + return keyName.Split( + KeyNameSeparators, StringSplitOptions.RemoveEmptyEntries); + } + + /////////////////////////////////////////////////////////////////// + + public static string LastSubKeyName( + string keyName + ) + { + string[] subKeyNames = SplitKeyName(keyName); + + if ((subKeyNames == null) || (subKeyNames.Length == 0)) + return null; + + return subKeyNames[subKeyNames.Length - 1]; + } + + /////////////////////////////////////////////////////////////////// + [MethodImpl(MethodImplOptions.NoInlining)] public static MockRegistryKey OpenSubKey( MockRegistryKey rootKey, string subKeyName, bool writable, @@ -1571,16 +1863,18 @@ bool whatIf, bool verbose ) { if (verbose) + { TraceOps.DebugAndTrace(writable ? TracePriority.Highest : TracePriority.Higher, debugCallback, traceCallback, String.Format( "rootKey = {0}, subKeyName = {1}, writable = {2}", ForDisplay(rootKey), ForDisplay(subKeyName), ForDisplay(writable)), traceCategory); + } if (rootKey == null) return null; // @@ -1603,15 +1897,17 @@ bool whatIf, bool verbose ) { if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, String.Format( "rootKey = {0}, subKeyName = {1}", ForDisplay(rootKey), ForDisplay(subKeyName)), traceCategory); + } if (rootKey == null) return null; try @@ -1657,15 +1953,17 @@ bool whatIf, bool verbose ) { if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, String.Format( "rootKey = {0}, subKeyName = {1}", ForDisplay(rootKey), ForDisplay(subKeyName)), traceCategory); + } if (rootKey == null) return; if (!whatIf) @@ -1683,15 +1981,17 @@ bool whatIf, bool verbose ) { if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, String.Format( "rootKey = {0}, subKeyName = {1}", ForDisplay(rootKey), ForDisplay(subKeyName)), traceCategory); + } if (rootKey == null) return; if (!whatIf) @@ -1708,13 +2008,15 @@ bool whatIf, bool verbose ) { if (verbose) + { TraceOps.DebugAndTrace(TracePriority.High, debugCallback, traceCallback, String.Format( "key = {0}", ForDisplay(key)), traceCategory); + } if (key == null) return null; return key.GetSubKeyNames(); @@ -1730,15 +2032,17 @@ bool whatIf, bool verbose ) { if (verbose) + { TraceOps.DebugAndTrace(TracePriority.High, debugCallback, traceCallback, String.Format( "key = {0}, name = {1}, defaultValue = {2}", ForDisplay(key), ForDisplay(name), ForDisplay(defaultValue)), traceCategory); + } if (key == null) return null; object value = key.GetValue(name, defaultValue); @@ -1758,15 +2062,17 @@ bool whatIf, bool verbose ) { if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, String.Format( "key = {0}, name = {1}, value = {2}", ForDisplay(key), ForDisplay(name), ForDisplay(value)), traceCategory); + } if (key == null) return; if (!whatIf) @@ -1785,14 +2091,16 @@ bool whatIf, bool verbose ) { if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, String.Format( "key = {0}, name = {1}", ForDisplay(key), ForDisplay(name)), traceCategory); + } if (key == null) return; if (!whatIf) @@ -3439,14 +3747,16 @@ // // NOTE: If the debugger is attached and "what-if" // mode is [now] disabled, issue a warning. // if (Debugger.IsAttached) + { TraceOps.DebugAndTrace(TracePriority.MediumHigh, debugCallback, traceCallback, "Forced to disable \"what-if\" mode with " + "debugger attached.", traceCategory); + } } else { TraceOps.DebugAndTrace(TracePriority.MediumHigh, debugCallback, traceCallback, @@ -5025,13 +5335,13 @@ // BUGFIX: Apparently, the per-user registry hive does not use // the "Wow6432Node" node to store settings for 32-bit // applications running on a 64-bit operating system. // Ticket [a0677309f0] has further details. // - return String.Format("{0}{1}", RootKeyName, + return RegistryHelper.JoinKeyNames(RootKeyName, !perUser && wow64 && Is64BitProcess() ? - "\\" + Wow64SubKeyName : String.Empty); + Wow64SubKeyName : String.Empty); } /////////////////////////////////////////////////////////////////////// private static string GetSystemDirectory( @@ -5202,12 +5512,13 @@ private static string GetFrameworkRootKeyName( bool perUser, bool wow64 ) { - return String.Format("{0}\\Microsoft\\.NETFramework", - GetRootKeyName(perUser, wow64)); + return RegistryHelper.JoinKeyNames( + GetRootKeyName(perUser, wow64), + "Microsoft", ".NETFramework"); } /////////////////////////////////////////////////////////////////////// private static string GetFrameworkKeyName( @@ -5216,16 +5527,16 @@ string platformName, bool perUser, bool wow64 ) { - string format = !String.IsNullOrEmpty(platformName) ? - "{0}\\Microsoft\\{1}\\v{2}\\{3}" : - "{0}\\Microsoft\\{1}\\v{2}"; + string frameworkVersionString = (frameworkVersion != null) ? + "v" + frameworkVersion.ToString() : null; - return String.Format(format, GetRootKeyName(perUser, wow64), - frameworkName, frameworkVersion, platformName); + return RegistryHelper.JoinKeyNames( + GetRootKeyName(perUser, wow64), "Microsoft", frameworkName, + frameworkVersionString, platformName); } /////////////////////////////////////////////////////////////////////// private static string GetImageRuntimeVersion( @@ -5703,15 +6014,17 @@ { if (localSaved && !saved) saved = true; if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Lowest, debugCallback, traceCallback, String.Format( "localSaved = {0}, saved = {1}", ForDisplay(localSaved), ForDisplay(saved)), traceCategory); + } } } } return true; @@ -6130,14 +6443,16 @@ } if (dirty || whatIf) { if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, String.Format( "addElement = {0}", ForDisplay(addElement)), traceCategory); + } if (!whatIf) document.Save(fileName); filesModified++; @@ -6173,12 +6488,12 @@ { addElement.ParentNode.RemoveChild(addElement); dirty = true; } - XmlElement removeElement = document.SelectSingleNode( - String.Format(XPathForRemoveElement, invariantName)) as XmlElement; + XmlElement removeElement = document.SelectSingleNode(String.Format( + XPathForRemoveElement, invariantName)) as XmlElement; if (removeElement != null) { removeElement.ParentNode.RemoveChild(removeElement); dirty = true; @@ -6185,15 +6500,17 @@ } if (dirty || whatIf) { if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, String.Format( "addElement = {0}, removeElement = {1}", ForDisplay(addElement), ForDisplay(removeElement)), traceCategory); + } if (!whatIf) document.Save(fileName); filesModified++; @@ -6259,21 +6576,21 @@ string platformName, bool perUser, bool wow64 ) { + string frameworkVersionString = (frameworkVersion != null) ? + "v" + frameworkVersion.ToString() : null; + // // NOTE: This registry key appears to always be 32-bit only // (i.e. probably because it is only used by Visual // Studio, which is currently always 32-bit only). // - string format = !String.IsNullOrEmpty(platformName) ? - "{0}\\Microsoft\\{1}\\v{2}\\{3}\\AssemblyFoldersEx" : - "{0}\\Microsoft\\{1}\\v{2}\\AssemblyFoldersEx"; - - return String.Format(format, GetRootKeyName(perUser, wow64), - frameworkName, frameworkVersion, platformName); + return String.Format(GetRootKeyName(perUser, wow64), + "Microsoft", frameworkName, frameworkVersionString, + platformName, "AssemblyFoldersEx"); } /////////////////////////////////////////////////////////////////////// private static bool AddToAssemblyFolders( @@ -6298,12 +6615,12 @@ rootKey, keyName, true, whatIf, verbose)) { if (key == null) { error = String.Format( - "could not open registry key: {0}\\{1}", - rootKey, keyName); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(rootKey, keyName)); return false; } using (MockRegistryKey subKey = RegistryHelper.CreateSubKey( @@ -6310,12 +6627,12 @@ key, subKeyName, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not create registry key: {0}\\{1}", - key, subKeyName); + "could not create registry key: {0}", + RegistryHelper.JoinKeyNames(key, subKeyName)); return false; } RegistryHelper.SetValue( @@ -6350,12 +6667,12 @@ rootKey, keyName, true, whatIf, verbose)) { if (key == null) { error = String.Format( - "could not open registry key: {0}\\{1}", - rootKey, keyName); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(rootKey, keyName)); return false; } RegistryHelper.DeleteSubKey( @@ -6417,12 +6734,13 @@ private static string GetVsRootKeyName( bool perUser, bool wow64 ) { - return String.Format("{0}\\Microsoft\\VisualStudio", - GetRootKeyName(perUser, wow64)); + return RegistryHelper.JoinKeyNames( + GetRootKeyName(perUser, wow64), + "Microsoft", "VisualStudio"); } /////////////////////////////////////////////////////////////////////// private static string GetVsKeyName( @@ -6433,13 +6751,13 @@ ) { if (vsVersion == null) return null; - return String.Format( - "{0}\\{1}{2}", GetVsRootKeyName(perUser, wow64), vsVersion, - suffix); + return RegistryHelper.JoinKeyNames( + GetVsRootKeyName(perUser, wow64), + String.Format("{0}{1}", vsVersion, suffix)); } /////////////////////////////////////////////////////////////////////// #region Visual Studio Data Source Handling @@ -6473,12 +6791,12 @@ rootKey, keyName, false, whatIf, verbose)) { if (key == null) { error = String.Format( - "could not open registry key: {0}\\{1}", - rootKey, keyName); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(rootKey, keyName)); return false; } using (MockRegistryKey subKey = RegistryHelper.OpenSubKey( @@ -6485,12 +6803,13 @@ key, "DataSources", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\DataSources", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "DataSources")); return false; } using (MockRegistryKey dataSourceKey = @@ -6499,12 +6818,14 @@ whatIf, verbose)) { if (dataSourceKey == null) { error = String.Format( - "could not create registry key: {0}\\{1}", key, - package.DataSourceId.ToString(VsIdFormat)); + "could not create registry key: {0}", + RegistryHelper.JoinKeyNames(key, + package.DataSourceId.ToString( + VsIdFormat))); return false; } RegistryHelper.SetValue( @@ -6519,12 +6840,12 @@ dataSourceKey, "DefaultProvider", package.DataProviderId.ToString(VsIdFormat), whatIf, verbose); RegistryHelper.CreateSubKey(dataSourceKey, - String.Format("SupportingProviders\\{0}", - package.DataProviderId.ToString(VsIdFormat)), + RegistryHelper.JoinKeyNames("SupportingProviders", + package.DataProviderId.ToString(VsIdFormat)), whatIf, verbose); } } } @@ -6563,12 +6884,12 @@ rootKey, keyName, false, whatIf, verbose)) { if (key == null) { error = String.Format( - "could not open registry key: {0}\\{1}", - rootKey, keyName); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(rootKey, keyName)); return false; } using (MockRegistryKey subKey = RegistryHelper.OpenSubKey( @@ -6575,12 +6896,13 @@ key, "DataSources", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\DataSources", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "DataSources")); return false; } RegistryHelper.DeleteSubKeyTree( @@ -6672,12 +6994,12 @@ rootKey, keyName, false, whatIf, verbose)) { if (key == null) { error = String.Format( - "could not open registry key: {0}\\{1}", - rootKey, keyName); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(rootKey, keyName)); return false; } using (MockRegistryKey subKey = RegistryHelper.OpenSubKey( @@ -6684,12 +7006,13 @@ key, "DataProviders", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\DataProviders", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "DataProviders")); return false; } using (MockRegistryKey dataProviderKey = @@ -6698,12 +7021,14 @@ whatIf, verbose)) { if (dataProviderKey == null) { error = String.Format( - "could not create registry key: {0}\\{1}", key, - package.DataProviderId.ToString(VsIdFormat)); + "could not create registry key: {0}", + RegistryHelper.JoinKeyNames(key, + package.DataProviderId.ToString( + VsIdFormat))); return false; } RegistryHelper.SetValue( @@ -6749,28 +7074,28 @@ dataProviderKey, "FactoryService", package.ServiceId.ToString(VsIdFormat), whatIf, verbose); RegistryHelper.CreateSubKey(dataProviderKey, - "SupportedObjects\\DataConnectionUIControl", - whatIf, verbose); - - RegistryHelper.CreateSubKey(dataProviderKey, - "SupportedObjects\\DataConnectionProperties", - whatIf, verbose); - - RegistryHelper.CreateSubKey(dataProviderKey, - "SupportedObjects\\DataConnectionSupport", whatIf, - verbose); - - RegistryHelper.CreateSubKey(dataProviderKey, - "SupportedObjects\\DataObjectSupport", whatIf, - verbose); - - RegistryHelper.CreateSubKey(dataProviderKey, - "SupportedObjects\\DataViewSupport", whatIf, - verbose); + RegistryHelper.JoinKeyNames("SupportedObjects", + "DataConnectionUIControl"), whatIf, verbose); + + RegistryHelper.CreateSubKey(dataProviderKey, + RegistryHelper.JoinKeyNames("SupportedObjects", + "DataConnectionProperties"), whatIf, verbose); + + RegistryHelper.CreateSubKey(dataProviderKey, + RegistryHelper.JoinKeyNames("SupportedObjects", + "DataConnectionSupport"), whatIf, verbose); + + RegistryHelper.CreateSubKey(dataProviderKey, + RegistryHelper.JoinKeyNames("SupportedObjects", + "DataObjectSupport"), whatIf, verbose); + + RegistryHelper.CreateSubKey(dataProviderKey, + RegistryHelper.JoinKeyNames("SupportedObjects", + "DataViewSupport"), whatIf, verbose); } } } return true; @@ -6802,12 +7127,12 @@ rootKey, keyName, false, whatIf, verbose)) { if (key == null) { error = String.Format( - "could not open registry key: {0}\\{1}", - rootKey, keyName); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(rootKey, keyName)); return false; } using (MockRegistryKey subKey = RegistryHelper.OpenSubKey( @@ -6814,12 +7139,13 @@ key, "DataProviders", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\DataProviders", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "DataProviders")); return false; } RegistryHelper.DeleteSubKeyTree( @@ -6943,12 +7269,12 @@ rootKey, keyName, false, whatIf, verbose)) { if (key == null) { error = String.Format( - "could not open registry key: {0}\\{1}", - rootKey, keyName); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(rootKey, keyName)); return false; } using (MockRegistryKey subKey = RegistryHelper.OpenSubKey( @@ -6955,12 +7281,13 @@ key, "Packages", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\Packages", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "Packages")); return false; } // @@ -6988,12 +7315,13 @@ verbose)) { if (packageKey == null) { error = String.Format( - "could not create registry key: {0}\\{1}", - key, package.PackageId.ToString(VsIdFormat)); + "could not create registry key: {0}", + RegistryHelper.JoinKeyNames(key, + package.PackageId.ToString(VsIdFormat))); return false; } RegistryHelper.SetValue(packageKey, null, @@ -7036,12 +7364,13 @@ "Toolbox", whatIf, verbose)) { if (toolboxKey == null) { error = String.Format( - "could not create registry key: " + - "{0}\\Toolbox", packageKey); + "could not create registry key: {0}", + RegistryHelper.JoinKeyNames(packageKey, + "Toolbox")); return false; } RegistryHelper.SetValue( @@ -7055,12 +7384,13 @@ key, "Menus", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\Menus", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "Menus")); return false; } RegistryHelper.SetValue( @@ -7072,12 +7402,13 @@ key, "Services", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\Services", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "Services")); return false; } using (MockRegistryKey serviceKey = @@ -7086,12 +7417,13 @@ verbose)) { if (serviceKey == null) { error = String.Format( - "could not create registry key: {0}\\{1}", - key, package.ServiceId.ToString(VsIdFormat)); + "could not create registry key: {0}", + RegistryHelper.JoinKeyNames(key, + package.ServiceId.ToString(VsIdFormat))); return false; } RegistryHelper.SetValue(serviceKey, null, @@ -7141,12 +7473,12 @@ rootKey, keyName, false, whatIf, verbose)) { if (key == null) { error = String.Format( - "could not open registry key: {0}\\{1}", - rootKey, keyName); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(rootKey, keyName)); return false; } using (MockRegistryKey subKey = RegistryHelper.OpenSubKey( @@ -7153,12 +7485,13 @@ key, "Packages", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\Packages", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "Packages")); return false; } RegistryHelper.DeleteSubKeyTree( @@ -7170,12 +7503,13 @@ key, "Menus", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\Menus", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "Menus")); return false; } RegistryHelper.DeleteValue( @@ -7187,12 +7521,13 @@ key, "Services", true, whatIf, verbose)) { if (subKey == null) { error = String.Format( - "could not open registry key: {0}\\Services", - key); + "could not open registry key: {0}", + RegistryHelper.JoinKeyNames(key, + "Services")); return false; } RegistryHelper.DeleteSubKeyTree( @@ -7334,26 +7669,30 @@ process.ErrorDataReceived += new DataReceivedEventHandler( VsDevEnvSetupErrorDataReceived); if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, ForDisplay(startInfo), traceCategory); + } // // NOTE: In "what-if" mode, do not actually start the process. // if (!whatIf) { process.Start(); if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, String.Format( "process = {0}", ForDisplay(process)), traceCategory); + } process.BeginOutputReadLine(); process.BeginErrorReadLine(); process.WaitForExit(); } @@ -7381,15 +7720,17 @@ // effectively 'remove' the package being processed since // this is being done after all the other changes for the // package removal have been completed). // if (verbose) + { TraceOps.DebugAndTrace(TracePriority.Highest, debugCallback, traceCallback, String.Format( "Preparing to run Visual Studio {0} 'setup' mode to " + "refresh its configuration.", ForDisplay(vsVersion)), traceCategory); + } return AddVsDevEnvSetup( vsVersion, directory, perUser, whatIf, verbose, ref error); }