Skip to content

Commit d768a5f

Browse files
authored
Upgrade to NUKE 8 (#6)
1 parent 02f18af commit d768a5f

File tree

15 files changed

+61
-87
lines changed

15 files changed

+61
-87
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ jobs:
3838
env:
3939
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
4040
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
41+
- name: 'Publish: test-results'
42+
uses: actions/upload-artifact@v3
43+
with:
44+
name: test-results
45+
path: artifacts/test-results
46+
- name: 'Publish: packages'
47+
uses: actions/upload-artifact@v3
48+
with:
49+
name: packages
50+
path: artifacts/packages
4151
ubuntu-latest:
4252
name: ubuntu-latest
4353
runs-on: ubuntu-latest
@@ -48,3 +58,13 @@ jobs:
4858
env:
4959
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
5060
MYGET_API_KEY: ${{ secrets.MYGET_API_KEY }}
61+
- name: 'Publish: test-results'
62+
uses: actions/upload-artifact@v3
63+
with:
64+
name: test-results
65+
path: artifacts/test-results
66+
- name: 'Publish: packages'
67+
uses: actions/upload-artifact@v3
68+
with:
69+
name: packages
70+
path: artifacts/packages

.nuke/build.schema.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"properties": {
99
"Configuration": {
1010
"type": "string",
11-
"description": "Configuration to build - Default is 'Debug' (local) or 'Release' (server)",
1211
"enum": [
1312
"Debug",
1413
"Release"
@@ -43,6 +42,10 @@
4342
"VSCode"
4443
]
4544
},
45+
"IgnoreFailedSources": {
46+
"type": "boolean",
47+
"description": "Ignore unreachable sources during Restore"
48+
},
4649
"MyGetApiKey": {
4750
"type": "string",
4851
"default": "Secrets must be entered via 'nuke :secrets [profile]'"
File renamed without changes.

Test262Harness.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ EndProject
1111
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{766D3EDA-21C8-4AD5-B391-0E1D9E42D1AF}"
1212
ProjectSection(SolutionItems) = preProject
1313
.editorconfig = .editorconfig
14-
src\Directory.Build.props = src\Directory.Build.props
14+
Directory.Build.props = Directory.Build.props
1515
global.json = global.json
1616
README.md = README.md
1717
EndProjectSection

build.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ $DotNetGlobalFile = "$PSScriptRoot\\global.json"
2020
$DotNetInstallUrl = "https://dot.net/v1/dotnet-install.ps1"
2121
$DotNetChannel = "STS"
2222

23-
$env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1
2423
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1
25-
$env:DOTNET_MULTILEVEL_LOOKUP = 0
24+
$env:DOTNET_NOLOGO = 1
2625

2726
###########################################################################
2827
# EXECUTION
@@ -61,6 +60,7 @@ else {
6160
ExecSafe { & powershell $DotNetInstallFile -InstallDir $DotNetDirectory -Version $DotNetVersion -NoPath }
6261
}
6362
$env:DOTNET_EXE = "$DotNetDirectory\dotnet.exe"
63+
$env:PATH = "$DotNetDirectory;$env:PATH"
6464
}
6565

6666
Write-Output "Microsoft (R) .NET SDK version $(& $env:DOTNET_EXE --version)"

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ DOTNET_INSTALL_URL="https://dot.net/v1/dotnet-install.sh"
1717
DOTNET_CHANNEL="STS"
1818

1919
export DOTNET_CLI_TELEMETRY_OPTOUT=1
20-
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
21-
export DOTNET_MULTILEVEL_LOOKUP=0
20+
export DOTNET_NOLOGO=1
2221

2322
###########################################################################
2423
# EXECUTION
@@ -54,6 +53,7 @@ else
5453
"$DOTNET_INSTALL_FILE" --install-dir "$DOTNET_DIRECTORY" --version "$DOTNET_VERSION" --no-path
5554
fi
5655
export DOTNET_EXE="$DOTNET_DIRECTORY/dotnet"
56+
export PATH="$DOTNET_DIRECTORY:$PATH"
5757
fi
5858

5959
echo "Microsoft (R) .NET SDK version $("$DOTNET_EXE" --version)"

build/Build.CI.GitHubActions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Nuke.Common.CI.GitHubActions;
2+
using Nuke.Components;
23

34
[GitHubActions(
45
"pr",
@@ -9,7 +10,7 @@
910
OnPullRequestExcludePaths = ["**/*.md"],
1011
PublishArtifacts = false,
1112
CacheKeyFiles = new string[0],
12-
InvokedTargets = [nameof(Compile), nameof(Test), nameof(Pack)])
13+
InvokedTargets = [nameof(ICompile.Compile), nameof(ITest.Test), nameof(IPack.Pack)])
1314
]
1415
[GitHubActions(
1516
"build",
@@ -21,7 +22,7 @@
2122
OnPushExcludePaths = ["**/*.md"],
2223
PublishArtifacts = true,
2324
CacheKeyFiles = new string[0],
24-
InvokedTargets = [nameof(Compile), nameof(Test), nameof(Pack), nameof(Publish)],
25+
InvokedTargets = [nameof(ICompile.Compile), nameof(ITest.Test), nameof(IPack.Pack), nameof(Publish)],
2526
ImportSecrets = ["NUGET_API_KEY", "MYGET_API_KEY"])
2627
]
2728
public partial class Build

build/Build.Publish.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using Nuke.Common.IO;
66
using Nuke.Common.Tooling;
77
using Nuke.Common.Tools.DotNet;
8-
8+
using Nuke.Components;
99
using static Nuke.Common.Tools.DotNet.DotNetTasks;
1010

1111
public partial class Build
@@ -21,7 +21,7 @@ public partial class Build
2121

2222
Target Publish => _ => _
2323
.OnlyWhenDynamic(() => IsRunningOnWindows && (GitRepository.IsOnMainOrMasterBranch() || IsTaggedBuild))
24-
.DependsOn(Pack)
24+
.DependsOn<IPack>()
2525
.Requires(() => NuGetApiKey, () => MyGetApiKey)
2626
.Executes(() =>
2727
{
@@ -38,7 +38,7 @@ public partial class Build
3838
Configure<DotNetNuGetPushSettings> PushSettingsBase => _ => _
3939
.SetSource(SourceToUse)
4040
.SetApiKey(ApiKeyToUse)
41-
.SetSkipDuplicate(true);
41+
.EnableSkipDuplicate();
4242

4343
Configure<DotNetNuGetPushSettings> PushSettings => _ => _;
4444
Configure<DotNetNuGetPushSettings> PackagePushSettings => _ => _;

build/Build.cs

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Runtime.InteropServices;
45
using System.Xml.Linq;
@@ -7,24 +8,21 @@
78
using Nuke.Common.Git;
89
using Nuke.Common.IO;
910
using Nuke.Common.ProjectModel;
11+
using Nuke.Common.Tooling;
1012
using Nuke.Common.Tools.DotNet;
1113
using Nuke.Common.Utilities.Collections;
12-
using static Nuke.Common.Tools.DotNet.DotNetTasks;
14+
using Nuke.Components;
1315

1416
[ShutdownDotNetAfterServerBuild]
15-
partial class Build : NukeBuild
17+
partial class Build : NukeBuild, ITest, IPack
1618
{
1719
/// Support plugins are available for:
1820
/// - JetBrains ReSharper https://nuke.build/resharper
1921
/// - JetBrains Rider https://nuke.build/rider
2022
/// - Microsoft VisualStudio https://nuke.build/visualstudio
2123
/// - Microsoft VSCode https://nuke.build/vscode
22-
public static int Main() => Execute<Build>(x => x.Compile);
24+
public static int Main() => Execute<Build>(x => ((ICompile) x).Compile);
2325

24-
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
25-
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
26-
27-
[Solution] readonly Solution Solution;
2826
[GitRepository] readonly GitRepository GitRepository;
2927

3028
AbsolutePath SourceDirectory => RootDirectory / "src";
@@ -39,15 +37,15 @@ partial class Build : NukeBuild
3937

4038
string DetermineVersionPrefix()
4139
{
42-
var versionPrefix = GitRepository.Tags.SingleOrDefault(x => x.StartsWith("v"))?[1..];
40+
var versionPrefix = GitRepository.Tags.SingleOrDefault(x => x.StartsWith('v'))?[1..];
4341
if (!string.IsNullOrWhiteSpace(versionPrefix))
4442
{
4543
IsTaggedBuild = true;
4644
Serilog.Log.Information($"Tag version {VersionPrefix} from Git found, using it as version prefix", versionPrefix);
4745
}
4846
else
4947
{
50-
var propsDocument = XDocument.Parse((SourceDirectory / "Directory.Build.props").ReadAllText());
48+
var propsDocument = XDocument.Parse((RootDirectory / "Directory.Build.props").ReadAllText());
5149
versionPrefix = propsDocument.Element("Project").Element("PropertyGroup").Element("VersionPrefix").Value;
5250
Serilog.Log.Information("Version prefix {VersionPrefix} read from Directory.Build.props", versionPrefix);
5351
}
@@ -69,67 +67,29 @@ protected override void OnBuildInitialized()
6967
}
7068

7169
Serilog.Log.Information("BUILD SETUP");
72-
Serilog.Log.Information("Configuration:\t{Configuration}", Configuration);
70+
Serilog.Log.Information("Configuration:\t{Configuration}", ((ICompile) this).Configuration);
7371
Serilog.Log.Information("Version prefix:\t{VersionPrefix}", VersionPrefix);
7472
Serilog.Log.Information("Version suffix:\t{VersionSuffix}", VersionSuffix);
7573
Serilog.Log.Information("Tagged build:\t{IsTaggedBuild}", IsTaggedBuild);
7674
}
7775

7876
Target Clean => _ => _
79-
.Before(Restore)
8077
.Executes(() =>
8178
{
8279
SourceDirectory.GlobDirectories("**/bin", "**/obj").ForEach(x => x.DeleteDirectory());
8380
TestsDirectory.GlobDirectories("**/bin", "**/obj").ForEach(x => x.DeleteDirectory());
8481
ArtifactsDirectory.CreateOrCleanDirectory();
8582
});
8683

87-
Target Restore => _ => _
88-
.Executes(() =>
89-
{
90-
DotNetRestore(s => s
91-
.SetProjectFile(Solution));
92-
});
93-
94-
Target Compile => _ => _
95-
.DependsOn(Restore)
96-
.Executes(() =>
97-
{
98-
DotNetBuild(s => s
99-
.SetProjectFile(Solution)
100-
.SetConfiguration(Configuration)
101-
.SetAssemblyVersion(VersionPrefix)
102-
.SetFileVersion(VersionPrefix)
103-
.SetInformationalVersion(VersionPrefix)
104-
.SetDeterministic(IsServerBuild)
105-
.SetContinuousIntegrationBuild(IsServerBuild)
106-
.EnableNoRestore()
107-
);
108-
});
84+
public Configure<DotNetBuildSettings> CompileSettings => _ => _
85+
.SetAssemblyVersion(VersionPrefix)
86+
.SetFileVersion(VersionPrefix)
87+
.SetInformationalVersion(VersionPrefix);
10988

110-
Target Test => _ => _
111-
.DependsOn(Compile)
112-
.Before(Pack, Publish)
113-
.Executes(() =>
114-
{
115-
DotNetTest(s => s
116-
.SetProjectFile(Solution)
117-
.SetConfiguration(Configuration)
118-
.EnableNoBuild()
119-
.EnableNoRestore()
120-
);
121-
});
89+
public IEnumerable<Project> TestProjects => ((ICompile) this).Solution.AllProjects.Where(x => x.Name.EndsWith("Tests"));
12290

123-
Target Pack => _ => _
124-
.DependsOn(Compile)
125-
.Executes(() =>
126-
{
127-
DotNetPack(s => s
128-
.EnableNoBuild()
129-
.SetConfiguration(Configuration)
130-
.SetOutputDirectory(ArtifactsDirectory)
131-
.SetVersionPrefix(VersionPrefix)
132-
.SetVersionSuffix(VersionSuffix)
133-
);
134-
});
91+
public Configure<DotNetPackSettings> PackSettings => _ => _
92+
.SetOutputDirectory(ArtifactsDirectory)
93+
.SetVersionPrefix(VersionPrefix)
94+
.SetVersionSuffix(VersionSuffix);
13595
}

build/Configuration.cs

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)