diff --git a/appveyor.yml b/appveyor.yml index 58f41fb1..3086bd28 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -103,7 +103,7 @@ before_build: # scripts to run after build (working directory and environment changes are persisted from the previous steps) after_build: - ps: |+ - function CalculateHash($file) + function Calculate-Hash($file) { $newLine = "`r`n" $text = (Split-Path $file -Leaf) + $newLine @@ -119,35 +119,37 @@ after_build: } $WorkingFolder = "$env:APPVEYOR_BUILD_FOLDER\working" - $ExeFileName = "Shadowsocks-$env:APPVEYOR_BUILD_VERSION-$env:CONFIGURATION.exe" - $DllFileName = "Shadowsocks.dll" - $ExeFile = "$WorkingFolder\$DNVer\$ExeFileName" - $DllFile = "$WorkingFolder\$DNVer\$DllFileName" - New-Item $WorkingFolder -ItemType Directory -Force - Copy-Item $env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:CONFIGURATION\netcoreapp3.1\Shadowsocks.exe $WorkingFolder\Shadowsocks.exe - Copy-Item $env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:CONFIGURATION\netcoreapp3.1\Shadowsocks.dll $WorkingFolder\Shadowsocks.dll - Copy-Item $env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:CONFIGURATION\netcoreapp3.1\Shadowsocks.runtimeconfig.json $WorkingFolder\Shadowsocks.runtimeconfig.json - - Copy-Item $WorkingFolder\Shadowsocks.exe $ExeFile - # Copy-Item $WorkingFolder\Shadowsocks.dll $DllFile - + # Create and deploy the release zip - $ReleaseFile = "$WorkingFolder\Shadowsocks.exe" - $ReleaseFile2 = "$WorkingFolder\Shadowsocks.dll" - $ReleaseFile3 = "$WorkingFolder\Shadowsocks.runtimeconfig.json" - $ZipFile = "$WorkingFolder\Shadowsocks-$env:APPVEYOR_BUILD_VERSION.zip" + $ReleaseFile = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:CONFIGURATION\netcoreapp3.1\Shadowsocks.exe" + $ReleaseFile2 = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:CONFIGURATION\netcoreapp3.1\Shadowsocks.dll" + $ReleaseFile3 = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:CONFIGURATION\netcoreapp3.1\Shadowsocks.runtimeconfig.json" + $ZipFile = "$WorkingFolder\Shadowsocks-$env:APPVEYOR_BUILD_VERSION-minimal.zip" $ZipHashFile = "$ZipFile.hash" - # Calculate exe Hash and archieve both exe and hash to zip - CalculateHash -file $ReleaseFile | Out-File -FilePath $hashFile 7z a $ZipFile $ReleaseFile 7z a $ZipFile $ReleaseFile2 7z a $ZipFile $ReleaseFile3 Push-AppveyorArtifact $ZipFile - # Calculate zip Hash - CalculateHash -file $ZipFile | Out-File -FilePath $ZipHashFile + Calculate-Hash -file $ZipFile | Out-File -FilePath $ZipHashFile -Append + + # Package into a self-contained single-file executable + dotnet publish -f netcoreapp3.1 -r win-x64 -c $env:CONFIGURATION -p:PublishSingleFile=true -p:PublishTrimmed=true $env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\shadowsocks-csharp.csproj + dotnet publish -f netcoreapp3.1 -r win-x86 -c $env:CONFIGURATION -p:PublishSingleFile=true -p:PublishTrimmed=true $env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\shadowsocks-csharp.csproj + $SingleExeX64 = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\Any CPU\$env:CONFIGURATION\netcoreapp3.1\win-x64\publish\Shadowsocks.exe" + $SingleExeX86 = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\Any CPU\$env:CONFIGURATION\netcoreapp3.1\win-x86\publish\Shadowsocks.exe" + $ZipSingleExeX64 = "$WorkingFolder\Shadowsocks-$env:APPVEYOR_BUILD_VERSION-portable-x64.zip" + $ZipSingleExeX86 = "$WorkingFolder\Shadowsocks-$env:APPVEYOR_BUILD_VERSION-portable-x86.zip" + $HashZipX64 = "$ZipSingleExeX64.hash" + $HashZipX86 = "$ZipSingleExeX86.hash" + 7z a $ZipSingleExeX64 $SingleExeX64 + 7z a $ZipSingleExeX86 $SingleExeX86 + Calculate-Hash -file $ZipSingleExeX64 | Out-File -FilePath $ZipHashFile -Append + Calculate-Hash -file $ZipSingleExeX86 | Out-File -FilePath $ZipHashFile -Append + Push-AppveyorArtifact $ZipSingleExeX64 + Push-AppveyorArtifact $ZipSingleExeX86 + Push-AppveyorArtifact $ZipHashFile - # scripts to run *after* solution is built and *before* automatic packaging occurs (web apps, NuGet packages, Azure Cloud Services) # before_package: