diff --git a/.github/workflows/dotnetcore.yml b/.github/workflows/dotnetcore.yml index 52510f58..885eef8f 100644 --- a/.github/workflows/dotnetcore.yml +++ b/.github/workflows/dotnetcore.yml @@ -12,6 +12,5 @@ jobs: - uses: actions/checkout@v1 - uses: actions/setup-dotnet@v1 with: - dotnet-version: 3.1.202 - - name: Run the Cake script - uses: ecampidoglio/cake-action@master + dotnet-version: 3.1.300 + - run: dotnet run -p build/build.csproj diff --git a/SharpCompress.sln b/SharpCompress.sln index d6f16c37..c3482a53 100644 --- a/SharpCompress.sln +++ b/SharpCompress.sln @@ -13,6 +13,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpCompress", "src\SharpC EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharpCompress.Test", "tests\SharpCompress.Test\SharpCompress.Test.csproj", "{F2B1A1EB-0FA6-40D0-8908-E13247C7226F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "build", "src\build\build.csproj", "{D4D613CB-5E94-47FB-85BE-B8423D20C545}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -27,6 +29,10 @@ Global {F2B1A1EB-0FA6-40D0-8908-E13247C7226F}.Debug|Any CPU.Build.0 = Debug|Any CPU {F2B1A1EB-0FA6-40D0-8908-E13247C7226F}.Release|Any CPU.ActiveCfg = Release|Any CPU {F2B1A1EB-0FA6-40D0-8908-E13247C7226F}.Release|Any CPU.Build.0 = Release|Any CPU + {D4D613CB-5E94-47FB-85BE-B8423D20C545}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4D613CB-5E94-47FB-85BE-B8423D20C545}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4D613CB-5E94-47FB-85BE-B8423D20C545}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4D613CB-5E94-47FB-85BE-B8423D20C545}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -34,5 +40,6 @@ Global GlobalSection(NestedProjects) = preSolution {FD19DDD8-72B2-4024-8665-0D1F7A2AA998} = {3C5BE746-03E5-4895-9988-0B57F162F86C} {F2B1A1EB-0FA6-40D0-8908-E13247C7226F} = {0F0901FF-E8D9-426A-B5A2-17C7F47C1529} + {D4D613CB-5E94-47FB-85BE-B8423D20C545} = {3C5BE746-03E5-4895-9988-0B57F162F86C} EndGlobalSection EndGlobal diff --git a/build.cake b/build.cake deleted file mode 100644 index 22c401bd..00000000 --- a/build.cake +++ /dev/null @@ -1,89 +0,0 @@ -var target = Argument("target", "Default"); -var tag = Argument("tag", "cake"); - -Task("Restore") - .Does(() => -{ - DotNetCoreRestore("."); -}); - -Task("Build") - .IsDependentOn("Restore") - .Does(() => -{ - if (IsRunningOnWindows()) - { - MSBuild("./sharpcompress.sln", c => - { - c.SetConfiguration("Release") - .SetVerbosity(Verbosity.Minimal) - .UseToolVersion(MSBuildToolVersion.VS2019); - }); - } - else - { - var settings = new DotNetCoreBuildSettings - { - Framework = "netstandard1.3", - Configuration = "Release", - NoRestore = true - }; - - DotNetCoreBuild("./src/SharpCompress/SharpCompress.csproj", settings); - - settings.Framework = "netstandard2.0"; - DotNetCoreBuild("./src/SharpCompress/SharpCompress.csproj", settings); - - settings.Framework = "netstandard2.1"; - DotNetCoreBuild("./src/SharpCompress/SharpCompress.csproj", settings); - } -}); - -Task("Test") - .IsDependentOn("Build") - .Does(() => -{ - var files = GetFiles("tests/**/*.csproj"); - foreach(var file in files) - { - var settings = new DotNetCoreTestSettings - { - Configuration = "Release", - Framework = "netcoreapp3.1" - }; - DotNetCoreTest(file.ToString(), settings); - } -}); - -Task("Pack") - .IsDependentOn("Build") - .Does(() => -{ - if (IsRunningOnWindows()) - { - MSBuild("src/SharpCompress/SharpCompress.csproj", c => c - .SetConfiguration("Release") - .SetVerbosity(Verbosity.Minimal) - .UseToolVersion(MSBuildToolVersion.VS2019) - .WithProperty("NoBuild", "true") - .WithTarget("Pack")); - } - else - { - Information("Skipping Pack as this is not Windows"); - } -}); - -Task("Default") - .IsDependentOn("Restore") - .IsDependentOn("Build") - .IsDependentOn("Test") - .IsDependentOn("Pack"); - - Task("RunTests") - .IsDependentOn("Restore") - .IsDependentOn("Build") - .IsDependentOn("Test"); - - -RunTarget(target); \ No newline at end of file diff --git a/build.ps1 b/build.ps1 deleted file mode 100644 index 6d04c8cf..00000000 --- a/build.ps1 +++ /dev/null @@ -1,228 +0,0 @@ -########################################################################## -# This is the Cake bootstrapper script for PowerShell. -# This file was downloaded from https://github.com/cake-build/resources -# Feel free to change this file to fit your needs. -########################################################################## - -<# - -.SYNOPSIS -This is a Powershell script to bootstrap a Cake build. - -.DESCRIPTION -This Powershell script will download NuGet if missing, restore NuGet tools (including Cake) -and execute your Cake build script with the parameters you provide. - -.PARAMETER Script -The build script to execute. -.PARAMETER Target -The build script target to run. -.PARAMETER Configuration -The build configuration to use. -.PARAMETER Verbosity -Specifies the amount of information to be displayed. -.PARAMETER Experimental -Tells Cake to use the latest Roslyn release. -.PARAMETER WhatIf -Performs a dry run of the build script. -No tasks will be executed. -.PARAMETER Mono -Tells Cake to use the Mono scripting engine. -.PARAMETER SkipToolPackageRestore -Skips restoring of packages. -.PARAMETER ScriptArgs -Remaining arguments are added here. - -.LINK -http://cakebuild.net - -#> - -[CmdletBinding()] -Param( - [string]$Script = "build.cake", - [string]$Target = "Default", - [ValidateSet("Release", "Debug")] - [string]$Configuration = "Release", - [ValidateSet("Quiet", "Minimal", "Normal", "Verbose", "Diagnostic")] - [string]$Verbosity = "Verbose", - [switch]$Experimental, - [Alias("DryRun","Noop")] - [switch]$WhatIf, - [switch]$Mono, - [switch]$SkipToolPackageRestore, - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$ScriptArgs -) - -[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null -function MD5HashFile([string] $filePath) -{ - if ([string]::IsNullOrEmpty($filePath) -or !(Test-Path $filePath -PathType Leaf)) - { - return $null - } - - [System.IO.Stream] $file = $null; - [System.Security.Cryptography.MD5] $md5 = $null; - try - { - $md5 = [System.Security.Cryptography.MD5]::Create() - $file = [System.IO.File]::OpenRead($filePath) - return [System.BitConverter]::ToString($md5.ComputeHash($file)) - } - finally - { - if ($file -ne $null) - { - $file.Dispose() - } - } -} - -Write-Host "Preparing to run build script..." - -if(!$PSScriptRoot){ - $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent -} - -$TOOLS_DIR = Join-Path $PSScriptRoot "tools" -$ADDINS_DIR = Join-Path $TOOLS_DIR "addins" -$MODULES_DIR = Join-Path $TOOLS_DIR "modules" -$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" -$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" -$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -$PACKAGES_CONFIG = Join-Path $TOOLS_DIR "packages.config" -$PACKAGES_CONFIG_MD5 = Join-Path $TOOLS_DIR "packages.config.md5sum" -$ADDINS_PACKAGES_CONFIG = Join-Path $ADDINS_DIR "packages.config" -$MODULES_PACKAGES_CONFIG = Join-Path $MODULES_DIR "packages.config" - -# Should we use mono? -$UseMono = ""; -if($Mono.IsPresent) { - Write-Verbose -Message "Using the Mono based scripting engine." - $UseMono = "-mono" -} - -# Should we use the new Roslyn? -$UseExperimental = ""; -if($Experimental.IsPresent -and !($Mono.IsPresent)) { - Write-Verbose -Message "Using experimental version of Roslyn." - $UseExperimental = "-experimental" -} - -# Is this a dry run? -$UseDryRun = ""; -if($WhatIf.IsPresent) { - $UseDryRun = "-dryrun" -} - -# Make sure tools folder exists -if ((Test-Path $PSScriptRoot) -and !(Test-Path $TOOLS_DIR)) { - Write-Verbose -Message "Creating tools directory..." - New-Item -Path $TOOLS_DIR -Type directory | out-null -} - -# Make sure that packages.config exist. -if (!(Test-Path $PACKAGES_CONFIG)) { - Write-Verbose -Message "Downloading packages.config..." - try { (New-Object System.Net.WebClient).DownloadFile("http://cakebuild.net/download/bootstrapper/packages", $PACKAGES_CONFIG) } catch { - Throw "Could not download packages.config." - } -} - -# Try find NuGet.exe in path if not exists -if (!(Test-Path $NUGET_EXE)) { - Write-Verbose -Message "Trying to find nuget.exe in PATH..." - $existingPaths = $Env:Path -Split ';' | Where-Object { (![string]::IsNullOrEmpty($_)) -and (Test-Path $_ -PathType Container) } - $NUGET_EXE_IN_PATH = Get-ChildItem -Path $existingPaths -Filter "nuget.exe" | Select -First 1 - if ($NUGET_EXE_IN_PATH -ne $null -and (Test-Path $NUGET_EXE_IN_PATH.FullName)) { - Write-Verbose -Message "Found in PATH at $($NUGET_EXE_IN_PATH.FullName)." - $NUGET_EXE = $NUGET_EXE_IN_PATH.FullName - } -} - -# Try download NuGet.exe if not exists -if (!(Test-Path $NUGET_EXE)) { - Write-Verbose -Message "Downloading NuGet.exe..." - try { - (New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE) - } catch { - Throw "Could not download NuGet.exe." - } -} - -# Save nuget.exe path to environment to be available to child processed -$ENV:NUGET_EXE = $NUGET_EXE - -# Restore tools from NuGet? -if(-Not $SkipToolPackageRestore.IsPresent) { - Push-Location - Set-Location $TOOLS_DIR - - # Check for changes in packages.config and remove installed tools if true. - [string] $md5Hash = MD5HashFile($PACKAGES_CONFIG) - if((!(Test-Path $PACKAGES_CONFIG_MD5)) -Or - ($md5Hash -ne (Get-Content $PACKAGES_CONFIG_MD5 ))) { - Write-Verbose -Message "Missing or changed package.config hash..." - Remove-Item * -Recurse -Exclude packages.config,nuget.exe - } - - Write-Verbose -Message "Restoring tools from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$TOOLS_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occured while restoring NuGet tools." - } - else - { - $md5Hash | Out-File $PACKAGES_CONFIG_MD5 -Encoding "ASCII" - } - Write-Verbose -Message ($NuGetOutput | out-string) - - Pop-Location -} - -# Restore addins from NuGet -if (Test-Path $ADDINS_PACKAGES_CONFIG) { - Push-Location - Set-Location $ADDINS_DIR - - Write-Verbose -Message "Restoring addins from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$ADDINS_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occured while restoring NuGet addins." - } - - Write-Verbose -Message ($NuGetOutput | out-string) - - Pop-Location -} - -# Restore modules from NuGet -if (Test-Path $MODULES_PACKAGES_CONFIG) { - Push-Location - Set-Location $MODULES_DIR - - Write-Verbose -Message "Restoring modules from NuGet..." - $NuGetOutput = Invoke-Expression "&`"$NUGET_EXE`" install -ExcludeVersion -OutputDirectory `"$MODULES_DIR`"" - - if ($LASTEXITCODE -ne 0) { - Throw "An error occured while restoring NuGet modules." - } - - Write-Verbose -Message ($NuGetOutput | out-string) - - Pop-Location -} - -# Make sure that Cake has been installed. -if (!(Test-Path $CAKE_EXE)) { - Throw "Could not find Cake.exe at $CAKE_EXE" -} - -# Start Cake -Write-Host "Running build script..." -Invoke-Expression "& `"$CAKE_EXE`" `"$Script`" -target=`"$Target`" -configuration=`"$Configuration`" -verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" -exit $LASTEXITCODE \ No newline at end of file diff --git a/build.sh b/build.sh deleted file mode 100755 index d478e0a7..00000000 --- a/build.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -########################################################################## -# This is the Cake bootstrapper script for Linux and OS X. -# This file was downloaded from https://github.com/cake-build/resources -# Feel free to change this file to fit your needs. -########################################################################## - -# Define directories. -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -TOOLS_DIR=$SCRIPT_DIR/tools -CAKE_VERSION=0.27.1 -CAKE_DLL=$TOOLS_DIR/Cake.CoreCLR.$CAKE_VERSION/Cake.dll - -# Make sure the tools folder exist. -if [ ! -d "$TOOLS_DIR" ]; then - mkdir "$TOOLS_DIR" -fi - -########################################################################### -# INSTALL CAKE -########################################################################### - -if [ ! -f "$CAKE_DLL" ]; then - curl -Lsfo Cake.CoreCLR.zip "https://www.nuget.org/api/v2/package/Cake.CoreCLR/$CAKE_VERSION" && unzip -q Cake.CoreCLR.zip -d "$TOOLS_DIR/Cake.CoreCLR.$CAKE_VERSION" && rm -f Cake.CoreCLR.zip - if [ $? -ne 0 ]; then - echo "An error occured while installing Cake." - exit 1 - fi -fi - -# Make sure that Cake has been installed. -if [ ! -f "$CAKE_DLL" ]; then - echo "Could not find Cake.exe at '$CAKE_DLL'." - exit 1 -fi - -########################################################################### -# RUN BUILD SCRIPT -########################################################################### - -# Start Cake -exec dotnet "$CAKE_DLL" "$@" \ No newline at end of file diff --git a/global.json b/global.json new file mode 100644 index 00000000..9ee6c25f --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "3.1.300" + } +} \ No newline at end of file diff --git a/src/SharpCompress/SharpCompress.csproj b/src/SharpCompress/SharpCompress.csproj index 879a944f..a41f0198 100644 --- a/src/SharpCompress/SharpCompress.csproj +++ b/src/SharpCompress/SharpCompress.csproj @@ -17,7 +17,7 @@ SharpCompress rar;unrar;zip;unzip;bzip2;gzip;tar;7zip;lzip;xz https://github.com/adamhathcock/sharpcompress - https://github.com/adamhathcock/sharpcompress/blob/master/LICENSE.txt + https://github.com/adamhathcock/sharpcompress/blob/master/LICENSE.txt false false SharpCompress is a compression library for NET Standard 1.3/2.0/NET 4.6 that can unrar, decompress 7zip, decompress xz, zip/unzip, tar/untar lzip/unlzip, bzip2/unbzip2 and gzip/ungzip with forward-only reading and file random access APIs. Write support for zip/tar/bzip2/gzip is implemented. diff --git a/src/build/Program.cs b/src/build/Program.cs new file mode 100644 index 00000000..5e7561df --- /dev/null +++ b/src/build/Program.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Runtime.InteropServices; +using GlobExpressions; +using static Bullseye.Targets; +using static SimpleExec.Command; + +class Program +{ + private const string Clean = "clean"; + private const string Build = "build"; + private const string Test = "test"; + private const string Publish = "publish"; + + static void Main(string[] args) + { + Target(Clean, + ForEach("**/bin", "**/obj"), + dir => + { + IEnumerable GetDirectories(string d) + { + return Glob.Directories(".", d); + } + + void RemoveDirectory(string d) + { + if (Directory.Exists(d)) + { + Console.WriteLine(d); + Directory.Delete(d, true); + } + } + + foreach (var d in GetDirectories(dir)) + { + RemoveDirectory(d); + } + }); + + Target(Build, ForEach("net46", "netstandard2.0", "netstandard2.1"), + framework => + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && framework == "net46") + { + return; + } + Run("dotnet", "build src/SharpCompress/SharpCompress.csproj -c Release"); + }); + + Target(Test, DependsOn(Build), ForEach("netcoreapp3.1"), + framework => + { + IEnumerable GetFiles(string d) + { + return Glob.Files(".", d); + } + + foreach (var file in GetFiles("*.Tests/**/*.csproj")) + { + Run("dotnet", $"test {file} -c Release -f {framework} --no-restore --no-build --verbosity=normal"); + } + }); + + Target(Publish, DependsOn(Test), + () => + { + Run("dotnet", "pack src/SharpCompress/SharpCompress.csproj -c Release"); + }); + + Target("default", DependsOn(Publish), () => Console.WriteLine("Done!")); + + RunTargetsAndExit(args); + } +} \ No newline at end of file diff --git a/src/build/build.csproj b/src/build/build.csproj new file mode 100644 index 00000000..897e9515 --- /dev/null +++ b/src/build/build.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + +