From ad96dacb5ce7783d494ff7040db58e7fde2b379a Mon Sep 17 00:00:00 2001 From: n00mkrad <61149547+n00mkrad@users.noreply.github.com> Date: Sun, 9 Nov 2025 18:44:50 +0100 Subject: [PATCH] BuildRelease.ps1 script for building Flowframes & FlowframesCmd --- CodeLegacy/BuildRelease.ps1 | 83 +++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 CodeLegacy/BuildRelease.ps1 diff --git a/CodeLegacy/BuildRelease.ps1 b/CodeLegacy/BuildRelease.ps1 new file mode 100644 index 0000000..aaab933 --- /dev/null +++ b/CodeLegacy/BuildRelease.ps1 @@ -0,0 +1,83 @@ +# Define paths and tools +$winDir = ${env:WINDIR} +$progFiles64 = ${env:ProgramW6432} +$msBuildPath = [IO.Path]::Combine($progFiles64, "Microsoft Visual Studio", "2022", "Community", "MSBuild", "Current", "Bin", "MSBuild.exe") +$solutionRoot = $PSScriptRoot +$ilRepackPath = [IO.Path]::Combine($solutionRoot, "packages", "ILRepack.2.0.34", "tools", "ILRepack.exe") +$solutionPath = [IO.Path]::Combine($solutionPath, "Flowframes.sln") +$outputDir = [IO.Path]::Combine($solutionRoot, "bin") +$packedDir = [IO.Path]::Combine($outputDir, "packed") + +# Check if files exist +if (Test-Path $msBuildPath) { Write-Host "Found MSBuild at $msBuildPath" } else { Write-Host "MSBuild not found! ($msBuildPath)"; exit 1 } +if (Test-Path $ilRepackPath) { Write-Host "Found ILRepack at $ilRepackPath" } else { Write-Host "ILRepack not found! ($ilRepackPath)"; exit 1 } +if (Test-Path $solutionPath) { Write-Host "Found solution at $solutionPath" } else { Write-Host "Solution not found! ($solutionPath)"; exit 1 } + +# Ensure output directory exists +if (-not (Test-Path $outputDir)) { + New-Item -ItemType Directory -Path $outputDir +} + +# Define configurations and platforms +$configurations = @("Release", "ConsoleRelease") +$assemblyNames = @("Flowframes", "FlowframesCmd") +$buildDirs = @("RelGui", "RelCmd") + +# Function to build and repack +function Build-And-Repack ($config, $assemblyName, $buildDir) { + # Build the project + & $msBuildPath $solutionPath /p:Configuration=$config /p:Platform="x64" /m + if ($LASTEXITCODE -ne 0) { + Write-Error "Build failed for configuration: $config" + return + } + + # ILRepack to merge all assemblies into a single executable + $targetDir = "$outputDir\$buildDir" + + # Rename files matching *Native*.dll to .xdll to exclude them from repacking + Get-ChildItem $targetDir -Filter "*Native*.dll" | Rename-Item -NewName { $_.Name -replace '\.dll$', '.xdll' } + + $mainAssembly = "$targetDir\Flowframes.exe" + $outputAssembly = "$packedDir\$assemblyName.exe" + Write-Host "------------" + $target = "winexe" + if ($assemblyName -like "*Cmd") { $target = "exe" } + & $ilRepackPath /out:$outputAssembly /target:$target /targetplatform:v4,"$winDir\Microsoft.NET\Framework64\v4.0.30319" /union /wildcards "$mainAssembly" "$targetDir\*.dll" + if ($LASTEXITCODE -ne 0) { + Write-Error "Repacking failed for configuration: $config" + } else { + Write-Host "Successfully repacked: $outputAssembly" + } + + # Delete everything in $targetDir except .xdll files + Get-ChildItem $targetDir -Exclude "*.xdll" | Remove-Item -Force + + # Reverse the renaming from .xdll back to .dll + Get-ChildItem $targetDir -Filter "*.xdll" | Rename-Item -NewName { $_.Name -replace '\.xdll$', '.dll' } +} + +# Remove $packedDir +if (Test-Path $packedDir) { + Remove-Item -Recurse -Force $packedDir +} + +# Process each configuration +foreach ($index in 0..1) { + Build-And-Repack -config $configurations[$index] -assemblyName $assemblyNames[$index] -buildDir $buildDirs[$index] +} + +Write-Host "Build and repack process completed." + +# Delete files other than .exe +Get-ChildItem $packedDir -Exclude "*.exe" | Remove-Item -Force + +# Copy all files matching "*Native*.dll" from first $buildDirs directory to $packedDir +Get-ChildItem "$outputDir\$($buildDirs[0])" -Filter "*Native*.dll" | Copy-Item -Destination $packedDir + +# Remove buildDirs +foreach ($buildDir in $buildDirs) { + Remove-Item -Recurse -Force "$outputDir\$buildDir" +} + +Write-Host "All done." \ No newline at end of file