From 9293ff87dc3350c1268140ba1e9295c744eb3658 Mon Sep 17 00:00:00 2001 From: Dennis Doomen Date: Tue, 3 Dec 2024 08:29:41 +0100 Subject: [PATCH] Bumped Nuke to v9 --- Build/Build.cs | 26 ++++++++++++++++---------- Build/CustomNpmTasks.cs | 5 +++-- Build/_build.csproj | 3 ++- build.ps1 | 33 +++++++++++++-------------------- build.sh | 33 +++++++++++++-------------------- global.json | 8 ++++---- 6 files changed, 51 insertions(+), 57 deletions(-) diff --git a/Build/Build.cs b/Build/Build.cs index e377fa3187..4be48db9e0 100644 --- a/Build/Build.cs +++ b/Build/Build.cs @@ -120,7 +120,7 @@ class Build : NukeBuild DotNetBuild(s => s .SetProjectFile(Solution) .SetConfiguration(Configuration) - .When(GenerateBinLog is true, c => c + .When(_ => GenerateBinLog is true, c => c .SetBinaryLog(ArtifactsDirectory / $"{Solution.Core.FluentAssertions.Name}.binlog") ) .EnableNoLogo() @@ -298,12 +298,12 @@ from framework in frameworks (settings, v) => settings .SetProjectFile(v.project) .SetFramework(v.framework) - .SetProcessArgumentConfigurator(args => args - .Add("--") - .Add("--coverage") - .Add("--report-trx") - .Add($"--report-trx-filename {v.project.Name}_{v.framework}.trx") - .Add($"--results-directory {TestResultsDirectory}") + .SetProcessAdditionalArguments( + "--", + "--coverage", + "--report-trx", + $"--report-trx-filename {v.project.Name}_{v.framework}.trx", + $"--results-directory {TestResultsDirectory}" ) ) ); @@ -373,9 +373,15 @@ from framework in frameworks NpmFetchRuntime(); - ReportSummary(s => s - .When(HasCachedNodeModules, conf => conf - .AddPair("Skipped", "Downloading and extracting"))); + ReportSummary(conf => + { + if (HasCachedNodeModules) + { + conf.AddPair("Skipped", "Downloading and extracting"); + } + + return conf; + }); }); bool HasDocumentationChanges => Changes.Any(x => IsDocumentation(x)); diff --git a/Build/CustomNpmTasks.cs b/Build/CustomNpmTasks.cs index 9b71d312d3..840bf988ea 100644 --- a/Build/CustomNpmTasks.cs +++ b/Build/CustomNpmTasks.cs @@ -167,9 +167,10 @@ static void LinkTools() static void SetEnvVars() { - NpmEnvironmentVariables = NukeDictionaryExtensions.AsReadOnly(EnvironmentInfo.Variables + NpmEnvironmentVariables = EnvironmentInfo.Variables .ToDictionary(x => x.Key, x => x.Value) - .SetKeyValue("path", WorkingDirectory)); + .SetKeyValue("path", WorkingDirectory) + .AsReadOnly(); } public static void NpmInstall(bool silent = false, string workingDirectory = null) diff --git a/Build/_build.csproj b/Build/_build.csproj index dc49eed481..273671c2cd 100644 --- a/Build/_build.csproj +++ b/Build/_build.csproj @@ -7,6 +7,7 @@ ..\ ..\ 8.1.4 + 1 OS_WINDOWS @@ -22,7 +23,7 @@ - + diff --git a/build.ps1 b/build.ps1 index f21bd6129c..4634dc03e9 100644 --- a/build.ps1 +++ b/build.ps1 @@ -14,18 +14,14 @@ $PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent ########################################################################### $BuildProjectFile = "$PSScriptRoot\build\_build.csproj" -$TempDirectory = "$PSScriptRoot\.nuke\temp" +$TempDirectory = "$PSScriptRoot\\.nuke\temp" -$DotNetGlobalFile = "$PSScriptRoot\global.json" +$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_ROLL_FORWARD = "Major" -$env:NUKE_TELEMETRY_OPTOUT = 1 -$env:DOTNET_CLI_UI_LANGUAGE = "en-US" +$env:DOTNET_NOLOGO = 1 ########################################################################### # EXECUTION @@ -36,18 +32,9 @@ function ExecSafe([scriptblock] $cmd) { if ($LASTEXITCODE) { exit $LASTEXITCODE } } -# Print environment variables -# WARNING: Make sure that secrets are actually scrambled in build log -# Get-Item -Path Env:* | Sort-Object -Property Name | ForEach-Object {"{0}={1}" -f $_.Name,$_.Value} - -# Check if any dotnet is installed -if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue)) { - ExecSafe { & dotnet --info } -} - # 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) { + $(dotnet --version) -and $LASTEXITCODE -eq 0) { $env:DOTNET_EXE = (Get-Command "dotnet").Path } else { @@ -73,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 Core SDK version $(& $env:DOTNET_EXE --version)" +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 } +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 d691404685..fdff0c6236 100755 --- a/build.sh +++ b/build.sh @@ -9,19 +9,15 @@ SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd) # CONFIGURATION ########################################################################### -BUILD_PROJECT_FILE="$SCRIPT_DIR/Build/_build.csproj" -TEMP_DIRECTORY="$SCRIPT_DIR/.nuke/temp" +BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj" +TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp" -DOTNET_GLOBAL_FILE="$SCRIPT_DIR/global.json" +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_ROLL_FORWARD="Major" -export NUKE_TELEMETRY_OPTOUT=1 -export DOTNET_CLI_UI_LANGUAGE="en-US" +export DOTNET_NOLOGO=1 ########################################################################### # EXECUTION @@ -31,15 +27,6 @@ function FirstJsonValue { perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}" } -# Print environment variables -# WARNING: Make sure that secrets are actually scrambled in build log -# env | sort - -# Check if any dotnet is installed -if [[ -x "$(command -v dotnet)" ]]; then - dotnet --info -fi - # 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)" @@ -66,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 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 /p:UseSharedCompilation=false -nologo -clp:NoSummary +"$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/global.json b/global.json index 368a14e31c..b829814972 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { - "sdk": { - "version": "8.0.100", - "rollForward": "latestMajor" - } + "sdk": { + "version": "8.0.404", + "rollForward": "latestMajor" + } }