From 28c6e30aaa61ac907d484b0ab014fee6b8c5fb42 Mon Sep 17 00:00:00 2001 From: database64128 Date: Thu, 21 May 2020 16:38:45 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=93=A6=20More=20artifacts:=20Package?= =?UTF-8?q?=20into=20a=20self-contained=20single-file=20executable=20for?= =?UTF-8?q?=20better=20portability.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - New artifact: single .exe for better portability. - Cleanup: removed unnecessary copies. --- appveyor.yml | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 58f41fb1..41d8aa8f 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 Release -p:PublishSingleFile=true -p:PublishTrimmed=true $env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\shadowsocks-csharp.csproj + dotnet publish -f netcoreapp3.1 -r win-x86 -c Release -p:PublishSingleFile=true -p:PublishTrimmed=true $env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\shadowsocks-csharp.csproj + $SingleExeX64 = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:CONFIGURATION\netcoreapp3.1\win-x64\publish\Shadowsocks.exe" + $SingleExeX86 = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$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: From ba2670b2c48979ccf4958292c43b3c2620747f0a Mon Sep 17 00:00:00 2001 From: database64128 Date: Thu, 21 May 2020 16:49:21 +0800 Subject: [PATCH 2/3] Fix typo: Wrong configuration --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 41d8aa8f..cf7b57cc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -134,8 +134,8 @@ after_build: 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 Release -p:PublishSingleFile=true -p:PublishTrimmed=true $env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\shadowsocks-csharp.csproj - dotnet publish -f netcoreapp3.1 -r win-x86 -c Release -p:PublishSingleFile=true -p:PublishTrimmed=true $env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\shadowsocks-csharp.csproj + 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\$env:CONFIGURATION\netcoreapp3.1\win-x64\publish\Shadowsocks.exe" $SingleExeX86 = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:CONFIGURATION\netcoreapp3.1\win-x86\publish\Shadowsocks.exe" $ZipSingleExeX64 = "$WorkingFolder\Shadowsocks-$env:APPVEYOR_BUILD_VERSION-portable-x64.zip" From 83d846672b0cae2d4953e5c7ef19752a5048e393 Mon Sep 17 00:00:00 2001 From: database64128 Date: Thu, 21 May 2020 16:59:46 +0800 Subject: [PATCH 3/3] Fix CI path --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index cf7b57cc..3086bd28 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -136,8 +136,8 @@ after_build: # 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\$env:CONFIGURATION\netcoreapp3.1\win-x64\publish\Shadowsocks.exe" - $SingleExeX86 = "$env:APPVEYOR_BUILD_FOLDER\shadowsocks-csharp\bin\$env:CONFIGURATION\netcoreapp3.1\win-x86\publish\Shadowsocks.exe" + $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"