Skip to content

Commit 9e6d97d

Browse files
gautamdshethGautam Sheth
andauthored
Enhance Build-Nightly script to support copying of runtime files for linux-x64 and improve runtime folder checks (#4955)
Co-authored-by: Gautam Sheth <gautam.sheth@staffbase.com>
1 parent dc99133 commit 9e6d97d

File tree

1 file changed

+60
-25
lines changed

1 file changed

+60
-25
lines changed

build/Build-Nightly.ps1

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -92,35 +92,70 @@ if ($runPublish -eq $true) {
9292
$coreRuntimePathWin64 = "$destinationFolder/Core/runtimes/win-x64/native"
9393
$coreRuntimePathArm64 = "$destinationFolder/Core/runtimes/win-arm64/native"
9494
$coreRuntimePathx86 = "$destinationFolder/Core/runtimes/win-x86/native"
95+
$coreRuntimePathLinx64 = "$destinationFolder/Core/runtimes/linux-x64/native"
9596

9697
$assemblyExceptions = @("System.Memory.dll");
9798

9899
Try {
99-
# Module folder there?
100-
if (Test-Path $destinationFolder) {
101-
# Yes, empty it
102-
Remove-Item $destinationFolder\* -Recurse -Force -ErrorAction Stop
103-
}
104-
# No, create it
105-
Write-Host "Creating target folders: $destinationFolder" -ForegroundColor Yellow
106-
New-Item -Path $destinationFolder -ItemType Directory -Force | Out-Null
107-
New-Item -Path "$destinationFolder\Core" -ItemType Directory -Force | Out-Null
108-
New-Item -Path "$destinationFolder\Core\runtimes" -ItemType Directory -Force | Out-Null
109-
New-Item -Path "$destinationFolder\Core\runtimes\win-x64\native" -ItemType Directory -Force | Out-Null
110-
New-Item -Path "$destinationFolder\Core\runtimes\win-arm64\native" -ItemType Directory -Force | Out-Null
111-
New-Item -Path "$destinationFolder\Core\runtimes\win-x86\native" -ItemType Directory -Force | Out-Null
112-
New-Item -Path "$destinationFolder\Common" -ItemType Directory -Force | Out-Null
113-
114-
Write-Host "Copying files to $destinationFolder" -ForegroundColor Yellow
115-
116-
$commonFiles = [System.Collections.Generic.Hashset[string]]::new()
117-
Copy-Item -Path "$PSscriptRoot/../resources/*.ps1xml" -Destination "$destinationFolder"
118-
Get-ChildItem -Path "$PSScriptRoot/../src/ALC/bin/Release/net8.0" | Where-Object { $_.Extension -in '.dll', '.pdb' } | Foreach-Object { if (!$assemblyExceptions.Contains($_.Name)) { [void]$commonFiles.Add($_.Name) }; Copy-Item -LiteralPath $_.FullName -Destination $commonPath }
119-
Get-ChildItem -Path "$PSScriptRoot/../src/Commands/bin/Release/net8.0" | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $corePath }
120-
Get-ChildItem -Path "$PSScriptRoot/../src/Commands/bin/Release/net8.0/runtimes/win-x64/native" -Recurse | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $coreRuntimePathWin64 }
121-
Get-ChildItem -Path "$PSScriptRoot/../src/Commands/bin/Release/net8.0/runtimes/win-arm64/native" -Recurse | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $coreRuntimePathArm64 }
122-
Get-ChildItem -Path "$PSScriptRoot/../src/Commands/bin/Release/net8.0/runtimes/win-x86/native" -Recurse | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $coreRuntimePathx86 }
123-
}
100+
# Module folder there?
101+
if (Test-Path $destinationFolder) {
102+
# Yes, empty it
103+
Remove-Item $destinationFolder\* -Recurse -Force -ErrorAction Stop
104+
}
105+
# No, create it
106+
Write-Host "Creating target folders: $destinationFolder" -ForegroundColor Yellow
107+
New-Item -Path $destinationFolder -ItemType Directory -Force | Out-Null
108+
New-Item -Path "$destinationFolder\Core" -ItemType Directory -Force | Out-Null
109+
New-Item -Path "$destinationFolder\Common" -ItemType Directory -Force | Out-Null
110+
111+
Write-Host "Copying files to $destinationFolder" -ForegroundColor Yellow
112+
113+
$commonFiles = [System.Collections.Generic.Hashset[string]]::new()
114+
Copy-Item -Path "$PSscriptRoot/../resources/*.ps1xml" -Destination "$destinationFolder"
115+
Get-ChildItem -Path "$PSScriptRoot/../src/ALC/bin/Release/net8.0" | Where-Object { $_.Extension -in '.dll', '.pdb' } | Foreach-Object { if (!$assemblyExceptions.Contains($_.Name)) { [void]$commonFiles.Add($_.Name) }; Copy-Item -LiteralPath $_.FullName -Destination $commonPath }
116+
Get-ChildItem -Path "$PSScriptRoot/../src/Commands/bin/Release/net8.0" | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $corePath }
117+
118+
# Check if runtime folders exist in source before copying
119+
$sourceRuntimeBase = "$PSScriptRoot/../src/Commands/bin/Release/net8.0/runtimes"
120+
if (Test-Path $sourceRuntimeBase) {
121+
Write-Host "Runtime folders found in source, creating destination runtime structure" -ForegroundColor Yellow
122+
New-Item -Path "$destinationFolder\Core\runtimes" -ItemType Directory -Force | Out-Null
123+
124+
# Copy win-x64 runtime if exists
125+
$sourceRuntimePathWin64 = "$sourceRuntimeBase/win-x64/native"
126+
if (Test-Path $sourceRuntimePathWin64) {
127+
New-Item -Path "$destinationFolder\Core\runtimes\win-x64\native" -ItemType Directory -Force | Out-Null
128+
Get-ChildItem -Path $sourceRuntimePathWin64 -Recurse | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $coreRuntimePathWin64 }
129+
Write-Host "Copied win-x64 runtime files" -ForegroundColor Green
130+
}
131+
132+
# Copy win-arm64 runtime if exists
133+
$sourceRuntimePathArm64 = "$sourceRuntimeBase/win-arm64/native"
134+
if (Test-Path $sourceRuntimePathArm64) {
135+
New-Item -Path "$destinationFolder\Core\runtimes\win-arm64\native" -ItemType Directory -Force | Out-Null
136+
Get-ChildItem -Path $sourceRuntimePathArm64 -Recurse | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $coreRuntimePathArm64 }
137+
Write-Host "Copied win-arm64 runtime files" -ForegroundColor Green
138+
}
139+
140+
# Copy win-x86 runtime if exists
141+
$sourceRuntimePathx86 = "$sourceRuntimeBase/win-x86/native"
142+
if (Test-Path $sourceRuntimePathx86) {
143+
New-Item -Path "$destinationFolder\Core\runtimes\win-x86\native" -ItemType Directory -Force | Out-Null
144+
Get-ChildItem -Path $sourceRuntimePathx86 -Recurse | Where-Object { $_.Extension -in '.dll', '.pdb' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $coreRuntimePathx86 }
145+
Write-Host "Copied win-x86 runtime files" -ForegroundColor Green
146+
}
147+
148+
# Copy linux-x64 runtime if exists
149+
$sourceRuntimePathLinx64 = "$sourceRuntimeBase/linux-x64/native"
150+
if (Test-Path $sourceRuntimePathLinx64) {
151+
New-Item -Path "$destinationFolder\Core\runtimes\linux-x64\native" -ItemType Directory -Force | Out-Null
152+
Get-ChildItem -Path $sourceRuntimePathLinx64 -Recurse | Where-Object { $_.Extension -in '.dll', '.pdb', '.so' -and -not $commonFiles.Contains($_.Name) } | Foreach-Object { Copy-Item -LiteralPath $_.FullName -Destination $coreRuntimePathLinx64 }
153+
Write-Host "Copied linux-x64 runtime files" -ForegroundColor Green
154+
}
155+
} else {
156+
Write-Host "No runtime folders found in build output - this is normal for projects without native dependencies" -ForegroundColor Yellow
157+
}
158+
}
124159
Catch {
125160
Write-Host "Error: Cannot copy files to $destinationFolder. Maybe a PowerShell session is still using the module?"
126161
exit 1

0 commit comments

Comments
 (0)