Skip to content

Commit 9e00582

Browse files
committed
Merge branch 'develop'
2 parents e72ec92 + 298f35c commit 9e00582

File tree

8 files changed

+85
-101
lines changed

8 files changed

+85
-101
lines changed

.config/dotnet-tools.json

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

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ jobs:
5959
NUGET_APIKEY: ${{steps.login.outputs.NUGET_API_KEY}}
6060
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6161
with:
62-
cake-version: tool-manifest
62+
file-path: cake.cs
6363
target: GitHub-Actions

build/helpers.cake

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

build/helpers.cs

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*****************************
2+
* Helpers
3+
*****************************/
4+
5+
public partial class Program
6+
{
7+
static void Main_SetupExtensions()
8+
{
9+
if (BuildSystem.GitHubActions.IsRunningOnGitHubActions)
10+
{
11+
TaskSetup(context => BuildSystem.GitHubActions.Commands.StartGroup(context.Task.Name));
12+
TaskTeardown(context => BuildSystem.GitHubActions.Commands.EndGroup());
13+
}
14+
}
15+
}
16+
17+
18+
public static partial class CakeTaskBuilderExtensions
19+
{
20+
private static ExtensionHelper extensionHelper = new (Task, () => RunTarget(Argument("target", "Default")));
21+
22+
public static CakeTaskBuilder Then(this CakeTaskBuilder cakeTaskBuilder, string name)
23+
=> extensionHelper
24+
.TaskCreate(name)
25+
.IsDependentOn(cakeTaskBuilder);
26+
27+
28+
public static CakeReport Run(this CakeTaskBuilder cakeTaskBuilder)
29+
=> extensionHelper.Run();
30+
31+
public static CakeTaskBuilder Default(this CakeTaskBuilder cakeTaskBuilder)
32+
{
33+
extensionHelper
34+
.TaskCreate("Default")
35+
.IsDependentOn(cakeTaskBuilder);
36+
return cakeTaskBuilder;
37+
}
38+
39+
}
40+
41+
public class FilePathJsonConverter : PathJsonConverter<FilePath>
42+
{
43+
protected override FilePath? ConvertFromString(string value) => FilePath.FromString(value);
44+
}
45+
46+
public abstract class PathJsonConverter<TPath> : System.Text.Json.Serialization.JsonConverter<TPath> where TPath : Cake.Core.IO.Path
47+
{
48+
public override TPath? Read(ref System.Text.Json.Utf8JsonReader reader, Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
49+
{
50+
var value = reader.GetString();
51+
52+
return value is null ? null : ConvertFromString(value);
53+
}
54+
55+
public override void Write(System.Text.Json.Utf8JsonWriter writer, TPath value, System.Text.Json.JsonSerializerOptions options)
56+
{
57+
writer.WriteStringValue(value.FullPath);
58+
}
59+
60+
protected abstract TPath? ConvertFromString(string value);
61+
}
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#load "helpers.cake"
21
using System.Text.Json.Serialization;
32

43
/*****************************
@@ -22,15 +21,15 @@ DirectoryPath OutputPath
2221
public DirectoryPath MarkdownPath { get; } = OutputPath.Combine(Markdown);
2322
public FilePath MarkdownIndexPath { get; } = OutputPath.Combine(Markdown).CombineWithFilePath("index.md");
2423

25-
public string GitHubNuGetSource { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_SOURCE");
26-
public string GitHubNuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_APIKEY");
24+
public string? GitHubNuGetSource { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_SOURCE");
25+
public string? GitHubNuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_APIKEY");
2726

2827
public bool ShouldPushGitHubPackages() => !ShouldNotPublish
2928
&& !string.IsNullOrWhiteSpace(GitHubNuGetSource)
3029
&& !string.IsNullOrWhiteSpace(GitHubNuGetApiKey);
3130

32-
public string NuGetSource { get; } = System.Environment.GetEnvironmentVariable("NUGET_SOURCE");
33-
public string NuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("NUGET_APIKEY");
31+
public string? NuGetSource { get; } = System.Environment.GetEnvironmentVariable("NUGET_SOURCE");
32+
public string? NuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("NUGET_APIKEY");
3433
public bool ShouldPushNuGetPackages() => IsMainBranch &&
3534
!ShouldNotPublish &&
3635
!string.IsNullOrWhiteSpace(NuGetSource) &&
@@ -44,7 +43,7 @@ public bool ShouldPushNuGetPackages() => IsMainBranch &&
4443
};
4544
}
4645

47-
private record ExtensionHelper(Func<string, CakeTaskBuilder> TaskCreate, Func<CakeReport> Run);
46+
internal record ExtensionHelper(Func<string, CakeTaskBuilder> TaskCreate, Func<CakeReport> Run);
4847

4948

5049
public record DPIPackageReference(

build.cake renamed to cake.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=6.5.0"
2-
#addin nuget:?package=System.Text.Json&version=10.0.0&loaddependencies=true
3-
#load "build/records.cake"
4-
#load "build/helpers.cake"
1+
#:sdk Cake.Sdk@6.0.0
2+
#:package xunit.v3.assert@3.2.1
3+
#:property IncludeAdditionalFiles=./build/*.cs
4+
using Xunit;
55
66
/*****************************
77
* Setup
88
*****************************/
99
Setup(
1010
static context => {
11-
var assertedVersions = context.GitVersion(new GitVersionSettings
11+
InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=6.5.1");
12+
var assertedVersions = context.GitVersion(new GitVersionSettings
1213
{
1314
OutputType = GitVersionOutput.Json
1415
});
1516

1617
var branchName = assertedVersions.BranchName;
1718
var isMainBranch = StringComparer.OrdinalIgnoreCase.Equals("main", branchName);
1819

19-
var gh = context.GitHubActions();
2020
var buildDate = DateTime.UtcNow;
21-
var runNumber = gh.IsRunningOnGitHubActions
22-
? gh.Environment.Workflow.RunNumber
21+
var runNumber = GitHubActions.IsRunningOnGitHubActions
22+
? GitHubActions.Environment.Workflow.RunNumber
2323
: (short)((buildDate - buildDate.Date).TotalSeconds/3);
2424

2525
var version = FormattableString
@@ -51,7 +51,7 @@
5151
.WithProperty("PackageTags", "tool")
5252
.WithProperty("PackageDescription", "Dependency Inventory .NET Tool - Inventories dependencies to Azure Log Analytics")
5353
.WithProperty("RepositoryUrl", "https://github.com/devlead/DPI.git")
54-
.WithProperty("ContinuousIntegrationBuild", gh.IsRunningOnGitHubActions ? "true" : "false")
54+
.WithProperty("ContinuousIntegrationBuild", GitHubActions.IsRunningOnGitHubActions ? "true" : "false")
5555
.WithProperty("EmbedUntrackedSources", "true"),
5656
artifactsPath,
5757
artifactsPath.Combine(version)
@@ -100,11 +100,9 @@
100100
.Then("Upload-Artifacts")
101101
.WithCriteria(BuildSystem.IsRunningOnGitHubActions, nameof(BuildSystem.IsRunningOnGitHubActions))
102102
.Does<BuildData>(
103-
static (context, data) => context
104-
.GitHubActions() is var gh && gh != null
105-
? gh.Commands
106-
.UploadArtifact(data.ArtifactsPath, $"Artifact_{gh.Environment.Runner.ImageOS ?? gh.Environment.Runner.OS}_{context.Environment.Runtime.BuiltFramework.Identifier}_{context.Environment.Runtime.BuiltFramework.Version}")
107-
: throw new Exception("GitHubActions not available")
103+
static (context, data) => GitHubActions
104+
.Commands
105+
.UploadArtifact(data.ArtifactsPath, $"Artifact_{GitHubActions.Environment.Runner.ImageOS ?? GitHubActions.Environment.Runner.OS}_{context.Environment.Runtime.BuiltFramework.Identifier}_{context.Environment.Runtime.BuiltFramework.Version}")
108106
)
109107
.Then("Integration-Tests-Restore-MultiTarget")
110108
.Does<BuildData>(
@@ -191,6 +189,8 @@ out json
191189
string.Concat(json)
192190
);
193191

192+
Assert.NotNull(packageReferences);
193+
194194
Array.ForEach(
195195
packageReferences,
196196
packageReference => Assert.Equal(

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
33
"rollForward": "latestFeature",
4-
"version": "10.0.100"
4+
"version": "10.0.101"
55
}
66
}

src/DPI/DPI.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
</PropertyGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="Devlead.Console" Version="2025.11.25.507" />
14+
<PackageReference Include="Devlead.Console" Version="2025.12.17.530" />
1515
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
1616
<PackageReference Include="Cake.Core" Version="6.0.0" />
1717
<PackageReference Include="Cake.Common" Version="6.0.0" />
18-
<PackageReference Include="Cake.Bridge.DependencyInjection" Version="2025.11.24.417" />
18+
<PackageReference Include="Cake.Bridge.DependencyInjection" Version="2025.12.17.441" />
1919
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1 " Condition="'$(TargetFramework)' == 'net8.0'" />
2020
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.11" Condition="'$(TargetFramework)' == 'net9.0'" />
21-
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0" Condition="'$(TargetFramework)' == 'net10.0'" />
21+
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.1" Condition="'$(TargetFramework)' == 'net10.0'" />
2222
</ItemGroup>
2323

2424
<ItemGroup>

0 commit comments

Comments
 (0)