From 081630155c36d234eda04dfd0e7484a036e27e96 Mon Sep 17 00:00:00 2001 From: Nano Date: Sat, 2 May 2026 20:54:02 -0400 Subject: [PATCH] Fix deploy script: preserve public/ subfolder structure for IIS --- ci/aspblogbrainordure-setup.ps1 | 2 +- ci/deploy-aspblogbrainordure-test.ps1 | 48 ++++++++++++++++++--------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/ci/aspblogbrainordure-setup.ps1 b/ci/aspblogbrainordure-setup.ps1 index 9183669..0df8bd6 100644 --- a/ci/aspblogbrainordure-setup.ps1 +++ b/ci/aspblogbrainordure-setup.ps1 @@ -31,7 +31,7 @@ Write-Host "App pool configured (32-bit, v4.0)." # Create IIS site $existingSite = Get-Website -Name $SITENAME -ErrorAction SilentlyContinue if ($existingSite) { - Write-Host "Site $SITENAME already exists — skipping creation." + Write-Host "Site $SITENAME already exists - skipping creation." } else { New-Website -Name $SITENAME -PhysicalPath $WEBROOT -Port $PORT -ApplicationPool $APPPOOL Write-Host "IIS site $SITENAME created on port $PORT." diff --git a/ci/deploy-aspblogbrainordure-test.ps1 b/ci/deploy-aspblogbrainordure-test.ps1 index 96ac5ba..3c2bb19 100644 --- a/ci/deploy-aspblogbrainordure-test.ps1 +++ b/ci/deploy-aspblogbrainordure-test.ps1 @@ -73,41 +73,57 @@ $srcPath = $extracted.FullName Log "Extracted to $srcPath" -# Copy public/ folder contents to webroot (this is the IIS-served content) -$publicSrc = Join-Path $srcPath "public" -if (Test-Path $publicSrc) { - # Copy all files from public/ to webroot root - Copy-Item "$publicSrc\*" $WEBROOT -Recurse -Force - Log "Copied public/ to webroot." -} else { - # If no public folder, copy everything - Copy-Item "$srcPath\*" $WEBROOT -Recurse -Force - Log "Copied all files to webroot." -} +# Deploy structure mirrors the repo layout: +# IIS serves from $WEBROOT\public\ (Default.asp lives here) +# core\, app\, db\ go alongside public\ so ../core/ includes resolve correctly + +$publicDst = Join-Path $WEBROOT "public" +New-Item -ItemType Directory -Force -Path $publicDst | Out-Null -# Copy core/, app/ alongside Default.asp (needed for ../core/ relative includes) -foreach ($folder in @("core", "app", "db")) { +foreach ($folder in @("public", "core", "app")) { $folderSrc = Join-Path $srcPath $folder $folderDst = Join-Path $WEBROOT $folder if (Test-Path $folderSrc) { if (Test-Path $folderDst) { Remove-Item $folderDst -Recurse -Force } Copy-Item $folderSrc $WEBROOT -Recurse -Force - Log "Copied $folder/ to webroot." + Log "Copied $folder/." + } +} + +# Only update db/ if webdata.accdb doesn't exist yet (preserve live data) +$dbSrc = Join-Path $srcPath "db" +$dbDst = Join-Path $WEBROOT "db" +if (Test-Path $dbSrc) { + if (-not (Test-Path "$dbDst\webdata.accdb")) { + if (Test-Path $dbDst) { Remove-Item $dbDst -Recurse -Force } + Copy-Item $dbSrc $WEBROOT -Recurse -Force + Log "Copied db/ (first deploy)." + } else { + # Only copy migration files, not the live database + $migSrc = Join-Path $dbSrc "migrations" + if (Test-Path $migSrc) { + Copy-Item "$migSrc\*" "$dbDst\migrations\" -Recurse -Force + Log "Updated db/migrations/." + } } } # Update web.config ConnectionString to point to correct DB path -$webConfigPath = Join-Path $WEBROOT "web.config" +$webConfigPath = Join-Path $publicDst "web.config" if (Test-Path $webConfigPath) { $wc = [System.IO.File]::ReadAllText($webConfigPath) $newConn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=$WEBROOT\db\webdata.accdb;Persist Security Info=False;" $wc = [regex]::Replace($wc, 'Provider=Microsoft\.ACE\.OLEDB[^"]+', $newConn) + if ($wc -notmatch 'enableParentPaths') { + $wc = $wc -replace '', '' + } [System.IO.File]::WriteAllText($webConfigPath, $wc) - Log "Updated web.config ConnectionString." + Log "Updated web.config." } # Grant IIS_IUSRS write access to db folder $dbPath = Join-Path $WEBROOT "db" +New-Item -ItemType Directory -Force -Path $dbPath | Out-Null if (Test-Path $dbPath) { $acl = Get-Acl $dbPath $rule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "Modify", "ContainerInherit,ObjectInherit", "None", "Allow")