Skip to content

Commit

Permalink
Copy build files in onebranch pipeline (#165)
Browse files Browse the repository at this point in the history
* copy build files

* add arch option

---------

Co-authored-by: Laksh Kotian <[email protected]>
Co-authored-by: Alan Jowett <[email protected]>
  • Loading branch information
3 people authored Nov 19, 2024
1 parent 4b7197c commit eaeebce
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions scripts/onebranch/post-build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,42 @@ Set-Location $scriptPath\..\..
$OneBranchArch = $env:ONEBRANCH_ARCH
$OneBranchConfig = $env:ONEBRANCH_CONFIG

function Copy-BuildFolder {
param (
[Parameter(Mandatory=$true)]
[ValidateSet("Release", "Debug")]
[string]$Configuration,
[Parameter(Mandatory=$true)]
[string]$Arch
)

# Define the source folder and zip file path based on the configuration
$SourceFolder = ".\$Arch\$Configuration"
$ZipFile = ".\build\bin\$($Arch)_$($Configuration)\Build-$($Arch)-$($Configuration).zip"

# Remove any existing zip file to avoid conflicts
if (Test-Path $ZipFile) {
Remove-Item $ZipFile
}

# Compress the folder into a zip file
Compress-Archive -Path $SourceFolder -DestinationPath $ZipFile

Write-Host "$SourceFolder folder has been zipped into $ZipFile"
}

# Copy the signed binaries to the output directory
if ($OneBranchConfig -eq "Debug" -and $OneBranchArch -eq "x64")
{
if ($OneBranchConfig -eq "Debug" -and $OneBranchArch -eq "x64") {
xcopy /y build\bin\x64_Debug .\x64\Debug
xcopy /y build\bin\x64_Debug\Install-Extension.ps1 .\scripts\
Get-ChildItem -Path .\build\bin\x64_Debug -Recurse | Remove-Item -Force -Recurse
}
elseif ($OneBranchConfig -eq "Release" -and $OneBranchArch -eq "x64")
{
elseif ($OneBranchConfig -eq "Release" -and $OneBranchArch -eq "x64") {
xcopy /y build\bin\x64_Release .\x64\Release
xcopy /y build\bin\x64_Release\Install-Extension.ps1 .\scripts\
Get-ChildItem -Path .\build\bin\x64_Release -Recurse | Remove-Item -Force -Recurse
}
else
{
else {
throw ("Configuration $OneBranchConfig|$OneBranchArch is not supported.")
}

Expand All @@ -37,15 +58,14 @@ $SolutionDir = Get-Location
msbuild /p:SolutionDir=$SolutionDir\ /p:Configuration=$OneBranchConfig /p:Platform=$OneBranchArch /p:BuildProjectReferences=false .\tools\nuget\nuget.proj /t:Restore,Build,Pack

# Copy the nupkg and msi to the output directory
if ($OneBranchConfig -eq "Debug" -and $OneBranchArch -eq "x64")
{
if ($OneBranchConfig -eq "Debug" -and $OneBranchArch -eq "x64") {
xcopy /y .\x64\Debug\*.nupkg .\build\bin\x64_Debug
Copy-BuildFolder -Configuration Debug -Arch x64
}
elseif ($OneBranchConfig -eq "Release" -and $OneBranchArch -eq "x64")
{
elseif ($OneBranchConfig -eq "Release" -and $OneBranchArch -eq "x64") {
xcopy /y .\x64\Release\*.nupkg .\build\bin\x64_Release
Copy-BuildFolder -Configuration Release -Arch x64
}
else
{
else {
throw ("Configuration $OneBranchConfig|$OneBranchArch is not supported.")
}

0 comments on commit eaeebce

Please sign in to comment.