Update build.ps1

refactoring codes
This commit is contained in:
DecorativeFamily 2024-11-07 18:27:08 +03:30 committed by GitHub
parent 7bcc5ab30b
commit 85b332ba84
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,12 +1,12 @@
param ( param (
[Parameter()] [Parameter()]
[ValidateNotNullOrEmpty()] [ValidateNotNullOrEmpty()]
[string] [string] $OutputPath = '.\bin\v2rayN'
$OutputPath = '.\bin\v2rayN'
) )
Write-Host 'Building' Write-Host 'Building...'
# Publish for Windows
dotnet publish ` dotnet publish `
.\v2rayN\v2rayN.csproj ` .\v2rayN\v2rayN.csproj `
-c Release ` -c Release `
@ -16,6 +16,7 @@ dotnet publish `
-p:PublishSingleFile=true ` -p:PublishSingleFile=true `
-o "$OutputPath\win-x64" -o "$OutputPath\win-x64"
# Publish for Linux
dotnet publish ` dotnet publish `
.\v2rayN.Desktop\v2rayN.Desktop.csproj ` .\v2rayN.Desktop\v2rayN.Desktop.csproj `
-c Release ` -c Release `
@ -25,18 +26,25 @@ dotnet publish `
-p:PublishSingleFile=true ` -p:PublishSingleFile=true `
-o "$OutputPath\linux-x64" -o "$OutputPath\linux-x64"
# Check if the publish succeeded
if (-Not $?) { if (-Not $?) {
exit $lastExitCode exit $LASTEXITCODE
} }
if ( Test-Path -Path .\bin\v2rayN ) { # Clean up PDB files if they exist
rm -Force "$OutputPath\win-x64\*.pdb" if (Test-Path -Path "$OutputPath\win-x64") {
rm -Force "$OutputPath\linux-x64\*.pdb" Remove-Item -Force "$OutputPath\win-x64\*.pdb"
}
if (Test-Path -Path "$OutputPath\linux-x64") {
Remove-Item -Force "$OutputPath\linux-x64\*.pdb"
} }
Write-Host 'Build done' Write-Host 'Build done.'
ls $OutputPath # List the output directory contents
Get-ChildItem $OutputPath
# Create a zip archive of the output
7z a v2rayN.zip $OutputPath 7z a v2rayN.zip $OutputPath
exit 0 exit 0