Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy build files in onebranch pipeline #165

Merged
merged 3 commits into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.")
}
Loading