From 46df1e376e36028a73d01b364fbbb0f363c5af18 Mon Sep 17 00:00:00 2001 From: Florian Rappl Date: Sun, 15 Jan 2023 01:37:09 +0100 Subject: [PATCH] Prepare for 1.0 --- .github/workflows/ci.yml | 12 +- .nuke/build.schema.json | 134 +++++++ .nuke/parameters.json | 4 + .nuke/temp/build-attempt.log | 4 + .nuke/temp/build.2023-01-15_01-27-08.log | 29 ++ .nuke/temp/build.2023-01-15_01-29-22.log | 29 ++ .nuke/temp/build.2023-01-15_01-30-03.log | 71 ++++ .nuke/temp/build.log | 71 ++++ CHANGELOG.md | 6 + LICENSE | 2 +- build.cake | 13 - build.cmd | 7 + build.ps1 | 114 +++--- build.sh | 129 +++--- nuke/.editorconfig | 11 + nuke/Build.cs | 286 +++++++++++++ nuke/Configuration.cs | 16 + nuke/Directory.Build.props | 8 + nuke/Directory.Build.targets | 8 + nuke/Extensions/StringExtensions.cs | 80 ++++ nuke/ReleaseNotes.cs | 81 ++++ nuke/ReleaseNotesParser.cs | 156 ++++++++ nuke/SemVersion.cs | 378 ++++++++++++++++++ nuke/_build.csproj | 21 + .../AngleSharp.Io.Tests.csproj | 4 +- src/AngleSharp.Io.nuspec | 4 +- src/AngleSharp.Io/AngleSharp.Io.csproj | 8 +- tools/anglesharp.cake | 198 --------- tools/packages.config | 6 - 29 files changed, 1515 insertions(+), 375 deletions(-) create mode 100644 .nuke/build.schema.json create mode 100644 .nuke/parameters.json create mode 100644 .nuke/temp/build-attempt.log create mode 100644 .nuke/temp/build.2023-01-15_01-27-08.log create mode 100644 .nuke/temp/build.2023-01-15_01-29-22.log create mode 100644 .nuke/temp/build.2023-01-15_01-30-03.log create mode 100644 .nuke/temp/build.log delete mode 100644 build.cake create mode 100644 build.cmd create mode 100644 nuke/.editorconfig create mode 100644 nuke/Build.cs create mode 100644 nuke/Configuration.cs create mode 100644 nuke/Directory.Build.props create mode 100644 nuke/Directory.Build.targets create mode 100644 nuke/Extensions/StringExtensions.cs create mode 100644 nuke/ReleaseNotes.cs create mode 100644 nuke/ReleaseNotesParser.cs create mode 100644 nuke/SemVersion.cs create mode 100644 nuke/_build.csproj delete mode 100644 tools/anglesharp.cake delete mode 100644 tools/packages.config diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 810411b..f01d24d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,12 +50,12 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/setup-dotnet@v1 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 with: dotnet-version: | - 3.1.x - 5.0.x 6.0.x + 7.0.x - name: Build run: ./build.sh @@ -66,12 +66,12 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: actions/setup-dotnet@v1 + - name: Setup dotnet + uses: actions/setup-dotnet@v1 with: dotnet-version: | - 3.1.x - 5.0.x 6.0.x + 7.0.x - name: Build run: | diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json new file mode 100644 index 0000000..c1999a9 --- /dev/null +++ b/.nuke/build.schema.json @@ -0,0 +1,134 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "Build Schema", + "$ref": "#/definitions/build", + "definitions": { + "build": { + "type": "object", + "properties": { + "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" + }, + "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" + ] + }, + "NoLogo": { + "type": "boolean", + "description": "Disables displaying the NUKE logo" + }, + "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" + } + }, + "ReleaseNotesFilePath": { + "type": "string", + "description": "ReleaseNotesFilePath - To determine the SemanticVersion" + }, + "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": [ + "Clean", + "Compile", + "CopyFiles", + "CreatePackage", + "Default", + "Package", + "PrePublish", + "Publish", + "PublishPackage", + "PublishPreRelease", + "PublishRelease", + "Restore", + "RunUnitTests" + ] + } + }, + "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": [ + "Clean", + "Compile", + "CopyFiles", + "CreatePackage", + "Default", + "Package", + "PrePublish", + "Publish", + "PublishPackage", + "PublishPreRelease", + "PublishRelease", + "Restore", + "RunUnitTests" + ] + } + }, + "Verbosity": { + "type": "string", + "description": "Logging verbosity during build execution. Default is 'Normal'", + "enum": [ + "Minimal", + "Normal", + "Quiet", + "Verbose" + ] + } + } + } + } +} \ No newline at end of file diff --git a/.nuke/parameters.json b/.nuke/parameters.json new file mode 100644 index 0000000..0ec41ee --- /dev/null +++ b/.nuke/parameters.json @@ -0,0 +1,4 @@ +{ + "$schema": "./build.schema.json", + "Solution": "src/AngleSharp.Io.sln" +} \ No newline at end of file diff --git a/.nuke/temp/build-attempt.log b/.nuke/temp/build-attempt.log new file mode 100644 index 0000000..d4f0c5d --- /dev/null +++ b/.nuke/temp/build-attempt.log @@ -0,0 +1,4 @@ +77a74fac8e4ce00c1d0fbd53c441f1ea +Restore +Compile +RunUnitTests diff --git a/.nuke/temp/build.2023-01-15_01-27-08.log b/.nuke/temp/build.2023-01-15_01-27-08.log new file mode 100644 index 0000000..479c93e --- /dev/null +++ b/.nuke/temp/build.2023-01-15_01-27-08.log @@ -0,0 +1,29 @@ +V | | ArgumentsFromParametersFile.OnBuildCreated (150) +V | | Passing value for Build.Solution (src/AngleSharp.Io.sln) +V | | InjectParameterValues.OnBuildCreated (100) +V | | HandleShellCompletion.OnBuildCreated (75) +V | | GenerateBuildServerConfigurations.OnBuildCreated (50) +V | | InvokeBuildServerConfigurationGeneration.OnBuildCreated (45) +V | | UpdateNotification.OnBuildCreated (10) +V | | UnsetVisualStudioEnvironmentVariables.OnBuildCreated (0) +V | | HandleVisualStudioDebugging.OnBuildCreated (0) +V | | HandleSingleFileExecution.OnBuildCreated (-50) +V | | EventInvoker.OnBuildCreated (-3.4028235E+38) +V | | HandleHelpRequests.OnBuildInitialized (5) +V | | Telemetry.OnBuildInitialized (0) +V | | InjectNonParameterValues.OnBuildInitialized (-100) +V | | EventInvoker.OnBuildInitialized (-3.4028235E+38) +D | | Reading ChangeLog E:\Code\AngleSharp\AngleSharp.Io\CHANGELOG.md... +D | | Using LastestVersion from ChangeLog: 1.0.0 +I | | Building version: 1.0.0 +V | | Target-unrelated exception was thrown +System.ArgumentException: TargetProject could not be loaded! + at Nuke.Common.Assert.NotNull[T](T obj, String message, String argumentExpression) in /_/source/Nuke.Common/Assert.cs:line 61 + at Build.OnBuildInitialized() in E:\Code\AngleSharp\AngleSharp.Io\nuke\Build.cs:line 103 + at Nuke.Common.Execution.EventInvoker.OnBuildInitialized(NukeBuild build, IReadOnlyCollection`1 executableTargets, IReadOnlyCollection`1 executionPlan) in /_/source/Nuke.Common/Execution/EventInvoker.cs:line 27 + at Nuke.Common.Utilities.Collections.EnumerableExtensions.ForEach[T](IEnumerable`1 enumerable, Action`1 action) in /_/source/Nuke.Common/Utilities/Collections/Enumerable.ForEach.cs:line 17 + at Nuke.Common.NukeBuild.ExecuteExtension[TExtension](Expression`1 action) + at Nuke.Common.Execution.BuildManager.Execute[T](Expression`1[] defaultTargetExpressions) in /_/source/Nuke.Common/Execution/BuildManager.cs:line 58 +V | | UpdateNotification.OnBuildFinished (10) +V | | SerializeBuildServerState.OnBuildFinished (0) +V | | EventInvoker.OnBuildFinished (-3.4028235E+38) diff --git a/.nuke/temp/build.2023-01-15_01-29-22.log b/.nuke/temp/build.2023-01-15_01-29-22.log new file mode 100644 index 0000000..479c93e --- /dev/null +++ b/.nuke/temp/build.2023-01-15_01-29-22.log @@ -0,0 +1,29 @@ +V | | ArgumentsFromParametersFile.OnBuildCreated (150) +V | | Passing value for Build.Solution (src/AngleSharp.Io.sln) +V | | InjectParameterValues.OnBuildCreated (100) +V | | HandleShellCompletion.OnBuildCreated (75) +V | | GenerateBuildServerConfigurations.OnBuildCreated (50) +V | | InvokeBuildServerConfigurationGeneration.OnBuildCreated (45) +V | | UpdateNotification.OnBuildCreated (10) +V | | UnsetVisualStudioEnvironmentVariables.OnBuildCreated (0) +V | | HandleVisualStudioDebugging.OnBuildCreated (0) +V | | HandleSingleFileExecution.OnBuildCreated (-50) +V | | EventInvoker.OnBuildCreated (-3.4028235E+38) +V | | HandleHelpRequests.OnBuildInitialized (5) +V | | Telemetry.OnBuildInitialized (0) +V | | InjectNonParameterValues.OnBuildInitialized (-100) +V | | EventInvoker.OnBuildInitialized (-3.4028235E+38) +D | | Reading ChangeLog E:\Code\AngleSharp\AngleSharp.Io\CHANGELOG.md... +D | | Using LastestVersion from ChangeLog: 1.0.0 +I | | Building version: 1.0.0 +V | | Target-unrelated exception was thrown +System.ArgumentException: TargetProject could not be loaded! + at Nuke.Common.Assert.NotNull[T](T obj, String message, String argumentExpression) in /_/source/Nuke.Common/Assert.cs:line 61 + at Build.OnBuildInitialized() in E:\Code\AngleSharp\AngleSharp.Io\nuke\Build.cs:line 103 + at Nuke.Common.Execution.EventInvoker.OnBuildInitialized(NukeBuild build, IReadOnlyCollection`1 executableTargets, IReadOnlyCollection`1 executionPlan) in /_/source/Nuke.Common/Execution/EventInvoker.cs:line 27 + at Nuke.Common.Utilities.Collections.EnumerableExtensions.ForEach[T](IEnumerable`1 enumerable, Action`1 action) in /_/source/Nuke.Common/Utilities/Collections/Enumerable.ForEach.cs:line 17 + at Nuke.Common.NukeBuild.ExecuteExtension[TExtension](Expression`1 action) + at Nuke.Common.Execution.BuildManager.Execute[T](Expression`1[] defaultTargetExpressions) in /_/source/Nuke.Common/Execution/BuildManager.cs:line 58 +V | | UpdateNotification.OnBuildFinished (10) +V | | SerializeBuildServerState.OnBuildFinished (0) +V | | EventInvoker.OnBuildFinished (-3.4028235E+38) diff --git a/.nuke/temp/build.2023-01-15_01-30-03.log b/.nuke/temp/build.2023-01-15_01-30-03.log new file mode 100644 index 0000000..e21502c --- /dev/null +++ b/.nuke/temp/build.2023-01-15_01-30-03.log @@ -0,0 +1,71 @@ +V | | ArgumentsFromParametersFile.OnBuildCreated (150) +V | | Passing value for Build.Solution (src/AngleSharp.Io.sln) +V | | InjectParameterValues.OnBuildCreated (100) +V | | HandleShellCompletion.OnBuildCreated (75) +V | | GenerateBuildServerConfigurations.OnBuildCreated (50) +V | | InvokeBuildServerConfigurationGeneration.OnBuildCreated (45) +V | | UpdateNotification.OnBuildCreated (10) +V | | UnsetVisualStudioEnvironmentVariables.OnBuildCreated (0) +V | | HandleVisualStudioDebugging.OnBuildCreated (0) +V | | HandleSingleFileExecution.OnBuildCreated (-50) +V | | EventInvoker.OnBuildCreated (-3.4028235E+38) +V | | HandleHelpRequests.OnBuildInitialized (5) +V | | Telemetry.OnBuildInitialized (0) +V | | InjectNonParameterValues.OnBuildInitialized (-100) +V | | EventInvoker.OnBuildInitialized (-3.4028235E+38) +D | | Reading ChangeLog E:\Code\AngleSharp\AngleSharp.Io\CHANGELOG.md... +D | | Using LastestVersion from ChangeLog: 1.0.0 +I | | Building version: 1.0.0 +I | | Target Framework(s): ["netstandard2.0", "net461", "net472", "net6.0", "net7.0"] +V | Restore | EventInvoker.OnTargetRunning (-3.4028235E+38) +I | Restore | > "C:\Program Files\dotnet\dotnet.exe" restore E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.sln +D | Restore | Determining projects to restore... +D | Restore | Restored E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj (in 230 ms). +D | Restore | Restored E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj (in 1,51 sec). +V | Restore | Telemetry.OnTargetSucceeded (0) +V | Restore | EventInvoker.OnTargetSucceeded (-3.4028235E+38) +V | Compile | EventInvoker.OnTargetRunning (-3.4028235E+38) +I | Compile | > "C:\Program Files\dotnet\dotnet.exe" build E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.sln --configuration Debug --no-restore +D | Compile | MSBuild version 17.4.0+18d5aef85 for .NET +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FtpRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net6.0] +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FileRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net6.0] +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FtpRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net7.0] +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FileRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net7.0] +D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\net7.0\AngleSharp.Io.dll +D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\net461\AngleSharp.Io.dll +D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\net472\AngleSharp.Io.dll +D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\net6.0\AngleSharp.Io.dll +D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\netstandard2.0\AngleSharp.Io.dll +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\Network\HttpClientRequesterTests.cs(37,13): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj::TargetFramework=net6.0] +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\Network\HttpClientRequesterTests.cs(56,13): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj::TargetFramework=net6.0] +D | Compile | AngleSharp.Io.Tests -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\bin\Debug\net6.0\AngleSharp.Io.Tests.dll +D | Compile | +D | Compile | Build succeeded. +D | Compile | +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FtpRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net6.0] +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FileRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net6.0] +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FtpRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net7.0] +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FileRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net7.0] +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\Network\HttpClientRequesterTests.cs(37,13): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj::TargetFramework=net6.0] +W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\Network\HttpClientRequesterTests.cs(56,13): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj::TargetFramework=net6.0] +D | Compile | 6 Warning(s) +D | Compile | 0 Error(s) +D | Compile | +D | Compile | Time Elapsed 00:00:01.83 +V | Compile | Telemetry.OnTargetSucceeded (0) +V | Compile | EventInvoker.OnTargetSucceeded (-3.4028235E+38) +V | RunUnitTests | EventInvoker.OnTargetRunning (-3.4028235E+38) +I | RunUnitTests | > "C:\Program Files\dotnet\dotnet.exe" test E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.sln --configuration Debug --no-build --no-restore +D | RunUnitTests | Test run for E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\bin\Debug\net6.0\AngleSharp.Io.Tests.dll (.NETCoreApp,Version=v6.0) +D | RunUnitTests | Microsoft (R) Test Execution Command Line Tool Version 17.4.0 (x64) +D | RunUnitTests | Copyright (c) Microsoft Corporation. All rights reserved. +D | RunUnitTests | +D | RunUnitTests | Starting test execution, please wait... +D | RunUnitTests | A total of 1 test files matched the specified pattern. +D | RunUnitTests | Skipped SettingCookieIsPreservedViaRedirect [< 1 ms] +D | RunUnitTests | Skipped SettingCookieIsPreservedViaRedirect [< 1 ms] +D | RunUnitTests | Skipped SettingCookieIsPreservedViaRedirectToDifferentProtocol [< 1 ms] +D | RunUnitTests | +D | RunUnitTests | Passed! - Failed: 0, Passed: 102, Skipped: 3, Total: 105, Duration: 14 s - AngleSharp.Io.Tests.dll (net6.0) +V | RunUnitTests | Telemetry.OnTargetSucceeded (0) +V | RunUnitTests | EventInvoker.OnTargetSucceeded (-3.4028235E+38) diff --git a/.nuke/temp/build.log b/.nuke/temp/build.log new file mode 100644 index 0000000..01c1a29 --- /dev/null +++ b/.nuke/temp/build.log @@ -0,0 +1,71 @@ +01:30:03.042 | V | | ArgumentsFromParametersFile.OnBuildCreated (150) +01:30:03.083 | V | | Passing value for Build.Solution (src/AngleSharp.Io.sln) +01:30:03.093 | V | | InjectParameterValues.OnBuildCreated (100) +01:30:03.134 | V | | HandleShellCompletion.OnBuildCreated (75) +01:30:03.233 | V | | GenerateBuildServerConfigurations.OnBuildCreated (50) +01:30:03.233 | V | | InvokeBuildServerConfigurationGeneration.OnBuildCreated (45) +01:30:03.245 | V | | UpdateNotification.OnBuildCreated (10) +01:30:03.245 | V | | UnsetVisualStudioEnvironmentVariables.OnBuildCreated (0) +01:30:03.245 | V | | HandleVisualStudioDebugging.OnBuildCreated (0) +01:30:03.246 | V | | HandleSingleFileExecution.OnBuildCreated (-50) +01:30:03.247 | V | | EventInvoker.OnBuildCreated (-3.4028235E+38) +01:30:03.267 | V | | HandleHelpRequests.OnBuildInitialized (5) +01:30:03.267 | V | | Telemetry.OnBuildInitialized (0) +01:30:03.701 | V | | InjectNonParameterValues.OnBuildInitialized (-100) +01:30:03.702 | V | | EventInvoker.OnBuildInitialized (-3.4028235E+38) +01:30:03.704 | D | | Reading ChangeLog E:\Code\AngleSharp\AngleSharp.Io\CHANGELOG.md... +01:30:03.716 | D | | Using LastestVersion from ChangeLog: 1.0.0 +01:30:03.717 | I | | Building version: 1.0.0 +01:30:03.759 | I | | Target Framework(s): ["netstandard2.0", "net461", "net472", "net6.0", "net7.0"] +01:30:03.776 | V | Restore | EventInvoker.OnTargetRunning (-3.4028235E+38) +01:30:03.812 | I | Restore | > "C:\Program Files\dotnet\dotnet.exe" restore E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.sln +01:30:04.291 | D | Restore | Determining projects to restore... +01:30:05.004 | D | Restore | Restored E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj (in 230 ms). +01:30:06.264 | D | Restore | Restored E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj (in 1,51 sec). +01:30:06.300 | V | Restore | Telemetry.OnTargetSucceeded (0) +01:30:06.300 | V | Restore | EventInvoker.OnTargetSucceeded (-3.4028235E+38) +01:30:06.305 | V | Compile | EventInvoker.OnTargetRunning (-3.4028235E+38) +01:30:06.309 | I | Compile | > "C:\Program Files\dotnet\dotnet.exe" build E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.sln --configuration Debug --no-restore +01:30:06.445 | D | Compile | MSBuild version 17.4.0+18d5aef85 for .NET +01:30:07.169 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FtpRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net6.0] +01:30:07.173 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FileRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net6.0] +01:30:07.180 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FtpRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net7.0] +01:30:07.182 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FileRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net7.0] +01:30:07.275 | D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\net7.0\AngleSharp.Io.dll +01:30:07.276 | D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\net461\AngleSharp.Io.dll +01:30:07.277 | D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\net472\AngleSharp.Io.dll +01:30:07.282 | D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\net6.0\AngleSharp.Io.dll +01:30:07.635 | D | Compile | AngleSharp.Io -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\bin\Debug\netstandard2.0\AngleSharp.Io.dll +01:30:08.155 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\Network\HttpClientRequesterTests.cs(37,13): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj::TargetFramework=net6.0] +01:30:08.157 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\Network\HttpClientRequesterTests.cs(56,13): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj::TargetFramework=net6.0] +01:30:08.289 | D | Compile | AngleSharp.Io.Tests -> E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\bin\Debug\net6.0\AngleSharp.Io.Tests.dll +01:30:08.313 | D | Compile | +01:30:08.313 | D | Compile | Build succeeded. +01:30:08.314 | D | Compile | +01:30:08.315 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FtpRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net6.0] +01:30:08.317 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FileRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net6.0] +01:30:08.318 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FtpRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net7.0] +01:30:08.319 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\Network\FileRequester.cs(21,17): warning SYSLIB0014: 'WebRequest.Create(string)' is obsolete: 'WebRequest, HttpWebRequest, ServicePoint, and WebClient are obsolete. Use HttpClient instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io\AngleSharp.Io.csproj::TargetFramework=net7.0] +01:30:08.321 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\Network\HttpClientRequesterTests.cs(37,13): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj::TargetFramework=net6.0] +01:30:08.322 | W | Compile | E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\Network\HttpClientRequesterTests.cs(56,13): warning CS0618: 'HttpRequestMessage.Properties' is obsolete: 'HttpRequestMessage.Properties has been deprecated. Use Options instead.' [E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\AngleSharp.Io.Tests.csproj::TargetFramework=net6.0] +01:30:08.324 | D | Compile | 6 Warning(s) +01:30:08.325 | D | Compile | 0 Error(s) +01:30:08.325 | D | Compile | +01:30:08.326 | D | Compile | Time Elapsed 00:00:01.83 +01:30:08.349 | V | Compile | Telemetry.OnTargetSucceeded (0) +01:30:08.349 | V | Compile | EventInvoker.OnTargetSucceeded (-3.4028235E+38) +01:30:08.353 | V | RunUnitTests | EventInvoker.OnTargetRunning (-3.4028235E+38) +01:30:08.367 | I | RunUnitTests | > "C:\Program Files\dotnet\dotnet.exe" test E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.sln --configuration Debug --no-build --no-restore +01:30:09.184 | D | RunUnitTests | Test run for E:\Code\AngleSharp\AngleSharp.Io\src\AngleSharp.Io.Tests\bin\Debug\net6.0\AngleSharp.Io.Tests.dll (.NETCoreApp,Version=v6.0) +01:30:09.266 | D | RunUnitTests | Microsoft (R) Test Execution Command Line Tool Version 17.4.0 (x64) +01:30:09.267 | D | RunUnitTests | Copyright (c) Microsoft Corporation. All rights reserved. +01:30:09.269 | D | RunUnitTests | +01:30:09.357 | D | RunUnitTests | Starting test execution, please wait... +01:30:09.475 | D | RunUnitTests | A total of 1 test files matched the specified pattern. +01:30:15.843 | D | RunUnitTests | Skipped SettingCookieIsPreservedViaRedirect [< 1 ms] +01:30:20.439 | D | RunUnitTests | Skipped SettingCookieIsPreservedViaRedirect [< 1 ms] +01:30:20.439 | D | RunUnitTests | Skipped SettingCookieIsPreservedViaRedirectToDifferentProtocol [< 1 ms] +01:30:26.104 | D | RunUnitTests | +01:30:26.109 | D | RunUnitTests | Passed! - Failed: 0, Passed: 102, Skipped: 3, Total: 105, Duration: 14 s - AngleSharp.Io.Tests.dll (net6.0) +01:30:26.199 | V | RunUnitTests | Telemetry.OnTargetSucceeded (0) +01:30:26.199 | V | RunUnitTests | EventInvoker.OnTargetSucceeded (-3.4028235E+38) diff --git a/CHANGELOG.md b/CHANGELOG.md index fd1eac2..f35dce0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 1.0.0 + +Released on Sunday, January 15 2023. + +- Updated to use AngleSharp 1.0 + # 0.17.0 Released on Tuesday, May 31 2022. diff --git a/LICENSE b/LICENSE index aa13fe9..470f190 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013 - 2022 AngleSharp +Copyright (c) 2013 - 2023 AngleSharp Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/build.cake b/build.cake deleted file mode 100644 index 1bf7423..0000000 --- a/build.cake +++ /dev/null @@ -1,13 +0,0 @@ -var target = Argument("target", "Default"); -var projectName = "AngleSharp.Io"; -var solutionName = "AngleSharp.Io"; -var frameworks = new Dictionary -{ - { "net461", "net461" }, - { "net472", "net472" }, - { "netstandard2.0", "netstandard2.0" }, -}; - -#load tools/anglesharp.cake - -RunTarget(target); diff --git a/build.cmd b/build.cmd new file mode 100644 index 0000000..b08cc59 --- /dev/null +++ b/build.cmd @@ -0,0 +1,7 @@ +:; set -eo pipefail +:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) +:; ${SCRIPT_DIR}/build.sh "$@" +:; exit $? + +@ECHO OFF +powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %* diff --git a/build.ps1 b/build.ps1 index 6f27bfd..1f264e7 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,81 +1,69 @@ +[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, - [switch]$WhatIf, - [switch]$Mono, - [switch]$SkipToolPackageRestore, [Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)] - [string[]]$ScriptArgs + [string[]]$BuildArguments ) -$PSScriptRoot = split-path -parent $MyInvocation.MyCommand.Definition; -$UseDryRun = ""; -$UseMono = ""; -$TOOLS_DIR = Join-Path $PSScriptRoot "tools" -$NUGET_EXE = Join-Path $TOOLS_DIR "nuget.exe" -$NUGET_OLD_EXE = Join-Path $TOOLS_DIR "nuget_old.exe" -$CAKE_EXE = Join-Path $TOOLS_DIR "Cake/Cake.exe" -$NUGET_URL = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe" -$NUGET_OLD_URL = "https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe" +Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)" -# Should we use experimental build of Roslyn? -$UseExperimental = ""; -if ($Experimental.IsPresent) { - $UseExperimental = "--experimental" -} +Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 } +$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent -# Is this a dry run? -if ($WhatIf.IsPresent) { - $UseDryRun = "--dryrun" -} +########################################################################### +# CONFIGURATION +########################################################################### -# Should we use mono? -if ($Mono.IsPresent) { - $UseMono = "--mono" -} +$BuildProjectFile = "$PSScriptRoot\nuke\_build.csproj" +$TempDirectory = "$PSScriptRoot\\.nuke\temp" -# Try download NuGet.exe if do not exist. -if (!(Test-Path $NUGET_EXE)) { - (New-Object System.Net.WebClient).DownloadFile($NUGET_URL, $NUGET_EXE) -} +$DotNetGlobalFile = "$PSScriptRoot\\global.json" +$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" +$DotNetChannel = "Current" -# Try download NuGet.exe if do not exist. -if (!(Test-Path $NUGET_OLD_URL)) { - (New-Object System.Net.WebClient).DownloadFile($NUGET_OLD_URL, $NUGET_OLD_EXE) -} +$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 +$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 +$env:DOTNET_MULTILEVEL_LOOKUP = 0 -# Make sure NuGet (latest) exists where we expect it. -if (!(Test-Path $NUGET_EXE)) { - Throw "Could not find nuget.exe" +########################################################################### +# EXECUTION +########################################################################### + +function ExecSafe([scriptblock] $cmd) { + & $cmd + if ($LASTEXITCODE) { exit $LASTEXITCODE } } -# Make sure NuGet (v3.5.0) exists where we expect it. -if (!(Test-Path $NUGET_OLD_EXE)) { - Throw "Could not find nuget_old.exe" +# 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) -# Restore tools from NuGet? -if (-Not $SkipToolPackageRestore.IsPresent) -{ - Push-Location - Set-Location $TOOLS_DIR - Invoke-Expression "$NUGET_EXE install -ExcludeVersion" - Pop-Location - if ($LASTEXITCODE -ne 0) { - 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 + } } -} -# Make sure that Cake has been installed. -if (!(Test-Path $CAKE_EXE)) { - Throw "Could not find Cake.exe" + # 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" } -# Start Cake -Invoke-Expression "$CAKE_EXE `"$Script`" --target=`"$Target`" --configuration=`"$Configuration`" --verbosity=`"$Verbosity`" $UseMono $UseDryRun $UseExperimental $ScriptArgs" -exit $LASTEXITCODE \ No newline at end of file +Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)" + +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 c62ce5c..7534123 100755 --- a/build.sh +++ b/build.sh @@ -1,93 +1,62 @@ #!/usr/bin/env bash -############################################################### -# This is the Cake bootstrapper script that is responsible for -# downloading Cake and all specified tools from NuGet. -############################################################### -# Define directories. -SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) -TOOLS_DIR=$SCRIPT_DIR/tools -NUGET_EXE=$TOOLS_DIR/nuget.exe -NUGET_OLD_EXE=$TOOLS_DIR/nuget_old.exe -CAKE_EXE=$TOOLS_DIR/Cake/Cake.exe +bash --version 2>&1 | head -n 1 -# Define default arguments. -SCRIPT="build.cake" -TARGET="Default" -CONFIGURATION="Release" -VERBOSITY="verbose" -DRYRUN= -SHOW_VERSION=false -SCRIPT_ARGUMENTS=() +set -eo pipefail +SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) -# Parse arguments. -for i in "$@"; do - case $1 in - -s|--script) SCRIPT="$2"; shift ;; - -t|--target) TARGET="$2"; shift ;; - -c|--configuration) CONFIGURATION="$2"; shift ;; - -v|--verbosity) VERBOSITY="$2"; shift ;; - -d|--dryrun) DRYRUN="--dryrun" ;; - --version) SHOW_VERSION=true ;; - --) shift; SCRIPT_ARGUMENTS+=("$@"); break ;; - *) SCRIPT_ARGUMENTS+=("$1") ;; - esac - shift -done +########################################################################### +# CONFIGURATION +########################################################################### -# Make sure the tools folder exist. -if [ ! -d $TOOLS_DIR ]; then - mkdir $TOOLS_DIR -fi +BUILD_PROJECT_FILE="$SCRIPT_DIR/nuke/_build.csproj" +TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" -# Make sure that packages.config exist. -if [ ! -f $TOOLS_DIR/packages.config ]; then - echo "Downloading packages.config..." - curl -Lsfo $TOOLS_DIR/packages.config http://cakebuild.net/bootstrapper/packages - if [ $? -ne 0 ]; then - echo "An error occured while downloading packages.config." - exit 1 - fi -fi +DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" +DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" +DOTNET_CHANNEL="Current" -# Download NuGet (v3.5.0) if it does not exist. -if [ ! -f $NUGET_OLD_EXE ]; then - echo "Downloading NuGet..." - curl -Lsfo $NUGET_OLD_EXE https://dist.nuget.org/win-x86-commandline/v3.5.0/nuget.exe - if [ $? -ne 0 ]; then - echo "An error occured while downloading nuget.exe." - exit 1 - fi -fi +export DOTNET_CLI_TELEMETRY_OPTOUT=1 +export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 +export DOTNET_MULTILEVEL_LOOKUP=0 + +########################################################################### +# EXECUTION +########################################################################### -# Download NuGet (latest) if it does not exist. -if [ ! -f $NUGET_EXE ]; then - echo "Downloading NuGet..." - curl -Lsfo $NUGET_EXE https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - if [ $? -ne 0 ]; then - echo "An error occured while downloading nuget.exe." - exit 1 +function FirstJsonValue { + perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" +} + +# 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 + # 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 -fi -# Restore tools from NuGet. -pushd $TOOLS_DIR >/dev/null -mono $NUGET_EXE install -ExcludeVersion -if [ $? -ne 0 ]; then - echo "Could not restore NuGet packages." - exit 1 + # Install by channel or version + 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" fi -popd >/dev/null -# Make sure that Cake has been installed. -if [ ! -f $CAKE_EXE ]; then - echo "Could not find Cake.exe at '$CAKE_EXE'." - exit 1 -fi +echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)" -# Start Cake -if $SHOW_VERSION; then - exec mono $CAKE_EXE --version -else - exec mono $CAKE_EXE $SCRIPT --verbosity=$VERBOSITY --configuration=$CONFIGURATION --target=$TARGET $DRYRUN "${SCRIPT_ARGUMENTS[@]}" -fi \ No newline at end of file +"$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/nuke/.editorconfig b/nuke/.editorconfig new file mode 100644 index 0000000..31e43dc --- /dev/null +++ b/nuke/.editorconfig @@ -0,0 +1,11 @@ +[*.cs] +dotnet_style_qualification_for_field = false:warning +dotnet_style_qualification_for_property = false:warning +dotnet_style_qualification_for_method = false:warning +dotnet_style_qualification_for_event = false:warning +dotnet_style_require_accessibility_modifiers = never:warning + +csharp_style_expression_bodied_methods = true:silent +csharp_style_expression_bodied_properties = true:warning +csharp_style_expression_bodied_indexers = true:warning +csharp_style_expression_bodied_accessors = true:warning diff --git a/nuke/Build.cs b/nuke/Build.cs new file mode 100644 index 0000000..fd91872 --- /dev/null +++ b/nuke/Build.cs @@ -0,0 +1,286 @@ +using Microsoft.Build.Exceptions; +using Nuke.Common; +using Nuke.Common.CI.GitHubActions; +using Nuke.Common.IO; +using Nuke.Common.ProjectModel; +using Nuke.Common.Tools.DotNet; +using Nuke.Common.Tools.GitHub; +using Nuke.Common.Tools.NuGet; +using Nuke.Common.Utilities.Collections; +using Octokit; +using Octokit.Internal; +using Serilog; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using static Nuke.Common.IO.FileSystemTasks; +using static Nuke.Common.IO.PathConstruction; +using static Nuke.Common.Tools.DotNet.DotNetTasks; +using static Nuke.Common.Tools.NuGet.NuGetTasks; +using Project = Nuke.Common.ProjectModel.Project; + +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.RunUnitTests); + + [Nuke.Common.Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")] + readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release; + + [Nuke.Common.Parameter("ReleaseNotesFilePath - To determine the SemanticVersion")] + readonly AbsolutePath ReleaseNotesFilePath = RootDirectory / "CHANGELOG.md"; + + [Solution] + readonly Solution Solution; + + string TargetProjectName => "AngleSharp.Io"; + + string TargetLibName => $"{TargetProjectName}"; + + AbsolutePath SourceDirectory => RootDirectory / "src"; + + AbsolutePath BuildDirectory => SourceDirectory / TargetProjectName / "bin" / Configuration; + + AbsolutePath ResultDirectory => RootDirectory / "bin" / Version; + + AbsolutePath NugetDirectory => ResultDirectory / "nuget"; + + GitHubActions GitHubActions => GitHubActions.Instance; + + Project TargetProject { get; set; } + + // Note: The ChangeLogTasks from Nuke itself look buggy. So using the Cake source code. + IReadOnlyList ChangeLog { get; set; } + + ReleaseNotes LatestReleaseNotes { get; set; } + + SemVersion SemVersion { get; set; } + + string Version { get; set; } + + IReadOnlyCollection TargetFrameworks { get; set; } + + protected override void OnBuildInitialized() + { + var parser = new ReleaseNotesParser(); + + Log.Debug("Reading ChangeLog {FilePath}...", ReleaseNotesFilePath); + ChangeLog = parser.Parse(File.ReadAllText(ReleaseNotesFilePath)); + ChangeLog.NotNull("ChangeLog / ReleaseNotes could not be read!"); + + LatestReleaseNotes = ChangeLog.First(); + LatestReleaseNotes.NotNull("LatestVersion could not be read!"); + + Log.Debug("Using LastestVersion from ChangeLog: {LatestVersion}", LatestReleaseNotes.Version); + SemVersion = LatestReleaseNotes.SemVersion; + Version = LatestReleaseNotes.Version.ToString(); + + if (GitHubActions != null) + { + Log.Debug("Add Version Postfix if under CI - GithubAction(s)..."); + + var buildNumber = GitHubActions.RunNumber; + + if (ScheduledTargets.Contains(Default)) + { + Version = $"{Version}-ci-{buildNumber}"; + } + else if (ScheduledTargets.Contains(PrePublish)) + { + Version = $"{Version}-alpha-{buildNumber}"; + } + } + + Log.Information("Building version: {Version}", Version); + + TargetProject = Solution.GetProject(SourceDirectory / TargetProjectName / $"{TargetLibName}.csproj" ); + TargetProject.NotNull("TargetProject could not be loaded!"); + + TargetFrameworks = TargetProject.GetTargetFrameworks(); + TargetFrameworks.NotNull("No TargetFramework(s) found to build for!"); + + Log.Information("Target Framework(s): {Frameworks}", TargetFrameworks); + } + + Target Clean => _ => _ + .Before(Restore) + .Executes(() => + { + SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); + }); + + Target Restore => _ => _ + .Executes(() => + { + DotNetRestore(s => s + .SetProjectFile(Solution)); + }); + + Target Compile => _ => _ + .DependsOn(Restore) + .Executes(() => + { + DotNetBuild(s => s + .SetProjectFile(Solution) + .SetConfiguration(Configuration) + .EnableNoRestore()); + }); + + Target RunUnitTests => _ => _ + .DependsOn(Compile) + .Executes(() => + { + DotNetTest(s => s + .SetProjectFile(Solution) + .SetConfiguration(Configuration) + .EnableNoRestore() + .EnableNoBuild()); + }); + + Target CopyFiles => _ => _ + .DependsOn(Compile) + .Executes(() => + { + foreach (var item in TargetFrameworks) + { + var targetDir = NugetDirectory / "lib" / item; + var srcDir = BuildDirectory / item; + + CopyFile(srcDir / $"{TargetProjectName}.dll", targetDir / $"{TargetProjectName}.dll", FileExistsPolicy.OverwriteIfNewer); + CopyFile(srcDir / $"{TargetProjectName}.pdb", targetDir / $"{TargetProjectName}.pdb", FileExistsPolicy.OverwriteIfNewer); + CopyFile(srcDir / $"{TargetProjectName}.xml", targetDir / $"{TargetProjectName}.xml", FileExistsPolicy.OverwriteIfNewer); + } + + CopyFile(SourceDirectory / $"{TargetProjectName}.nuspec", NugetDirectory / $"{TargetProjectName}.nuspec", FileExistsPolicy.OverwriteIfNewer); + CopyFile(RootDirectory / "logo.png", NugetDirectory / "logo.png", FileExistsPolicy.OverwriteIfNewer); + }); + + Target CreatePackage => _ => _ + .DependsOn(CopyFiles) + .Executes(() => + { + var nuspec = NugetDirectory / $"{TargetProjectName}.nuspec"; + + NuGetPack(_ => _ + .SetTargetPath(nuspec) + .SetVersion(Version) + .SetOutputDirectory(NugetDirectory) + .SetSymbols(true) + .SetSymbolPackageFormat("snupkg") + .AddProperty("Configuration", Configuration) + ); + }); + + Target PublishPackage => _ => _ + .DependsOn(CreatePackage) + .DependsOn(RunUnitTests) + .Executes(() => + { + var apiKey = Environment.GetEnvironmentVariable("NUGET_API_KEY"); + + + if (apiKey.IsNullOrEmpty()) + { + throw new BuildAbortedException("Could not resolve the NuGet API key."); + } + + foreach (var nupkg in GlobFiles(NugetDirectory, "*.nupkg")) + { + NuGetPush(s => s + .SetTargetPath(nupkg) + .SetSource("https://api.nuget.org/v3/index.json") + .SetApiKey(apiKey)); + } + }); + + Target PublishPreRelease => _ => _ + .DependsOn(PublishPackage) + .Executes(() => + { + string gitHubToken; + + if (GitHubActions != null) + { + gitHubToken = GitHubActions.Token; + } + else + { + gitHubToken = Environment.GetEnvironmentVariable("GITHUB_TOKEN"); + } + + if (gitHubToken.IsNullOrEmpty()) + { + throw new BuildAbortedException("Could not resolve GitHub token."); + } + + var credentials = new Credentials(gitHubToken); + + GitHubTasks.GitHubClient = new GitHubClient( + new ProductHeaderValue(nameof(NukeBuild)), + new InMemoryCredentialStore(credentials)); + + GitHubTasks.GitHubClient.Repository.Release + .Create("AngleSharp", TargetProjectName, new NewRelease(Version) + { + Name = Version, + Body = String.Join(Environment.NewLine, LatestReleaseNotes.Notes), + Prerelease = true, + TargetCommitish = "devel", + }); + }); + + Target PublishRelease => _ => _ + .DependsOn(PublishPackage) + .Executes(() => + { + string gitHubToken; + + if (GitHubActions != null) + { + gitHubToken = GitHubActions.Token; + } + else + { + gitHubToken = Environment.GetEnvironmentVariable("GITHUB_TOKEN"); + } + + if (gitHubToken.IsNullOrEmpty()) + { + throw new BuildAbortedException("Could not resolve GitHub token."); + } + + var credentials = new Credentials(gitHubToken); + + GitHubTasks.GitHubClient = new GitHubClient( + new ProductHeaderValue(nameof(NukeBuild)), + new InMemoryCredentialStore(credentials)); + + GitHubTasks.GitHubClient.Repository.Release + .Create("AngleSharp", TargetProjectName, new NewRelease(Version) + { + Name = Version, + Body = String.Join(Environment.NewLine, LatestReleaseNotes.Notes), + Prerelease = false, + TargetCommitish = "main", + }); + }); + + Target Package => _ => _ + .DependsOn(RunUnitTests) + .DependsOn(CreatePackage); + + Target Default => _ => _ + .DependsOn(Package); + + Target Publish => _ => _ + .DependsOn(PublishRelease); + + Target PrePublish => _ => _ + .DependsOn(PublishPreRelease); +} diff --git a/nuke/Configuration.cs b/nuke/Configuration.cs new file mode 100644 index 0000000..9c08b1a --- /dev/null +++ b/nuke/Configuration.cs @@ -0,0 +1,16 @@ +using System; +using System.ComponentModel; +using System.Linq; +using Nuke.Common.Tooling; + +[TypeConverter(typeof(TypeConverter))] +public class Configuration : Enumeration +{ + public static Configuration Debug = new Configuration { Value = nameof(Debug) }; + public static Configuration Release = new Configuration { Value = nameof(Release) }; + + public static implicit operator string(Configuration configuration) + { + return configuration.Value; + } +} diff --git a/nuke/Directory.Build.props b/nuke/Directory.Build.props new file mode 100644 index 0000000..e147d63 --- /dev/null +++ b/nuke/Directory.Build.props @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nuke/Directory.Build.targets b/nuke/Directory.Build.targets new file mode 100644 index 0000000..2532609 --- /dev/null +++ b/nuke/Directory.Build.targets @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/nuke/Extensions/StringExtensions.cs b/nuke/Extensions/StringExtensions.cs new file mode 100644 index 0000000..5dd4b54 --- /dev/null +++ b/nuke/Extensions/StringExtensions.cs @@ -0,0 +1,80 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; + +// ReSharper disable once CheckNamespace +/// +/// Contains extension methods for . +/// +/// +/// Original from Cake build tool source: +/// https://github.com/cake-build/cake/blob/9828d7b246d332054896e52ba56983822feb3f05/src/Cake.Core/Extensions/StringExtensions.cs +/// +public static class StringExtensions +{ + /// + /// Quotes the specified . + /// + /// The string to quote. + /// A quoted string. + public static string Quote(this string value) + { + if (!IsQuoted(value)) + { + value = string.Concat("\"", value, "\""); + } + + return value; + } + + /// + /// Unquote the specified . + /// + /// The string to unquote. + /// An unquoted string. + public static string UnQuote(this string value) + { + if (IsQuoted(value)) + { + value = value.Trim('"'); + } + + return value; + } + + /// + /// Splits the into lines. + /// + /// The string to split. + /// The lines making up the provided string. + public static string[] SplitLines(this string content) + { + content = NormalizeLineEndings(content); + return content.Split(new[] { "\r\n" }, StringSplitOptions.None); + } + + /// + /// Normalizes the line endings in a . + /// + /// The string to normalize line endings in. + /// A with normalized line endings. + public static string NormalizeLineEndings(this string value) + { + if (value != null) + { + value = value.Replace("\r\n", "\n"); + value = value.Replace("\r", string.Empty); + return value.Replace("\n", "\r\n"); + } + + return string.Empty; + } + + private static bool IsQuoted(this string value) + { + return value.StartsWith("\"", StringComparison.OrdinalIgnoreCase) + && value.EndsWith("\"", StringComparison.OrdinalIgnoreCase); + } +} \ No newline at end of file diff --git a/nuke/ReleaseNotes.cs b/nuke/ReleaseNotes.cs new file mode 100644 index 0000000..01dcdad --- /dev/null +++ b/nuke/ReleaseNotes.cs @@ -0,0 +1,81 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; + +/// +/// Represent release notes. +/// +/// +/// Original from Cake build tool source: +/// https://github.com/cake-build/cake/blob/9828d7b246d332054896e52ba56983822feb3f05/src/Cake.Common/ReleaseNotes.cs +/// +public sealed class ReleaseNotes +{ + private readonly List _notes; + + /// + /// Gets the version. + /// + /// The version. + public SemVersion SemVersion { get; } + + /// + /// Gets the version. + /// + /// The version. + public Version Version { get; } + + /// + /// Gets the release notes. + /// + /// The release notes. + public IReadOnlyList Notes => _notes; + + /// + /// Gets the raw text of the line that was extracted from. + /// + /// The raw text of the Version line. + public string RawVersionLine { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The semantic version. + /// The notes. + /// The raw text of the version line. + public ReleaseNotes(SemVersion semVersion, IEnumerable notes, string rawVersionLine) + : this( + semVersion?.AssemblyVersion ?? throw new ArgumentNullException(nameof(semVersion)), + semVersion, + notes, + rawVersionLine) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The version. + /// The notes. + /// The raw text of the version line. + public ReleaseNotes(Version version, IEnumerable notes, string rawVersionLine) + : this( + version ?? throw new ArgumentNullException(nameof(version)), + new SemVersion(version.Major, version.Minor, version.Build), + notes, + rawVersionLine) + { + } + + private ReleaseNotes(Version version, SemVersion semVersion, IEnumerable notes, string rawVersionLine) + { + Version = version ?? throw new ArgumentNullException(nameof(version)); + SemVersion = semVersion ?? throw new ArgumentNullException(nameof(semVersion)); + RawVersionLine = rawVersionLine; + _notes = new List(notes ?? Enumerable.Empty()); + } +} \ No newline at end of file diff --git a/nuke/ReleaseNotesParser.cs b/nuke/ReleaseNotesParser.cs new file mode 100644 index 0000000..4b00a07 --- /dev/null +++ b/nuke/ReleaseNotesParser.cs @@ -0,0 +1,156 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using Microsoft.Build.Exceptions; + +/// +/// The release notes parser. +/// +/// +/// Original from Cake build tool source: +/// https://github.com/cake-build/cake/blob/9828d7b246d332054896e52ba56983822feb3f05/src/Cake.Common/ReleaseNotesParser.cs +/// +public sealed class ReleaseNotesParser +{ + private readonly Regex _versionRegex; + + /// + /// Initializes a new instance of the class. + /// + public ReleaseNotesParser() + { + _versionRegex = new Regex(@"(?\d+(\s*\.\s*\d+){0,3})(?-[a-z][0-9a-z-]*)?"); + } + + /// + /// Parses all release notes. + /// + /// The content. + /// All release notes. + public IReadOnlyList Parse(string content) + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + var lines = content.SplitLines(); + if (lines.Length > 0) + { + var line = lines[0].Trim(); + + if (line.StartsWith("#", StringComparison.OrdinalIgnoreCase)) + { + return ParseComplexFormat(lines); + } + + if (line.StartsWith("*", StringComparison.OrdinalIgnoreCase)) + { + return ParseSimpleFormat(lines); + } + } + + throw new BuildAbortedException("Unknown release notes format."); + } + + private IReadOnlyList ParseComplexFormat(string[] lines) + { + var lineIndex = 0; + var result = new List(); + + while (true) + { + if (lineIndex >= lines.Length) + { + break; + } + + // Create release notes. + var semVer = SemVersion.Zero; + var version = SemVersion.TryParse(lines[lineIndex], out semVer); + if (!version) + { + throw new BuildAbortedException("Could not parse version from release notes header."); + } + + var rawVersionLine = lines[lineIndex]; + + // Increase the line index. + lineIndex++; + + // Parse content. + var notes = new List(); + while (true) + { + // Sanity checks. + if (lineIndex >= lines.Length) + { + break; + } + + if (lines[lineIndex].StartsWith("#", StringComparison.OrdinalIgnoreCase)) + { + break; + } + + // Get the current line. + var line = (lines[lineIndex] ?? string.Empty).Trim('*').Trim(); + if (!string.IsNullOrWhiteSpace(line)) + { + notes.Add(line); + } + + lineIndex++; + } + + result.Add(new ReleaseNotes(semVer, notes, rawVersionLine)); + } + + return result.OrderByDescending(x => x.SemVersion).ToArray(); + } + + private IReadOnlyList ParseSimpleFormat(string[] lines) + { + var lineIndex = 0; + var result = new List(); + + while (true) + { + if (lineIndex >= lines.Length) + { + break; + } + + // Trim the current line. + var line = (lines[lineIndex] ?? string.Empty).Trim('*', ' '); + if (string.IsNullOrWhiteSpace(line)) + { + lineIndex++; + continue; + } + + // Parse header. + var semVer = SemVersion.Zero; + var version = SemVersion.TryParse(lines[lineIndex], out semVer); + if (!version) + { + throw new BuildAbortedException("Could not parse version from release notes header."); + } + + // Parse the description. + line = line.Substring(semVer.ToString().Length).Trim('-', ' '); + + // Add the release notes to the result. + result.Add(new ReleaseNotes(semVer, new[] { line }, line)); + + lineIndex++; + } + + return result.OrderByDescending(x => x.SemVersion).ToArray(); + } +} \ No newline at end of file diff --git a/nuke/SemVersion.cs b/nuke/SemVersion.cs new file mode 100644 index 0000000..4a9a715 --- /dev/null +++ b/nuke/SemVersion.cs @@ -0,0 +1,378 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Globalization; +using System.Text; +using System.Text.RegularExpressions; + +/// +/// Class for representing semantic versions. +/// +/// +/// Original from Cake build tool source: +/// https://github.com/cake-build/cake/blob/9828d7b246d332054896e52ba56983822feb3f05/src/Cake.Common/SemanticVersion.cs +/// +public class SemVersion : IComparable, IComparable, IEquatable +{ + /// + /// Gets the default version of a SemanticVersion. + /// + public static SemVersion Zero { get; } = new SemVersion(0, 0, 0, null, null, "0.0.0"); + + /// + /// Regex property for parsing a semantic version number. + /// + public static readonly Regex SemVerRegex = + new Regex( + @"(?0|(?:[1-9]\d*))(?:\.(?0|(?:[1-9]\d*))(?:\.(?0|(?:[1-9]\d*)))?(?:\-(?[0-9A-Z\.-]+))?(?:\+(?[0-9A-Z\.-]+))?)?", + RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture | RegexOptions.IgnoreCase); + + /// + /// Gets the major number of the version. + /// + public int Major { get; } + + /// + /// Gets the minor number of the version. + /// + public int Minor { get; } + + /// + /// Gets the patch number of the version. + /// + public int Patch { get; } + + /// + /// Gets the prerelease of the version. + /// + public string PreRelease { get; } + + /// + /// Gets the meta of the version. + /// + public string Meta { get; } + + /// + /// Gets a value indicating whether semantic version is a prerelease or not. + /// + public bool IsPreRelease { get; } + + /// + /// Gets a value indicating whether semantic version has meta or not. + /// + public bool HasMeta { get; } + + /// + /// Gets the VersionString of the semantic version. + /// + public string VersionString { get; } + + /// + /// Gets the AssemblyVersion of the semantic version. + /// + public Version AssemblyVersion { get; } + + /// + /// Initializes a new instance of the class. + /// + /// Major number. + /// Minor number. + /// Patch number. + /// Prerelease string. + /// Meta string. + public SemVersion(int major, int minor, int patch, string preRelease = null, string meta = null) : this(major, + minor, patch, preRelease, meta, null) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// Major number. + /// Minor number. + /// Patch number. + /// Prerelease string. + /// Meta string. + /// The complete version number. + public SemVersion(int major, int minor, int patch, string preRelease, string meta, string versionString) + { + Major = major; + Minor = minor; + Patch = patch; + AssemblyVersion = new Version(major, minor, patch); + IsPreRelease = !string.IsNullOrEmpty(preRelease); + HasMeta = !string.IsNullOrEmpty(meta); + PreRelease = IsPreRelease ? preRelease : null; + Meta = HasMeta ? meta : null; + + if (!string.IsNullOrEmpty(versionString)) + { + VersionString = versionString; + } + else + { + var sb = new StringBuilder(); + sb.AppendFormat(CultureInfo.InvariantCulture, "{0}.{1}.{2}", Major, Minor, Patch); + + if (IsPreRelease) + { + sb.AppendFormat(CultureInfo.InvariantCulture, "-{0}", PreRelease); + } + + if (HasMeta) + { + sb.AppendFormat(CultureInfo.InvariantCulture, "+{0}", Meta); + } + + VersionString = sb.ToString(); + } + } + + /// + /// Method which tries to parse a semantic version string. + /// + /// the version that should be parsed. + /// the out parameter the parsed version should be stored in. + /// Returns a boolean indicating if the parse was successful. + public static bool TryParse(string version, + out SemVersion semVersion) + { + semVersion = Zero; + + if (string.IsNullOrEmpty(version)) + { + return false; + } + + var match = SemVerRegex.Match(version); + if (!match.Success) + { + return false; + } + + if (!int.TryParse( + match.Groups["Major"].Value, + NumberStyles.Integer, + CultureInfo.InvariantCulture, + out var major) || + !int.TryParse( + match.Groups["Minor"].Value, + NumberStyles.Integer, + CultureInfo.InvariantCulture, + out var minor) || + !int.TryParse( + match.Groups["Patch"].Value, + NumberStyles.Integer, + CultureInfo.InvariantCulture, + out var patch)) + { + return false; + } + + semVersion = new SemVersion( + major, + minor, + patch, + match.Groups["PreRelease"]?.Value, + match.Groups["Meta"]?.Value, + version); + + return true; + } + + /// + /// Checks if two SemVersion objects are equal. + /// + /// the other SemVersion want to test equality to. + /// A boolean indicating whether the objecst we're equal or not. + public bool Equals(SemVersion other) + { + return other is object + && Major == other.Major + && Minor == other.Minor + && Patch == other.Patch + && string.Equals(PreRelease, other.PreRelease, StringComparison.OrdinalIgnoreCase) + && string.Equals(Meta, other.Meta, StringComparison.OrdinalIgnoreCase); + } + + /// + /// Compares to SemVersion objects to and another. + /// + /// The SemVersion object we compare with. + /// Return 0 if the objects are identical, 1 if the version is newer and -1 if the version is older. + public int CompareTo(SemVersion other) + { + if (other is null) + { + return 1; + } + + if (Equals(other)) + { + return 0; + } + + if (Major > other.Major) + { + return 1; + } + + if (Major < other.Major) + { + return -1; + } + + if (Minor > other.Minor) + { + return 1; + } + + if (Minor < other.Minor) + { + return -1; + } + + if (Patch > other.Patch) + { + return 1; + } + + if (Patch < other.Patch) + { + return -1; + } + + if (IsPreRelease != other.IsPreRelease) + { + return other.IsPreRelease ? 1 : -1; + } + + switch (StringComparer.InvariantCultureIgnoreCase.Compare(PreRelease, other.PreRelease)) + { + case 1: + return 1; + + case -1: + return -1; + + default: + { + return (string.IsNullOrEmpty(Meta) != string.IsNullOrEmpty(other.Meta)) + ? string.IsNullOrEmpty(Meta) ? 1 : -1 + : StringComparer.InvariantCultureIgnoreCase.Compare(Meta, other.Meta); + } + } + } + + /// + /// Compares to SemVersion objects to and another. + /// + /// The object we compare with. + /// Return 0 if the objects are identical, 1 if the version is newer and -1 if the version is older. + public int CompareTo(object obj) + { + return (obj is SemVersion semVersion) + ? CompareTo(semVersion) + : -1; + } + + /// + /// Equals-method for the SemVersion class. + /// + /// the other SemVersion want to test equality to. + /// A boolean indicating whether the objecst we're equal or not. + public override bool Equals(object obj) + { + return (obj is SemVersion semVersion) + && Equals(semVersion); + } + + /// + /// Method for getting the hashcode of the SemVersion object. + /// + /// The hashcode of the SemVersion object. + public override int GetHashCode() + { + unchecked + { + var hashCode = Major; + hashCode = (hashCode * 397) ^ Minor; + hashCode = (hashCode * 397) ^ Patch; + hashCode = (hashCode * 397) ^ + (PreRelease != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(PreRelease) : 0); + hashCode = (hashCode * 397) ^ (Meta != null ? StringComparer.OrdinalIgnoreCase.GetHashCode(Meta) : 0); + return hashCode; + } + } + + /// + /// Returns the string representation of an SemVersion object. + /// + /// The string representation of the object. + public override string ToString() + { + int[] verParts = { Major, Minor, Patch }; + string ver = string.Join(".", verParts); + return $"{ver}{(IsPreRelease ? "-" : string.Empty)}{PreRelease}{Meta}"; + } + + /// + /// The greater than-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was greater than operand2. + public static bool operator >(SemVersion operand1, SemVersion operand2) + => operand1 is { } && operand1.CompareTo(operand2) == 1; + + /// + /// The less than-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was less than operand2. + public static bool operator <(SemVersion operand1, SemVersion operand2) + => operand1 is { } + ? operand1.CompareTo(operand2) == -1 + : operand2 is { }; + + /// + /// The greater than or equal to-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was greater than or equal to operand2. + public static bool operator >=(SemVersion operand1, SemVersion operand2) + => operand1 is { } + ? operand1.CompareTo(operand2) >= 0 + : operand2 is null; + + /// + /// The lesser than or equal to-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was lesser than or equal to operand2. + public static bool operator <=(SemVersion operand1, SemVersion operand2) + => operand1 is null || operand1.CompareTo(operand2) <= 0; + + /// + /// The equal to-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was equal to operand2. + public static bool operator ==(SemVersion operand1, SemVersion operand2) + => operand1?.Equals(operand2) ?? operand2 is null; + + /// + /// The not equal to-operator for the SemVersion class. + /// + /// first SemVersion. + /// second. SemVersion. + /// A value indicating if the operand1 was not equal to operand2. + public static bool operator !=(SemVersion operand1, SemVersion operand2) + => !(operand1?.Equals(operand2) ?? operand2 is null); +} \ No newline at end of file diff --git a/nuke/_build.csproj b/nuke/_build.csproj new file mode 100644 index 0000000..7521e1b --- /dev/null +++ b/nuke/_build.csproj @@ -0,0 +1,21 @@ + + + + Exe + net6.0 + + CS0649;CS0169 + .. + .. + 1 + + + + + + + + + + + diff --git a/src/AngleSharp.Io.Tests/AngleSharp.Io.Tests.csproj b/src/AngleSharp.Io.Tests/AngleSharp.Io.Tests.csproj index 6661e89..eb013d1 100644 --- a/src/AngleSharp.Io.Tests/AngleSharp.Io.Tests.csproj +++ b/src/AngleSharp.Io.Tests/AngleSharp.Io.Tests.csproj @@ -4,7 +4,7 @@ true Key.snk false - 7.1 + 9 AngleSharp.Io.Tests true @@ -17,7 +17,7 @@ - + diff --git a/src/AngleSharp.Io.nuspec b/src/AngleSharp.Io.nuspec index 72877cc..703d530 100644 --- a/src/AngleSharp.Io.nuspec +++ b/src/AngleSharp.Io.nuspec @@ -11,10 +11,10 @@ false Providers additional requesters and IO helpers for AngleSharp. https://github.com/AngleSharp/AngleSharp.Io/blob/main/CHANGELOG.md - Copyright 2016-2022, AngleSharp + Copyright 2016-2023, AngleSharp html html5 css css3 dom requester http https io filesystem storage httpclient cache - + diff --git a/src/AngleSharp.Io/AngleSharp.Io.csproj b/src/AngleSharp.Io/AngleSharp.Io.csproj index 8665678..3e07a2c 100644 --- a/src/AngleSharp.Io/AngleSharp.Io.csproj +++ b/src/AngleSharp.Io/AngleSharp.Io.csproj @@ -2,12 +2,12 @@ AngleSharp.Io AngleSharp.Io - netstandard2.0 - netstandard2.0;net461;net472 + netstandard2.0;net6.0;net7.0 + netstandard2.0;net461;net472;net6.0;net7.0 true Key.snk true - 7.1 + 9 https://github.com/AngleSharp/AngleSharp.Io git true @@ -21,7 +21,7 @@ - + diff --git a/tools/anglesharp.cake b/tools/anglesharp.cake deleted file mode 100644 index b9d674b..0000000 --- a/tools/anglesharp.cake +++ /dev/null @@ -1,198 +0,0 @@ -#addin nuget:?package=Cake.FileHelpers&version=3.2.0 -#addin nuget:?package=Octokit&version=0.32.0 -using Octokit; - -var configuration = Argument("configuration", "Release"); -var isRunningOnUnix = IsRunningOnUnix(); -var isRunningOnWindows = IsRunningOnWindows(); -var isRunningOnGitHubActions = BuildSystem.GitHubActions.IsRunningOnGitHubActions; -var releaseNotes = ParseReleaseNotes("./CHANGELOG.md"); -var version = releaseNotes.Version.ToString(); -var buildDir = Directory($"./src/{projectName}/bin") + Directory(configuration); -var buildResultDir = Directory("./bin") + Directory(version); -var nugetRoot = buildResultDir + Directory("nuget"); - -if (isRunningOnGitHubActions) -{ - var buildNumber = BuildSystem.GitHubActions.Environment.Workflow.RunNumber; - - if (target == "Default") - { - version = $"{version}-ci-{buildNumber}"; - } - else if (target == "PrePublish") - { - version = $"{version}-alpha-{buildNumber}"; - } -} - -if (!isRunningOnWindows) -{ - frameworks.Remove("net461"); - frameworks.Remove("net472"); -} - -// Initialization -// ---------------------------------------- - -Setup(_ => -{ - Information($"Building version {version} of {projectName}."); - Information("For the publish target the following environment variables need to be set:"); - Information("- NUGET_API_KEY"); - Information("- GITHUB_API_TOKEN"); -}); - -// Tasks -// ---------------------------------------- - -Task("Clean") - .Does(() => - { - CleanDirectories(new DirectoryPath[] { buildDir, buildResultDir, nugetRoot }); - }); - -Task("Restore-Packages") - .IsDependentOn("Clean") - .Does(() => - { - NuGetRestore($"./src/{solutionName}.sln", new NuGetRestoreSettings - { - ToolPath = "tools/nuget.exe", - }); - }); - -Task("Build") - .IsDependentOn("Restore-Packages") - .Does(() => - { - ReplaceRegexInFiles("./src/Directory.Build.props", "(?<=)(.+?)(?=)", version); - DotNetCoreBuild($"./src/{solutionName}.sln", new DotNetCoreBuildSettings - { - Configuration = configuration, - }); - }); - -Task("Run-Unit-Tests") - .IsDependentOn("Build") - .Does(() => - { - var settings = new DotNetCoreTestSettings - { - Configuration = configuration, - }; - - if (isRunningOnGitHubActions) - { - settings.Loggers.Add("GitHubActions"); - } - - DotNetCoreTest($"./src/{solutionName}.Tests/", settings); - }); - -Task("Copy-Files") - .IsDependentOn("Build") - .Does(() => - { - foreach (var item in frameworks) - { - var targetDir = nugetRoot + Directory("lib") + Directory(item.Key); - CreateDirectory(targetDir); - CopyFiles(new FilePath[] - { - buildDir + Directory(item.Value) + File($"{projectName}.dll"), - buildDir + Directory(item.Value) + File($"{projectName}.xml"), - }, targetDir); - } - - CopyFiles(new FilePath[] { - $"src/{projectName}.nuspec", - "logo.png" - }, nugetRoot); - }); - -Task("Create-Package") - .IsDependentOn("Copy-Files") - .Does(() => - { - var nugetExe = GetFiles("./tools/**/nuget.exe").FirstOrDefault() - ?? throw new InvalidOperationException("Could not find nuget.exe."); - - var nuspec = nugetRoot + File($"{projectName}.nuspec"); - - NuGetPack(nuspec, new NuGetPackSettings - { - Version = version, - OutputDirectory = nugetRoot, - Symbols = false, - Properties = new Dictionary - { - { "Configuration", configuration }, - }, - }); - }); - -Task("Publish-Package") - .IsDependentOn("Create-Package") - .IsDependentOn("Run-Unit-Tests") - .Does(() => - { - var apiKey = EnvironmentVariable("NUGET_API_KEY"); - - if (String.IsNullOrEmpty(apiKey)) - { - throw new InvalidOperationException("Could not resolve the NuGet API key."); - } - - foreach (var nupkg in GetFiles(nugetRoot.Path.FullPath + "/*.nupkg")) - { - NuGetPush(nupkg, new NuGetPushSettings - { - Source = "https://nuget.org/api/v2/package", - ApiKey = apiKey, - }); - } - }); - -Task("Publish-Release") - .IsDependentOn("Publish-Package") - .IsDependentOn("Run-Unit-Tests") - .Does(() => - { - var githubToken = EnvironmentVariable("GITHUB_TOKEN"); - - if (String.IsNullOrEmpty(githubToken)) - { - throw new InvalidOperationException("Could not resolve GitHub token."); - } - - var github = new GitHubClient(new ProductHeaderValue("AngleSharpCakeBuild")) - { - Credentials = new Credentials(githubToken), - }; - - var newRelease = github.Repository.Release; - newRelease.Create("AngleSharp", projectName, new NewRelease("v" + version) - { - Name = version, - Body = String.Join(Environment.NewLine, releaseNotes.Notes), - Prerelease = false, - TargetCommitish = "main", - }).Wait(); - }); - -// Targets -// ---------------------------------------- - -Task("Package") - .IsDependentOn("Run-Unit-Tests") - .IsDependentOn("Create-Package"); - -Task("Default") - .IsDependentOn("Package"); - -Task("Publish") - .IsDependentOn("Publish-Release"); - -Task("PrePublish") - .IsDependentOn("Publish-Package"); diff --git a/tools/packages.config b/tools/packages.config deleted file mode 100644 index e714645..0000000 --- a/tools/packages.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file