Skip to content

Commit 041e8a4

Browse files
committed
Use returned installation path
1 parent 742eb69 commit 041e8a4

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

scripts/Install-Rubberduck-VBA.ps1

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ function Test-RubberduckInstalled {
161161
$addinProgId = "Rubberduck.Extension"
162162
$addinCLSID = "8D052AD8-BBD2-4C59-8DEC-F697CA1F8A66"
163163
$isInstalled = $false
164+
$installPath = ""
164165

165166
# Check for registry keys in current user hive
166167
if (Test-Path "HKCU:\Software\Microsoft\VBA\VBE\6.0\Addins\$addinProgId") {
@@ -201,21 +202,22 @@ function Test-RubberduckInstalled {
201202
if (Test-Path $path) {
202203
Write-Host "✅ Rubberduck DLL found at: $path"
203204
$isInstalled = $true
205+
$installPath = Split-Path -Parent $path # Get the directory containing the DLL
204206
break
205207
}
206208
}
207209

208210
if (-not $isInstalled) {
209211
Write-Host "❌ Rubberduck installation verification failed. No registry entries or DLL files found."
210-
return $false
212+
return "" # Return empty string if not found
211213
}
212214

213215
Write-Host "✅ Rubberduck installation verification completed successfully."
214-
return $true
216+
return $installPath # Return the path where Rubberduck.dll was found
215217
}
216218

217-
$rubberduckInstalled = Test-RubberduckInstalled
218-
if (-not $rubberduckInstalled) {
219+
$rubberduckInstallPath = Test-RubberduckInstalled
220+
if (-not $rubberduckInstallPath) {
219221
Write-Host "⚠️ Warning: Rubberduck installation could not be verified. Office addins may not function correctly."
220222
Write-Host "Please check the installation log for more details or try reinstalling manually."
221223

@@ -230,14 +232,13 @@ if (-not $rubberduckInstalled) {
230232

231233
# Now we need to download the artifacts from the latest build in https://github.com/DecimalTurn/Rubberduck/actions/runs/14609505761/artifacts/2990874874
232234
# The artifacts are stored in a zip file and we need to extract them to the installation folder.
233-
# The installation folder is usually located in the following path: C:\ProgramData\Rubberduck\
234235

235236
Write-Host "⏳ Downloading and installing additional components..."
236237

237238
# Define the artifact URL and download location
238239
$artifactUrl = "https://github.com/DecimalTurn/Rubberduck/actions/runs/14609505761/artifacts/2990874874"
239240
$artifactZipPath = "$env:TEMP\RubberduckArtifacts.zip"
240-
$rubberduckInstallDir = "C:\ProgramData\Rubberduck"
241+
$rubberduckInstallDir = $rubberduckInstallPath # Use the path returned by Test-RubberduckInstalled
241242

242243
# Function to check if we have GitHub CLI installed
243244
function Test-GitHubCLI {
@@ -251,6 +252,13 @@ function Test-GitHubCLI {
251252

252253
# Download the artifact
253254
try {
255+
# If we don't have an install path, try default location
256+
if (-not $rubberduckInstallDir) {
257+
$commonAppDataPath = [System.Environment]::GetFolderPath("CommonApplicationData")
258+
$rubberduckInstallDir = "$commonAppDataPath\Rubberduck"
259+
Write-Host "🔍 Using default installation directory: $rubberduckInstallDir"
260+
}
261+
254262
# Check if GitHub CLI is available
255263
if (Test-GitHubCLI) {
256264
# Use GitHub CLI to download the artifact

0 commit comments

Comments
 (0)