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,42 +1,50 @@
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 `
-r win-x64 ` -r win-x64 `
--self-contained false ` --self-contained false `
-p:PublishReadyToRun=false ` -p:PublishReadyToRun=false `
-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 `
-r linux-x64 ` -r linux-x64 `
--self-contained true ` --self-contained true `
-p:PublishReadyToRun=false ` -p:PublishReadyToRun=false `
-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 ) {
rm -Force "$OutputPath\win-x64\*.pdb"
rm -Force "$OutputPath\linux-x64\*.pdb"
} }
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 Write-Host 'Build done.'
7z a v2rayN.zip $OutputPath
exit 0 # List the output directory contents
Get-ChildItem $OutputPath
# Create a zip archive of the output
7z a v2rayN.zip $OutputPath
exit 0