Skip to content

Commit

Permalink
Merge branch 'release/2.2.0' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
devlead committed Apr 14, 2022
2 parents 4606ac7 + f38bb05 commit 7fa4a79
Show file tree
Hide file tree
Showing 49 changed files with 1,488 additions and 163 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"cake.tool": {
"version": "2.0.0",
"version": "2.1.0",
"commands": [
"dotnet-cake"
]
Expand Down
6 changes: 2 additions & 4 deletions GitReleaseManager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ close:
The release is available on:
- [GitHub Release](https://github.com/{owner}/{repository}/releases/tag/{milestone})
- [NuGet Package](https://www.nuget.org/packages/Cake/{milestone})
- [Chocolatey Package](https://chocolatey.org/packages/cake.portable/{milestone})
- [.Net Global Tool](https://www.nuget.org/packages/Cake.Tool/{milestone})
- [.NET Tool](https://www.nuget.org/packages/Cake.Tool/{milestone})
Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package::rocket:
19 changes: 19 additions & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
### New in 2.2.0 (Released 2022/04/15)

* 3821 PostAction is not setable on DotNetSettings.
* 3485 Add alias for dotnet workload search command.
* 2099 Cache compiled script on disk.
* 3866 Update Microsoft.NETCore.Platforms to 6.0.3.
* 3854 Update Spectre.Console to 0.44.0.
* 3851 Update System.Reflection.Metadata to 6.0.1.
* 3846 Update Microsoft.CodeAnalysis.CSharp.Scripting to 4.1.0.
* 3844 Update Microsoft.NETCore.Platforms to 6.0.2.
* 3843 Update NuGet.* to 6.1.0.
* 2763 Provide property to return parent directory on DirectoryPath.
* 2431 UploadFile should support option of username/password.
* 3819 Update Git Release Manager Comment template to remove Cake NuGet package and Chocolatey portable.
* 3859 PathCollapser.Collapse breaks UNC paths.
* 3858 PathCollapser.Collapse shows wrong output for if .. is the second segment in the path.
* 3823 Executing a cake script leads to System.IO.FileNotFoundException for several System.(...) assemblies.
* 3735 Incorrect warnings in diagnostic logs.

### New in 2.1.0 (Released 2022/02/19)

* 2524 XmlTransform support for xsl arguments
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"src"
],
"sdk": {
"version": "6.0.102",
"version": "6.0.202",
"rollForward": "latestFeature"
}
}
2 changes: 1 addition & 1 deletion src/Cake.Cli/Cake.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

<ItemGroup>
<PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="Spectre.Console" Version="0.43.0" />
<PackageReference Include="Spectre.Console" Version="0.44.0" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion src/Cake.Common.Tests/Cake.Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>
<!-- Global packages -->
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Collections.Generic;
using Cake.Common.Tools.DotNet.Workload.Search;

namespace Cake.Common.Tests.Fixtures.Tools.DotNet.Workload.Search
{
internal sealed class DotNetWorkloadSearcherFixture : DotNetFixture<DotNetWorkloadSearchSettings>
{
public string SearchString { get; set; }
public IEnumerable<DotNetWorkload> Workloads { get; set; }

public void GivenAvailableWorkloadsResult()
{
ProcessRunner.Process.SetStandardOutput(new string[]
{
"Workload ID Description",
"-----------------------------------------------------",
"maui .NET MAUI SDK for all platforms",
"maui-desktop .NET MAUI SDK for Desktop",
"maui-mobile .NET MAUI SDK for Mobile"
});
}

protected override void RunTool()
{
var tool = new DotNetWorkloadSearcher(FileSystem, Environment, ProcessRunner, Tools);
Workloads = tool.Search(SearchString, Settings);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using Cake.Common.Tests.Fixtures.Tools.DotNet.Workload.Search;
using Cake.Testing;
using Xunit;

namespace Cake.Common.Tests.Unit.Tools.DotNet.Workload.Search
{
public sealed class DotNetWorkloadSearchTests
{
public sealed class TheWorkloadSearchMethod
{
[Fact]
public void Should_Throw_If_Process_Was_Not_Started()
{
// Given
var fixture = new DotNetWorkloadSearcherFixture();
fixture.GivenProcessCannotStart();

// When
var result = Record.Exception(() => fixture.Run());

// Then
AssertEx.IsCakeException(result, ".NET CLI: Process was not started.");
}

[Fact]
public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
{
// Given
var fixture = new DotNetWorkloadSearcherFixture();
fixture.GivenProcessExitsWithCode(1);

// When
var result = Record.Exception(() => fixture.Run());

// Then
AssertEx.IsCakeException(result, ".NET CLI: Process returned an error (exit code 1).");
}

[Fact]
public void Should_Add_SearchString_Argument()
{
// Given
var fixture = new DotNetWorkloadSearcherFixture();
fixture.SearchString = "maui";

// When
var result = fixture.Run();

// Then
Assert.Equal("workload search maui", result.Args);
}

[Fact]
public void Should_Return_Correct_List_Of_Workloads()
{
// Given
var fixture = new DotNetWorkloadSearcherFixture();
fixture.SearchString = "maui";
fixture.GivenAvailableWorkloadsResult();

// When
var result = fixture.Run();

// Then
Assert.Collection(fixture.Workloads,
item =>
{
Assert.Equal(item.Id, "maui");
Assert.Equal(item.Description, ".NET MAUI SDK for all platforms");
},
item =>
{
Assert.Equal(item.Id, "maui-desktop");
Assert.Equal(item.Description, ".NET MAUI SDK for Desktop");
},
item =>
{
Assert.Equal(item.Id, "maui-mobile");
Assert.Equal(item.Description, ".NET MAUI SDK for Mobile");
});
}
}
}
}
43 changes: 35 additions & 8 deletions src/Cake.Common/Net/HttpAliases.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,20 @@ public static void DownloadFile(this ICakeContext context, Uri address, FilePath
/// <example>
/// <code>
/// var address = new Uri("http://www.example.org/upload");
/// UploadFile(address, @"path/to/file.txt");
/// UploadFile(address, @"path/to/file.txt", new UploadFileSettings()
/// {
/// Username = "bob",
/// Password = "builder"
/// }
/// </code>
/// </example>
/// <param name="context">The context.</param>
/// <param name="address">The URL of the upload resource.</param>
/// <param name="filePath">The file to upload.</param>
/// <param name="settings">The settings.</param>
[CakeMethodAlias]
[CakeAliasCategory("Upload")]
public static void UploadFile(this ICakeContext context, Uri address, FilePath filePath)
public static void UploadFile(this ICakeContext context, Uri address, FilePath filePath, UploadFileSettings settings)
{
if (context == null)
{
Expand All @@ -259,8 +264,17 @@ public static void UploadFile(this ICakeContext context, Uri address, FilePath f
}

context.Log.Verbose("Uploading file: {0}", address);
using (var client = GetHttpClient(context, false))
using (var client = GetHttpClient(context, settings.UseDefaultCredentials))
{
if (!settings.UseDefaultCredentials)
{
if (!string.IsNullOrWhiteSpace(settings.Username) && !string.IsNullOrWhiteSpace(settings.Password))
{
var byteArray = Encoding.ASCII.GetBytes(string.Concat(settings.Username, ":", settings.Password));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
}
}

client.UploadFileAsync(address, filePath.FullPath).Wait();
}
context.Log.Verbose("File upload complete");
Expand All @@ -282,7 +296,7 @@ public static void UploadFile(this ICakeContext context, Uri address, FilePath f
[CakeAliasCategory("Upload")]
public static void UploadFile(this ICakeContext context, string address, FilePath filePath)
{
UploadFile(context, new Uri(address), filePath);
UploadFile(context, new Uri(address), filePath, new UploadFileSettings());
}

/// <summary>
Expand All @@ -291,16 +305,20 @@ public static void UploadFile(this ICakeContext context, string address, FilePat
/// <example>
/// <code>
/// var address = new Uri("http://www.example.org/upload");
/// UploadFile(address, @"path/to/file.txt");
/// UploadFile(address, @"path/to/file.txt", new UploadFileSettings() {
/// Username = "bob",
/// Password = "builder"
/// });
/// </code>
/// </example>
/// <param name="context">The context.</param>
/// <param name="address">The URL of the upload resource.</param>
/// <param name="data">The data to upload.</param>
/// <param name="fileName">The filename to give the uploaded data.</param>
/// <param name="settings">The settings.</param>
[CakeMethodAlias]
[CakeAliasCategory("Upload")]
public static void UploadFile(this ICakeContext context, Uri address, byte[] data, string fileName)
public static void UploadFile(this ICakeContext context, Uri address, byte[] data, string fileName, UploadFileSettings settings)
{
if (context == null)
{
Expand All @@ -316,8 +334,17 @@ public static void UploadFile(this ICakeContext context, Uri address, byte[] dat
}

context.Log.Verbose("Uploading file: {0}", address);
using (var client = GetHttpClient(context, false))
using (var client = GetHttpClient(context, settings.UseDefaultCredentials))
{
if (!settings.UseDefaultCredentials)
{
if (!string.IsNullOrWhiteSpace(settings.Username) && !string.IsNullOrWhiteSpace(settings.Password))
{
var byteArray = Encoding.ASCII.GetBytes(string.Concat(settings.Username, ":", settings.Password));
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(byteArray));
}
}

client.UploadFileAsync(address, data, fileName).Wait();
}
context.Log.Verbose("File upload complete");
Expand All @@ -340,7 +367,7 @@ public static void UploadFile(this ICakeContext context, Uri address, byte[] dat
[CakeAliasCategory("Upload")]
public static void UploadFile(this ICakeContext context, string address, byte[] data, string fileName)
{
UploadFile(context, new Uri(address), data, fileName);
UploadFile(context, new Uri(address), data, fileName, new UploadFileSettings());
}

/// <summary>
Expand Down
30 changes: 30 additions & 0 deletions src/Cake.Common/Net/UploadFileSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

namespace Cake.Common.Net
{
/// <summary>
/// Contains settings for <see cref="HttpAliases"/>.
/// </summary>
public sealed class UploadFileSettings
{
/// <summary>
/// Gets or sets the username to use when uploadingthe file.
/// </summary>
public string Username { get; set; }

/// <summary>
/// Gets or sets the password to use when uploading the file.
/// </summary>
public string Password { get; set; }

/// <summary>
/// Gets or sets a value indicating whether default credentials are sent when uploading the file.
/// </summary>
/// <remarks>
/// If set to true, any username and password that has been specified will be ignored.
/// </remarks>
public bool UseDefaultCredentials { get; set; }
}
}
Loading

0 comments on commit 7fa4a79

Please sign in to comment.