Skip to content

Commit 6a588e0

Browse files
committed
Merge branch 'develop' of https://github.com/Marusyk/cake into rmarusyk/4224
2 parents f7b18fa + ed61202 commit 6a588e0

File tree

144 files changed

+1002
-709
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+1002
-709
lines changed

.config/dotnet-tools.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"cake.tool": {
6-
"version": "3.1.0",
6+
"version": "4.0.0",
77
"commands": [
88
"dotnet-cake"
99
]

.editorconfig

+11-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,14 @@ indent_size = 4
2020

2121
[*.js]
2222
indent_style = tab
23-
indent_size = 2
23+
indent_size = 2
24+
25+
# Verify settings
26+
[*.{received,verified}.{txt,xml,json,cake}]
27+
charset = "utf-8-bom"
28+
end_of_line = lf
29+
indent_size = unset
30+
indent_style = unset
31+
insert_final_newline = false
32+
tab_width = unset
33+
trim_trailing_whitespace = false

.gitattributes

+13-4
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919
# Merging from the command prompt will add diff markers to the files if there
2020
# are conflicts (Merging from VS is not affected by the settings below, in VS
21-
# the diff markers are never inserted). Diff markers may cause the following
21+
# the diff markers are never inserted). Diff markers may cause the following
2222
# file extensions to fail to load in VS. An alternative would be to treat
2323
# these files as binary and thus will always conflict and require user
2424
# intervention with every merge. To do so, just uncomment the entries below
@@ -47,9 +47,9 @@
4747

4848
###############################################################################
4949
# diff behavior for common document formats
50-
#
50+
#
5151
# Convert binary document formats to text before diffing them. This feature
52-
# is only available from the command line. Turn it on by uncommenting the
52+
# is only available from the command line. Turn it on by uncommenting the
5353
# entries below.
5454
###############################################################################
5555
#*.doc diff=astextplain
@@ -61,4 +61,13 @@
6161
#*.pdf diff=astextplain
6262
#*.PDF diff=astextplain
6363
#*.rtf diff=astextplain
64-
#*.RTF diff=astextplain
64+
#*.RTF diff=astextplain
65+
66+
###############################################################################
67+
# Verify files
68+
###############################################################################
69+
70+
*.verified.txt text eol=lf working-tree-encoding=UTF-8
71+
*.verified.xml text eol=lf working-tree-encoding=UTF-8
72+
*.verified.json text eol=lf working-tree-encoding=UTF-8
73+
*.verified.cake text eol=lf working-tree-encoding=UTF-8

.github/workflows/build.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23-
- name: Install .NET SDK 6.0.x
23+
- name: Install .NET SDK 6.0.x - 8.0.x
2424
uses: actions/setup-dotnet@v3
2525
with:
26-
dotnet-version: '6.0.x'
26+
dotnet-version: |
27+
6.0.x
28+
7.0.x
29+
8.0.x
2730
2831
- name: Install .NET Core SDK (global.json)
2932
uses: actions/setup-dotnet@v3
@@ -46,4 +49,5 @@ jobs:
4649
arguments: |
4750
CAKE_NETCOREAPP_6_0_VERSION_OS: ${{ steps.build-cake.outputs.CAKE_NETCOREAPP_6_0_VERSION_OS }}
4851
CAKE_NETCOREAPP_7_0_VERSION_OS: ${{ steps.build-cake.outputs.CAKE_NETCOREAPP_7_0_VERSION_OS }}
49-
52+
CAKE_NETCOREAPP_8_0_VERSION_OS: ${{ steps.build-cake.outputs.CAKE_NETCOREAPP_8_0_VERSION_OS }}
53+
ValidateGitHubActionsProvider: true

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,7 @@ Thumbs.db
9494
.DS_Store
9595

9696
# Generated Assembly info
97-
AssemblyInfo.Generated.cs
97+
AssemblyInfo.Generated.cs
98+
99+
# Verify
100+
*.received

GitVersion.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
next-version: 3.0.0
1+
next-version: 4.0.0
22
branches:
33
master:
44
regex: main

ReleaseNotes.md

+23
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
### New in 4.0.0 (Released 2023/11/18)
2+
3+
* 4266 Update LatestPotentialBreakingChange to 4.0.0.
4+
* 4132 Add File APIs for setting timestamps (creation time, last write time, last access time).
5+
* 4250 Update System.Collections.Immutable to 8.0.0.
6+
* 4260 Unzip alias should support overwrite files.
7+
* 4251 Update System.Reflection.Metadata 8.0.0.
8+
* 4249 Update Microsoft.Extensions.DependencyInjection to 8.0.0.
9+
* 4197 Execution of Cake script fails if an addin defines an alias that uses nullable reference types in its signature.
10+
* 4150 Cake script is contributing unactionable diagnostics in VS Code Problems pane.
11+
12+
### New in 3.2.0 (Released 2023/11/10)
13+
14+
* 4225 Add DotNetRemovePackage alias for dotnet remove package command.
15+
* 4187 Add DotNetAddPackage alias for dotnet add package command.
16+
* 4221 Add Azure Pipelines group logging commands.
17+
* 4219 Update Microsoft.CodeAnalysis.CSharp.Scripting to 4.7.0.
18+
* 4217 Update NuGet.* to 6.7.0.
19+
* 4215 Update Autofac to 7.1.0.
20+
* 4157 Upgrading to spectre.console 0.47.0 breaks the cake build.
21+
* 4144 DotNetMSBuildSettings is missing NodeReuse.
22+
* 3996 Error: Bad IL format with Cake MacOSX (2.3.0 - 3.1.0).
23+
124
### New in 3.1.0 (Released 2023/07/09)
225

326
* 4122 Call multiple tasks from CLI in Frosting.

SECURITY.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
| Version | Supported |
66
| --------- | ------------------ |
7-
| 3.x.x | :white_check_mark: |
7+
| 4.x.x | :white_check_mark: |
8+
| 3.x.x | :x: |
89
| 2.x.x | :x: |
910
| 1.0.x | :x: |
1011
| 0.38.5 | :x: |

build.cake

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
// Install .NET Core Global tools.
55
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitVersion.Tool&version=5.12.0"
6-
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.13.0"
7-
#tool "dotnet:https://api.nuget.org/v3/index.json?package=sign&version=0.9.1-beta.23274.1&prerelease"
6+
#tool "dotnet:https://api.nuget.org/v3/index.json?package=GitReleaseManager.Tool&version=0.16.0"
7+
#tool "dotnet:https://api.nuget.org/v3/index.json?package=sign&version=0.9.1-beta.23530.1&prerelease"
88

99
// Load other scripts.
1010
#load "./build/parameters.cake"
@@ -108,7 +108,7 @@ Task("Run-Unit-Tests")
108108
() => GetFiles("./src/**/*.Tests.csproj"),
109109
(parameters, project, context) =>
110110
{
111-
foreach(var framework in new[] { "net6.0", "net7.0" })
111+
foreach(var framework in new[] { "net6.0", "net7.0", "net8.0" })
112112
{
113113
FilePath testResultsPath = MakeAbsolute(parameters.Paths.Directories.TestResults
114114
.CombineWithFilePath($"{project.GetFilenameWithoutExtension()}_{framework}_TestResults.xml"));
@@ -368,7 +368,8 @@ Task("Run-Integration-Tests")
368368
.DoesForEach<BuildParameters, FilePath>(
369369
parameters => new[] {
370370
GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net6.0/**/Cake.dll").Single(),
371-
GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net7.0/**/Cake.dll").Single()
371+
GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net7.0/**/Cake.dll").Single(),
372+
GetFiles($"{parameters.Paths.Directories.IntegrationTestsBinTool.FullPath}/**/net8.0/**/Cake.dll").Single()
372373
},
373374
(parameters, cakeAssembly, context) =>
374375
{

global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"src"
44
],
55
"sdk": {
6-
"version": "7.0.402",
6+
"version": "8.0.100",
77
"rollForward": "latestFeature"
88
}
99
}

src/Cake.Cli/Cake.Cli.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<ItemGroup>
2121
<PackageReference Include="Autofac" Version="7.1.0" />
22-
<PackageReference Include="Spectre.Console" Version="0.46.0" />
23-
<PackageReference Include="Spectre.Console.Cli" Version="0.46.0" />
22+
<PackageReference Include="Spectre.Console" Version="0.47.0" />
23+
<PackageReference Include="Spectre.Console.Cli" Version="0.47.0" />
2424
</ItemGroup>
2525
</Project>

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
</ItemGroup>
1717
<!-- Global packages -->
1818
<ItemGroup>
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">
19+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
20+
<PackageReference Include="xunit" Version="2.6.2" />
21+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
2222
<PrivateAssets>all</PrivateAssets>
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
2424
</PackageReference>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 Cake.Common.Tools.DotNet.Package.Remove;
6+
7+
namespace Cake.Common.Tests.Fixtures.Tools.DotNet.Package.Remove
8+
{
9+
internal sealed class DotNetPackageRemoverFixture : DotNetFixture<DotNetPackageRemoveSettings>
10+
{
11+
public string PackageName { get; set; }
12+
13+
public string Project { get; set; }
14+
15+
protected override void RunTool()
16+
{
17+
var tool = new DotNetPackageRemover(FileSystem, Environment, ProcessRunner, Tools);
18+
tool.Remove(PackageName, Project);
19+
}
20+
}
21+
}

src/Cake.Common.Tests/Unit/Tools/DotNet/Package/Add/DotNetPackageAdderTests.cs

-3
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
// See the LICENSE file in the project root for more information.
44

55
using Cake.Common.Tests.Fixtures.Tools.DotNet.Package.Add;
6-
using Cake.Common.Tests.Fixtures.Tools.DotNet.SDKCheck;
7-
using Cake.Common.Tests.Fixtures.Tools.DotNet.Workload.Restore;
86
using Cake.Common.Tools.DotNet;
9-
using Cake.Common.Tools.DotNet.Package.Add;
107
using Cake.Testing;
118
using Xunit;
129

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
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 Cake.Common.Tests.Fixtures.Tools.DotNet.Package.Remove;
6+
using Cake.Common.Tools.DotNet;
7+
using Cake.Testing;
8+
using Xunit;
9+
10+
namespace Cake.Common.Tests.Unit.Tools.DotNet.Package.Remove
11+
{
12+
public sealed class DotNetPackageRemoverTests
13+
{
14+
public sealed class TheRemoveMethod
15+
{
16+
[Fact]
17+
public void Should_Throw_If_Process_Was_Not_Started()
18+
{
19+
// Given
20+
var fixture = new DotNetPackageRemoverFixture();
21+
fixture.PackageName = "Microsoft.AspNetCore.StaticFiles";
22+
fixture.GivenProcessCannotStart();
23+
24+
// When
25+
var result = Record.Exception(() => fixture.Run());
26+
27+
// Then
28+
AssertEx.IsCakeException(result, ".NET CLI: Process was not started.");
29+
}
30+
31+
[Fact]
32+
public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
33+
{
34+
// Given
35+
var fixture = new DotNetPackageRemoverFixture();
36+
fixture.PackageName = "Microsoft.AspNetCore.StaticFiles";
37+
fixture.GivenProcessExitsWithCode(1);
38+
39+
// When
40+
var result = Record.Exception(() => fixture.Run());
41+
42+
// Then
43+
AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1).");
44+
}
45+
46+
[Fact]
47+
public void Should_Throw_If_PackageName_Is_Null()
48+
{
49+
// Given
50+
var fixture = new DotNetPackageRemoverFixture();
51+
fixture.PackageName = null;
52+
fixture.GivenDefaultToolDoNotExist();
53+
54+
// When
55+
var result = Record.Exception(() => fixture.Run());
56+
57+
// Then
58+
AssertEx.IsArgumentNullException(result, "packageName");
59+
}
60+
61+
[Fact]
62+
public void Should_Add_Project_Argument()
63+
{
64+
// Given
65+
var fixture = new DotNetPackageRemoverFixture();
66+
fixture.PackageName = "Microsoft.AspNetCore.StaticFiles";
67+
fixture.Project = "ToDo.csproj";
68+
69+
// When
70+
var result = fixture.Run();
71+
72+
// Then
73+
Assert.Equal("remove \"ToDo.csproj\" package Microsoft.AspNetCore.StaticFiles", result.Args);
74+
}
75+
}
76+
}
77+
}

src/Cake.Common/IO/ZipAliases.cs

+18-5
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,27 @@ public static void Zip(this ICakeContext context, DirectoryPath rootPath, FilePa
135135
/// </example>
136136
[CakeMethodAlias]
137137
public static void Unzip(this ICakeContext context, FilePath zipFile, DirectoryPath outputPath)
138+
=> context.Unzip(zipFile, outputPath, false);
139+
140+
/// <summary>
141+
/// Unzips the specified file.
142+
/// </summary>
143+
/// <param name="context">The context.</param>
144+
/// <param name="zipFile">Zip file to unzip.</param>
145+
/// <param name="outputPath">Output path to unzip into.</param>
146+
/// <param name="overwriteFiles">Flag for if files should be overwritten in output.</param>
147+
/// <example>
148+
/// <code>
149+
/// Unzip("Cake.zip", "./cake", true);
150+
/// </code>
151+
/// </example>
152+
[CakeMethodAlias]
153+
public static void Unzip(this ICakeContext context, FilePath zipFile, DirectoryPath outputPath, bool overwriteFiles)
138154
{
139-
if (context == null)
140-
{
141-
throw new ArgumentNullException(nameof(context));
142-
}
155+
ArgumentNullException.ThrowIfNull(context);
143156

144157
var zipper = new Zipper(context.FileSystem, context.Environment, context.Log);
145-
zipper.Unzip(zipFile, outputPath);
158+
zipper.Unzip(zipFile, outputPath, overwriteFiles);
146159
}
147160
}
148161
}

src/Cake.Common/IO/Zipper.cs

+13-10
Original file line numberDiff line numberDiff line change
@@ -204,22 +204,25 @@ public void Zip(DirectoryPath rootPath, FilePath outputPath, IEnumerable<FilePat
204204
/// <param name="zipPath">Zip file path.</param>
205205
/// <param name="outputPath">Output directory path.</param>
206206
public void Unzip(FilePath zipPath, DirectoryPath outputPath)
207+
=> Unzip(zipPath, outputPath, false);
208+
209+
/// <summary>
210+
/// Unzips the specified file to the specified output path.
211+
/// </summary>
212+
/// <param name="zipPath">Zip file path.</param>
213+
/// <param name="outputPath">Output directory path.</param>
214+
/// <param name="overwriteFiles">Flag for if files should be overwritten in output.</param>
215+
public void Unzip(FilePath zipPath, DirectoryPath outputPath, bool overwriteFiles)
207216
{
208-
if (zipPath == null)
209-
{
210-
throw new ArgumentNullException(nameof(zipPath));
211-
}
212-
if (outputPath == null)
213-
{
214-
throw new ArgumentNullException(nameof(outputPath));
215-
}
217+
ArgumentNullException.ThrowIfNull(zipPath);
218+
ArgumentNullException.ThrowIfNull(outputPath);
216219

217220
// Make root path and output file path absolute.
218221
zipPath = zipPath.MakeAbsolute(_environment);
219222
outputPath = outputPath.MakeAbsolute(_environment);
220223

221-
_log.Verbose("Unzipping file {0} to {1}", zipPath.FullPath, outputPath.FullPath);
222-
ZipFile.ExtractToDirectory(zipPath.FullPath, outputPath.FullPath);
224+
_log.Verbose("Unzipping file {0} to {1} (overwrite files: {2})", zipPath.FullPath, outputPath.FullPath, overwriteFiles);
225+
ZipFile.ExtractToDirectory(zipPath.FullPath, outputPath.FullPath, overwriteFiles);
223226
}
224227

225228
private string GetRelativePath(DirectoryPath root, Path path)

0 commit comments

Comments
 (0)