Skip to content

Commit

Permalink
Bumped Nuke to v9
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisdoomen committed Dec 3, 2024
1 parent c14f48b commit 9293ff8
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 57 deletions.
26 changes: 16 additions & 10 deletions Build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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}"
)
)
);
Expand Down Expand Up @@ -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));
Expand Down
5 changes: 3 additions & 2 deletions Build/CustomNpmTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion Build/_build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<NukeRootDirectory>..\</NukeRootDirectory>
<NukeScriptDirectory>..\</NukeScriptDirectory>
<NukeVersion>8.1.4</NukeVersion>
<NukeTelemetryVersion>1</NukeTelemetryVersion>
</PropertyGroup>
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Windows'))">
<DefineConstants>OS_WINDOWS</DefineConstants>
Expand All @@ -22,7 +23,7 @@
<PackageDownload Include="ReportGenerator" Version="[5.2.0]" />
<PackageDownload Include="xunit.runner.console" Version="[2.9.2]" />
<PackageReference Include="LibGit2Sharp" Version="0.30.0" />
<PackageReference Include="Nuke.Common" Version="$(NukeVersion)" />
<PackageReference Include="Nuke.Common" Version="9.0.2" />
<PackageReference Include="Nuke.Components" Version="$(NukeVersion)" />
<PackageReference Include="SharpCompress" Version="0.38.0" />
<PackageReference Include="System.Formats.Asn1" Version="9.0.0" />
Expand Down
33 changes: 13 additions & 20 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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 }
33 changes: 13 additions & 20 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)"
Expand All @@ -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 -- "$@"
8 changes: 4 additions & 4 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.100",
"rollForward": "latestMajor"
}
"sdk": {
"version": "8.0.404",
"rollForward": "latestMajor"
}
}

0 comments on commit 9293ff8

Please sign in to comment.