Skip to content

Commit 374c8e7

Browse files
committed
Additional bug fixes & tweaks
1 parent b778c90 commit 374c8e7

File tree

4 files changed

+12
-24
lines changed

4 files changed

+12
-24
lines changed

Rubberduck.Deployment.Build/RubberduckPostBuildTask.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public override bool Execute()
8484
{
8585
this.LogMessage(FormatParameterList());
8686

87-
CleanOldImports(ProjectDir);
87+
CleanOldImports(Path.Combine(ProjectDir, "LocalRegistryEntries"));
8888

8989
var dllFiles = FilesToExtract.Split(new[] {"|"}, StringSplitOptions.RemoveEmptyEntries);
9090
var hasVCTools = TryGetVCToolsPath(out var batchPath);
@@ -341,6 +341,7 @@ private void UpdateDebugRegistration(IOrderedEnumerable<RegistryEntry> entries,
341341
// is a registry script with deletion instructions for the keys to be deleted
342342
// in the next build.
343343
var writer = new LocalDebugRegistryWriter();
344+
writer.CurrentPath = TargetDir;
344345
var content = writer.Write(entries, parameters.DllFile, parameters.Tlb32File, parameters.Tlb64File);
345346
File.AppendAllText(RegFilePath, content, Encoding.ASCII);
346347
}

Rubberduck.Deployment.Build/RubberduckPreBuildTask.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ private void VerifyFileLocks()
3737
var files = Directory.GetFiles(OutputDir);
3838
foreach (var file in files)
3939
{
40-
if (file.StartsWith("Rubberduck") && file.EndsWith(".dll"))
40+
var fileName = Path.GetFileName(file);
41+
if (fileName.StartsWith("Rubberduck") && fileName.EndsWith(".dll"))
4142
{
4243
//If we can't delete it, then file is in use.
4344
File.Delete(file);

Rubberduck.Deployment.Build/Writers/LocalDebugRegistryWriter.cs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.IO;
45
using System.Linq;
5-
using System.Reflection;
66
using System.Text;
77
using Microsoft.Win32;
88
using Rubberduck.Deployment.Build.Structs;
@@ -14,6 +14,8 @@ public class LocalDebugRegistryWriter : IRegistryWriter
1414
private string _dllName;
1515
private string _tlb32Name;
1616
private string _tlb64Name;
17+
18+
public string CurrentPath { get; set; }
1719

1820
public string Write(IOrderedEnumerable<RegistryEntry> entries, string dllName, string tlb32Name, string tlb64Name)
1921
{
@@ -78,37 +80,21 @@ private void MakeRegistryEntries(RegistryEntry entry, RegistryKey hKey)
7880
}
7981
}
8082

81-
//Cache the string so we call the AssemblyDirectory only once
82-
private string _currentPath;
8383
private string ReplacePlaceholder(string value, Bitness bitness)
8484
{
85-
if (_currentPath == null)
86-
{
87-
_currentPath = AssemblyDirectory;
88-
}
85+
Debug.Assert(!string.IsNullOrWhiteSpace(CurrentPath));
8986

9087
switch (value)
9188
{
9289
case PlaceHolders.InstallPath:
93-
return _currentPath;
90+
return CurrentPath;
9491
case PlaceHolders.DllPath:
95-
return Path.Combine( _currentPath, _dllName);
92+
return Path.Combine(CurrentPath, _dllName);
9693
case PlaceHolders.TlbPath:
97-
return Path.Combine(_currentPath, bitness == Bitness.Is64Bit ? _tlb64Name : _tlb32Name);
94+
return Path.Combine(CurrentPath, bitness == Bitness.Is64Bit ? _tlb64Name : _tlb32Name);
9895
default:
9996
return value;
10097
}
10198
}
102-
103-
public static string AssemblyDirectory
104-
{
105-
get
106-
{
107-
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
108-
UriBuilder uri = new UriBuilder(codeBase);
109-
string path = Uri.UnescapeDataString(uri.Path);
110-
return Path.GetDirectoryName(path);
111-
}
112-
}
11399
}
114100
}

Rubberduck.Deployment/Rubberduck.Deployment.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
<Target Name="PreBuildTask" BeforeTargets="PreBuildEvent">
4747
<RubberduckPreBuildTask
4848
WorkingDir="$(ProjectDir)"
49-
OutputDir="$(OutputPath)" />
49+
OutputDir="$(TargetDir)" />
5050

5151
<Message Text="Ran Rubberduck prebuild task" Importance="normal" />
5252
</Target>

0 commit comments

Comments
 (0)