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 (
[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
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