Skip to content

Commit

Permalink
Merge branch 'hotfix/8.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
matkoch committed Oct 5, 2024
2 parents 9ced2aa + 03e52b3 commit fd4f71b
Show file tree
Hide file tree
Showing 27 changed files with 189 additions and 163 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [vNext]

## [8.1.1] / 2024-10-05
- Fixed nested solution folders in `StronglyTypedSolutionGenerator`
- Fixed whitespace arguments in `ArgumentStringHandler`
- Fixed output logging in parallel execution
- Fixed exclusion of invoked targets from skipping
- Fixed definite argument in `EntityFrameworkTasks`

## [8.1.0] / 2024-09-10
- Added schema generation with references for `build.schema.json`
- Added deserialization of full objects from `parameters.json`
Expand Down Expand Up @@ -1150,7 +1157,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added CLT tasks for Git
- Fixed background color in console output

[vNext]: https://github.com/nuke-build/nuke/compare/8.1.0...HEAD
[vNext]: https://github.com/nuke-build/nuke/compare/8.1.1...HEAD
[8.1.1]: https://github.com/nuke-build/nuke/compare/8.1.0...8.1.1
[8.1.0]: https://github.com/nuke-build/nuke/compare/8.0.0...8.1.0
[8.0.0]: https://github.com/nuke-build/nuke/compare/7.0.6...8.0.0
[7.0.6]: https://github.com/nuke-build/nuke/compare/7.0.5...7.0.6
Expand Down
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.10.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.10.0" />
</ItemGroup>

<!-- MSBuild (Nuke.ProjectModel + Nuke.MSBuildTasks) -->
<ItemGroup>
<PackageVersion Include="Microsoft.Build.Locator" Version="1.7.8" />
Expand All @@ -81,4 +81,4 @@
<PackageVersion Update="Microsoft.Build.Utilities.Core" Version="16.9.0" />
</ItemGroup>

</Project>
</Project>
8 changes: 4 additions & 4 deletions docs/02-fundamentals/05-targets.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ class Build : NukeBuild
// highlight-start
.OnlyWhenDynamic(() => Data.Any())
// highlight-end
.Execute(() => { });
.Executes(() => { });
}
```

Expand All @@ -229,7 +229,7 @@ class Build : NukeBuild
.WhenSkipped(DependencyBehavior.Execute)
// highlight-end
.DependsOn(A)
.Execute(() => { });
.Executes(() => { });
}
```

Expand Down Expand Up @@ -286,7 +286,7 @@ class Build : NukeBuild

Target B => _ => _
.DependsOn(A)
.Execute(() => { });
.Executes(() => { });
}
```

Expand All @@ -309,7 +309,7 @@ class Build : NukeBuild
.AssuredAfterFailure()
// highlight-end
.DependsOn(A)
.Execute(() => { });
.Executes(() => { });
}
```

Expand Down
2 changes: 1 addition & 1 deletion docs/03-common/07-solution-project-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ With an instance of the `Solution` type you can **read and write the solution**
```csharp
// Gather projects
var globalToolProject = Solution.GetProject("Nuke.GlobalTool");
var testProjects = Solution.GetProjects("*.Tests");
var testProjects = Solution.GetAllProjects("*.Tests");

// Gather all solution items
var allItems = Solution.AllSolutionFolders.SelectMany(x => x.Items);
Expand Down
61 changes: 39 additions & 22 deletions source/Nuke.Build.Tests/BuildExecutorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ public void TestDefault()
}

[Fact]
public void TestParameterSkipped_All()
{
ExecuteBuild(skippedTargets: new ExecutableTarget[0]);
AssertSkipped(A, B, C);
}

[Fact]
public void TestParameterSkipped_Single()
public void TestParameterSkipped()
{
ExecuteBuild(skippedTargets: new[] { A });
AssertSucceeded(B, C);
Expand All @@ -52,9 +45,21 @@ public void TestParameterSkipped_Single()
}

[Fact]
public void TestParameterSkipped_Multiple()
public void TestParameterSkipped_Default()
{
C.IsDefault = true;
C.Invoked = false;

ExecuteBuild(skippedTargets: new ExecutableTarget[0]);
AssertSkipped(A, B, C);
}

[Fact]
public void TestParameterSkipped_Invoked()
{
ExecuteBuild(skippedTargets: new[] { A, B });
C.Invoked = true;

ExecuteBuild(skippedTargets: new ExecutableTarget[0]);
AssertSucceeded(C);
AssertSkipped(A, B);
}
Expand All @@ -66,6 +71,7 @@ public void TestParameterSkipped_DependencyBehavior_Skip()
ExecuteBuild(skippedTargets: new[] { B });
AssertSucceeded(C);
AssertSkipped(A, B);
A.Skipped.Should().Be("because of B");
}

[Fact]
Expand Down Expand Up @@ -109,6 +115,16 @@ public void TestStaticCondition_Multiple()
A.OnlyWhen.Should().Be("A && B");
}

[Fact]
public void TestStaticCondition_Throwing()
{
A.StaticConditions.Add(("condition", () => throw new Exception()));
var action = () => ExecuteBuild();

action.Should().Throw<TargetExecutionException>()
.WithMessage("Target 'A' has thrown an exception.");
}

[Fact]
public void TestDynamicCondition_Unchanged()
{
Expand All @@ -130,6 +146,16 @@ public void TestDynamicCondition_Changed()
AssertSucceeded(A, B, C);
}

[Fact]
public void TestDynamicCondition_Throwing()
{
B.DynamicConditions.Add(("condition", () => throw new Exception()));
var action = () => ExecuteBuild();

action.Should().Throw<TargetExecutionException>()
.WithMessage("Target 'B' has thrown an exception.");
}

[Fact]
public void TestMixedConditions()
{
Expand All @@ -140,22 +166,13 @@ public void TestMixedConditions()
}

[Fact]
public void TestThrowingCondition()
{
A.StaticConditions.Add(("condition", () => throw new Exception()));
var action = () => ExecuteBuild();

action.Should().Throw<TargetExecutionException>();
}

[Fact]
public void TestSkipTriggers()
public void TestTriggers_Skipped()
{
B.ExecutionDependencies.Clear();
C.ExecutionDependencies.Clear();
A.DynamicConditions.Add(("condition", () => false));
A.Triggers.Add(B);
B.Triggers.Add(C);
B.ExecutionDependencies.Clear();
C.ExecutionDependencies.Clear();

ExecuteBuild();

Expand Down
7 changes: 5 additions & 2 deletions source/Nuke.Build/Execution/BuildExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,11 @@ private static void MarkTargetSkipped(INukeBuild build, ExecutableTarget target,
if (target.Status != ExecutionStatus.Scheduled)
return;

target.Status = ExecutionStatus.Skipped;
target.Skipped ??= reason;
if (!target.Invoked)
{
target.Status = ExecutionStatus.Skipped;
target.Skipped ??= reason;
}

if (target.DependencyBehavior == DependencyBehavior.Execute)
return;
Expand Down
1 change: 1 addition & 0 deletions source/Nuke.Build/Execution/BuildManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public static int Execute<T>(Expression<Func<T, Target>>[] defaultTargetExpressi
if (!build.NoLogo)
build.WriteLogo();

// TODO: move InvokedTargets to ExecutableTargetFactory
build.ExecutionPlan = ExecutionPlanner.GetExecutionPlan(
build.ExecutableTargets,
ParameterService.GetParameter<string[]>(() => build.InvokedTargets));
Expand Down
8 changes: 4 additions & 4 deletions source/Nuke.Build/Execution/ExecutionPlanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ public static IReadOnlyCollection<ExecutableTarget> GetExecutionPlan(
IReadOnlyCollection<ExecutableTarget> executableTargets,
[CanBeNull] IReadOnlyCollection<string> invokedTargetNames)
{
var invokedTargets = invokedTargetNames?.Select(x => GetExecutableTarget(x, executableTargets)).ToList() ??
executableTargets.Where(x => x.IsDefault).ToList();
invokedTargets.ForEach(x => x.Invoked = true);
var invokedTargets = invokedTargetNames?.Select(x => GetExecutableTarget(x, executableTargets)).ToList();
invokedTargets?.ForEach(x => x.Invoked = true);

// Repeat to create the plan with triggers taken into account until plan doesn't change
IReadOnlyCollection<ExecutableTarget> executionPlan;
Expand Down Expand Up @@ -74,7 +73,8 @@ private static IReadOnlyCollection<ExecutableTarget> GetExecutionPlanInternal(
graphAsList.Remove(independent);

var executableTarget = independent.Value;
if (!invokedTargets.Contains(executableTarget) &&
if (!(invokedTargets != null && invokedTargets.Contains(executableTarget)) &&
!(invokedTargets == null && executableTarget.IsDefault) &&
!scheduledTargets.SelectMany(x => x.ExecutionDependencies).Contains(executableTarget))
continue;

Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Build/INukeBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Nuke.Common;
[PublicAPI]
public interface INukeBuild
{
void ReportSummary(Configure<IDictionary<string, string>> configurator = null);
void ReportSummary(Configure<Dictionary<string, string>> configurator = null);

internal IReadOnlyCollection<ExecutableTarget> ExecutableTargets { get; }
internal IReadOnlyCollection<IBuildExtension> BuildExtensions { get; }
Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Build/NukeBuild.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,13 @@ ExecutionStatus.Aborted or

private bool IsInterceptorExecution => Environment.GetEnvironmentVariable(InterceptorEnvironmentKey) == "1";

public void ReportSummary(Configure<IDictionary<string, string>> configurator = null)
public void ReportSummary(Configure<Dictionary<string, string>> configurator = null)
{
var target = ExecutionPlan.Single(x => x.Status == ExecutionStatus.Running);
ReportSummary(target, configurator);
}

internal void ReportSummary(ExecutableTarget target, Configure<IDictionary<string, string>> configurator)
internal void ReportSummary(ExecutableTarget target, Configure<Dictionary<string, string>> configurator)
{
target.SummaryInformation = configurator.InvokeSafe(new Dictionary<string, string>()).ToDictionary(x => x.Key, x => x.Value);
ExecuteExtension<IOnTargetSummaryUpdated>(x => x.OnTargetSummaryUpdated(this, target));
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Build/Telemetry/Telemetry.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public static void AddPackage()
.AddDictionary(GetRepositoryProperties(EnvironmentInfo.WorkingDirectory)));
}

private static void TrackEvent(string eventName, Func<IDictionary<string, string>> propertiesProvider)
private static void TrackEvent(string eventName, Func<Dictionary<string, string>> propertiesProvider)
{
if (s_client == null)
return;
Expand Down
13 changes: 7 additions & 6 deletions source/Nuke.Build/Telemetry/Telemetry.Properties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
Expand All @@ -20,7 +21,7 @@ internal partial class Telemetry
{
private static readonly string[] s_knownTargets = { "Restore", "Compile", "Test" };

private static IDictionary<string, string> GetCommonProperties(INukeBuild build = null)
private static Dictionary<string, string> GetCommonProperties(INukeBuild build = null)
{
var version = ControlFlow.SuppressErrors(
() =>
Expand All @@ -42,7 +43,7 @@ private static IDictionary<string, string> GetCommonProperties(INukeBuild build
};
}

private static IDictionary<string, string> GetRepositoryProperties(string directory)
private static Dictionary<string, string> GetRepositoryProperties(string directory)
{
var repository = ControlFlow.SuppressErrors(() => GitRepository.FromLocalDirectory(directory), logWarning: false);
if (repository == null)
Expand Down Expand Up @@ -76,7 +77,7 @@ private static IDictionary<string, string> GetRepositoryProperties(string direct
};
}

private static IDictionary<string, string> GetBuildProperties(INukeBuild build)
private static ReadOnlyDictionary<string, string> GetBuildProperties(INukeBuild build)
{
var startTimeString = EnvironmentInfo.Variables.GetValueOrDefault(Constants.GlobalToolStartTimeEnvironmentKey);
var compileTime = startTimeString != null
Expand All @@ -99,10 +100,10 @@ private static IDictionary<string, string> GetBuildProperties(INukeBuild build)
.Select(GetTypeName).Distinct().OrderBy(x => x).JoinCommaSpace(),
["build_components"] = build.GetType().GetInterfaces().Where(x => IsCommonType(x) && x != typeof(INukeBuild))
.Select(GetTypeName).Distinct().OrderBy(x => x).JoinCommaSpace()
};
}.AsReadOnly();
}

private static IDictionary<string, string> GetTargetProperties(INukeBuild build, ExecutableTarget target)
private static Dictionary<string, string> GetTargetProperties(INukeBuild build, ExecutableTarget target)
{
return new Dictionary<string, string>
{
Expand All @@ -113,7 +114,7 @@ private static IDictionary<string, string> GetTargetProperties(INukeBuild build,
};
}

private static IDictionary<string, string> GetGeneratorProperties(Type hostType, string generatorId)
private static Dictionary<string, string> GetGeneratorProperties(Type hostType, string generatorId)
{
return new Dictionary<string, string>
{
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Common/CI/AzurePipelines/AzurePipelines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private string GetText(AzurePipelinesIssueType type)
public void WriteCommand(
string command,
string message = null,
Func<IDictionary<string, object>, IDictionary<string, object>> dictionaryConfigurator = null)
Func<Dictionary<string, object>, Dictionary<string, object>> dictionaryConfigurator = null)
{
var escapedTokens =
dictionaryConfigurator?
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Common/CI/GitHubActions/GitHubActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void WriteError(string message)
public void WriteCommand(
string command,
string message = null,
Configure<IDictionary<string, object>> dictionaryConfigurator = null)
Configure<Dictionary<string, object>> dictionaryConfigurator = null)
{
var parameters = dictionaryConfigurator.InvokeSafe(new Dictionary<string, object>())
.Select(x => $"{x.Key}={EscapeProperty(x.Value.ToString())}")
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Common/CI/TeamCity/TeamCity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ public void WriteError(string text, string errorDetails = null)
.AddPairWhenValueNotNull("errorDetails", errorDetails));
}

public void Write(string command, Func<IDictionary<string, object>, IDictionary<string, object>> dictionaryConfigurator)
public void Write(string command, Func<Dictionary<string, object>, Dictionary<string, object>> dictionaryConfigurator)
{
Write(new[] { command }.Concat(dictionaryConfigurator(new Dictionary<string, object>())
.Select(x => $"{x.Key}='{Escape(x.Value.ToString())}'")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using JetBrains.Annotations;
Expand Down Expand Up @@ -142,7 +141,7 @@ bool IsUpToDate() => build.BuildAssemblyDirectory.GlobFiles("*.dll")
return definition;
}

private static IReadOnlyDictionary<string, string> GetEnvironmentVariables(
private static Dictionary<string, string> GetEnvironmentVariables(
ToolSettings settings,
AbsolutePath rootDirectory,
AbsolutePath tempDirectory)
Expand Down Expand Up @@ -184,7 +183,6 @@ private static IReadOnlyDictionary<string, string> GetEnvironmentVariables(
!x.Key.Contains(' ') &&
!x.Key.EqualsAnyOrdinalIgnoreCase(excludedEnvironmentVariables) &&
!x.Value.Contains(EnvironmentInfo.NewLine))
.ToDictionary(x => x.Key, _ => default(string)).AsReadOnly())
.ToImmutableSortedDictionary();
.ToDictionary(x => x.Key, _ => default(string)));
}
}
Loading

0 comments on commit fd4f71b

Please sign in to comment.