diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index fbac934cc..7db9184bf 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -125,10 +125,6 @@ jobs:
uses: actions/setup-dotnet@v5.0.0
with:
dotnet-version: '10.0.x'
- - name: 🚒 dotnet workload restore
- continue-on-error: true
- run: |
- dotnet workload restore
- name: ⚒️ dotnet tool restore
run: |
dotnet tool restore
diff --git a/.github/workflows/inputs.yml b/.github/workflows/inputs.yml
index d65f6c8a8..e0b29730f 100644
--- a/.github/workflows/inputs.yml
+++ b/.github/workflows/inputs.yml
@@ -54,10 +54,6 @@ jobs:
uses: actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493
with:
clean: 'false'
- - name: 🚒 dotnet workload restore
- continue-on-error: true
- run: |
- dotnet workload restore
- name: ⚒️ dotnet tool restore
run: |
dotnet tool restore
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 9ea47a55c..0832210e9 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -71,10 +71,6 @@ jobs:
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
- - name: 🚒 dotnet workload restore
- continue-on-error: true
- run: |
- dotnet workload restore
- name: ⚒️ dotnet tool restore
run: |
dotnet tool restore
diff --git a/src/Nuke/DotNetCore/DisableWorkloadRestoreAttribute.cs b/src/Nuke/DotNetCore/DisableWorkloadRestoreAttribute.cs
new file mode 100644
index 000000000..2f2643d66
--- /dev/null
+++ b/src/Nuke/DotNetCore/DisableWorkloadRestoreAttribute.cs
@@ -0,0 +1,17 @@
+namespace Rocket.Surgery.Nuke.DotNetCore;
+
+///
+/// A customized attribute to disable dotnet workload restore
+///
+[AttributeUsage(AttributeTargets.Class)]
+public class DisableDotnetWorkloadRestoreAttribute : Attribute
+{
+ ///
+ /// Represents an attribute used to disable the restoration of .NET workloads.
+ ///
+ ///
+ /// This attribute, when applied to a class, sets the flag Extensions.EnableDotNetWorkloadRestore
+ /// to false to disable the restoration process for workloads during the build.
+ ///
+ public DisableDotnetWorkloadRestoreAttribute() => Extensions.EnableDotNetWorkloadRestore = false;
+}
diff --git a/src/Nuke/Extensions.cs b/src/Nuke/Extensions.cs
index 0ee502440..27097e650 100644
--- a/src/Nuke/Extensions.cs
+++ b/src/Nuke/Extensions.cs
@@ -227,15 +227,14 @@ public static IEnumerable Match(this IEnumerable abs
///
///
public static ITargetDefinition Net9MsBuildFix(this ITargetDefinition target) => target
- .Executes(
- () =>
- {
- if (DisableNet9MsBuildFix) return;
-
- EnvironmentInfo.SetVariable("MSBuildExtensionsPath", "");
- EnvironmentInfo.SetVariable("MSBUILD_EXE_PATH", "");
- EnvironmentInfo.SetVariable("MSBuildSDKsPath", "");
- }
+ .Executes(() =>
+ {
+ if (DisableNet9MsBuildFix) return;
+
+ EnvironmentInfo.SetVariable("MSBuildExtensionsPath", "");
+ EnvironmentInfo.SetVariable("MSBUILD_EXE_PATH", "");
+ EnvironmentInfo.SetVariable("MSBuildSDKsPath", "");
+ }
);
///
@@ -309,6 +308,11 @@ public static bool ShouldUpdate(this AbsolutePath path, TimeSpan? waitTime = nul
///
public static bool DisableNet9MsBuildFix { get; set; }
+ ///
+ /// allow disabling dotnet workload restore.
+ ///
+ public static bool EnableDotNetWorkloadRestore { get; set; }
+
///
/// allow disabling the temporary fix for net9 msbuild issues
///
diff --git a/src/Nuke/GithubActions/GitHubActionsStepsAttribute.cs b/src/Nuke/GithubActions/GitHubActionsStepsAttribute.cs
index 4e6027172..95454cf04 100644
--- a/src/Nuke/GithubActions/GitHubActionsStepsAttribute.cs
+++ b/src/Nuke/GithubActions/GitHubActionsStepsAttribute.cs
@@ -104,15 +104,14 @@ public override ConfigurationEntity GetConfiguration(IReadOnlyCollection()
.Select(z => z.ToInput())
- .SelectMany(
- z =>
- {
- return new[]
- {
- new KeyValuePair(z.Name, z),
- new KeyValuePair(z.Alias ?? z.Name.Pascalize(), z),
- };
- }
+ .SelectMany(z =>
+ {
+ return new[]
+ {
+ new KeyValuePair(z.Name, z),
+ new KeyValuePair(z.Alias ?? z.Name.Pascalize(), z),
+ };
+ }
)
.DistinctBy(z => z.Key, StringComparer.OrdinalIgnoreCase)
.ToDictionary(z => z.Key, z => z.Value, StringComparer.OrdinalIgnoreCase);
@@ -152,23 +151,21 @@ .. onePasswordServiceAccountSecrets
steps.AddRange(
onePasswordServiceAccountSecrets
.GroupBy(z => z.Secret)
- .Select(
- static secrets => new UsingStep($"Load 1Password Secrets ({secrets.Key})")
- {
- Id = secrets.First().OutputId,
- Uses = "1password/load-secrets-action@v1",
- Outputs = [.. secrets.Select(secret => new GitHubActionsOutput(secret.Name, secret.Description))],
- With = new() { ["export-env"] = "false" },
- Environment = Enumerable
+ .Select(static secrets => new UsingStep($"Load 1Password Secrets ({secrets.Key})")
+ {
+ Id = secrets.First().OutputId,
+ Uses = "1password/load-secrets-action@v1",
+ Outputs = [.. secrets.Select(secret => new GitHubActionsOutput(secret.Name, secret.Description))],
+ With = new() { ["export-env"] = "false" },
+ Environment = Enumerable
.Concat(
secrets
- .Select(
- z => new KeyValuePair(
- z.Name,
- string.IsNullOrWhiteSpace(z.Variable)
- ? $"{z.Path}"
- : $$$"""${{ vars.{{{z.Variable}}} }}/{{{z.Path.TrimStart('/')}}}"""
- )
+ .Select(z => new KeyValuePair(
+ z.Name,
+ string.IsNullOrWhiteSpace(z.Variable)
+ ? $"{z.Path}"
+ : $$$"""${{ vars.{{{z.Variable}}} }}/{{{z.Path.TrimStart('/')}}}"""
+ )
),
[
new(
@@ -178,7 +175,7 @@ .. onePasswordServiceAccountSecrets
]
)
.ToDictionary(z => z.Key, z => z.Value),
- }
+ }
)
);
}
@@ -211,23 +208,21 @@ .. onePasswordConnectServerSecrets
steps.AddRange(
onePasswordConnectServerSecrets
.GroupBy(z => $"{z.ConnectHost}, {z.ConnectToken}")
- .Select(
- static secrets => new UsingStep($"Load 1Password Secrets ({secrets.Key})")
- {
- Id = secrets.First().OutputId,
- Uses = "1password/load-secrets-action@v1",
- Outputs = [.. secrets.Select(secret => new GitHubActionsOutput(secret.Name, secret.Description))],
- With = new() { ["export-env"] = "false" },
- Environment = Enumerable
+ .Select(static secrets => new UsingStep($"Load 1Password Secrets ({secrets.Key})")
+ {
+ Id = secrets.First().OutputId,
+ Uses = "1password/load-secrets-action@v1",
+ Outputs = [.. secrets.Select(secret => new GitHubActionsOutput(secret.Name, secret.Description))],
+ With = new() { ["export-env"] = "false" },
+ Environment = Enumerable
.Concat(
secrets
- .Select(
- z => new KeyValuePair(
- z.Name,
- string.IsNullOrWhiteSpace(z.Variable)
- ? $"{z.Path}"
- : $$$"""${{ vars.{{{z.Variable}}} }}/{{{z.Path.TrimStart('/')}}}"""
- )
+ .Select(z => new KeyValuePair(
+ z.Name,
+ string.IsNullOrWhiteSpace(z.Variable)
+ ? $"{z.Path}"
+ : $$$"""${{ vars.{{{z.Variable}}} }}/{{{z.Path.TrimStart('/')}}}"""
+ )
),
[
new(
@@ -241,7 +236,7 @@ .. onePasswordConnectServerSecrets
]
)
.ToDictionary(z => z.Key, z => z.Value),
- }
+ }
)
);
}
@@ -252,14 +247,18 @@ .. onePasswordConnectServerSecrets
{
Run = "dotnet tool install -g Nuke.GlobalTool",
};
- // TODO: Add configuration to disable this?
- steps.Add(
- new RunStep("dotnet workload restore")
- {
- Run = "dotnet workload restore",
- ContinueOnError = true,
- }
- );
+
+ if (Extensions.EnableDotNetWorkloadRestore)
+ {
+ steps.Add(
+ new RunStep("dotnet workload restore")
+ {
+ Run = "dotnet workload restore",
+ ContinueOnError = true,
+ }
+ );
+ }
+
var dotnetTools = Path.Combine(NukeBuild.RootDirectory, ".config/dotnet-tools.json");
if (File.Exists(dotnetTools))
{
@@ -285,15 +284,14 @@ .. onePasswordConnectServerSecrets
environmentAttributes
)
// ReSharper enable CoVariantArrayConversion
- .SelectMany(
- z =>
- {
- return new[]
- {
- new KeyValuePair(z.Name, z),
- new KeyValuePair(z.Alias ?? z.Name.Pascalize(), z),
- };
- }
+ .SelectMany(z =>
+ {
+ return new[]
+ {
+ new KeyValuePair(z.Name, z),
+ new KeyValuePair(z.Alias ?? z.Name.Pascalize(), z),
+ };
+ }
)
.DistinctBy(z => z.Key, StringComparer.OrdinalIgnoreCase)
.ToDictionary(z => z.Key, z => z.Value, StringComparer.OrdinalIgnoreCase);
@@ -319,9 +317,8 @@ .. onePasswordConnectServerSecrets
var lookupTable = new LookupTable();
var initialArguments = localTool ? new Arguments().Add("dotnet").Add("nuke") : new Arguments().Add("nuke");
foreach ((var execute, var targets) in relevantTargets
- .Select(
- x => (ExecutableTarget: x,
- Targets: GetInvokedTargets(x, relevantTargets).ToArray())
+ .Select(x => (ExecutableTarget: x,
+ Targets: GetInvokedTargets(x, relevantTargets).ToArray())
)
.ForEachLazy(x => lookupTable.Add(x.ExecutableTarget, [.. x.Targets]))
)
@@ -425,11 +422,8 @@ .. onePasswordConnectServerSecrets
ApplyEnhancements(config);
if (!buildJob.Name.Equals(Settings.DefaultGithubJobName, StringComparison.OrdinalIgnoreCase))
- {
// ReSharper disable once PossibleMultipleEnumeration
- config.DetailedTriggers = [.. GetTriggers(requiredInputs, outputs, secrets)
-, .. config.DetailedTriggers.Except(triggers)];
- }
+ config.DetailedTriggers = [.. GetTriggers(requiredInputs, outputs, secrets), .. config.DetailedTriggers.Except(triggers)];
// need a better way to do this more generically
if (buildJob.Steps.OfType().Any(z => z.Uses?.StartsWith("codecov/codecov-action", StringComparison.OrdinalIgnoreCase) == true))
@@ -491,10 +485,9 @@ protected void NormalizeActionVersions(RocketSurgeonGitHubActionsConfiguration c
.Documents
.SelectMany(z => z.AllNodes)
.OfType()
- .Where(
- z => z.Children.ContainsKey(key)
- && z.Children[key] is YamlScalarNode sn
- && sn.Value?.Contains('@', StringComparison.OrdinalIgnoreCase) == true
+ .Where(z => z.Children.ContainsKey(key)
+ && z.Children[key] is YamlScalarNode sn
+ && sn.Value?.Contains('@', StringComparison.OrdinalIgnoreCase) == true
)
.Select(
// ReSharper disable once NullableWarningSuppressionIsUsed
@@ -518,9 +511,7 @@ protected void NormalizeActionVersions(RocketSurgeonGitHubActionsConfiguration c
foreach (var job in config.Jobs)
{
if (job is RocketSurgeonsGithubWorkflowJob workflowJob)
- {
workflowJob.Uses = GetValue(workflowJob.Uses);
- }
else if (job is RocketSurgeonsGithubActionsJob actionsJob)
{
foreach (var step in actionsJob.Steps.OfType())
@@ -547,12 +538,11 @@ protected virtual IEnumerable GetParameters(INukeBui
.Where(x => x.GetCustomAttribute() is { });
foreach (var parameter in parameters)
{
- if (Parameters.Any(
- z => z.Equals(parameter.Name, StringComparison.OrdinalIgnoreCase)
- || z.Equals(
- parameter.GetCustomAttribute()?.Name,
- StringComparison.OrdinalIgnoreCase
- )
+ if (Parameters.Any(z => z.Equals(parameter.Name, StringComparison.OrdinalIgnoreCase)
+ || z.Equals(
+ parameter.GetCustomAttribute()?.Name,
+ StringComparison.OrdinalIgnoreCase
+ )
))
{
var value = parameter.GetValue(build);