Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions .config/dotnet-tools.json

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ jobs:
AZURE_AUTHORITY_HOST: "https://login.microsoftonline.com"
AZURE_DOMAIN: ${{ secrets.AZURE_DOMAIN }}
with:
cake-version: tool-manifest
file-path: cake.cs
target: GitHub-Actions

- name: Setup Pages
Expand Down
56 changes: 0 additions & 56 deletions build/helpers.cake

This file was deleted.

61 changes: 61 additions & 0 deletions build/helpers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*****************************
* Helpers
*****************************/

public partial class Program
{
static void Main_SetupExtensions()
{
if (BuildSystem.GitHubActions.IsRunningOnGitHubActions)
{
TaskSetup(context => BuildSystem.GitHubActions.Commands.StartGroup(context.Task.Name));
TaskTeardown(context => BuildSystem.GitHubActions.Commands.EndGroup());
}
}
}


public static partial class CakeTaskBuilderExtensions
{
private static ExtensionHelper extensionHelper = new (Task, () => RunTarget(Argument("target", "Default")));

public static CakeTaskBuilder Then(this CakeTaskBuilder cakeTaskBuilder, string name)
=> extensionHelper
.TaskCreate(name)
.IsDependentOn(cakeTaskBuilder);


public static CakeReport Run(this CakeTaskBuilder cakeTaskBuilder)
=> extensionHelper.Run();

public static CakeTaskBuilder Default(this CakeTaskBuilder cakeTaskBuilder)
{
extensionHelper
.TaskCreate("Default")
.IsDependentOn(cakeTaskBuilder);
return cakeTaskBuilder;
}

}

public class FilePathJsonConverter : PathJsonConverter<FilePath>
{
protected override FilePath ConvertFromString(string value) => FilePath.FromString(value);
}

public abstract class PathJsonConverter<TPath> : System.Text.Json.Serialization.JsonConverter<TPath> where TPath : Cake.Core.IO.Path
{
public override TPath Read(ref System.Text.Json.Utf8JsonReader reader, Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
{
var value = reader.GetString();

return value is null ? null : ConvertFromString(value);
}

public override void Write(System.Text.Json.Utf8JsonWriter writer, TPath value, System.Text.Json.JsonSerializerOptions options)
{
writer.WriteStringValue(value.FullPath);
}

protected abstract TPath ConvertFromString(string value);
}
24 changes: 12 additions & 12 deletions build/records.cake → build/records.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#load "helpers.cake"
using System.Text.Json.Serialization;

/*****************************
Expand All @@ -25,15 +24,15 @@ DirectoryPath OutputPath
public DirectoryPath StatiqWebPath { get; } = ArtifactsPath.Combine(Web);
public DirectoryPath StatiqWebOutputPath { get; } = ArtifactsPath.Combine(Web).Combine(Output);

public string GitHubNuGetSource { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_SOURCE");
public string GitHubNuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("GITHUB_TOKEN");
public string? GitHubNuGetSource { get; } = System.Environment.GetEnvironmentVariable("GH_PACKAGES_NUGET_SOURCE");
public string? GitHubNuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("GITHUB_TOKEN");

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

public string NuGetSource { get; } = System.Environment.GetEnvironmentVariable("NUGET_SOURCE");
public string NuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("NUGET_APIKEY");
public string? NuGetSource { get; } = System.Environment.GetEnvironmentVariable("NUGET_SOURCE");
public string? NuGetApiKey { get; } = System.Environment.GetEnvironmentVariable("NUGET_APIKEY");
public bool ShouldPushNuGetPackages() => IsMainBranch &&
!ShouldNotPublish &&
!string.IsNullOrWhiteSpace(NuGetSource) &&
Expand All @@ -54,8 +53,8 @@ public bool ShouldPushNuGetPackages() => IsMainBranch &&
System.Environment.GetEnvironmentVariable("AZURE_AUTHORITY_HOST")
);

public string AzureTenantId { get; } = System.Environment.GetEnvironmentVariable("AZURE_TENANT_ID");
public string AzureDomain { get; } = System.Environment.GetEnvironmentVariable("AZURE_DOMAIN");
public string? AzureTenantId { get; } = System.Environment.GetEnvironmentVariable("AZURE_TENANT_ID");
public string? AzureDomain { get; } = System.Environment.GetEnvironmentVariable("AZURE_DOMAIN");

public bool ShouldRunIntegrationTests() => !string.IsNullOrWhiteSpace(AzureDomain) &&
(
Expand All @@ -65,15 +64,16 @@ public bool ShouldRunIntegrationTests() => !string.IsNullOrWhiteSpace(AzureDoma
}

public record AzureCredentials(
string TenantId,
string ClientId,
string ClientSecret,
string AuthorityHost = "login.microsoftonline.com"
string? TenantId,
string? ClientId,
string? ClientSecret,
string? AuthorityHost = "login.microsoftonline.com"
)
{
public bool AzureCredentialsSpecified { get; } = !string.IsNullOrWhiteSpace(TenantId) &&
!string.IsNullOrWhiteSpace(ClientId) &&
!string.IsNullOrWhiteSpace(ClientSecret) &&
!string.IsNullOrWhiteSpace(AuthorityHost);
}
private record ExtensionHelper(Func<string, CakeTaskBuilder> TaskCreate, Func<CakeReport> Run);

internal record ExtensionHelper(Func<string, CakeTaskBuilder> TaskCreate, Func<CakeReport> Run);
72 changes: 34 additions & 38 deletions build.cake → cake.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
#tool dotnet:?package=GitVersion.Tool&version=6.5.1
#load "build/records.cake"
#load "build/helpers.cake"
#:sdk Cake.Sdk@6.0.0
#:property IncludeAdditionalFiles=./build/*.cs

/*****************************
* Setup
*****************************/
Setup(
static context => {
var assertedVersions = context.GitVersion(new GitVersionSettings
InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=6.5.1");
InstallTool("dotnet:https://api.nuget.org/v3/index.json?package=DPI&version=2025.12.17.349");
var assertedVersions = context.GitVersion(new GitVersionSettings
{
OutputType = GitVersionOutput.Json
});

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

var gh = context.GitHubActions();
var buildDate = DateTime.UtcNow;
var runNumber = gh.IsRunningOnGitHubActions
? gh.Environment.Workflow.RunNumber
var runNumber = GitHubActions.IsRunningOnGitHubActions
? GitHubActions.Environment.Workflow.RunNumber
: (short)((buildDate - buildDate.Date).TotalSeconds/3);

var version = FormattableString
Expand All @@ -41,7 +41,7 @@
version,
isMainBranch,
!context.IsRunningOnWindows(),
context.BuildSystem().IsLocalBuild,
BuildSystem.IsLocalBuild,
projectRoot,
projectPath,
new DotNetMSBuildSettings()
Expand All @@ -54,7 +54,7 @@
.WithProperty("PackageTags", "tool;bicep;acr;azure")
.WithProperty("PackageDescription", "Azure Resource Inventory .NET Tool - Inventories and documents Azure Tenant resources")
.WithProperty("RepositoryUrl", "https://github.com/devlead/ARI.git")
.WithProperty("ContinuousIntegrationBuild", gh.IsRunningOnGitHubActions ? "true" : "false")
.WithProperty("ContinuousIntegrationBuild", GitHubActions.IsRunningOnGitHubActions ? "true" : "false")
.WithProperty("EmbedUntrackedSources", "true"),
artifactsPath,
artifactsPath.Combine(version)
Expand All @@ -80,27 +80,25 @@
)
.Then("DPI")
.Does<BuildData>(
static (context, data) => context.DotNetTool(
"tool",
new DotNetToolSettings {
ArgumentCustomization = args => args
.Append("run")
.Append("dpi")
.Append("nuget")
.Append("--silent")
.AppendSwitchQuoted("--output", "table")
.Append(
(
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("NuGetReportSettings_SharedKey"))
&&
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("NuGetReportSettings_WorkspaceId"))
)
? "report"
: "analyze"
)
.AppendSwitchQuoted("--buildversion", data.Version)
}
)
static (context, data) => {
Command(
["dpi", "dpi.exe"],
new ProcessArgumentBuilder()
.Append("nuget")
.Append("--silent")
.AppendSwitchQuoted("--output", "table")
.Append(
(
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("NuGetReportSettings_SharedKey"))
&&
!string.IsNullOrWhiteSpace(context.EnvironmentVariable("NuGetReportSettings_WorkspaceId"))
)
? "report"
: "analyze"
)
.AppendSwitchQuoted("--buildversion", data.Version)
);
}
)
.Then("Build")
.Does<BuildData>(
Expand Down Expand Up @@ -138,11 +136,9 @@
.Then("Upload-Artifacts")
.WithCriteria(BuildSystem.IsRunningOnGitHubActions, nameof(BuildSystem.IsRunningOnGitHubActions))
.Does<BuildData>(
static (context, data) => context
.GitHubActions() is var gh && gh != null
? gh.Commands
.UploadArtifact(data.ArtifactsPath, $"Artifact_{gh.Environment.Runner.ImageOS ?? gh.Environment.Runner.OS}_{context.Environment.Runtime.BuiltFramework.Identifier}_{context.Environment.Runtime.BuiltFramework.Version}")
: throw new Exception("GitHubActions not available")
static (context, data) => GitHubActions
.Commands
.UploadArtifact(data.ArtifactsPath, $"Artifact_{GitHubActions.Environment.Runner.ImageOS ?? GitHubActions.Environment.Runner.OS}_{context.Environment.Runtime.BuiltFramework.Identifier}_{context.Environment.Runtime.BuiltFramework.Version}")
)
.Then("Integration-Tests-Tool-Manifest")
.Does<BuildData>(
Expand Down Expand Up @@ -192,9 +188,9 @@
.WithCriteria(BuildSystem.IsRunningOnGitHubActions, nameof(BuildSystem.IsRunningOnGitHubActions))
.WithCriteria<BuildData>((context, data) => data.ShouldRunIntegrationTests(), "ShouldRunIntegrationTests")
.Does<BuildData>(
async (context, data) => {
static (context, data) => {
var resultPath = data.IntegrationTestPath;
await GitHubActions.Commands.UploadArtifact(
GitHubActions.Commands.UploadArtifact(
resultPath,
$"{data.AzureDomain}_{GitHubActions.Environment.Runner.ImageOS ?? GitHubActions.Environment.Runner.OS}_{context.Environment.Runtime.BuiltFramework.Identifier}_{context.Environment.Runtime.BuiltFramework.Version}"
);
Expand All @@ -206,7 +202,7 @@ await GitHubActions.Commands.UploadArtifact(
.SelectMany(line => line)
)
);
}
}
)
.Then("Integration-Tests")
.Then("Generate-Statiq-Web")
Expand Down
6 changes: 3 additions & 3 deletions src/ARI/ARI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.1 " Condition="'$(TargetFramework)' == 'net8.0'" />
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.11" Condition="'$(TargetFramework)' == 'net9.0'" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.0" Condition="'$(TargetFramework)' == 'net10.0'" />
<PackageReference Include="Microsoft.Extensions.Http" Version="10.0.1" Condition="'$(TargetFramework)' == 'net10.0'" />
<PackageReference Include="System.Linq.Async" Version="7.0.0" Condition="'$(TargetFramework)' != 'net10.0'" />
<PackageReference Include="Cake.Bridge.DependencyInjection" Version="2025.11.24.417" />
<PackageReference Include="Cake.Bridge.DependencyInjection" Version="2025.12.17.441" />
<PackageReference Include="Cake.Common" Version="6.0.0" />
<PackageReference Include="Devlead.Console" Version="2025.11.25.507" />
<PackageReference Include="Devlead.Console" Version="2025.12.17.530" />
</ItemGroup>

<ItemGroup>
Expand Down