Skip to content

Commit 19d2fb0

Browse files
authored
Merge branch 'develop' into rmarusyk/4187
2 parents 3cc0cf1 + 4ae30f3 commit 19d2fb0

File tree

27 files changed

+335
-49
lines changed

27 files changed

+335
-49
lines changed

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
| Version | Supported |
66
| --------- | ------------------ |
77
| 3.x.x | :white_check_mark: |
8-
| 2.x.x | :white_check_mark: |
8+
| 2.x.x | :x: |
99
| 1.0.x | :x: |
1010
| 0.38.5 | :x: |
1111
| <= 0.38.4 | :x: |

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"src"
44
],
55
"sdk": {
6-
"version": "7.0.305",
6+
"version": "7.0.401",
77
"rollForward": "latestFeature"
88
}
99
}

src/Cake.Cli/Cake.Cli.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="Autofac" Version="7.0.1" />
21+
<PackageReference Include="Autofac" Version="7.1.0" />
2222
<PackageReference Include="Spectre.Console" Version="0.46.0" />
2323
<PackageReference Include="Spectre.Console.Cli" Version="0.46.0" />
2424
</ItemGroup>

src/Cake.Common.Tests/Cake.Common.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
</ItemGroup>
1717
<!-- Global packages -->
1818
<ItemGroup>
19-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.3" />
20-
<PackageReference Include="xunit" Version="2.5.0" />
21-
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.0">
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
20+
<PackageReference Include="xunit" Version="2.5.1" />
21+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
2222
<PrivateAssets>all</PrivateAssets>
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
2424
</PackageReference>
25-
<PackageReference Include="NSubstitute" Version="5.0.0" />
25+
<PackageReference Include="NSubstitute" Version="5.1.0" />
2626
<PackageReference Include="Castle.Core" Version="5.1.1" />
2727
</ItemGroup>
2828
<!-- .NET Framework packages -->

src/Cake.Common.Tests/Unit/Build/AzurePipelines/AzurePipelinesCommandTests.cs

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,48 @@ public void Should_Log_Error_Message_With_Data()
127127
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[task.logissue sourcepath=./code.cs;linenumber=1;columnnumber=2;code=3;type=error;]build error");
128128
}
129129

130+
[Fact]
131+
public void Should_Begin_Group_With_Name()
132+
{
133+
// Given
134+
var fixture = new AzurePipelinesFixture();
135+
var service = fixture.CreateAzurePipelinesService();
136+
137+
// When
138+
service.Commands.BeginGroup("Example Group");
139+
140+
// Then
141+
Assert.Contains(fixture.Writer.Entries, m => m == $"##[group]Example Group");
142+
}
143+
144+
[Fact]
145+
public void Should_End_Group()
146+
{
147+
// Given
148+
var fixture = new AzurePipelinesFixture();
149+
var service = fixture.CreateAzurePipelinesService();
150+
151+
// When
152+
service.Commands.EndGroup();
153+
154+
// Then
155+
Assert.Contains(fixture.Writer.Entries, m => m == $"##[endgroup]");
156+
}
157+
158+
[Fact]
159+
public void Should_Section_With_Name()
160+
{
161+
// Given
162+
var fixture = new AzurePipelinesFixture();
163+
var service = fixture.CreateAzurePipelinesService();
164+
165+
// When
166+
service.Commands.Section("Example Section");
167+
168+
// Then
169+
Assert.Contains(fixture.Writer.Entries, m => m == $"##[section]Example Section");
170+
}
171+
130172
[Fact]
131173
public void Should_Set_Current_Progress()
132174
{
@@ -152,7 +194,7 @@ public void Should_Complete_Current_Task()
152194
service.Commands.CompleteCurrentTask();
153195

154196
// Then
155-
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[task.complete ]DONE");
197+
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[task.complete]DONE");
156198
}
157199

158200
[Fact]
@@ -281,7 +323,7 @@ public void Should_Upload_Task_Summary()
281323
service.Commands.UploadTaskSummary("./summary.md");
282324

283325
// Then
284-
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[task.uploadsummary ]{path}");
326+
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[task.uploadsummary]{path}");
285327
}
286328

287329
[Fact]
@@ -296,7 +338,7 @@ public void Should_Upload_Task_Log()
296338
service.Commands.UploadTaskLogFile("./logs/task.log");
297339

298340
// Then
299-
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[task.uploadfile ]{path}");
341+
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[task.uploadfile]{path}");
300342
}
301343

302344
[Theory]
@@ -432,7 +474,7 @@ public void Should_Upload_Build_Log()
432474
service.Commands.UploadBuildLogFile("./dist/buildlog.txt");
433475

434476
// Then
435-
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[build.uploadlog ]{path}");
477+
Assert.Contains(fixture.Writer.Entries, m => m == $"##vso[build.uploadlog]{path}");
436478
}
437479

438480
[Fact]
@@ -446,7 +488,7 @@ public void Should_Update_Build_Number()
446488
service.Commands.UpdateBuildNumber("CIBuild_1");
447489

448490
// Then
449-
Assert.Contains(fixture.Writer.Entries, m => m == "##vso[build.updatebuildnumber ]CIBuild_1");
491+
Assert.Contains(fixture.Writer.Entries, m => m == "##vso[build.updatebuildnumber]CIBuild_1");
450492
}
451493

452494
[Fact]
@@ -460,7 +502,7 @@ public void Should_Add_Build_Tag()
460502
service.Commands.AddBuildTag("Stable");
461503

462504
// Then
463-
Assert.Contains(fixture.Writer.Entries, m => m == "##vso[build.addbuildtag ]Stable");
505+
Assert.Contains(fixture.Writer.Entries, m => m == "##vso[build.addbuildtag]Stable");
464506
}
465507

466508
[Fact]

src/Cake.Common.Tests/Unit/Tools/DotNet/MSBuild/DotNetMSBuildBuilderTests.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System;
6+
using Cake.Common.Tests.Fixtures.Tools;
67
using Cake.Common.Tests.Fixtures.Tools.DotNet.MSBuild;
78
using Cake.Common.Tools.DotNet;
89
using Cake.Common.Tools.DotNet.MSBuild;
@@ -801,6 +802,20 @@ public void Should_Add_Host_Arguments()
801802
// Then
802803
Assert.Equal("--diagnostics msbuild", result.Args);
803804
}
805+
806+
[Fact]
807+
public void Should_Use_Node_Reuse_If_Specified()
808+
{
809+
// Given
810+
var fixture = new DotNetMSBuildBuilderFixture();
811+
fixture.Settings.NodeReuse = true;
812+
813+
// When
814+
var result = fixture.Run();
815+
816+
// Then
817+
Assert.Equal("msbuild /nodeReuse:true", result.Args);
818+
}
804819
}
805820

806821
public class TheConsoleLoggerSettingsProperty

src/Cake.Common.Tests/Unit/Tools/DotNet/MSBuild/DotNetMSBuildSettingsExtensionsTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,37 @@ public void Should_Return_The_Same_Configuration()
712712
}
713713
}
714714

715+
public sealed class TheNodeReuseMethod
716+
{
717+
[Theory]
718+
[InlineData(true)]
719+
[InlineData(false)]
720+
public void Should_Set_Node_Reuse(bool reuse)
721+
{
722+
// Given
723+
var settings = new DotNetMSBuildSettings();
724+
725+
// When
726+
settings.SetNodeReuse(reuse);
727+
728+
// Then
729+
Assert.Equal(reuse, settings.NodeReuse);
730+
}
731+
732+
[Fact]
733+
public void Should_Return_The_Same_Configuration()
734+
{
735+
// Given
736+
var settings = new DotNetMSBuildSettings();
737+
738+
// When
739+
var result = settings.SetNodeReuse(true);
740+
741+
// Then
742+
Assert.Equal(settings, result);
743+
}
744+
}
745+
715746
public sealed class TheSetConfigurationMethod
716747
{
717748
private const string Configuration = "TheConfiguration";

src/Cake.Common.Tests/Unit/Tools/DotNet/MSBuild/DotNetMSBuildSettingsTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,5 +484,18 @@ public void Should_Be_Empty_By_Default()
484484
Assert.Empty(settings.DistributedLoggers);
485485
}
486486
}
487+
488+
public sealed class TheNodeReuseProperty
489+
{
490+
[Fact]
491+
public void Should_Be_Null_By_Default()
492+
{
493+
// Given
494+
var settings = new DotNetMSBuildSettings();
495+
496+
// Then
497+
Assert.Null(settings.NodeReuse);
498+
}
499+
}
487500
}
488501
}

src/Cake.Common/Build/AzurePipelines/AzurePipelinesCommands.cs

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace Cake.Common.Build.AzurePipelines
1818
/// </summary>
1919
public sealed class AzurePipelinesCommands : IAzurePipelinesCommands
2020
{
21+
private const string FormatPrefix = "##[";
2122
private const string MessagePrefix = "##vso[";
2223
private const string MessagePostfix = "]";
2324

@@ -69,6 +70,24 @@ public void WriteError(string message, AzurePipelinesMessageData data)
6970
WriteLoggingCommand("task.logissue", properties, message);
7071
}
7172

73+
/// <inheritdoc/>
74+
public void BeginGroup(string name)
75+
{
76+
WriteFormatCommand("group", name);
77+
}
78+
79+
/// <inheritdoc/>
80+
public void EndGroup()
81+
{
82+
WriteFormatCommand("endgroup", string.Empty);
83+
}
84+
85+
/// <inheritdoc/>
86+
public void Section(string name)
87+
{
88+
WriteFormatCommand("section", name);
89+
}
90+
7291
/// <inheritdoc/>
7392
public void SetProgress(int progress, string currentOperation)
7493
{
@@ -287,9 +306,14 @@ public void PublishCodeCoverage(FilePath summaryFilePath, Action<AzurePipelinesP
287306
PublishCodeCoverage(summaryFilePath, data);
288307
}
289308

309+
private void WriteFormatCommand(string actionName, string value)
310+
{
311+
_writer.Write("{0}{1}{2}{3}", FormatPrefix, actionName, MessagePostfix, value);
312+
}
313+
290314
private void WriteLoggingCommand(string actionName, string value)
291315
{
292-
WriteLoggingCommand(actionName, new Dictionary<string, string>(), value);
316+
_writer.Write("{0}{1}{2}{3}", MessagePrefix, actionName, MessagePostfix, value);
293317
}
294318

295319
private void WriteLoggingCommand(string actionName, Dictionary<string, string> properties, string value)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using System;
6+
7+
namespace Cake.Common.Build.AzurePipelines
8+
{
9+
/// <summary>
10+
/// A set of extensions for allowing "using" with Azure Pipelines "blocks".
11+
/// </summary>
12+
public static class AzurePipelinesDisposableExtensions
13+
{
14+
/// <summary>
15+
/// Groups Azure Pipelines output.
16+
/// </summary>
17+
/// <param name="azurePipelinesCommands">The Azure Pipelines Commands.</param>
18+
/// <param name="name">The name.</param>
19+
/// <returns>An <see cref="IDisposable"/>.</returns>
20+
public static IDisposable Group(this IAzurePipelinesCommands azurePipelinesCommands, string name)
21+
{
22+
ArgumentNullException.ThrowIfNull(name);
23+
24+
azurePipelinesCommands.BeginGroup(name);
25+
return new AzurePipelinesActionDisposable<IAzurePipelinesCommands>(azurePipelinesCommands, apc => apc.EndGroup());
26+
}
27+
28+
/// <summary>
29+
/// Disposable helper for writing Azure Pipelines message blocks.
30+
/// </summary>
31+
internal sealed class AzurePipelinesActionDisposable<T> : IDisposable
32+
{
33+
private readonly Action<T> _disposeAction;
34+
private readonly T _instance;
35+
36+
/// <summary>
37+
/// Initializes a new instance of the <see cref="AzurePipelinesActionDisposable{T}"/> class.
38+
/// </summary>
39+
/// <param name="instance">The instance.</param>
40+
/// <param name="disposeAction">The dispose action.</param>
41+
public AzurePipelinesActionDisposable(T instance, Action<T> disposeAction)
42+
{
43+
_instance = instance;
44+
_disposeAction = disposeAction;
45+
}
46+
47+
/// <summary>
48+
/// Calls dispose action.
49+
/// </summary>
50+
public void Dispose()
51+
{
52+
_disposeAction(_instance);
53+
}
54+
}
55+
}
56+
}

src/Cake.Common/Build/AzurePipelines/IAzurePipelinesCommands.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,23 @@ public interface IAzurePipelinesCommands
3939
/// <param name="data">The message data.</param>
4040
void WriteError(string message, AzurePipelinesMessageData data);
4141

42+
/// <summary>
43+
/// Begin a collapsible group.
44+
/// </summary>
45+
/// <param name="name">The name of the group.</param>
46+
public void BeginGroup(string name);
47+
48+
/// <summary>
49+
/// End a collapsible group.
50+
/// </summary>
51+
public void EndGroup();
52+
53+
/// <summary>
54+
/// Log section.
55+
/// </summary>
56+
/// <param name="name">The name of the section.</param>
57+
public void Section(string name);
58+
4259
/// <summary>
4360
/// Set progress and current operation for current task.
4461
/// </summary>

src/Cake.Common/Tools/DotNet/MSBuild/DotNetMSBuildSettings.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,13 @@ public string PackageReleaseNotes
214214
/// </summary>
215215
public IList<string> WarningCodesAsMessage { get; }
216216

217+
/// <summary>
218+
/// Gets or sets a value indicating whether or not node reuse is used.
219+
/// When you’re doing multiple builds in a row, this helps reduce your total build time,
220+
/// by avoiding the start up costs of each MSBuild child node.
221+
/// </summary>
222+
public bool? NodeReuse { get; set; }
223+
217224
/// <summary>
218225
/// Initializes a new instance of the <see cref="DotNetMSBuildSettings"/> class.
219226
/// </summary>

0 commit comments

Comments
 (0)