From 85b332ba848a0b6188a530430e70e6cce764c51e Mon Sep 17 00:00:00 2001 From: DecorativeFamily <185765765+decorativefamily@users.noreply.github.com> Date: Thu, 7 Nov 2024 18:27:08 +0330 Subject: [PATCH] Update build.ps1 refactoring codes --- v2rayN/build.ps1 | 70 +++++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/v2rayN/build.ps1 b/v2rayN/build.ps1 index f6d9b148..cb9d6712 100644 --- a/v2rayN/build.ps1 +++ b/v2rayN/build.ps1 @@ -1,42 +1,50 @@ param ( - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] - $OutputPath = '.\bin\v2rayN' + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] $OutputPath = '.\bin\v2rayN' ) -Write-Host 'Building' +Write-Host 'Building...' +# Publish for Windows dotnet publish ` - .\v2rayN\v2rayN.csproj ` - -c Release ` - -r win-x64 ` - --self-contained false ` - -p:PublishReadyToRun=false ` - -p:PublishSingleFile=true ` - -o "$OutputPath\win-x64" + .\v2rayN\v2rayN.csproj ` + -c Release ` + -r win-x64 ` + --self-contained false ` + -p:PublishReadyToRun=false ` + -p:PublishSingleFile=true ` + -o "$OutputPath\win-x64" +# Publish for Linux dotnet publish ` - .\v2rayN.Desktop\v2rayN.Desktop.csproj ` - -c Release ` - -r linux-x64 ` - --self-contained true ` - -p:PublishReadyToRun=false ` - -p:PublishSingleFile=true ` - -o "$OutputPath\linux-x64" + .\v2rayN.Desktop\v2rayN.Desktop.csproj ` + -c Release ` + -r linux-x64 ` + --self-contained true ` + -p:PublishReadyToRun=false ` + -p:PublishSingleFile=true ` + -o "$OutputPath\linux-x64" - -if ( -Not $? ) { - exit $lastExitCode - } - -if ( Test-Path -Path .\bin\v2rayN ) { - rm -Force "$OutputPath\win-x64\*.pdb" - rm -Force "$OutputPath\linux-x64\*.pdb" +# Check if the publish succeeded +if (-Not $?) { + exit $LASTEXITCODE } -Write-Host 'Build done' +# Clean up PDB files if they exist +if (Test-Path -Path "$OutputPath\win-x64") { + Remove-Item -Force "$OutputPath\win-x64\*.pdb" +} +if (Test-Path -Path "$OutputPath\linux-x64") { + Remove-Item -Force "$OutputPath\linux-x64\*.pdb" +} -ls $OutputPath -7z a v2rayN.zip $OutputPath -exit 0 \ No newline at end of file +Write-Host 'Build done.' + +# List the output directory contents +Get-ChildItem $OutputPath + +# Create a zip archive of the output +7z a v2rayN.zip $OutputPath + +exit 0