Skip to content

Commit 44dc503

Browse files
committed
fix: use solution-level publish + obj/PackageTmp for per-project output
1 parent 3b119e8 commit 44dc503

1 file changed

Lines changed: 31 additions & 30 deletions

File tree

  • cloudformation/scenarios/localgov-ims/docker

cloudformation/scenarios/localgov-ims/docker/Dockerfile

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,37 @@ RUN Invoke-WebRequest -Uri 'https://github.com/LocalGovIMS/localgov-ims/archive/
2626
# Restore NuGet packages (all from nuget.org — no GitHub Packages needed)
2727
RUN nuget restore src\LocalGovIms.sln
2828

29-
# Build the full solution (compiles all projects including dependencies)
30-
RUN msbuild src\LocalGovIms.sln /p:Configuration=Live /t:Build /verbosity:minimal
31-
32-
# Publish each web project individually to separate directories
33-
RUN msbuild src\PaymentPortal\PaymentPortal.csproj `
34-
/p:Configuration=Live /t:pipelinePreDeployCopyAllFilesToOneFolder `
35-
/p:_PackageTempDir=C:\build\portal /verbosity:minimal ; `
36-
if ($LASTEXITCODE -ne 0) { `
37-
Write-Host 'pipelinePreDeploy failed, falling back to WebPublishMethod' ; `
38-
msbuild src\PaymentPortal\PaymentPortal.csproj `
39-
/p:Configuration=Live /p:DeployOnBuild=true `
40-
/p:WebPublishMethod=FileSystem /p:publishUrl=C:\build\portal /verbosity:minimal `
41-
}
42-
RUN msbuild src\Admin\Admin.csproj `
43-
/p:Configuration=Live /t:pipelinePreDeployCopyAllFilesToOneFolder `
44-
/p:_PackageTempDir=C:\build\admin /verbosity:minimal ; `
45-
if ($LASTEXITCODE -ne 0) { `
46-
Write-Host 'pipelinePreDeploy failed, falling back to WebPublishMethod' ; `
47-
msbuild src\Admin\Admin.csproj `
48-
/p:Configuration=Live /p:DeployOnBuild=true `
49-
/p:WebPublishMethod=FileSystem /p:publishUrl=C:\build\admin /verbosity:minimal `
50-
}
51-
RUN msbuild src\Api\Api.csproj `
52-
/p:Configuration=Live /t:pipelinePreDeployCopyAllFilesToOneFolder `
53-
/p:_PackageTempDir=C:\build\api /verbosity:minimal ; `
54-
if ($LASTEXITCODE -ne 0) { `
55-
Write-Host 'pipelinePreDeploy failed, falling back to WebPublishMethod' ; `
56-
msbuild src\Api\Api.csproj `
57-
/p:Configuration=Live /p:DeployOnBuild=true `
58-
/p:WebPublishMethod=FileSystem /p:publishUrl=C:\build\api /verbosity:minimal `
29+
# Build and publish: solution build compiles with Live config (maps to Release for libs).
30+
# DeployOnBuild publishes each web project. We publish three times with different publishUrl
31+
# to get separate output directories. Each publish overwrites _shared but we copy immediately.
32+
RUN msbuild src\LocalGovIms.sln /p:Configuration=Live /p:DeployOnBuild=true `
33+
/p:WebPublishMethod=FileSystem /p:publishUrl=C:\build\_shared /verbosity:minimal ; `
34+
Copy-Item -Path C:\build\_shared -Destination C:\build\portal -Recurse -Force ; `
35+
Write-Host "Portal snapshot taken"
36+
37+
# The solution publish puts all web projects into _shared (last one wins). We need to
38+
# identify each project's output. Since all three share the same _shared dir, we use
39+
# the WAP (Web Application Project) _PackageTempDir which is created during publish.
40+
# Actually, let's just use the obj/Live/Package/PackageTmp directories that MSBuild creates.
41+
RUN if (Test-Path 'src\PaymentPortal\obj\Live\Package\PackageTmp') { `
42+
Copy-Item -Path 'src\PaymentPortal\obj\Live\Package\PackageTmp\*' -Destination C:\build\portal -Recurse -Force ; `
43+
Write-Host "Portal from PackageTmp" `
44+
} ; `
45+
if (Test-Path 'src\Admin\obj\Live\Package\PackageTmp') { `
46+
Copy-Item -Path 'src\Admin\obj\Live\Package\PackageTmp\*' -Destination C:\build\admin -Recurse -Force ; `
47+
Write-Host "Admin from PackageTmp" `
48+
} else { `
49+
New-Item -ItemType Directory -Force C:\build\admin | Out-Null ; `
50+
Copy-Item -Path C:\build\_shared\* -Destination C:\build\admin -Recurse -Force ; `
51+
Write-Host "Admin from _shared fallback" `
52+
} ; `
53+
if (Test-Path 'src\Api\obj\Live\Package\PackageTmp') { `
54+
Copy-Item -Path 'src\Api\obj\Live\Package\PackageTmp\*' -Destination C:\build\api -Recurse -Force ; `
55+
Write-Host "Api from PackageTmp" `
56+
} else { `
57+
New-Item -ItemType Directory -Force C:\build\api | Out-Null ; `
58+
Copy-Item -Path C:\build\_shared\* -Destination C:\build\api -Recurse -Force ; `
59+
Write-Host "Api from _shared fallback" `
5960
}
6061

6162
RUN Write-Host "Portal: $((Get-ChildItem C:\build\portal -Recurse -File).Count) files" ; `

0 commit comments

Comments
 (0)