Skip to content

Commit 60595eb

Browse files
committed
Bug fixes for the local registry writers.
1 parent 8879000 commit 60595eb

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

Rubberduck.Deployment/BuildRegistryScript.ps1

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,9 @@ try
8484
# Register the debug build on the local machine
8585
if($config -eq "Debug")
8686
{
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)
9090
$dir = ((Get-ScriptDirectory) + "\LocalRegistryEntries");
9191
$regFile = $dir + "\DebugRegistryEntries.reg";
9292

@@ -104,6 +104,13 @@ try
104104
{
105105
New-Item $dir -ItemType Directory
106106
}
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+
107114
$encoding = New-Object System.Text.ASCIIEncoding;
108115
[System.IO.File]::WriteAllLines($regFile, $content, $encoding);
109116
}

Rubberduck.Deployment/Writers/LocalDebugRegistryWriter.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ public string Write(IOrderedEnumerable<RegistryEntry> entries)
3333
var value = ReplacePlaceholder(entry.Value, entry.Bitness);
3434

3535
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)))
4137
{
4238
key.SetValue(entry.Name, value);
4339
}
@@ -51,7 +47,7 @@ public string Write(IOrderedEnumerable<RegistryEntry> entries)
5147
foreach (var key in distinctKeys)
5248
{
5349
//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);
5551
}
5652

5753
return sb.ToString();

0 commit comments

Comments
 (0)