From ed32b64e612987bea436e5da93fa63ab476e1e3d Mon Sep 17 00:00:00 2001 From: KaiL3 Date: Wed, 28 Feb 2024 10:20:33 +0100 Subject: [PATCH 1/2] Update Framework to 4.8.1 Update .netcore 3.1 => .net 8 Update all NuGet Packages Depend on Update the TestPackage, migrate the Testcode AreEqual => That() --- .nuke | 1 - README.md | 2 +- build.ps1 | 142 +-- build.sh | 51 +- build/Build.cs | 1012 +++++++++-------- build/_build.csproj | 29 +- chocolatey/logexpert.portable.nuspec.template | 3 + src/AutoColumnizer/AutoColumnizer.csproj | 2 +- src/ColumnizerLib.UnitTests/ColumnTests.cs | 18 +- .../ColumnizerLib.UnitTests.csproj | 6 +- .../Extensions/LogLineExtensionsTests.cs | 2 +- src/ColumnizerLib/ColumnizerLib.csproj | 2 +- src/CsvColumnizer/CsvColumnizer.csproj | 6 +- src/DefaultPlugins/DefaultPlugins.csproj | 2 +- .../FlashIconHighlighter.csproj | 2 +- .../GlassfishColumnizer.csproj | 2 +- src/JsonColumnizer/JsonColumnizer.csproj | 4 +- .../JsonCompactColumnizer.csproj | 4 +- .../Log4jXmlColumnizer.csproj | 2 +- src/LogExpert.Tests/ColumnizerPickerTest.cs | 8 +- src/LogExpert.Tests/DateFormatParserTest.cs | 18 +- .../Extensions/EnumerableTests.cs | 12 +- src/LogExpert.Tests/JSONSaveTest.cs | 8 +- src/LogExpert.Tests/JsonColumnizerTest.cs | 2 +- .../JsonCompactColumnizerTest.cs | 2 +- src/LogExpert.Tests/LogExpert.Tests.csproj | 47 +- src/LogExpert.Tests/LogStreamReaderTest.cs | 13 +- src/LogExpert.Tests/LogWindowTest.cs | 4 +- .../SquareBracketColumnizerTest.cs | 9 +- src/LogExpert/LogExpert.csproj | 8 +- .../Properties/Resources.Designer.cs | 2 +- src/LogExpert/Properties/Settings.Designer.cs | 2 +- src/LogExpert/app.config | 2 +- .../RegexColumnizer.UnitTests.csproj | 147 +-- .../RegexColumnizerTests.cs | 4 +- src/RegexColumnizer/RegexColumnizer.csproj | 2 +- .../SftpFileSystemx64.csproj | 244 ++-- src/SftpFileSystemx64/SftpLogFileInfo.cs | 4 +- .../SftpFileSystemx86.csproj | 18 +- src/WinFormsUI/Docking/Resources.Designer.cs | 2 +- src/WinFormsUI/Docking/Strings.Designer.cs | 2 +- src/WinFormsUI/WinFormsUI.csproj | 2 +- 42 files changed, 914 insertions(+), 940 deletions(-) delete mode 100644 .nuke diff --git a/.nuke b/.nuke deleted file mode 100644 index 7360e257..00000000 --- a/.nuke +++ /dev/null @@ -1 +0,0 @@ -src/LogExpert.sln \ No newline at end of file diff --git a/README.md b/README.md index ca139347..ea9a4aff 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ Or Install via chocolatey ```choco install logexpert``` Requirements -- .NET 4.7.2 +- [.NET 4.8.1](https://dotnet.microsoft.com/en-us/download/dotnet-framework/thank-you/net481-web-installer) ## CI This is a continous integration build. So always the latest and greates changes. It should be stable but no promises. Can be viewed as Beta. diff --git a/build.ps1 b/build.ps1 index cb7fbdb2..381a7bec 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,68 +1,74 @@ -[CmdletBinding()] -Param( - [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$BuildArguments -) - -Write-Output "Windows PowerShell $($Host.Version)" - -Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { exit 1 } -$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent - -########################################################################### -# CONFIGURATION -########################################################################### - -$BuildProjectFile = "$PSScriptRoot\build\_build.csproj" -$TempDirectory = "$PSScriptRoot\\.tmp" - -$DotNetGlobalFile = "$PSScriptRoot\\global.json" -$DotNetInstallUrl = "https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.ps1" -$DotNetChannel = "Current" - -$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 -$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 - -########################################################################### -# EXECUTION -########################################################################### - -function ExecSafe([scriptblock] $cmd) { - & $cmd - if ($LASTEXITCODE) { exit $LASTEXITCODE } -} - -# If global.json exists, load expected version -if (Test-Path $DotNetGlobalFile) { - $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) - if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { - $DotNetVersion = $DotNetGlobal.sdk.version - } -} - -# If dotnet is installed locally, and expected version is not set or installation matches the expected version -if ((Get-Command "dotnet" -ErrorAction SilentlyContinue) -ne $null -and ` - (!(Test-Path variable:DotNetVersion) -or $(& dotnet --version) -eq $DotNetVersion)) { - $env:DOTNET_EXE = (Get-Command "dotnet").Path -} -else { - $DotNetDirectory = "$TempDirectory\dotnet-win" - $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" - - # Download install script - $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" - md -force $TempDirectory > $null - (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) - - # Install by channel or version - if (!(Test-Path variable:DotNetVersion)) { - ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } - } else { - ExecSafe { & $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } - } -} - -Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)" - -ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false } -ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } +[CmdletBinding()] +Param( + [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] + [string[]]$BuildArguments +) + +Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" + +Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 } +$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent + +########################################################################### +# CONFIGURATION +########################################################################### + +$BuildProjectFile = "$PSScriptRoot\build\_build.csproj" +$TempDirectory = "$PSScriptRoot\\.nuke\temp" + +$DotNetGlobalFile = "$PSScriptRoot\\global.json" +$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" +$DotNetChannel = "STS" + +$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 +$env:DOTNET_NOLOGO = 1 + +########################################################################### +# EXECUTION +########################################################################### + +function ExecSafe([scriptblock] $cmd) { + & $cmd + if ($LASTEXITCODE) { exit $LASTEXITCODE } +} + +# If dotnet CLI is installed globally and it matches requested version, use for execution +if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and ` + $(dotnet --version) -and $LASTEXITCODE -eq 0) { + $env:DOTNET_EXE = (Get-Command "dotnet").Path +} +else { + # Download install script + $DotNetInstallFile = "$TempDirectory\dotnet-install.ps1" + New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + (New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile) + + # If global.json exists, load expected version + if (Test-Path $DotNetGlobalFile) { + $DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json) + if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) { + $DotNetVersion = $DotNetGlobal.sdk.version + } + } + + # Install by channel or version + $DotNetDirectory = "$TempDirectory\dotnet-win" + if (!(Test-Path variable:DotNetVersion)) { + ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath } + } else { + ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath } + } + $env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe" + $env:PATH = "$DotNetDirectory;$env:PATH" +} + +Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)" + +if (Test-Path env:NUKE_ENTERPRISE_TOKEN) { + & $env:DOTNET_EXE nuget remove source "nuke-enterprise" > $null + & $env:DOTNET_EXE nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password $env:NUKE_ENTERPRISE_TOKEN > $null +} + +ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet } +ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments } diff --git a/build.sh b/build.sh index 6d6e2ad4..fdff0c62 100644 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -echo $(bash --version 2>&1 | head -n 1) +bash --version 2>&1 | head -n 1 set -eo pipefail SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) @@ -10,53 +10,58 @@ SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) ########################################################################### BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj" -TEMP_DIRECTORY="$SCRIPT_DIR//.tmp" +TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" -DOTNET_INSTALL_URL="https://raw.githubusercontent.com/dotnet/cli/master/scripts/obtain/dotnet-install.sh" -DOTNET_CHANNEL="Current" +DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" +DOTNET_CHANNEL="STS" export DOTNET_CLI_TELEMETRY_OPTOUT=1 -export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_NOLOGO=1 ########################################################################### # EXECUTION ########################################################################### function FirstJsonValue { - perl -nle 'print $1 if m{"'$1'": "([^"\-]+)",?}' <<< ${@:2} + perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" } -# If global.json exists, load expected version -if [ -f "$DOTNET_GLOBAL_FILE" ]; then - DOTNET_VERSION=$(FirstJsonValue "version" $(cat "$DOTNET_GLOBAL_FILE")) - if [ "$DOTNET_VERSION" == "" ]; then - unset DOTNET_VERSION - fi -fi - -# If dotnet is installed locally, and expected version is not set or installation matches the expected version -if [[ -x "$(command -v dotnet)" && (-z ${DOTNET_VERSION+x} || $(dotnet --version) == "$DOTNET_VERSION") ]]; then +# If dotnet CLI is installed globally and it matches requested version, use for execution +if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then export DOTNET_EXE="$(command -v dotnet)" else - DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" - export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" - # Download install script DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh" mkdir -p "$TEMP_DIRECTORY" curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL" chmod +x "$DOTNET_INSTALL_FILE" - + + # If global.json exists, load expected version + if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then + DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")") + if [[ "$DOTNET_VERSION" == "" ]]; then + unset DOTNET_VERSION + fi + fi + # Install by channel or version - if [ -z ${DOTNET_VERSION+x} ]; then + DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix" + if [[ -z ${DOTNET_VERSION+x} ]]; then "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path else "$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path fi + export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet" + export PATH="$DOTNET_DIRECTORY:$PATH" fi -echo "Microsoft (R) .NET Core SDK version $("$DOTNET_EXE" --version)" +echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)" + +if [[ ! -z ${NUKE_ENTERPRISE_TOKEN+x} && "$NUKE_ENTERPRISE_TOKEN" != "" ]]; then + "$DOTNET_EXE" nuget remove source "nuke-enterprise" &>/dev/null || true + "$DOTNET_EXE" nuget add source "https://f.feedz.io/nuke/enterprise/nuget" --name "nuke-enterprise" --username "PAT" --password "$NUKE_ENTERPRISE_TOKEN" --store-password-in-clear-text &>/dev/null || true +fi -"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false +"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet "$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" diff --git a/build/Build.cs b/build/Build.cs index 57b74734..07f55975 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -1,506 +1,508 @@ -using System; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using Nuke.Common; -using Nuke.Common.CI.AppVeyor; -using Nuke.Common.Execution; -using Nuke.Common.Git; -using Nuke.Common.IO; -using Nuke.Common.ProjectModel; -using Nuke.Common.Tooling; -using Nuke.Common.Tools.MSBuild; -using Nuke.Common.Tools.DotNet; -using Nuke.Common.Tools.GitVersion; -using Nuke.Common.Tools.NuGet; -using Nuke.Common.Utilities.Collections; -using Nuke.GitHub; -using static Nuke.Common.EnvironmentInfo; -using static Nuke.Common.IO.FileSystemTasks; -using static Nuke.Common.Tools.MSBuild.MSBuildTasks; -using static Nuke.Common.Tools.DotNet.DotNetTasks; -using static Nuke.Common.IO.TextTasks; -using static Nuke.Common.IO.CompressionTasks; -using static Nuke.GitHub.GitHubTasks; -using static Nuke.Common.ControlFlow; - -[CheckBuildProjectConfigurations] -[UnsetVisualStudioEnvironmentVariables] -class Build : NukeBuild -{ - /// Support plugins are available for: - /// - JetBrains ReSharper https://nuke.build/resharper - /// - JetBrains Rider https://nuke.build/rider - /// - Microsoft VisualStudio https://nuke.build/visualstudio - /// - Microsoft VSCode https://nuke.build/vscode - public static int Main() => Execute(x => x.Test); - - [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] - readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; - - [Solution] readonly Solution Solution; - [GitRepository] readonly GitRepository GitRepository; - [GitVersion(UpdateBuildNumber = true)] - readonly Nuke.Common.Tools.GitVersion.GitVersion GitVersion; - - AbsolutePath SourceDirectory => RootDirectory / "src"; - - AbsolutePath BinDirectory => RootDirectory / "bin"; - - AbsolutePath OutputDirectory => BinDirectory / Configuration; - - AbsolutePath PackageDirectory => BinDirectory / "Package"; - - AbsolutePath ChocolateyDirectory => BinDirectory / "chocolatey"; - - AbsolutePath ChocolateyTemplateFiles => RootDirectory / "chocolatey"; - - AbsolutePath SftpFileSystemPackagex86 => BinDirectory / "SftpFileSystemx86/"; - - AbsolutePath SftpFileSystemPackagex64 => BinDirectory / "SftpFileSystemx64/"; - - AbsolutePath SetupDirectory => BinDirectory / "SetupFiles"; - - AbsolutePath InnoSetupScript => SourceDirectory / "setup" / "LogExpertInstaller.iss"; - - string SetupCommandLineParameter => $"/dAppVersion=\"{VersionString}\" /O\"{BinDirectory}\" /F\"LogExpert-Setup-{VersionString}\""; - - Version Version - { - get - { - int patch = 0; - - if (AppVeyor.Instance != null) - { - patch = AppVeyor.Instance.BuildNumber; - } - - return new Version(1, 9, 0, patch); - } - } - - [Parameter("Version string")] - string VersionString => $"{Version.Major}.{Version.Minor}.{Version.Build}"; - - [Parameter("Version Information string")] - //.Branch.{GitVersion.BranchName}.{GitVersion.Sha} removed for testing purpose - string VersionInformationString => $"{VersionString} {Configuration}"; - - [Parameter("Version file string")] - string VersionFileString => $"{Version.Major}.{Version.Minor}.0"; - - [Parameter("Exclude file globs")] - string[] ExcludeFileGlob => new[] {"**/*.xml", "**/*.XML", "**/*.pdb"}; - - [PathExecutable("choco.exe")] readonly Tool Chocolatey; - - [Parameter("Exlcude directory glob")] - string[] ExcludeDirectoryGlob => new[] {"**/pluginsx86"}; - - [Parameter("My variable", Name = "my_variable")] string MyVariable = null; - - [Parameter("Nuget api key")] string NugetApiKey = null; - - [Parameter("Chocolatey api key")] string ChocolateyApiKey = null; - - [Parameter("GitHub Api key")] string GitHubApiKey = null; - - AbsolutePath[] AppveyorArtifacts => new[] - { - (BinDirectory / $"LogExpert-Setup-{VersionString}.exe"), - BinDirectory / $"LogExpert-CI-{VersionString}.zip", - BinDirectory / $"LogExpert.{VersionString}.zip", - BinDirectory / $"LogExpert.ColumnizerLib.{VersionString}.nupkg", - BinDirectory / $"SftpFileSystem.x64.{VersionString}.zip", - BinDirectory / $"SftpFileSystem.x86.{VersionString}.zip", - ChocolateyDirectory / $"logexpert.{VersionString}.nupkg" - }; - - protected override void OnBuildInitialized() - { - SetVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1"); - - base.OnBuildInitialized(); - } - - Target Clean => _ => _ - .Before(Compile, Restore) - .Executes(() => - { - SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); - - if (DirectoryExists(BinDirectory)) - { - BinDirectory.GlobFiles("*", "*.*", ".*").ForEach(DeleteFile); - BinDirectory.GlobDirectories("*").ForEach(DeleteDirectory); - - DeleteDirectory(BinDirectory); - - EnsureCleanDirectory(BinDirectory); - } - }); - - Target CleanPackage => _ => _ - .Before(Compile, Restore) - .OnlyWhenDynamic(() => DirectoryExists(BinDirectory)) - .Executes(() => - { - BinDirectory.GlobFiles("**/*.zip", "**/*.nupkg").ForEach(DeleteFile); - - if (DirectoryExists(PackageDirectory)) - { - DeleteDirectory(PackageDirectory); - - EnsureCleanDirectory(PackageDirectory); - } - - if (DirectoryExists(ChocolateyDirectory)) - { - DeleteDirectory(ChocolateyDirectory); - - EnsureCleanDirectory(ChocolateyDirectory); - } - }); - - Target Restore => _ => _ - .Executes(() => - { - MSBuild(s => s - .SetTargetPath(Solution) - .SetTargets("Restore")); - }); - - Target Compile => _ => _ - .DependsOn(Restore) - .Executes(() => - { - Logger.Info($"Version: '{VersionString}'"); - - MSBuild(s => s - .SetTargetPath(Solution) - .SetTargets("Rebuild") - .SetAssemblyVersion(VersionString) - .SetInformationalVersion(VersionInformationString) - .SetTargetPlatform(MSBuildTargetPlatform.MSIL) - .SetConfiguration(Configuration) - .SetMaxCpuCount(Environment.ProcessorCount)); - }); - - Target Test => _ => _ - .DependsOn(Compile) - .Executes(() => - { - DotNetTest(c =>c - .SetConfiguration(Configuration) - .EnableNoBuild() - .CombineWith(SourceDirectory.GlobFiles("**/*Tests.csproj"), (settings, path) => - settings.SetProjectFile(path)), degreeOfParallelism: 4, completeOnFailure: true); - }); - - Target PrepareChocolateyTemplates => _ => _ - .DependsOn(CleanPackage) - .Executes(() => - { - CopyDirectoryRecursively(ChocolateyTemplateFiles, ChocolateyDirectory, DirectoryExistsPolicy.Merge); - - ChocolateyDirectory.GlobFiles("**/*.template").ForEach(path => TransformTemplateFile(path, true)); - }); - - Target CopyOutputForChocolatey => _ => _ - .DependsOn(Compile, Test) - .Executes(() => - { - CopyDirectoryRecursively(OutputDirectory, ChocolateyDirectory / "tools", DirectoryExistsPolicy.Merge); - ChocolateyDirectory.GlobFiles(ExcludeFileGlob).ForEach(DeleteFile); - ChocolateyDirectory.GlobDirectories(ExcludeDirectoryGlob).ForEach(DeleteDirectory); - }); - - Target BuildChocolateyPackage => _ => _ - .DependsOn(PrepareChocolateyTemplates, CopyOutputForChocolatey) - .Executes(() => - { - Chocolatey("pack", WorkingDirectory = ChocolateyDirectory); - }); - - Target CreatePackage => _ => _ - .DependsOn(Compile, Test) - .Executes(() => - { - CopyDirectoryRecursively(OutputDirectory, PackageDirectory, DirectoryExistsPolicy.Merge); - PackageDirectory.GlobFiles(ExcludeFileGlob).ForEach(DeleteFile); - - PackageDirectory.GlobDirectories(ExcludeDirectoryGlob).ForEach(DeleteDirectory); - - Compress(PackageDirectory, BinDirectory / $"LogExpert.{VersionString}.zip"); - }); - - Target ChangeVersionNumber => _ => _ - .Before(Compile) - .Executes(() => - { - Logger.Info($"AssemblyVersion {VersionString}\r\nAssemblyFileVersion {VersionFileString}\r\nAssemblyInformationalVersion {VersionInformationString}"); - - AbsolutePath assemblyVersion = SourceDirectory / "Solution Items" / "AssemblyVersion.cs"; - - string text = ReadAllText(assemblyVersion); - Regex configurationRegex = new Regex(@"(\[assembly: AssemblyConfiguration\()(""[^""]*"")(\)\])"); - Regex assemblyVersionRegex = new Regex(@"(\[assembly: AssemblyVersion\("")([^""]*)(""\)\])"); - Regex assemblyFileVersionRegex = new Regex(@"(\[assembly: AssemblyFileVersion\("")([^""]*)(""\)\])"); - Regex assemblyInformationalVersionRegex = new Regex(@"(\[assembly: AssemblyInformationalVersion\("")([^""]*)(""\)\])"); - - text = configurationRegex.Replace(text, (match) => ReplaceVersionMatch(match, $"\"{Configuration}\"")); - text = assemblyVersionRegex.Replace(text, (match) => ReplaceVersionMatch(match, VersionString)); - text = assemblyFileVersionRegex.Replace(text, (match) => ReplaceVersionMatch(match, VersionFileString)); - text = assemblyInformationalVersionRegex.Replace(text, (match) => ReplaceVersionMatch(match, VersionInformationString)); - - Logger.Trace("Content of AssemblyVersion file"); - Logger.Trace(text); - Logger.Trace("End of Content"); - - WriteAllText(assemblyVersion, text); - - SourceDirectory.GlobFiles("**sftp-plugin/*.cs").ForEach(file => - { - if (string.IsNullOrWhiteSpace(MyVariable)) - { - return; - } - - string fileText = ReadAllText(file); - - Regex reg = new Regex(@"\w\w{2}[_]p?[tso]?[erzliasx]+[_rhe]{5}", RegexOptions.IgnoreCase); - - if (reg.IsMatch(fileText)) - { - fileText = reg.Replace(fileText, MyVariable); - WriteAllText(file, fileText); - } - }); - }); - - Target PackageSftpFileSystem => _ => _ - .DependsOn(Compile, Test) - .Executes(() => - { - string[] files = new[] {"SftpFileSystem.dll", "Renci.SshNet.dll" }; - - OutputDirectory.GlobFiles(files.Select(a => $"plugins/{a}").ToArray()).ForEach(file => CopyFileToDirectory(file, SftpFileSystemPackagex64, FileExistsPolicy.Overwrite)); - OutputDirectory.GlobFiles(files.Select(a => $"pluginsx86/{a}").ToArray()).ForEach(file => CopyFileToDirectory(file, SftpFileSystemPackagex86, FileExistsPolicy.Overwrite)); - - Compress(SftpFileSystemPackagex64, BinDirectory / $"SftpFileSystem.x64.{VersionString}.zip"); - Compress(SftpFileSystemPackagex86, BinDirectory / $"SftpFileSystem.x86.{VersionString}.zip"); - }); - - Target ColumnizerLibCreateNuget => _ => _ - .DependsOn(Compile, Test) - .Executes(() => - { - var columnizerFolder = SourceDirectory / "ColumnizerLib"; - - NuGetTasks.NuGetPack(s => - { - s = s.SetTargetPath(columnizerFolder / "ColumnizerLib.csproj") - .DisableBuild() - .SetConfiguration(Configuration) - .SetProperty("version", VersionString) - .SetOutputDirectory(BinDirectory); - - return s; - }); - }); - - Target Pack => _ => _ - .DependsOn(BuildChocolateyPackage, CreatePackage, PackageSftpFileSystem, ColumnizerLibCreateNuget); - - Target CopyFilesForSetup => _ => _ - .DependsOn(Compile) - .After(Test) - .Executes(() => - { - CopyDirectoryRecursively(OutputDirectory, SetupDirectory, DirectoryExistsPolicy.Merge); - SetupDirectory.GlobFiles(ExcludeFileGlob).ForEach(DeleteFile); - - SetupDirectory.GlobDirectories(ExcludeDirectoryGlob).ForEach(DeleteDirectory); - }); - - Target CreateSetup => _ => _ - .DependsOn(CopyFilesForSetup) - .Before(Publish) - .OnlyWhenStatic(() => Configuration == "Release") - .Executes(() => - { - var publishCombinations = - from framework in new[] {(AbsolutePath) SpecialFolder(SpecialFolders.ProgramFilesX86), (AbsolutePath) SpecialFolder(SpecialFolders.LocalApplicationData) / "Programs"} - from version in new[] {"5", "6"} - select framework / $"Inno Setup {version}" / "iscc.exe"; - bool executed = false; - foreach (var setupCombinations in publishCombinations) - { - if (!FileExists(setupCombinations)) - { - //Search for next combination - continue; - } - - ExecuteInnoSetup(setupCombinations); - executed = true; - break; - } - - if (!executed) - { - Fail("Inno setup was not found"); - } - }); - - Target PublishColumnizerNuget => _ => _ - .DependsOn(ColumnizerLibCreateNuget) - .Requires(() => NugetApiKey) - //.OnlyWhenDynamic(() => GitVersion.BranchName.Equals("master") || GitVersion.BranchName.Equals("origin/master")) - .Executes(() => - { - BinDirectory.GlobFiles("**/LogExpert.ColumnizerLib.*.nupkg").ForEach(file => - { - Logger.Normal($"Publish nuget {file}"); - - NuGetTasks.NuGetPush(s => - { - s = s.SetApiKey(NugetApiKey) - .SetSource("https://api.nuget.org/v3/index.json") - .SetApiKey(NugetApiKey) - .SetTargetPath(file); - - return s; - }); - }); - }); - - Target PublishChocolatey => _ => _ - .DependsOn(BuildChocolateyPackage) - .Requires(() => ChocolateyApiKey) - .Executes(() => - { - ChocolateyDirectory.GlobFiles("**/*.nupkg").ForEach(file => - { - Logger.Normal($"Publish chocolatey package {file}"); - - Chocolatey($"push {file} --key {ChocolateyApiKey} --source https://push.chocolatey.org/", WorkingDirectory = ChocolateyDirectory); - }); - }); - - Target PublishGithub => _ => _ - .DependsOn(Pack) - .Requires(() => GitHubApiKey) - .Executes(() => - { - var repositoryInfo = GetGitHubRepositoryInfo(GitRepository); - - Task task = PublishRelease(s => s - .SetArtifactPaths(BinDirectory.GlobFiles("**/*.zip", "**/*.nupkg", "**/LogExpert-Setup*.exe").Select(a => a.ToString()).ToArray()) - .SetCommitSha(GitVersion.Sha) - .SetReleaseNotes($"# Changes\r\n" + - $"# Bugfixes\r\n" + - $"# Contributors\r\n" + - $"Thanks to the contributors!\r\n" + - $"# Infos\r\n" + - $"It might be necessary to unblock the Executables / Dlls to get everything working, especially Plugins (see #55, #13, #8).") - .SetRepositoryName(repositoryInfo.repositoryName) - .SetRepositoryOwner(repositoryInfo.gitHubOwner) - .SetTag($"v{VersionString}") - .SetToken(GitHubApiKey) - .SetName(VersionString) - ); - - task.Wait(); - }); - - Target Publish => _ => _ - .DependsOn(PublishChocolatey, PublishColumnizerNuget, PublishGithub); - - Target PublishToAppveyor => _ => _ - .After(Publish, CreateSetup) - .OnlyWhenDynamic(() => AppVeyor.Instance != null) - .Executes(() => - { - CompressZip(BinDirectory / Configuration, BinDirectory / $"LogExpert-CI-{VersionString}.zip"); - - AppveyorArtifacts.ForEach((artifact) => - { - Process proc = new Process(); - proc.StartInfo = new ProcessStartInfo("appveyor", $"PushArtifact \"{artifact}\""); - if (!proc.Start()) - { - Fail("Failed to start appveyor pushartifact"); - } - - proc.WaitForExit(); - - if (proc.ExitCode != 0) - { - Fail($"Exit code is {proc.ExitCode}"); - } - }); - }); - - Target CleanupAppDataLogExpert => _ => _ - .Executes(() => - { - AbsolutePath logExpertApplicationData = ((AbsolutePath) SpecialFolder(SpecialFolders.ApplicationData)) / "LogExpert"; - - DirectoryInfo info = new DirectoryInfo(logExpertApplicationData); - info.GetDirectories().ForEach(a => a.Delete(true)); - DeleteDirectory(logExpertApplicationData); - }); - - Target CleanupDocumentsLogExpert => _ => _ - .Executes(() => - { - AbsolutePath logExpertDocuments = (AbsolutePath) SpecialFolder(SpecialFolders.UserProfile) / "Documents" / "LogExpert"; - - DirectoryInfo info = new DirectoryInfo(logExpertDocuments); - info.GetDirectories().ForEach(a => a.Delete(true)); - DeleteDirectory(logExpertDocuments); - }); - - private void ExecuteInnoSetup(AbsolutePath innoPath) - { - Process proc = new Process(); - - Logger.Info($"Start '{innoPath}' {SetupCommandLineParameter} \"{InnoSetupScript}\""); - - proc.StartInfo = new ProcessStartInfo(innoPath, $"{SetupCommandLineParameter} \"{InnoSetupScript}\""); - if (!proc.Start()) - { - Fail($"Failed to start {innoPath} with \"{SetupCommandLineParameter}\" \"{InnoSetupScript}\""); - } - - proc.WaitForExit(); - - Logger.Info($"Executed '{innoPath}' with exit code {proc.ExitCode}"); - - if (proc.ExitCode != 0) - { - Fail($"Error during execution of {innoPath}, exitcode {proc.ExitCode}"); - } - } - - private string ReplaceVersionMatch(Match match, string replacement) - { - return $"{match.Groups[1]}{replacement}{match.Groups[3]}"; - } - - private void TransformTemplateFile(AbsolutePath path, bool deleteTemplate) - { - string text = ReadAllText(path); - text = text.Replace("##version##", VersionString); - - WriteAllText($"{Regex.Replace(path, "\\.template$", "")}", text); - if (deleteTemplate) - { - DeleteFile(path); - } - } +using System; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Nuke.Common; +using Nuke.Common.CI.AppVeyor; +using Nuke.Common.Execution; +using Nuke.Common.Git; +using Nuke.Common.IO; +using Nuke.Common.ProjectModel; +using Nuke.Common.Tooling; +using Nuke.Common.Tools.MSBuild; +using Nuke.Common.Tools.DotNet; +using Nuke.Common.Tools.GitVersion; +using Nuke.Common.Tools.NuGet; +using Nuke.Common.Utilities.Collections; +using Nuke.GitHub; +using Serilog; +using static Nuke.Common.EnvironmentInfo; +using static Nuke.Common.IO.FileSystemTasks; +using static Nuke.Common.Tools.MSBuild.MSBuildTasks; +using static Nuke.Common.Tools.DotNet.DotNetTasks; +using static Nuke.Common.IO.CompressionTasks; +using static Nuke.GitHub.GitHubTasks; +using static Nuke.Common.Assert; + +//[CheckBuildProjectConfigurations] +[UnsetVisualStudioEnvironmentVariables] +class Build : NukeBuild +{ + /// Support plugins are available for: + /// - JetBrains ReSharper https://nuke.build/resharper + /// - JetBrains Rider https://nuke.build/rider + /// - Microsoft VisualStudio https://nuke.build/visualstudio + /// - Microsoft VSCode https://nuke.build/vscode + public static int Main() => Execute(x => x.Test); + + [Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] + readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; + + [Solution] readonly Solution Solution; + [GitRepository] readonly GitRepository GitRepository; + [GitVersion(UpdateBuildNumber = true)] + readonly Nuke.Common.Tools.GitVersion.GitVersion GitVersion; + + AbsolutePath SourceDirectory => RootDirectory / "src"; + + AbsolutePath BinDirectory => RootDirectory / "bin"; + + AbsolutePath OutputDirectory => BinDirectory / Configuration; + + AbsolutePath PackageDirectory => BinDirectory / "Package"; + + AbsolutePath ChocolateyDirectory => BinDirectory / "chocolatey"; + + AbsolutePath ChocolateyTemplateFiles => RootDirectory / "chocolatey"; + + AbsolutePath SftpFileSystemPackagex86 => BinDirectory / "SftpFileSystemx86/"; + AbsolutePath SftpFileSystemPackagex64 => BinDirectory / "SftpFileSystemx64/"; + + AbsolutePath SetupDirectory => BinDirectory / "SetupFiles"; + + AbsolutePath InnoSetupScript => SourceDirectory / "setup" / "LogExpertInstaller.iss"; + + string SetupCommandLineParameter => $"/dAppVersion=\"{VersionString}\" /O\"{BinDirectory}\" /F\"LogExpert-Setup-{VersionString}\""; + + Version Version + { + get + { + int patch = 0; + + if (AppVeyor.Instance != null) + { + patch = AppVeyor.Instance.BuildNumber; + } + + return new Version(1, 9, 0, patch); + } + } + + [Parameter("Version string")] + string VersionString => $"{Version.Major}.{Version.Minor}.{Version.Build}"; + + [Parameter("Version Information string")] + //.Branch.{GitVersion.BranchName}.{GitVersion.Sha} removed for testing purpose + string VersionInformationString => $"{VersionString} {Configuration}"; + + [Parameter("Version file string")] + string VersionFileString => $"{Version.Major}.{Version.Minor}.0"; + + [Parameter("Exclude file globs")] + string[] ExcludeFileGlob => new[] {"**/*.xml", "**/*.XML", "**/*.pdb", "**/ChilkatDotNet4.dll", "**/ChilkatDotNet47.dll", "**/SftpFileSystem.dll"}; + + [PathVariable("choco.exe")] readonly Tool Chocolatey; + + [Parameter("Exlcude directory glob")] + string[] ExcludeDirectoryGlob => new[] {"**/pluginsx86"}; + + [Parameter("My variable", Name = "my_variable")] string MyVariable = null; + + [Parameter("Nuget api key")] string NugetApiKey = null; + + [Parameter("Chocolatey api key")] string ChocolateyApiKey = null; + + [Parameter("GitHub Api key")] string GitHubApiKey = null; + + AbsolutePath[] AppveyorArtifacts => new[] + { + (BinDirectory / $"LogExpert-Setup-{VersionString}.exe"), + BinDirectory / $"LogExpert-CI-{VersionString}.zip", + BinDirectory / $"LogExpert.{VersionString}.zip", + BinDirectory / $"LogExpert.ColumnizerLib.{VersionString}.nupkg", + BinDirectory / $"SftpFileSystem.x64.{VersionString}.zip", + BinDirectory / $"SftpFileSystem.x86.{VersionString}.zip", + ChocolateyDirectory / $"logexpert.{VersionString}.nupkg" + }; + + protected override void OnBuildInitialized() + { + SetVariable("DOTNET_CLI_TELEMETRY_OPTOUT", "1"); + + base.OnBuildInitialized(); + } + + Target Clean => _ => _ + .Before(Compile, Restore) + .Executes(() => + { + SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(x => x.DeleteDirectory()); + + var path = AbsolutePath.Create(BinDirectory); + if (path.DirectoryExists()) + { + BinDirectory.GlobFiles("*", "*.*", ".*").ForEach(x => x.DeleteFile()); + BinDirectory.GlobDirectories("*").ForEach(x => x.DeleteDirectory()); + + path.DeleteDirectory(); + + path.CreateOrCleanDirectory(); + } + }); + + Target CleanPackage => _ => _ + .Before(Compile, Restore) + .OnlyWhenDynamic(() => AbsolutePath.Create(BinDirectory).DirectoryExists()) + .Executes(() => + { + BinDirectory.GlobFiles("**/*.zip", "**/*.nupkg").ForEach(x => x.DeleteFile()); + + var path = AbsolutePath.Create(PackageDirectory); + if (path.DirectoryExists()) + { + path.DeleteDirectory(); + + path.CreateOrCleanDirectory(); + } + + path = AbsolutePath.Create(ChocolateyDirectory); + if (path.DirectoryExists()) + { + path.DeleteDirectory(); + + path.CreateOrCleanDirectory(); + } + }); + + Target Restore => _ => _ + .Executes(() => + { + MSBuild(s => s + .SetTargetPath(Solution) + .SetTargets("Restore")); + }); + + Target Compile => _ => _ + .DependsOn(Restore) + .Executes(() => + { + Serilog.Log.Information($"Version: '{VersionString}'"); + + MSBuild(s => s + .SetTargetPath(Solution) + .SetTargets("Rebuild") + .SetAssemblyVersion(VersionString) + .SetInformationalVersion(VersionInformationString) + .SetTargetPlatform(MSBuildTargetPlatform.MSIL) + .SetConfiguration(Configuration) + .SetMaxCpuCount(Environment.ProcessorCount)); + }); + + Target Test => _ => _ + .DependsOn(Compile) + .Executes(() => + { + DotNetTest(c =>c + .SetConfiguration(Configuration) + .EnableNoBuild() + .CombineWith(SourceDirectory.GlobFiles("**/*Tests.csproj"), (settings, path) => + settings.SetProjectFile(path)), degreeOfParallelism: 4, completeOnFailure: true); + }); + + Target PrepareChocolateyTemplates => _ => _ + .DependsOn(CleanPackage) + .Executes(() => + { + CopyDirectoryRecursively(ChocolateyTemplateFiles, ChocolateyDirectory, DirectoryExistsPolicy.Merge); + + ChocolateyDirectory.GlobFiles("**/*.template").ForEach(path => TransformTemplateFile(path, true)); + }); + + Target CopyOutputForChocolatey => _ => _ + .DependsOn(Compile, Test) + .Executes(() => + { + CopyDirectoryRecursively(OutputDirectory, ChocolateyDirectory / "tools", DirectoryExistsPolicy.Merge); + ChocolateyDirectory.GlobFiles(ExcludeFileGlob).ForEach(x => x.DeleteFile()); + ChocolateyDirectory.GlobDirectories(ExcludeDirectoryGlob).ForEach(x => x.DeleteDirectory()); + }); + + Target BuildChocolateyPackage => _ => _ + .DependsOn(PrepareChocolateyTemplates, CopyOutputForChocolatey) + .Executes(() => + { + Chocolatey("pack", WorkingDirectory = ChocolateyDirectory); + }); + + Target CreatePackage => _ => _ + .DependsOn(Compile, Test) + .Executes(() => + { + CopyDirectoryRecursively(OutputDirectory, PackageDirectory, DirectoryExistsPolicy.Merge); + PackageDirectory.GlobFiles(ExcludeFileGlob).ForEach(x => x.DeleteFile()); + + PackageDirectory.GlobDirectories(ExcludeDirectoryGlob).ForEach(x => x.DeleteDirectory()); + + PackageDirectory.CompressTo(BinDirectory / $"LogExpert.{VersionString}.zip"); + }); + + Target ChangeVersionNumber => _ => _ + .Before(Compile) + .Executes(() => + { + Log.Information($"AssemblyVersion {VersionString}\r\nAssemblyFileVersion {VersionFileString}\r\nAssemblyInformationalVersion {VersionInformationString}"); + + AbsolutePath assemblyVersion = SourceDirectory / "Solution Items" / "AssemblyVersion.cs"; + + string text = AbsolutePath.Create(assemblyVersion).ReadAllText(); + Regex configurationRegex = new Regex(@"(\[assembly: AssemblyConfiguration\()(""[^""]*"")(\)\])"); + Regex assemblyVersionRegex = new Regex(@"(\[assembly: AssemblyVersion\("")([^""]*)(""\)\])"); + Regex assemblyFileVersionRegex = new Regex(@"(\[assembly: AssemblyFileVersion\("")([^""]*)(""\)\])"); + Regex assemblyInformationalVersionRegex = new Regex(@"(\[assembly: AssemblyInformationalVersion\("")([^""]*)(""\)\])"); + + text = configurationRegex.Replace(text, (match) => ReplaceVersionMatch(match, $"\"{Configuration}\"")); + text = assemblyVersionRegex.Replace(text, (match) => ReplaceVersionMatch(match, VersionString)); + text = assemblyFileVersionRegex.Replace(text, (match) => ReplaceVersionMatch(match, VersionFileString)); + text = assemblyInformationalVersionRegex.Replace(text, (match) => ReplaceVersionMatch(match, VersionInformationString)); + + Log.Verbose("Content of AssemblyVersion file"); + Log.Verbose(text); + Log.Verbose("End of Content"); + + assemblyVersion.WriteAllText(text); + + SourceDirectory.GlobFiles("**sftp-plugin/*.cs").ForEach(file => + { + if (string.IsNullOrWhiteSpace(MyVariable)) + { + return; + } + + string fileText = file.ReadAllText(); + + Regex reg = new Regex(@"\w\w{2}[_]p?[tso]?[erzliasx]+[_rhe]{5}", RegexOptions.IgnoreCase); + + if (reg.IsMatch(fileText)) + { + fileText = reg.Replace(fileText, MyVariable); + file.WriteAllText(fileText); + } + }); + }); + + Target PackageSftpFileSystem => _ => _ + .DependsOn(Compile, Test) + .Executes(() => + { + string[] files = new[] {"SftpFileSystem.dll", "ChilkatDotNet4.dll", "ChilkatDotNet47.dll" }; + + OutputDirectory.GlobFiles(files.Select(a => $"plugins/{a}").ToArray()).ForEach(file => CopyFileToDirectory(file, SftpFileSystemPackagex64, FileExistsPolicy.Overwrite)); + OutputDirectory.GlobFiles(files.Select(a => $"pluginsx86/{a}").ToArray()).ForEach(file => CopyFileToDirectory(file, SftpFileSystemPackagex86, FileExistsPolicy.Overwrite)); + + SftpFileSystemPackagex64.CompressTo(BinDirectory / $"SftpFileSystem.x64.{VersionString}.zip"); + SftpFileSystemPackagex86.CompressTo(BinDirectory / $"SftpFileSystem.x86.{VersionString}.zip"); + }); + + Target ColumnizerLibCreateNuget => _ => _ + .DependsOn(Compile, Test) + .Executes(() => + { + var columnizerFolder = SourceDirectory / "ColumnizerLib"; + + NuGetTasks.NuGetPack(s => + { + s = s.SetTargetPath(columnizerFolder / "ColumnizerLib.csproj") + .DisableBuild() + .SetConfiguration(Configuration) + .SetProperty("version", VersionString) + .SetOutputDirectory(BinDirectory); + + return s; + }); + }); + + Target Pack => _ => _ + .DependsOn(BuildChocolateyPackage, CreatePackage, PackageSftpFileSystem, ColumnizerLibCreateNuget); + + Target CopyFilesForSetup => _ => _ + .DependsOn(Compile) + .After(Test) + .Executes(() => + { + CopyDirectoryRecursively(OutputDirectory, SetupDirectory, DirectoryExistsPolicy.Merge); + SetupDirectory.GlobFiles(ExcludeFileGlob).ForEach(x => x.DeleteFile()); + + SetupDirectory.GlobDirectories(ExcludeDirectoryGlob).ForEach(x => x.DeleteDirectory()); + }); + + Target CreateSetup => _ => _ + .DependsOn(CopyFilesForSetup) + .Before(Publish) + .OnlyWhenStatic(() => Configuration == "Release") + .Executes(() => + { + var publishCombinations = + from framework in new[] {(AbsolutePath) SpecialFolder(SpecialFolders.ProgramFilesX86), (AbsolutePath) SpecialFolder(SpecialFolders.LocalApplicationData) / "Programs"} + from version in new[] {"5", "6"} + select framework / $"Inno Setup {version}" / "iscc.exe"; + bool executed = false; + foreach (var setupCombinations in publishCombinations) + { + if (!setupCombinations.FileExists()) + { + //Search for next combination + continue; + } + + ExecuteInnoSetup(setupCombinations); + executed = true; + break; + } + + if (!executed) + { + Fail("Inno setup was not found"); + } + }); + + Target PublishColumnizerNuget => _ => _ + .DependsOn(ColumnizerLibCreateNuget) + .Requires(() => NugetApiKey) + //.OnlyWhenDynamic(() => GitVersion.BranchName.Equals("master") || GitVersion.BranchName.Equals("origin/master")) + .Executes(() => + { + BinDirectory.GlobFiles("**/LogExpert.ColumnizerLib.*.nupkg").ForEach(file => + { + Log.Debug($"Publish nuget {file}"); + + NuGetTasks.NuGetPush(s => + { + s = s.SetApiKey(NugetApiKey) + .SetSource("https://api.nuget.org/v3/index.json") + .SetApiKey(NugetApiKey) + .SetTargetPath(file); + + return s; + }); + }); + }); + + Target PublishChocolatey => _ => _ + .DependsOn(BuildChocolateyPackage) + .Requires(() => ChocolateyApiKey) + .Executes(() => + { + ChocolateyDirectory.GlobFiles("**/*.nupkg").ForEach(file => + { + Log.Debug($"Publish chocolatey package {file}"); + + Chocolatey($"push {file} --key {ChocolateyApiKey} --source https://push.chocolatey.org/", WorkingDirectory = ChocolateyDirectory); + }); + }); + + Target PublishGithub => _ => _ + .DependsOn(Pack) + .Requires(() => GitHubApiKey) + .Executes(() => + { + var repositoryInfo = GetGitHubRepositoryInfo(GitRepository); + + Task task = PublishRelease(s => s + .SetArtifactPaths(BinDirectory.GlobFiles("**/*.zip", "**/*.nupkg", "**/LogExpert-Setup*.exe").Select(a => a.ToString()).ToArray()) + .SetCommitSha(GitVersion.Sha) + .SetReleaseNotes($"# Changes\r\n" + + $"# Bugfixes\r\n" + + $"# Contributors\r\n" + + $"Thanks to the contributors!\r\n" + + $"# Infos\r\n" + + $"It might be necessary to unblock the Executables / Dlls to get everything working, especially Plugins (see #55, #13, #8).") + .SetRepositoryName(repositoryInfo.repositoryName) + .SetRepositoryOwner(repositoryInfo.gitHubOwner) + .SetTag($"v{VersionString}") + .SetToken(GitHubApiKey) + .SetName(VersionString) + ); + + task.Wait(); + }); + + Target Publish => _ => _ + .DependsOn(PublishChocolatey, PublishColumnizerNuget, PublishGithub); + + Target PublishToAppveyor => _ => _ + .After(Publish, CreateSetup) + .OnlyWhenDynamic(() => AppVeyor.Instance != null) + .Executes(() => + { + AbsolutePath.Create(BinDirectory / Configuration).CompressTo(BinDirectory / $"LogExpert-CI-{VersionString}.zip"); + + AppveyorArtifacts.ForEach((artifact) => + { + Process proc = new Process(); + proc.StartInfo = new ProcessStartInfo("appveyor", $"PushArtifact \"{artifact}\""); + if (!proc.Start()) + { + Fail("Failed to start appveyor pushartifact"); + } + + proc.WaitForExit(); + + if (proc.ExitCode != 0) + { + Fail($"Exit code is {proc.ExitCode}"); + } + }); + }); + + Target CleanupAppDataLogExpert => _ => _ + .Executes(() => + { + AbsolutePath logExpertApplicationData = ((AbsolutePath) SpecialFolder(SpecialFolders.ApplicationData)) / "LogExpert"; + + DirectoryInfo info = new DirectoryInfo(logExpertApplicationData); + info.GetDirectories().ForEach(a => a.Delete(true)); + logExpertApplicationData.DeleteDirectory(); + }); + + Target CleanupDocumentsLogExpert => _ => _ + .Executes(() => + { + AbsolutePath logExpertDocuments = (AbsolutePath) SpecialFolder(SpecialFolders.UserProfile) / "Documents" / "LogExpert"; + + DirectoryInfo info = new DirectoryInfo(logExpertDocuments); + info.GetDirectories().ForEach(a => a.Delete(true)); + logExpertDocuments.DeleteDirectory(); + }); + + private void ExecuteInnoSetup(AbsolutePath innoPath) + { + Process proc = new Process(); + + Log.Information($"Start '{innoPath}' {SetupCommandLineParameter} \"{InnoSetupScript}\""); + + proc.StartInfo = new ProcessStartInfo(innoPath, $"{SetupCommandLineParameter} \"{InnoSetupScript}\""); + if (!proc.Start()) + { + Fail($"Failed to start {innoPath} with \"{SetupCommandLineParameter}\" \"{InnoSetupScript}\""); + } + + proc.WaitForExit(); + + Log.Information($"Executed '{innoPath}' with exit code {proc.ExitCode}"); + + if (proc.ExitCode != 0) + { + Fail($"Error during execution of {innoPath}, exitcode {proc.ExitCode}"); + } + } + + private string ReplaceVersionMatch(Match match, string replacement) + { + return $"{match.Groups[1]}{replacement}{match.Groups[3]}"; + } + + private void TransformTemplateFile(AbsolutePath path, bool deleteTemplate) + { + string text = path.ReadAllText(); + text = text.Replace("##version##", VersionString); + + AbsolutePath.Create($"{Regex.Replace(path, "\\.template$", "")}").WriteAllText(text); + if (deleteTemplate) + { + path.DeleteFile(); + } + } } \ No newline at end of file diff --git a/build/_build.csproj b/build/_build.csproj index a4bdedc5..5bc0bdfb 100644 --- a/build/_build.csproj +++ b/build/_build.csproj @@ -2,50 +2,39 @@ Exe - netcoreapp3.1 + net8.0 false False CS0649;CS0169 + 1 - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers - - - + + + - - - - - - - - - - - - diff --git a/chocolatey/logexpert.portable.nuspec.template b/chocolatey/logexpert.portable.nuspec.template index 37d36655..b6f32b7f 100644 --- a/chocolatey/logexpert.portable.nuspec.template +++ b/chocolatey/logexpert.portable.nuspec.template @@ -12,6 +12,9 @@ https://github.com/zarunbal/LogExpert/issues https://github.com/zarunbal/LogExpert/releases/tag/v##version## false + + + LogExpert is a Windows tail program (a GUI replacement for the Unix tail command). Summary of (most) features: diff --git a/src/AutoColumnizer/AutoColumnizer.csproj b/src/AutoColumnizer/AutoColumnizer.csproj index 087ba1f2..fd9c2400 100644 --- a/src/AutoColumnizer/AutoColumnizer.csproj +++ b/src/AutoColumnizer/AutoColumnizer.csproj @@ -9,7 +9,7 @@ Properties AutoColumnizer AutoColumnizer - v4.7.2 + v4.8.1 512 true diff --git a/src/ColumnizerLib.UnitTests/ColumnTests.cs b/src/ColumnizerLib.UnitTests/ColumnTests.cs index 73c22b4f..449074fb 100644 --- a/src/ColumnizerLib.UnitTests/ColumnTests.cs +++ b/src/ColumnizerLib.UnitTests/ColumnTests.cs @@ -27,8 +27,8 @@ public void Column_LineCutOf() column.FullValue = builder.ToString(); - Assert.AreEqual(expected, column.DisplayValue); - Assert.AreEqual(builder.ToString(), column.FullValue); + Assert.That(column.DisplayValue, Is.EqualTo(expected)); + Assert.That(column.FullValue, Is.EqualTo(builder.ToString())); } [Test] @@ -47,8 +47,8 @@ public void Column_NoLineCutOf() column.FullValue = expected; - Assert.AreEqual(expected, column.DisplayValue); - Assert.AreEqual(expected, column.FullValue); + Assert.That(column.DisplayValue, Is.EqualTo(expected)); + Assert.That(column.FullValue, Is.EqualTo(expected)); } [Test] @@ -63,14 +63,14 @@ public void Column_NullCharReplacement() //only one implementation depending on the windows version is executed if (Environment.Version >= Version.Parse("6.2")) { - Assert.AreEqual("asdf␀", column.DisplayValue); + Assert.That(column.DisplayValue, Is.EqualTo("asdf␀")); } else { - Assert.AreEqual("asdf ", column.DisplayValue); + Assert.That(column.DisplayValue, Is.EqualTo("asdf ")); } - Assert.AreEqual("asdf\0", column.FullValue); + Assert.That(column.FullValue, Is.EqualTo("asdf\0")); } [Test] @@ -80,8 +80,8 @@ public void Column_TabReplacement() column.FullValue = "asdf\t"; - Assert.AreEqual("asdf ", column.DisplayValue); - Assert.AreEqual("asdf\t", column.FullValue); + Assert.That(column.DisplayValue, Is.EqualTo("asdf ")); + Assert.That(column.FullValue, Is.EqualTo("asdf\t")); } } } \ No newline at end of file diff --git a/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj b/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj index de02cd89..e43b0638 100644 --- a/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj +++ b/src/ColumnizerLib.UnitTests/ColumnizerLib.UnitTests.csproj @@ -9,7 +9,7 @@ Properties ColumnizerLib.UnitTests ColumnizerLib.UnitTests - v4.7.2 + v4.8.1 512 @@ -60,10 +60,10 @@ - 3.13.3 + 4.1.0 - 4.4.2 + 4.5.0 diff --git a/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs b/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs index 013b9f61..a412642c 100644 --- a/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs +++ b/src/ColumnizerLib.UnitTests/Extensions/LogLineExtensionsTests.cs @@ -25,7 +25,7 @@ public void ToClipBoardText_ReturnsExpected() LineNumber = 89, Text = "a text" }; - Assert.AreEqual("\t90\ta fullLine", underTest.ToClipBoardText()); + Assert.That(underTest.ToClipBoardText(), Is.EqualTo("\t90\ta fullLine")); } } } diff --git a/src/ColumnizerLib/ColumnizerLib.csproj b/src/ColumnizerLib/ColumnizerLib.csproj index cc7cccd0..1cd71c22 100644 --- a/src/ColumnizerLib/ColumnizerLib.csproj +++ b/src/ColumnizerLib/ColumnizerLib.csproj @@ -10,7 +10,7 @@ Properties LogExpert ColumnizerLib - v4.7.2 + v4.8.1 512 diff --git a/src/CsvColumnizer/CsvColumnizer.csproj b/src/CsvColumnizer/CsvColumnizer.csproj index f9566321..5db8c8ec 100644 --- a/src/CsvColumnizer/CsvColumnizer.csproj +++ b/src/CsvColumnizer/CsvColumnizer.csproj @@ -10,7 +10,7 @@ Properties CsvColumnizer CsvColumnizer - v4.7.2 + v4.8.1 512 @@ -87,10 +87,10 @@ - 30.0.1 + 31.0.0 - 13.0.2 + 13.0.3 diff --git a/src/DefaultPlugins/DefaultPlugins.csproj b/src/DefaultPlugins/DefaultPlugins.csproj index f5d2684f..b21a656f 100644 --- a/src/DefaultPlugins/DefaultPlugins.csproj +++ b/src/DefaultPlugins/DefaultPlugins.csproj @@ -10,7 +10,7 @@ Properties LogExpert DefaultPlugins - v4.7.2 + v4.8.1 512 diff --git a/src/FlashIconHighlighter/FlashIconHighlighter.csproj b/src/FlashIconHighlighter/FlashIconHighlighter.csproj index 483e9bb6..d6290f76 100644 --- a/src/FlashIconHighlighter/FlashIconHighlighter.csproj +++ b/src/FlashIconHighlighter/FlashIconHighlighter.csproj @@ -10,7 +10,7 @@ Properties FlashIconHighlighter FlashIconHighlighter - v4.7.2 + v4.8.1 512 diff --git a/src/GlassfishColumnizer/GlassfishColumnizer.csproj b/src/GlassfishColumnizer/GlassfishColumnizer.csproj index 7c382fd6..217715bf 100644 --- a/src/GlassfishColumnizer/GlassfishColumnizer.csproj +++ b/src/GlassfishColumnizer/GlassfishColumnizer.csproj @@ -10,7 +10,7 @@ Properties GlassfishColumnizer GlassfishColumnizer - v4.7.2 + v4.8.1 512 diff --git a/src/JsonColumnizer/JsonColumnizer.csproj b/src/JsonColumnizer/JsonColumnizer.csproj index fb183e18..d79181f0 100644 --- a/src/JsonColumnizer/JsonColumnizer.csproj +++ b/src/JsonColumnizer/JsonColumnizer.csproj @@ -10,7 +10,7 @@ Properties JsonColumnizer JsonColumnizer - v4.7.2 + v4.8.1 512 @@ -72,7 +72,7 @@ - 13.0.2 + 13.0.3 diff --git a/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj b/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj index 9516c80c..666beef6 100644 --- a/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj +++ b/src/JsonCompactColumnizer/JsonCompactColumnizer.csproj @@ -10,7 +10,7 @@ Properties JsonColumnizer JsonCompactColumnizer - v4.7.2 + v4.8.1 512 @@ -76,7 +76,7 @@ - 13.0.2 + 13.0.3 diff --git a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj index 09c53807..879afe51 100644 --- a/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj +++ b/src/Log4jXmlColumnizer/Log4jXmlColumnizer.csproj @@ -10,7 +10,7 @@ Properties Log4jXmlColumnizer Log4jXmlColumnizer - v4.7.2 + v4.8.1 512 diff --git a/src/LogExpert.Tests/ColumnizerPickerTest.cs b/src/LogExpert.Tests/ColumnizerPickerTest.cs index 3fda0eea..824d1db2 100644 --- a/src/LogExpert.Tests/ColumnizerPickerTest.cs +++ b/src/LogExpert.Tests/ColumnizerPickerTest.cs @@ -57,7 +57,7 @@ public void FindColumnizer_ReturnCorrectColumnizer(string expectedColumnizerName var result = ColumnizerPicker.FindColumnizer(path, autoLogLineColumnizerCallbackMock.Object); - Assert.AreEqual(expectedColumnizerName, result.GetName()); + Assert.That(result.GetName(), Is.EqualTo(expectedColumnizerName)); } @@ -77,7 +77,7 @@ public void FindReplacementForAutoColumnizer_ValidTextFile_ReturnCorrectColumniz PluginRegistry.GetInstance().RegisteredColumnizers.Add(new JsonCompactColumnizer()); var result = ColumnizerPicker.FindReplacementForAutoColumnizer(fileName, reader, autoColumnizer.Object); - Assert.AreEqual(result.GetType(), columnizerType); + Assert.That(columnizerType, Is.EqualTo(result.GetType())); } [TestCase(@".\TestData\FileNotExists.txt", typeof(DefaultLogfileColumnizer))] @@ -91,7 +91,7 @@ public void DecideColumnizerByName_WhenReaderIsNotReady_ReturnCorrectColumnizer( var result = ColumnizerPicker.DecideColumnizerByName(fileName, PluginRegistry.GetInstance().RegisteredColumnizers); - Assert.AreEqual(result.GetType(), columnizerType); + Assert.That(columnizerType, Is.EqualTo(result.GetType())); } [TestCase(@"Invalid Name", typeof(DefaultLogfileColumnizer))] @@ -107,7 +107,7 @@ public void DecideColumnizerByName_ValidTextFile_ReturnCorrectColumnizer( var result = ColumnizerPicker.DecideColumnizerByName(columnizerName, PluginRegistry.GetInstance().RegisteredColumnizers); - Assert.AreEqual(result.GetType(), columnizerType); + Assert.That(columnizerType, Is.EqualTo(result.GetType())); } private class TestLogLine : ILogLine diff --git a/src/LogExpert.Tests/DateFormatParserTest.cs b/src/LogExpert.Tests/DateFormatParserTest.cs index f53f3bd9..d21c0d88 100644 --- a/src/LogExpert.Tests/DateFormatParserTest.cs +++ b/src/LogExpert.Tests/DateFormatParserTest.cs @@ -26,15 +26,15 @@ public void CanParseAllCultures() var message = $"Culture: {culture.Name} ({culture.EnglishName} {datePattern})"; var sections = Parser.ParseSections(datePattern, out bool syntaxError); - Assert.IsFalse(syntaxError, message); + Assert.That(syntaxError, Is.False, message); var dateSection = sections.FirstOrDefault(); - Assert.IsNotNull(dateSection, message); + Assert.That(dateSection, Is.Not.Null, message); var now = DateTime.Now; var expectedFormattedDate = now.ToString(datePattern); - var actualFormattedDate = now.ToString(string.Join("", dateSection.GeneralTextDateDurationParts)); - Assert.AreEqual(expectedFormattedDate, actualFormattedDate, message); + var actualFormattedDate = now.ToString(string.Join("", dateSection.GeneralTextDateDurationParts)); + Assert.That(actualFormattedDate, Is.EqualTo(expectedFormattedDate), message); } } @@ -55,24 +55,24 @@ public void TestDateFormatParserFromCulture(string cultureInfoName, params strin var message = $"Culture: {culture.EnglishName}, Actual date pattern: {datePattern}"; - Assert.IsFalse(syntaxError, message); + Assert.That(syntaxError, Is.False, message); var dateSection = sections.FirstOrDefault(); - Assert.IsNotNull(dateSection); + Assert.That(dateSection, Is.Not.Null); var dateParts = dateSection .GeneralTextDateDurationParts .Where(Token.IsDatePart) .Select(p => DateFormatPartAdjuster.AdjustDateTimeFormatPart(p)) .ToArray(); - - Assert.AreEqual(expectedDateParts.Length, dateParts.Length, message); + + Assert.That(dateParts.Length, Is.EqualTo(expectedDateParts.Length), message); for (var i = 0; i < expectedDateParts.Length; i++) { var expected = expectedDateParts[i]; var actual = dateParts[i]; - Assert.AreEqual(expected, actual, message); + Assert.That(actual, Is.EqualTo(expected), message); } } diff --git a/src/LogExpert.Tests/Extensions/EnumerableTests.cs b/src/LogExpert.Tests/Extensions/EnumerableTests.cs index 0ee02cd0..956695bf 100644 --- a/src/LogExpert.Tests/Extensions/EnumerableTests.cs +++ b/src/LogExpert.Tests/Extensions/EnumerableTests.cs @@ -13,7 +13,7 @@ public void Extensions_IsEmpty_NullArray() { object[] arrayObject = null; - Assert.IsTrue(arrayObject.IsEmpty()); + Assert.That(arrayObject.IsEmpty(), Is.True); } [Test] @@ -21,7 +21,7 @@ public void Extensions_IsEmpty_EmptyArray() { object[] arrayObject = Array.Empty(); - Assert.IsTrue(arrayObject.IsEmpty()); + Assert.That(arrayObject.IsEmpty(), Is.True); } [Test] @@ -29,7 +29,7 @@ public void Extensions_IsEmpty_FilledArray() { object[] arrayObject = {new object()}; - Assert.IsFalse(arrayObject.IsEmpty()); + Assert.That(arrayObject.IsEmpty(),Is.False); } [Test] @@ -37,7 +37,7 @@ public void Extensions_IsEmpty_NullIEnumerable() { IEnumerable arrayObject = null; - Assert.IsTrue(arrayObject.IsEmpty()); + Assert.That(arrayObject.IsEmpty(), Is.True); } [Test] @@ -45,7 +45,7 @@ public void Extensions_IsEmpty_EmptyIEnumerable() { IEnumerable arrayObject = new List(); - Assert.IsTrue(arrayObject.IsEmpty()); + Assert.That(arrayObject.IsEmpty(), Is.True); } [Test] @@ -53,7 +53,7 @@ public void Extensions_IsEmpty_FilledIEnumerable() { IEnumerable arrayObject = new List(new []{new object()}); - Assert.IsFalse(arrayObject.IsEmpty()); + Assert.That(arrayObject.IsEmpty(), Is.False); } } } \ No newline at end of file diff --git a/src/LogExpert.Tests/JSONSaveTest.cs b/src/LogExpert.Tests/JSONSaveTest.cs index a3b1ebfc..0df521d0 100644 --- a/src/LogExpert.Tests/JSONSaveTest.cs +++ b/src/LogExpert.Tests/JSONSaveTest.cs @@ -19,16 +19,16 @@ public void SaveOptionsAsJSON() Settings settings = null; Assert.DoesNotThrow(CastSettings); - Assert.NotNull(settings); - Assert.True(settings.alwaysOnTop); + Assert.That(settings, Is.Not.Null); + Assert.That(settings.alwaysOnTop, Is.True); ConfigManager.Settings.alwaysOnTop = false; ConfigManager.Save(SettingsFlags.All); settings = null; Assert.DoesNotThrow(CastSettings); - Assert.NotNull(settings); - Assert.False(settings.alwaysOnTop); + Assert.That(settings, Is.Not.Null); + Assert.That(settings.alwaysOnTop, Is.False); void CastSettings() diff --git a/src/LogExpert.Tests/JsonColumnizerTest.cs b/src/LogExpert.Tests/JsonColumnizerTest.cs index bfd75f66..10ae1923 100644 --- a/src/LogExpert.Tests/JsonColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonColumnizerTest.cs @@ -31,7 +31,7 @@ public void GetColumnNames_HappyFile_ColumnNameMatches(string fileName, string e var columnHeaders = jsonColumnizer.GetColumnNames(); var result = string.Join(" ", columnHeaders); - Assert.AreEqual(result, expectedHeaders); + Assert.That(result, Is.EqualTo( expectedHeaders)); } } } diff --git a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs index bfcbc137..942b7a3a 100644 --- a/src/LogExpert.Tests/JsonCompactColumnizerTest.cs +++ b/src/LogExpert.Tests/JsonCompactColumnizerTest.cs @@ -36,7 +36,7 @@ public void GetPriority_HappyFile_PriorityMatches(string fileName, Priority prio }; var result = jsonCompactColumnizer.GetPriority(path, loglines); - Assert.AreEqual(result, priority); + Assert.That(result, Is.EqualTo(priority)); } } } diff --git a/src/LogExpert.Tests/LogExpert.Tests.csproj b/src/LogExpert.Tests/LogExpert.Tests.csproj index bd5dcfb3..d170e589 100644 --- a/src/LogExpert.Tests/LogExpert.Tests.csproj +++ b/src/LogExpert.Tests/LogExpert.Tests.csproj @@ -9,7 +9,7 @@ Properties LogExpert.Tests LogExpert.Tests - v4.7.2 + v4.8.1 512 {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 15.0 @@ -51,47 +51,31 @@ - - - - - - - - 4.18.1 + 4.20.70 - 3.13.3 + 4.1.0 - 4.4.2 + 4.5.0 - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - PreserveNewest + Always PreserveNewest @@ -140,13 +124,13 @@ - PreserveNewest + Always - PreserveNewest + Always - PreserveNewest + Always @@ -154,21 +138,6 @@ PreserveNewest - - - Key.snk - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - \ No newline at end of file diff --git a/src/LogExpert.Tests/LogStreamReaderTest.cs b/src/LogExpert.Tests/LogStreamReaderTest.cs index 61f6e6a4..225a22fa 100644 --- a/src/LogExpert.Tests/LogStreamReaderTest.cs +++ b/src/LogExpert.Tests/LogStreamReaderTest.cs @@ -28,11 +28,10 @@ public void ReadLinesWithSystemNewLine(string text, int expectedLines) if (line == null) break; lineCount += 1; - - StringAssert.StartsWith($"Line {lineCount}", line, $"Invalid line: {line}"); + Assert.That(line, Does.StartWith($"Line {lineCount}"), $"Invalid line: {line}"); } - Assert.AreEqual(expectedLines, lineCount, $"Unexpected lines:\n{text}"); + Assert.That(lineCount, Is.EqualTo(expectedLines), $"Unexpected lines:\n{text}"); } } [Test] @@ -50,7 +49,7 @@ public void CountLinesWithSystemNewLine(string text, int expectedLines) lineCount += 1; } - Assert.AreEqual(expectedLines, lineCount, $"Unexpected lines:\n{text}"); + Assert.That(lineCount, Is.EqualTo(expectedLines), $"Unexpected lines:\n{text}"); } } @@ -74,10 +73,10 @@ public void ReadLinesWithLegacyNewLine(string text, int expectedLines) lineCount += 1; - StringAssert.StartsWith($"Line {lineCount}", line, $"Invalid line: {line}"); + Assert.That(line, Does.StartWith($"Line {lineCount}"), $"Invalid line: {line}"); } - Assert.AreEqual(expectedLines, lineCount, $"Unexpected lines:\n{text}"); + Assert.That(lineCount, Is.EqualTo(expectedLines), $"Unexpected lines:\n{text}"); } } [Test] @@ -95,7 +94,7 @@ public void CountLinesWithLegacyNewLine(string text, int expectedLines) lineCount += 1; } - Assert.AreEqual(expectedLines, lineCount, $"Unexpected lines:\n{text}"); + Assert.That(lineCount, Is.EqualTo(expectedLines), $"Unexpected lines:\n{text}"); } } } diff --git a/src/LogExpert.Tests/LogWindowTest.cs b/src/LogExpert.Tests/LogWindowTest.cs index 830260a2..7a7a15f0 100644 --- a/src/LogExpert.Tests/LogWindowTest.cs +++ b/src/LogExpert.Tests/LogWindowTest.cs @@ -20,7 +20,7 @@ public void Instantiate_JsonFile_BuildCorrectColumnizer(string fileName, Type co LogWindow logWindow = new LogWindow(logTabWindow, fileName, false, false); - Assert.AreEqual(columnizerType, logWindow.CurrentColumnizer.GetType()); + Assert.That(logWindow.CurrentColumnizer.GetType(),Is.EqualTo(columnizerType)); } [TestCase(@".\TestData\XmlTest_01.xml")] @@ -33,7 +33,7 @@ public void Instantiate_AnyFile_NotCrash(string fileName) LogTabWindow logTabWindow = new LogTabWindow(null, 0, false); LogWindow logWindow = new LogWindow(logTabWindow, fileName, false, false); - Assert.True(true); + Assert.That(true,Is.True); } } } diff --git a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs index 55604ba3..18ca876c 100644 --- a/src/LogExpert.Tests/SquareBracketColumnizerTest.cs +++ b/src/LogExpert.Tests/SquareBracketColumnizerTest.cs @@ -1,12 +1,13 @@ -using System; + +using NUnit.Framework; +using System; using System.Collections.Generic; using System.IO; using LogExpert.Classes.Columnizer; using LogExpert.Classes.Log; using LogExpert.Entities; -using NUnit.Framework; -namespace LogExpert.Tests +namespace LogExpert { [TestFixture] public class SquareBracketColumnizerTest @@ -38,7 +39,7 @@ public void GetPriority_HappyFile_ColumnCountMatches(string fileName, int count) }; squareBracketColumnizer.GetPriority(path, loglines); - Assert.AreEqual(squareBracketColumnizer.GetColumnCount(), count); + Assert.That(count, Is.EqualTo(squareBracketColumnizer.GetColumnCount())); } } diff --git a/src/LogExpert/LogExpert.csproj b/src/LogExpert/LogExpert.csproj index 24da56be..4f6baec4 100644 --- a/src/LogExpert/LogExpert.csproj +++ b/src/LogExpert/LogExpert.csproj @@ -8,7 +8,7 @@ Properties LogExpert LogExpert - v4.7.2 + v4.8.1 Resources\logexpert.ico @@ -584,10 +584,10 @@ - 13.0.2 + 13.0.3 - - 4.7.15 + + 5.2.8 diff --git a/src/LogExpert/Properties/Resources.Designer.cs b/src/LogExpert/Properties/Resources.Designer.cs index cfed0821..67fa91b0 100644 --- a/src/LogExpert/Properties/Resources.Designer.cs +++ b/src/LogExpert/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace LogExpert.Properties { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/LogExpert/Properties/Settings.Designer.cs b/src/LogExpert/Properties/Settings.Designer.cs index 12bf46ac..6f26ca6e 100644 --- a/src/LogExpert/Properties/Settings.Designer.cs +++ b/src/LogExpert/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace LogExpert.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/src/LogExpert/app.config b/src/LogExpert/app.config index 0f1ce6d4..8b3fc7ce 100644 --- a/src/LogExpert/app.config +++ b/src/LogExpert/app.config @@ -23,6 +23,6 @@ --> - + diff --git a/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj b/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj index b3c18f4d..15be083b 100644 --- a/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj +++ b/src/RegexColumnizer.UnitTests/RegexColumnizer.UnitTests.csproj @@ -1,74 +1,75 @@ - - - - - - Debug - AnyCPU - {FBFB598D-B94A-4AD3-A355-0D5A618CEEE3} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - Library - Properties - RegexColumnizer.UnitTests - RegexColumnizer.UnitTests - v4.7.2 - 512 - - - true - - - ..\Solution Items\Key.snk - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - {e72c2bb1-34de-4d66-a830-9647c3837833} - ColumnizerLib - - - {b5a7dfa4-48a8-4616-8008-7441699ec946} - RegexColumnizer - - - - - 4.18.4 - - - 3.13.3 - - - 4.4.2 - - - + + + + + + Debug + AnyCPU + {FBFB598D-B94A-4AD3-A355-0D5A618CEEE3} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Library + Properties + RegexColumnizer.UnitTests + RegexColumnizer.UnitTests + v4.8.1 + 512 + + + + true + + + ..\Solution Items\Key.snk + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + {e72c2bb1-34de-4d66-a830-9647c3837833} + ColumnizerLib + + + {b5a7dfa4-48a8-4616-8008-7441699ec946} + RegexColumnizer + + + + + 4.20.70 + + + 4.1.0 + + + 4.5.0 + + + \ No newline at end of file diff --git a/src/RegexColumnizer.UnitTests/RegexColumnizerTests.cs b/src/RegexColumnizer.UnitTests/RegexColumnizerTests.cs index f2a6984f..6ab29448 100644 --- a/src/RegexColumnizer.UnitTests/RegexColumnizerTests.cs +++ b/src/RegexColumnizer.UnitTests/RegexColumnizerTests.cs @@ -18,7 +18,7 @@ public void SplitLine_ColumnCountMatches(string lineToParse, string regex, int e TestLogLine testLogLine = new TestLogLine(4, lineToParse); IColumnizedLogLine parsedLogLine = columnizer.SplitLine(Mock.Of(), testLogLine); - Assert.AreEqual(expectedNumberOfColumns, parsedLogLine.ColumnValues.Length); + Assert.That(parsedLogLine.ColumnValues.Length, Is.EqualTo(expectedNumberOfColumns)); } //Using "" for empty string since string.Empty can't be passed to the TestCase attribute. @@ -34,7 +34,7 @@ public void SplitLine_ColumnValues(string lineToParse, string regex, int columnI TestLogLine testLogLine = new TestLogLine(3, lineToParse); IColumnizedLogLine parsedLogLine = columnizer.SplitLine(Mock.Of(), testLogLine); - Assert.AreEqual(expectedColumnValue, parsedLogLine.ColumnValues[columnIndexToTest].Text); + Assert.That(parsedLogLine.ColumnValues[columnIndexToTest].Text, Is.EqualTo(expectedColumnValue)); } private Regex1Columnizer CreateInitializedColumnizer(string regex) diff --git a/src/RegexColumnizer/RegexColumnizer.csproj b/src/RegexColumnizer/RegexColumnizer.csproj index b89f8451..9709b071 100644 --- a/src/RegexColumnizer/RegexColumnizer.csproj +++ b/src/RegexColumnizer/RegexColumnizer.csproj @@ -9,7 +9,7 @@ Properties RegexColumnizer RegexColumnizer - v4.7.2 + v4.8.1 512 diff --git a/src/SftpFileSystemx64/SftpFileSystemx64.csproj b/src/SftpFileSystemx64/SftpFileSystemx64.csproj index 7025fcc6..cc3f556b 100644 --- a/src/SftpFileSystemx64/SftpFileSystemx64.csproj +++ b/src/SftpFileSystemx64/SftpFileSystemx64.csproj @@ -1,129 +1,129 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {B9BF5AB6-4791-4CC1-B9B7-66151A212814} - Library - Properties - SftpFileSystem - SftpFileSystem - v4.7.2 - 512 - - - - true - full - false - ..\..\bin\Debug\plugins\ - DEBUG;TRACE - prompt - 4 - false - - - pdbonly - true - ..\..\bin\Release\plugins\ - TRACE - prompt - 4 - false - - - true - - - ..\Solution Items\Key.snk - - - - - - - - - - - Properties\AssemblyVersion.cs - - - - Form - - - ConfigDialog.cs - - - - - Form - - - FailedKeyDialog.cs - - - - Form - - - PrivateKeyPasswordDialog.cs - - - Form - - - LoginDialog.cs - - - - - - - - ConfigDialog.cs - - - FailedKeyDialog.cs - - - PrivateKeyPasswordDialog.cs - Designer - - - LoginDialog.cs - Designer - - - - - Key.snk - - - - - 2020.0.2 - - - - - {e72c2bb1-34de-4d66-a830-9647c3837833} - ColumnizerLib - - - + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {B9BF5AB6-4791-4CC1-B9B7-66151A212814} + Library + Properties + SftpFileSystem + SftpFileSystem + v4.8.1 + 512 + + + + true + full + false + ..\..\bin\Debug\plugins\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + ..\..\bin\Release\plugins\ + TRACE + prompt + 4 + false + + + true + + + ..\Solution Items\Key.snk + + + + + + + + + + + Properties\AssemblyVersion.cs + + + + Form + + + ConfigDialog.cs + + + + + Form + + + FailedKeyDialog.cs + + + + Form + + + PrivateKeyPasswordDialog.cs + + + Form + + + LoginDialog.cs + + + + + + + + ConfigDialog.cs + + + FailedKeyDialog.cs + + + PrivateKeyPasswordDialog.cs + Designer + + + LoginDialog.cs + Designer + + + + + Key.snk + + + + + 2024.0.0 + + + + + {e72c2bb1-34de-4d66-a830-9647c3837833} + ColumnizerLib + + + - - - - + --> + + + + \ No newline at end of file diff --git a/src/SftpFileSystemx64/SftpLogFileInfo.cs b/src/SftpFileSystemx64/SftpLogFileInfo.cs index c5fedcba..c780c539 100644 --- a/src/SftpFileSystemx64/SftpLogFileInfo.cs +++ b/src/SftpFileSystemx64/SftpLogFileInfo.cs @@ -168,7 +168,7 @@ public bool FileExists { try { - SftpFile file = _sftp.Get(_remoteFileName); + ISftpFile file = _sftp.Get(_remoteFileName); long len = file.Attributes.Size; return len != -1; } @@ -196,7 +196,7 @@ public long Length { get { - SftpFile file = _sftp.Get(_remoteFileName); + ISftpFile file = _sftp.Get(_remoteFileName); return file.Attributes.Size; } } diff --git a/src/SftpFileSystemx86/SftpFileSystemx86.csproj b/src/SftpFileSystemx86/SftpFileSystemx86.csproj index 268aaf3d..814229f1 100644 --- a/src/SftpFileSystemx86/SftpFileSystemx86.csproj +++ b/src/SftpFileSystemx86/SftpFileSystemx86.csproj @@ -9,7 +9,7 @@ Properties SftpFileSystem SftpFileSystem - v4.7.2 + v4.8.1 512 true @@ -53,7 +53,7 @@ Form - ConfigDialog.cs + ConfigDialog.cs ConfigDialog.Designer.cs @@ -67,7 +67,7 @@ Form - FailedKeyDialog.cs + FailedKeyDialog.cs FailedKeyDialog.Designer.cs @@ -86,7 +86,7 @@ Form - PrivateKeyPasswordDialog.cs + PrivateKeyPasswordDialog.cs PrivateKeyPasswordDialog.Designer.cs @@ -112,19 +112,19 @@ - ConfigDialog.cs + ConfigDialog.cs ConfigDialog.resx - FailedKeyDialog.cs + FailedKeyDialog.cs FailedKeyDialog.resx - LoginDialog.cs + LoginDialog.cs LoginDialog.resx - PrivateKeyPasswordDialog.cs + PrivateKeyPasswordDialog.cs PrivateKeyPasswordDialog.resx @@ -135,7 +135,7 @@ - 2020.0.2 + 2024.0.0 diff --git a/src/WinFormsUI/Docking/Resources.Designer.cs b/src/WinFormsUI/Docking/Resources.Designer.cs index 85d939d3..38344cce 100644 --- a/src/WinFormsUI/Docking/Resources.Designer.cs +++ b/src/WinFormsUI/Docking/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace WeifenLuo.WinFormsUI.Docking { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/src/WinFormsUI/Docking/Strings.Designer.cs b/src/WinFormsUI/Docking/Strings.Designer.cs index 8e876092..468be951 100644 --- a/src/WinFormsUI/Docking/Strings.Designer.cs +++ b/src/WinFormsUI/Docking/Strings.Designer.cs @@ -19,7 +19,7 @@ namespace WeifenLuo.WinFormsUI.Docking { // class via a tool like ResGen or Visual Studio. // To add or remove a member, edit your .ResX file then rerun ResGen // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Strings { diff --git a/src/WinFormsUI/WinFormsUI.csproj b/src/WinFormsUI/WinFormsUI.csproj index 5c301128..faed881b 100644 --- a/src/WinFormsUI/WinFormsUI.csproj +++ b/src/WinFormsUI/WinFormsUI.csproj @@ -16,7 +16,7 @@ SAK SAK SAK - v4.7.2 + v4.8.1 From f397b0a233b40ad4e45e94c07876fe3413d58613 Mon Sep 17 00:00:00 2001 From: KaiL3 Date: Wed, 28 Feb 2024 10:21:31 +0100 Subject: [PATCH 2/2] - Nuke Path added --- .nuke/build.schema.json | 190 ++++++++++++++++++++++++++++++++++++++++ .nuke/parameters.json | 4 + 2 files changed, 194 insertions(+) create mode 100644 .nuke/build.schema.json create mode 100644 .nuke/parameters.json diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json new file mode 100644 index 00000000..95b01a04 --- /dev/null +++ b/.nuke/build.schema.json @@ -0,0 +1,190 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/build", + "title": "Build Schema", + "definitions": { + "build": { + "type": "object", + "properties": { + "ChocolateyApiKey": { + "type": "string", + "description": "Chocolatey api key" + }, + "Configuration": { + "type": "string", + "description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)", + "enum": [ + "Debug", + "Release" + ] + }, + "Continue": { + "type": "boolean", + "description": "Indicates to continue a previously failed build attempt" + }, + "ExcludeDirectoryGlob": { + "type": "array", + "description": "Exlcude directory glob", + "items": { + "type": "string" + } + }, + "ExcludeFileGlob": { + "type": "array", + "description": "Exclude file globs", + "items": { + "type": "string" + } + }, + "GitHubApiKey": { + "type": "string", + "description": "GitHub Api key" + }, + "Help": { + "type": "boolean", + "description": "Shows the help text for this build assembly" + }, + "Host": { + "type": "string", + "description": "Host for execution. Default is 'automatic'", + "enum": [ + "AppVeyor", + "AzurePipelines", + "Bamboo", + "Bitbucket", + "Bitrise", + "GitHubActions", + "GitLab", + "Jenkins", + "Rider", + "SpaceAutomation", + "TeamCity", + "Terminal", + "TravisCI", + "VisualStudio", + "VSCode" + ] + }, + "my_variable": { + "type": "string", + "description": "My variable" + }, + "NoLogo": { + "type": "boolean", + "description": "Disables displaying the NUKE logo" + }, + "NugetApiKey": { + "type": "string", + "description": "Nuget api key" + }, + "Partition": { + "type": "string", + "description": "Partition to use on CI" + }, + "Plan": { + "type": "boolean", + "description": "Shows the execution plan (HTML)" + }, + "Profile": { + "type": "array", + "description": "Defines the profiles to load", + "items": { + "type": "string" + } + }, + "Root": { + "type": "string", + "description": "Root directory during build execution" + }, + "Skip": { + "type": "array", + "description": "List of targets to be skipped. Empty list skips all dependencies", + "items": { + "type": "string", + "enum": [ + "BuildChocolateyPackage", + "ChangeVersionNumber", + "Clean", + "CleanPackage", + "CleanupAppDataLogExpert", + "CleanupDocumentsLogExpert", + "ColumnizerLibCreateNuget", + "Compile", + "CopyFilesForSetup", + "CopyOutputForChocolatey", + "CreatePackage", + "CreateSetup", + "Pack", + "PackageSftpFileSystem", + "PrepareChocolateyTemplates", + "Publish", + "PublishChocolatey", + "PublishColumnizerNuget", + "PublishGithub", + "PublishToAppveyor", + "Restore", + "Test" + ] + } + }, + "Solution": { + "type": "string", + "description": "Path to a solution file that is automatically loaded" + }, + "Target": { + "type": "array", + "description": "List of targets to be invoked. Default is '{default_target}'", + "items": { + "type": "string", + "enum": [ + "BuildChocolateyPackage", + "ChangeVersionNumber", + "Clean", + "CleanPackage", + "CleanupAppDataLogExpert", + "CleanupDocumentsLogExpert", + "ColumnizerLibCreateNuget", + "Compile", + "CopyFilesForSetup", + "CopyOutputForChocolatey", + "CreatePackage", + "CreateSetup", + "Pack", + "PackageSftpFileSystem", + "PrepareChocolateyTemplates", + "Publish", + "PublishChocolatey", + "PublishColumnizerNuget", + "PublishGithub", + "PublishToAppveyor", + "Restore", + "Test" + ] + } + }, + "Verbosity": { + "type": "string", + "description": "Logging verbosity during build execution. Default is 'Normal'", + "enum": [ + "Minimal", + "Normal", + "Quiet", + "Verbose" + ] + }, + "VersionFileString": { + "type": "string", + "description": "Version file string" + }, + "VersionInformationString": { + "type": "string", + "description": "Version Information string" + }, + "VersionString": { + "type": "string", + "description": "Version string" + } + } + } + } +} diff --git a/.nuke/parameters.json b/.nuke/parameters.json new file mode 100644 index 00000000..90094ade --- /dev/null +++ b/.nuke/parameters.json @@ -0,0 +1,4 @@ +{ + "$schema": "./build.schema.json", + "Solution": "src/LogExpert.sln" +}