From 2c68f60d1fdd4b6539964223fecb1c74d4ba6caa Mon Sep 17 00:00:00 2001 From: Marko Lahma Date: Sat, 13 Apr 2024 11:55:09 +0300 Subject: [PATCH] Upgrade to NUKE 8 * enable deterministic build --- .nuke/build.schema.json | 4 ++-- build.cmd | 0 build.ps1 | 11 ++++++++--- build.sh | 11 ++++++++--- nuke/Build.cs | 16 +++++++++------- nuke/_build.csproj | 4 ++-- src/AngleSharp.Js.sln | 2 ++ 7 files changed, 31 insertions(+), 17 deletions(-) mode change 100644 => 100755 build.cmd diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index c1999a9..7616e4d 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -1,7 +1,7 @@ { "$schema": "http://json-schema.org/draft-04/schema#", - "title": "Build Schema", "$ref": "#/definitions/build", + "title": "Build Schema", "definitions": { "build": { "type": "object", @@ -131,4 +131,4 @@ } } } -} \ No newline at end of file +} diff --git a/build.cmd b/build.cmd old mode 100644 new mode 100755 diff --git a/build.ps1 b/build.ps1 index 1f264e7..3cca4ef 100644 --- a/build.ps1 +++ b/build.ps1 @@ -18,11 +18,10 @@ $TempDirectory = "$PSScriptRoot\\.nuke\temp" $DotNetGlobalFile = "$PSScriptRoot\\global.json" $DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1" -$DotNetChannel = "Current" +$DotNetChannel = "STS" -$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 $env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 -$env:DOTNET_MULTILEVEL_LOOKUP = 0 +$env:DOTNET_NOLOGO = 1 ########################################################################### # EXECUTION @@ -61,9 +60,15 @@ 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 7534123..a226b96 100755 --- a/build.sh +++ b/build.sh @@ -14,11 +14,10 @@ TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json" DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh" -DOTNET_CHANNEL="Current" +DOTNET_CHANNEL="STS" export DOTNET_CLI_TELEMETRY_OPTOUT=1 -export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 -export DOTNET_MULTILEVEL_LOOKUP=0 +export DOTNET_NOLOGO=1 ########################################################################### # EXECUTION @@ -54,9 +53,15 @@ 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 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 /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet "$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@" diff --git a/nuke/Build.cs b/nuke/Build.cs index 43ecd98..d8cd73a 100644 --- a/nuke/Build.cs +++ b/nuke/Build.cs @@ -16,7 +16,6 @@ using System.Linq; using Nuke.Common.Tooling; 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; @@ -100,7 +99,7 @@ protected override void OnBuildInitialized() Log.Information("Building version: {Version}", Version); - TargetProject = Solution.GetProject(SourceDirectory / TargetProjectName / $"{TargetLibName}.csproj" ); + TargetProject = Solution.GetProject(TargetLibName); TargetProject.NotNull("TargetProject could not be loaded!"); TargetFrameworks = TargetProject.GetTargetFrameworks(); @@ -113,7 +112,7 @@ protected override void OnBuildInitialized() .Before(Restore) .Executes(() => { - SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory); + SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(x => x.DeleteDirectory()); }); Target Restore => _ => _ @@ -130,6 +129,7 @@ protected override void OnBuildInitialized() DotNetBuild(s => s .SetProjectFile(Solution) .SetConfiguration(Configuration) + .SetContinuousIntegrationBuild(IsServerBuild) .EnableNoRestore()); }); @@ -143,6 +143,7 @@ protected override void OnBuildInitialized() .EnableNoRestore() .EnableNoBuild() .SetProcessEnvironmentVariable("prefetched", "false") + .When(GitHubActions.Instance is not null, x => x.SetLoggers("GitHubActions")) ); DotNetTest(s => s @@ -151,6 +152,7 @@ protected override void OnBuildInitialized() .EnableNoRestore() .EnableNoBuild() .SetProcessEnvironmentVariable("prefetched", "true") + .When(GitHubActions.Instance is not null, x => x.SetLoggers("GitHubActions")) ); }); @@ -183,9 +185,9 @@ protected override void OnBuildInitialized() .SetTargetPath(nuspec) .SetVersion(Version) .SetOutputDirectory(NugetDirectory) - .SetSymbols(true) - .SetSymbolPackageFormat("snupkg") - .AddProperty("Configuration", Configuration) + .EnableSymbols() + .SetSymbolPackageFormat(NuGetSymbolPackageFormat.snupkg) + .SetConfiguration(Configuration) ); }); @@ -202,7 +204,7 @@ protected override void OnBuildInitialized() throw new BuildAbortedException("Could not resolve the NuGet API key."); } - foreach (var nupkg in GlobFiles(NugetDirectory, "*.nupkg")) + foreach (var nupkg in NugetDirectory.GlobFiles("*.nupkg")) { NuGetPush(s => s .SetTargetPath(nupkg) diff --git a/nuke/_build.csproj b/nuke/_build.csproj index 7521e1b..a71fa1b 100644 --- a/nuke/_build.csproj +++ b/nuke/_build.csproj @@ -2,7 +2,7 @@ Exe - net6.0 + net8.0 CS0649;CS0169 .. @@ -11,7 +11,7 @@ - + diff --git a/src/AngleSharp.Js.sln b/src/AngleSharp.Js.sln index 46555c8..4ef0c1c 100644 --- a/src/AngleSharp.Js.sln +++ b/src/AngleSharp.Js.sln @@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AngleSharp.Js", "AngleSharp EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AngleSharp.Js.Tests", "AngleSharp.Js.Tests\AngleSharp.Js.Tests.csproj", "{18B0B97B-8795-4DC2-A1E7-8070255BE718}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "_build", "..\nuke\_build.csproj", "{07DA52AA-8F6F-4F43-B09E-6AE899E95E43}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU