File tree Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Expand file tree Collapse file tree 2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 84
84
# Register the debug build on the local machine
85
85
if ($config -eq " Debug" )
86
86
{
87
- $writer = New-Object Rubberduck.Deployment.Writers.LocalDebugRegistryWriter
88
- $content = $writer .Write ( $entries );
89
-
87
+ # First see if there are registry script from the previous build
88
+ # If so, execute them to delete previous build's keys (which may
89
+ # no longer exist for the current build and thus won't be overwritten)
90
90
$dir = ((Get-ScriptDirectory ) + " \LocalRegistryEntries" );
91
91
$regFile = $dir + " \DebugRegistryEntries.reg" ;
92
92
104
104
{
105
105
New-Item $dir - ItemType Directory
106
106
}
107
+
108
+ # NOTE: The local writer will perform the actual registry changes; the return
109
+ # is a registry script with deletion instructions for the keys to be deleted
110
+ # in the next build.
111
+ $writer = New-Object Rubberduck.Deployment.Writers.LocalDebugRegistryWriter
112
+ $content = $writer.Write ($entries );
113
+
107
114
$encoding = New-Object System.Text.ASCIIEncoding;
108
115
[System.IO.File ]::WriteAllLines($regFile , $content , $encoding );
109
116
}
Original file line number Diff line number Diff line change @@ -33,11 +33,7 @@ public string Write(IOrderedEnumerable<RegistryEntry> entries)
33
33
var value = ReplacePlaceholder ( entry . Value , entry . Bitness ) ;
34
34
35
35
var key = Registry . CurrentUser . CreateSubKey ( entry . Key ) ;
36
- if ( string . IsNullOrWhiteSpace ( entry . Name ) && string . IsNullOrWhiteSpace ( value ) )
37
- {
38
- key . CreateSubKey ( entry . Key ) ;
39
- }
40
- else
36
+ if ( ! ( string . IsNullOrWhiteSpace ( entry . Name ) && string . IsNullOrWhiteSpace ( value ) ) )
41
37
{
42
38
key . SetValue ( entry . Name , value ) ;
43
39
}
@@ -51,7 +47,7 @@ public string Write(IOrderedEnumerable<RegistryEntry> entries)
51
47
foreach ( var key in distinctKeys )
52
48
{
53
49
//we need a break each entry, so 2 newline is wanted (AppendLine adds one, and we add another)
54
- sb . AppendLine ( "[-" + key + "]" + Environment . NewLine ) ;
50
+ sb . AppendLine ( "[-HKEY_CURRENT_USER \\ " + key + "]" + Environment . NewLine ) ;
55
51
}
56
52
57
53
return sb . ToString ( ) ;
You can’t perform that action at this time.
0 commit comments