Update publish scripts

This commit is contained in:
Matt Nadareski
2024-02-20 20:51:59 -05:00
parent d6db84152f
commit 3203b56ef6
4 changed files with 195 additions and 113 deletions

View File

@@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Developer Guide.md = Developer Guide.md
LICENSE = LICENSE
publish-nix.sh = publish-nix.sh
publish-win.bat = publish-win.bat
publish-win.ps1 = publish-win.ps1
README.md = README.md
EndProjectSection
EndProject

View File

@@ -3,67 +3,111 @@
# This batch file assumes the following:
# - .NET 8.0 (or newer) SDK is installed and in PATH
# - zip is installed and in PATH
# - Git is installed and in PATH
# - The relevant commandline programs are already downloaded
# and put into their respective folders
#
# If any of these are not satisfied, the operation may fail
# in an unpredictable way and result in an incomplete output.
# Optional parameters
USE_ALL=false
INCLUDE_PROGRAMS=false
NO_BUILD=false
NO_ARCHIVE=false
while getopts "uba" OPTION
do
case $OPTION in
u)
USE_ALL=true
;;
b)
NO_BUILD=true
;;
a)
NO_ARCHIVE=true
;;
*)
echo "Invalid option provided"
exit 1
;;
esac
done
# Set the current directory as a variable
BUILD_FOLDER=$PWD
# Restore Nuget packages for all builds
echo "Restoring Nuget packages"
dotnet restore
# Set the current commit hash
COMMIT=`git log --pretty=%H -1`
# .NET 6.0 Debug
echo "Building .NET 6.0 debug"
dotnet publish Test/Test.csproj -f net6.0 -r win-x64 -c Debug --self-contained true -p:PublishSingleFile=true
dotnet publish Test/Test.csproj -f net6.0 -r linux-x64 -c Debug --self-contained true -p:PublishSingleFile=true
dotnet publish Test/Test.csproj -f net6.0 -r osx-x64 -c Debug --self-contained true -p:PublishSingleFile=true
# Create the build matrix arrays
FRAMEWORKS=("net8.0")
RUNTIMES=("win-x64")
# .NET 6.0 Release
echo "Building .NET 6.0 release"
dotnet publish Test/Test.csproj -f net6.0 -r win-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
dotnet publish Test/Test.csproj -f net6.0 -r linux-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
dotnet publish Test/Test.csproj -f net6.0 -r osx-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
# Use expanded lists, if requested
if [ $USE_ALL = true ]
then
FRAMEWORKS=("net20" "net35" "net40" "net452" "net462" "net472" "net48" "netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
RUNTIMES=("win-x86" "win-x64")
fi
# .NET 8.0 Debug
echo "Building .NET 8.0 debug"
dotnet publish Test/Test.csproj -f net8.0 -r win-x64 -c Debug --self-contained true -p:PublishSingleFile=true
dotnet publish Test/Test.csproj -f net8.0 -r linux-x64 -c Debug --self-contained true -p:PublishSingleFile=true
dotnet publish Test/Test.csproj -f net8.0 -r osx-x64 -c Debug --self-contained true -p:PublishSingleFile=true
# Create the filter arrays
SINGLE_FILE_CAPABLE=("net5.0" "net6.0" "net7.0" "net8.0")
VALID_CROSS_PLATFORM_FRAMEWORKS=("netcoreapp3.1" "net5.0" "net6.0" "net7.0" "net8.0")
VALID_CROSS_PLATFORM_RUNTIMES=("win-arm64" "linux-x64" "linux-arm64" "osx-x64")
# .NET 8.0 Release
echo "Building .NET 8.0 release"
dotnet publish Test/Test.csproj -f net8.0 -r win-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
dotnet publish Test/Test.csproj -f net8.0 -r linux-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
dotnet publish Test/Test.csproj -f net8.0 -r osx-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
# Only build if requested
if [ $NO_BUILD = false ]
then
# Restore Nuget packages for all builds
echo "Restoring Nuget packages"
dotnet restore
# Create Test Debug archives
cd $BUILD_FOLDER/Test/bin/Debug/net6.0/win-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net6.0_win-x64_debug.zip .
cd $BUILD_FOLDER/Test/bin/Debug/net6.0/linux-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net6.0_linux-x64_debug.zip .
cd $BUILD_FOLDER/Test/bin/Debug/net6.0/osx-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net6.0_osx-x64_debug.zip .
cd $BUILD_FOLDER/Test/bin/Debug/net8.0/win-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net8.0_win-x64_debug.zip .
cd $BUILD_FOLDER/Test/bin/Debug/net8.0/linux-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net8.0_linux-x64_debug.zip .
cd $BUILD_FOLDER/Test/bin/Debug/net8.0/osx-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net8.0_osx-x64_debug.zip .
# Create Nuget Package
dotnet pack --output $BUILD_FOLDER
# Create Test Release archives
cd $BUILD_FOLDER/Test/bin/Release/net6.0/win-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net6.0_win-x64_release.zip .
cd $BUILD_FOLDER/Test/bin/Release/net6.0/linux-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net6.0_linux-x64_release.zip .
cd $BUILD_FOLDER/Test/bin/Release/net6.0/osx-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net6.0_osx-x64_release.zip .
cd $BUILD_FOLDER/Test/bin/Release/net8.0/win-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net8.0_win-x64_release.zip .
cd $BUILD_FOLDER/Test/bin/Release/net8.0/linux-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net8.0_linux-x64_release.zip .
cd $BUILD_FOLDER/Test/bin/Release/net8.0/osx-x64/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_net8.0_osx-x64_release.zip .
# Build Test
for FRAMEWORK in "${FRAMEWORKS[@]}"
do
for RUNTIME in "${RUNTIMES[@]}"
do
# Only .NET 5 and above can publish to a single file
if [[ $(echo ${SINGLE_FILE_CAPABLE[@]} | fgrep -w $FRAMEWORK) ]]
then
dotnet publish Test/Test.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
dotnet publish Test/Test.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
else
dotnet publish Test/Test.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
dotnet publish Test/Test.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
fi
done
done
fi
# Only create archives if requested
if [ $NO_ARCHIVE = false ]
then
# Create Test archives
for FRAMEWORK in "${FRAMEWORKS[@]}"
do
# If we have an invalid combination of framework and runtime
if [[ ! $(echo ${VALID_CROSS_PLATFORM_FRAMEWORKS[@]} | fgrep -w $FRAMEWORK) ]]
then
if [[ $(echo ${VALID_CROSS_PLATFORM_RUNTIMES[@]} | fgrep -w $RUNTIME) ]]
then
continue
fi
fi
for RUNTIME in "${RUNTIMES[@]}"
do
cd $BUILD_FOLDER/Test/bin/Debug/${FRAMEWORK}/${RUNTIME}/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_${FRAMEWORK}_${RUNTIME}_debug.zip .
cd $BUILD_FOLDER/Test/bin/Release/${FRAMEWORK}/${RUNTIME}/publish/
zip -r $BUILD_FOLDER/BinaryObjectScanner_${FRAMEWORK}_${RUNTIME}_release.zip .
done
done
# Reset the directory
cd $BUILD_FOLDER
fi

View File

@@ -1,63 +0,0 @@
@echo OFF
REM This batch file assumes the following:
REM - .NET 8.0 (or newer) SDK is installed and in PATH
REM - 7-zip commandline (7z.exe) is installed and in PATH
REM - The relevant commandline programs are already downloaded
REM and put into their respective folders
REM
REM If any of these are not satisfied, the operation may fail
REM in an unpredictable way and result in an incomplete output.
REM Set the current directory as a variable
set BUILD_FOLDER=%~dp0
REM Restore Nuget packages for all builds
echo Restoring Nuget packages
dotnet restore
REM Debug
echo Building debug
dotnet publish Test\Test.csproj -f net6.0 -r win-x64 -c Debug --self-contained true -p:PublishSingleFile=true
dotnet publish Test\Test.csproj -f net6.0 -r linux-x64 -c Debug --self-contained true -p:PublishSingleFile=true
dotnet publish Test\Test.csproj -f net6.0 -r osx-x64 -c Debug --self-contained true -p:PublishSingleFile=true
dotnet publish Test\Test.csproj -f net8.0 -r win-x64 -c Debug --self-contained true -p:PublishSingleFile=true
dotnet publish Test\Test.csproj -f net8.0 -r linux-x64 -c Debug --self-contained true -p:PublishSingleFile=true
dotnet publish Test\Test.csproj -f net8.0 -r osx-x64 -c Debug --self-contained true -p:PublishSingleFile=true
REM Release
echo Building release
dotnet publish Test\Test.csproj -f net6.0 -r win-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
dotnet publish Test\Test.csproj -f net6.0 -r linux-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
dotnet publish Test\Test.csproj -f net6.0 -r osx-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
dotnet publish Test\Test.csproj -f net8.0 -r win-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
dotnet publish Test\Test.csproj -f net8.0 -r linux-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
dotnet publish Test\Test.csproj -f net8.0 -r osx-x64 -c Release --self-contained true -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
REM Create Test Debug archives
cd %BUILD_FOLDER%\Test\bin\Debug\net6.0\win-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net6.0_win-x64_debug.zip *
cd %BUILD_FOLDER%\Test\bin\Debug\net6.0\linux-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net6.0_linux-x64_debug.zip *
cd %BUILD_FOLDER%\Test\bin\Debug\net6.0\osx-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net6.0_osx-x64_debug.zip *
cd %BUILD_FOLDER%\Test\bin\Debug\net8.0\win-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net8.0_win-x64_debug.zip *
cd %BUILD_FOLDER%\Test\bin\Debug\net8.0\linux-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net8.0_linux-x64_debug.zip *
cd %BUILD_FOLDER%\Test\bin\Debug\net8.0\osx-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net8.0_osx-x64_debug.zip *
REM Create Test Release archives
cd %BUILD_FOLDER%\Test\bin\Release\net6.0\win-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net6.0_win-x64_release.zip *
cd %BUILD_FOLDER%\Test\bin\Release\net6.0\linux-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net6.0_linux-x64_release.zip *
cd %BUILD_FOLDER%\Test\bin\Release\net6.0\osx-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net6.0_osx-x64_release.zip *
cd %BUILD_FOLDER%\Test\bin\Release\net8.0\win-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net8.0_win-x64_release.zip *
cd %BUILD_FOLDER%\Test\bin\Release\net8.0\linux-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net8.0_linux-x64_release.zip *
cd %BUILD_FOLDER%\Test\bin\Release\net8.0\osx-x64\publish\
7z a -tzip %BUILD_FOLDER%\BinaryObjectScanner_net8.0_osx-x64_release.zip *

101
publish-win.ps1 Normal file
View File

@@ -0,0 +1,101 @@
# This batch file assumes the following:
# - .NET 8.0 (or newer) SDK is installed and in PATH
# - 7-zip commandline (7z.exe) is installed and in PATH
# - Git for Windows is installed and in PATH
# - The relevant commandline programs are already downloaded
# and put into their respective folders
#
# If any of these are not satisfied, the operation may fail
# in an unpredictable way and result in an incomplete output.
# Optional parameters
param(
[Parameter(Mandatory = $false)]
[Alias("UseAll")]
[switch]$USE_ALL,
[Parameter(Mandatory = $false)]
[Alias("NoBuild")]
[switch]$NO_BUILD,
[Parameter(Mandatory = $false)]
[Alias("NoArchive")]
[switch]$NO_ARCHIVE
)
# Set the current directory as a variable
$BUILD_FOLDER = $PSScriptRoot
# Set the current commit hash
$COMMIT = git log --pretty=format:"%H" -1
# Create the build matrix arrays
$FRAMEWORKS = @('net8.0')
$RUNTIMES = @('win-x64')
# Use expanded lists, if requested
if ($USE_ALL.IsPresent)
{
$FRAMEWORKS = @('net20', 'net35', 'net40', 'net452', 'net462', 'net472', 'net48', 'netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
$RUNTIMES = @('win-x86', 'win-x64')
}
# Create the filter arrays
$SINGLE_FILE_CAPABLE = @('net5.0', 'net6.0', 'net7.0', 'net8.0')
$VALID_CROSS_PLATFORM_FRAMEWORKS = @('netcoreapp3.1', 'net5.0', 'net6.0', 'net7.0', 'net8.0')
$VALID_CROSS_PLATFORM_RUNTIMES = @('win-arm64', 'linux-x64', 'linux-arm64', 'osx-x64')
# Only build if requested
if (!$NO_BUILD.IsPresent)
{
# Restore Nuget packages for all builds
Write-Host "Restoring Nuget packages"
dotnet restore
# Create Nuget Package
dotnet pack --output $BUILD_FOLDER
# Build Test
foreach ($FRAMEWORK in $FRAMEWORKS)
{
foreach ($RUNTIME in $RUNTIMES)
{
# Only .NET 5 and above can publish to a single file
if ($SINGLE_FILE_CAPABLE -contains $FRAMEWORK)
{
dotnet publish Test\Test.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
dotnet publish Test\Test.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
}
else
{
dotnet publish Test\Test.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
dotnet publish Test\Test.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
}
}
}
}
# Only create archives if requested
if (!$NO_ARCHIVE.IsPresent)
{
# Create Test archives
foreach ($FRAMEWORK in $FRAMEWORKS)
{
foreach ($RUNTIME in $RUNTIMES)
{
# If we have an invalid combination of framework and runtime
if ($VALID_CROSS_PLATFORM_FRAMEWORKS -notcontains $FRAMEWORK -and $VALID_CROSS_PLATFORM_RUNTIMES -contains $RUNTIME)
{
continue
}
Set-Location -Path $BUILD_FOLDER\Test\bin\Debug\${FRAMEWORK}\${RUNTIME}\publish\
7z a -tzip $BUILD_FOLDER\BinaryObjectScanner_${FRAMEWORK}_${RUNTIME}_debug.zip *
Set-Location -Path $BUILD_FOLDER\Test\bin\Release\${FRAMEWORK}\${RUNTIME}\publish\
7z a -tzip $BUILD_FOLDER\BinaryObjectScanner_${FRAMEWORK}_${RUNTIME}_release.zip *
}
}
# Reset the directory
Set-Location -Path $PSScriptRoot
}