Skip to content

Commit e4363c4

Browse files
committed
nuke (but not reference to build porjects)
1 parent 7540683 commit e4363c4

14 files changed

+400
-1
lines changed

.nuke/build.schema.json

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "Build Schema",
4+
"$ref": "#/definitions/build",
5+
"definitions": {
6+
"build": {
7+
"type": "object",
8+
"properties": {
9+
"Configuration": {
10+
"type": "string",
11+
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
12+
"enum": [
13+
"Debug",
14+
"Release"
15+
]
16+
},
17+
"Continue": {
18+
"type": "boolean",
19+
"description": "Indicates to continue a previously failed build attempt"
20+
},
21+
"Help": {
22+
"type": "boolean",
23+
"description": "Shows the help text for this build assembly"
24+
},
25+
"Host": {
26+
"type": "string",
27+
"description": "Host for execution. Default is 'automatic'",
28+
"enum": [
29+
"AppVeyor",
30+
"AzurePipelines",
31+
"Bamboo",
32+
"Bitbucket",
33+
"Bitrise",
34+
"GitHubActions",
35+
"GitLab",
36+
"Jenkins",
37+
"Rider",
38+
"SpaceAutomation",
39+
"TeamCity",
40+
"Terminal",
41+
"TravisCI",
42+
"VisualStudio",
43+
"VSCode"
44+
]
45+
},
46+
"NoLogo": {
47+
"type": "boolean",
48+
"description": "Disables displaying the NUKE logo"
49+
},
50+
"Partition": {
51+
"type": "string",
52+
"description": "Partition to use on CI"
53+
},
54+
"Plan": {
55+
"type": "boolean",
56+
"description": "Shows the execution plan (HTML)"
57+
},
58+
"Profile": {
59+
"type": "array",
60+
"description": "Defines the profiles to load",
61+
"items": {
62+
"type": "string"
63+
}
64+
},
65+
"Root": {
66+
"type": "string",
67+
"description": "Root directory during build execution"
68+
},
69+
"Skip": {
70+
"type": "array",
71+
"description": "List of targets to be skipped. Empty list skips all dependencies",
72+
"items": {
73+
"type": "string",
74+
"enum": [
75+
"Clean",
76+
"Compile",
77+
"Restore"
78+
]
79+
}
80+
},
81+
"Target": {
82+
"type": "array",
83+
"description": "List of targets to be invoked. Default is '{default_target}'",
84+
"items": {
85+
"type": "string",
86+
"enum": [
87+
"Clean",
88+
"Compile",
89+
"Restore"
90+
]
91+
}
92+
},
93+
"Verbosity": {
94+
"type": "string",
95+
"description": "Logging verbosity during build execution. Default is 'Normal'",
96+
"enum": [
97+
"Minimal",
98+
"Normal",
99+
"Quiet",
100+
"Verbose"
101+
]
102+
}
103+
}
104+
}
105+
}
106+
}

.nuke/parameters.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./build.schema.json",
3+
"Solution": "XunitLoggerSolution.sln"
4+
}

XunitLoggerSolution.sln

+4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@ Project("{0FE5DA83-E1B1-40C8-AD5D-85D5C7B96E69}") = "Xunit.Logging", "src\XunitL
77
EndProject
88
Project("{E56A8E82-7E73-4721-B961-06DFBDF0F11D}") = "XunitLoggerTest", "tests\XunitLoggerTest\XunitLoggerTest.csproj", "{E56A8E82-7E73-4721-B961-06DFBDF0F11D}"
99
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "_build", "build\_build.csproj", "{B7250922-064A-49ED-971F-5E7F760D57FB}"
11+
EndProject
1012
Global
1113
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1214
Debug|Any CPU = Debug|Any CPU
1315
Release|Any CPU = Release|Any CPU
1416
EndGlobalSection
1517
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{B7250922-064A-49ED-971F-5E7F760D57FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{B7250922-064A-49ED-971F-5E7F760D57FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
1620
{0FE5DA83-E1B1-40C8-AD5D-85D5C7B96E69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1721
{0FE5DA83-E1B1-40C8-AD5D-85D5C7B96E69}.Debug|Any CPU.Build.0 = Debug|Any CPU
1822
{0FE5DA83-E1B1-40C8-AD5D-85D5C7B96E69}.Release|Any CPU.ActiveCfg = Release|Any CPU

build.cmd

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
:; set -eo pipefail
2+
:; SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
3+
:; ${SCRIPT_DIR}/build.sh "$@"
4+
:; exit $?
5+
6+
@ECHO OFF
7+
powershell -ExecutionPolicy ByPass -NoProfile -File "%~dp0build.ps1" %*

build.ps1

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
[CmdletBinding()]
2+
Param(
3+
[Parameter(Position=0,Mandatory=$false,ValueFromRemainingArguments=$true)]
4+
[string[]]$BuildArguments
5+
)
6+
7+
Write-Output "PowerShell $($PSVersionTable.PSEdition) version $($PSVersionTable.PSVersion)"
8+
9+
Set-StrictMode -Version 2.0; $ErrorActionPreference = "Stop"; $ConfirmPreference = "None"; trap { Write-Error $_ -ErrorAction Continue; exit 1 }
10+
$PSScriptRoot = Split-Path $MyInvocation.MyCommand.Path -Parent
11+
12+
###########################################################################
13+
# CONFIGURATION
14+
###########################################################################
15+
16+
$BuildProjectFile = "$PSScriptRoot\build\_build.csproj"
17+
$TempDirectory = "$PSScriptRoot\\.nuke\temp"
18+
19+
$DotNetGlobalFile = "$PSScriptRoot\\global.json"
20+
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
21+
$DotNetChannel = "Current"
22+
23+
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
24+
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
25+
$env:DOTNET_MULTILEVEL_LOOKUP = 0
26+
27+
###########################################################################
28+
# EXECUTION
29+
###########################################################################
30+
31+
function ExecSafe([scriptblock] $cmd) {
32+
& $cmd
33+
if ($LASTEXITCODE) { exit $LASTEXITCODE }
34+
}
35+
36+
# If dotnet CLI is installed globally and it matches requested version, use for execution
37+
if ($null -ne (Get-Command "dotnet" -ErrorAction SilentlyContinue) -and `
38+
$(dotnet --version) -and $LASTEXITCODE -eq 0) {
39+
$env:DOTNET_EXE = (Get-Command "dotnet").Path
40+
}
41+
else {
42+
# Download install script
43+
$DotNetInstallFile = "$TempDirectory\dotnet-install.ps1"
44+
New-Item -ItemType Directory -Path $TempDirectory -Force | Out-Null
45+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
46+
(New-Object System.Net.WebClient).DownloadFile($DotNetInstallUrl, $DotNetInstallFile)
47+
48+
# If global.json exists, load expected version
49+
if (Test-Path $DotNetGlobalFile) {
50+
$DotNetGlobal = $(Get-Content $DotNetGlobalFile | Out-String | ConvertFrom-Json)
51+
if ($DotNetGlobal.PSObject.Properties["sdk"] -and $DotNetGlobal.sdk.PSObject.Properties["version"]) {
52+
$DotNetVersion = $DotNetGlobal.sdk.version
53+
}
54+
}
55+
56+
# Install by channel or version
57+
$DotNetDirectory = "$TempDirectory\dotnet-win"
58+
if (!(Test-Path variable:DotNetVersion)) {
59+
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Channel $DotNetChannel -NoPath }
60+
} else {
61+
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
62+
}
63+
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
64+
}
65+
66+
Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"
67+
68+
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
69+
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }

build.sh

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
3+
bash --version 2>&1 | head -n 1
4+
5+
set -eo pipefail
6+
SCRIPT_DIR=$(cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd)
7+
8+
###########################################################################
9+
# CONFIGURATION
10+
###########################################################################
11+
12+
BUILD_PROJECT_FILE="$SCRIPT_DIR/build/_build.csproj"
13+
TEMP_DIRECTORY="$SCRIPT_DIR//.nuke/temp"
14+
15+
DOTNET_GLOBAL_FILE="$SCRIPT_DIR//global.json"
16+
DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
17+
DOTNET_CHANNEL="Current"
18+
19+
export DOTNET_CLI_TELEMETRY_OPTOUT=1
20+
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
21+
export DOTNET_MULTILEVEL_LOOKUP=0
22+
23+
###########################################################################
24+
# EXECUTION
25+
###########################################################################
26+
27+
function FirstJsonValue {
28+
perl -nle 'print $1 if m{"'"$1"'": "([^"]+)",?}' <<< "${@:2}"
29+
}
30+
31+
# If dotnet CLI is installed globally and it matches requested version, use for execution
32+
if [ -x "$(command -v dotnet)" ] && dotnet --version &>/dev/null; then
33+
export DOTNET_EXE="$(command -v dotnet)"
34+
else
35+
# Download install script
36+
DOTNET_INSTALL_FILE="$TEMP_DIRECTORY/dotnet-install.sh"
37+
mkdir -p "$TEMP_DIRECTORY"
38+
curl -Lsfo "$DOTNET_INSTALL_FILE" "$DOTNET_INSTALL_URL"
39+
chmod +x "$DOTNET_INSTALL_FILE"
40+
41+
# If global.json exists, load expected version
42+
if [[ -f "$DOTNET_GLOBAL_FILE" ]]; then
43+
DOTNET_VERSION=$(FirstJsonValue "version" "$(cat "$DOTNET_GLOBAL_FILE")")
44+
if [[ "$DOTNET_VERSION" == "" ]]; then
45+
unset DOTNET_VERSION
46+
fi
47+
fi
48+
49+
# Install by channel or version
50+
DOTNET_DIRECTORY="$TEMP_DIRECTORY/dotnet-unix"
51+
if [[ -z ${DOTNET_VERSION+x} ]]; then
52+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --channel "$DOTNET_CHANNEL" --no-path
53+
else
54+
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
55+
fi
56+
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
57+
fi
58+
59+
echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"
60+
61+
"$DOTNET_EXE" build "$BUILD_PROJECT_FILE" /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet
62+
"$DOTNET_EXE" run --project "$BUILD_PROJECT_FILE" --no-build -- "$@"

build/.editorconfig

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[*.cs]
2+
dotnet_style_qualification_for_field = false:warning
3+
dotnet_style_qualification_for_property = false:warning
4+
dotnet_style_qualification_for_method = false:warning
5+
dotnet_style_qualification_for_event = false:warning
6+
dotnet_style_require_accessibility_modifiers = never:warning
7+
8+
csharp_style_expression_bodied_methods = true:silent
9+
csharp_style_expression_bodied_properties = true:warning
10+
csharp_style_expression_bodied_indexers = true:warning
11+
csharp_style_expression_bodied_accessors = true:warning

build/Build.cs

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.Linq;
3+
using Nuke.Common;
4+
using Nuke.Common.CI;
5+
using Nuke.Common.Execution;
6+
using Nuke.Common.Git;
7+
using Nuke.Common.IO;
8+
using Nuke.Common.ProjectModel;
9+
using Nuke.Common.Tooling;
10+
using Nuke.Common.Utilities.Collections;
11+
using static Nuke.Common.EnvironmentInfo;
12+
using static Nuke.Common.IO.FileSystemTasks;
13+
using static Nuke.Common.IO.PathConstruction;
14+
15+
class Build : NukeBuild
16+
{
17+
/// Support plugins are available for:
18+
/// - JetBrains ReSharper https://nuke.build/resharper
19+
/// - JetBrains Rider https://nuke.build/rider
20+
/// - Microsoft VisualStudio https://nuke.build/visualstudio
21+
/// - Microsoft VSCode https://nuke.build/vscode
22+
23+
public static int Main () => Execute<Build>(x => x.Compile);
24+
25+
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
26+
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
27+
28+
[Solution] readonly Solution Solution;
29+
[GitRepository] readonly GitRepository GitRepository;
30+
31+
AbsolutePath SourceDirectory => RootDirectory / "src";
32+
AbsolutePath TestsDirectory => RootDirectory / "tests";
33+
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
34+
35+
Target Clean => _ => _
36+
.Before(Restore)
37+
.Executes(() =>
38+
{
39+
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
40+
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(DeleteDirectory);
41+
EnsureCleanDirectory(ArtifactsDirectory);
42+
});
43+
44+
Target Restore => _ => _
45+
.Executes(() =>
46+
{
47+
DotNetRestore(s => s
48+
.SetProjectFile(Solution));
49+
});
50+
51+
Target Compile => _ => _
52+
.DependsOn(Restore)
53+
.Executes(() =>
54+
{
55+
DotNetBuild(s => s
56+
.SetProjectFile(Solution)
57+
.SetConfiguration(Configuration)
58+
.EnableNoRestore());
59+
});
60+
61+
}

build/Configuration.cs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System;
2+
using System.ComponentModel;
3+
using System.Linq;
4+
using Nuke.Common.Tooling;
5+
6+
[TypeConverter(typeof(TypeConverter<Configuration>))]
7+
public class Configuration : Enumeration
8+
{
9+
public static Configuration Debug = new Configuration { Value = nameof(Debug) };
10+
public static Configuration Release = new Configuration { Value = nameof(Release) };
11+
12+
public static implicit operator string(Configuration configuration)
13+
{
14+
return configuration.Value;
15+
}
16+
}

build/Directory.Build.props

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<!-- This file prevents unintended imports of unrelated MSBuild files -->
5+
<!-- Uncomment to include parent Directory.Build.props file -->
6+
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />-->
7+
8+
</Project>

build/Directory.Build.targets

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<!-- This file prevents unintended imports of unrelated MSBuild files -->
5+
<!-- Uncomment to include parent Directory.Build.targets file -->
6+
<!--<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.targets', '$(MSBuildThisFileDirectory)../'))" />-->
7+
8+
</Project>

build/_build.csproj

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
<RootNamespace></RootNamespace>
7+
<NoWarn>CS0649;CS0169</NoWarn>
8+
<NukeRootDirectory>..</NukeRootDirectory>
9+
<NukeScriptDirectory>..</NukeScriptDirectory>
10+
<NukeTelemetryVersion>1</NukeTelemetryVersion>
11+
</PropertyGroup>
12+
13+
<ItemGroup>
14+
<PackageReference Include="Nuke.Common" Version="6.2.1" />
15+
</ItemGroup>
16+
17+
</Project>

0 commit comments

Comments
 (0)