Skip to content

Commit

Permalink
Merge remote-tracking branch 'nuke-build/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandevo committed Jun 29, 2024
2 parents 2b74ee4 + 4bfee84 commit 0c5bf7d
Show file tree
Hide file tree
Showing 26 changed files with 95 additions and 62 deletions.
2 changes: 1 addition & 1 deletion build/Build.ReleaseImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

partial class Build
{
[LatestGitHubRelease("JetBrains/JetBrainsMono", TrimPrefix = true)]
[LatestGitHubRelease("JetBrains/JetBrainsMono")]
readonly string JetBrainsMonoVersion;

string[] FontDownloadUrls =>
Expand Down
17 changes: 16 additions & 1 deletion docs/04-sharing/01-global-builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,22 @@ As a first step, you need to extend the build project file with the [necessary i
</Project>
```

Afterwards, the project can be packaged and deployed as usual:
:::warning
Note that `PackageDownload` can only be used in the .NET global tool project directly, since they [do not work transitively](https://github.com/NuGet/Home/wiki/%5BSpec%5D-PackageDownload-support#package-declaration). Alternatively, you can reference tools the old way via `PackageReference` and set the `ExcludeAssets` property:

```xml
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="NUnit.ConsoleRunner" Version="3.9.0" ExcludeAssets="all" />
</ItemGroup>

</Project>
```

:::

Afterward, the project can be packaged and deployed as usual:

```powershell
# terminal-command
Expand Down
14 changes: 7 additions & 7 deletions source/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@
</ItemGroup>

<ItemGroup Condition="$(MSBuildProjectName.EndsWith('Tests'))">
<PackageReference Include="coverlet.msbuild" Version="6.0.0" />
<PackageReference Include="coverlet.msbuild" Version="6.0.2" />
<PackageReference Include="FluentAssertions" Version="6.12.0"/>
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
<PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.38"/>
<PackageReference Include="Verify.Xunit" Version="22.4.1" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1"/>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0"/>
<PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.40"/>
<PackageReference Include="Verify.Xunit" Version="25.0.2" />
<PackageReference Include="Verify.DiffPlex" Version="2.3.0" />
<PackageReference Include="xunit" Version="2.6.1"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3"/>
<PackageReference Include="xunit" Version="2.8.1"/>
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1"/>
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.Build.Shared/Nuke.Build.Shared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Text.Json" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>

</Project>
1 change: 0 additions & 1 deletion source/Nuke.Build.Tests/SchemaUtilityTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Nuke.Common.Tests;

[UsesVerify]
public class SchemaUtilityTest
{
[Fact]
Expand Down
6 changes: 3 additions & 3 deletions source/Nuke.Build/Nuke.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="8.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="2.0.0" />
<PackageReference Include="Serilog.Formatting.Compact" Version="3.0.0" />
<PackageReference Include="Serilog.Formatting.Compact.Reader" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
</ItemGroup>

Expand Down
1 change: 0 additions & 1 deletion source/Nuke.Common.Tests/CI/ConfigurationGenerationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

namespace Nuke.Common.Tests.CI;

[UsesVerify]
public class ConfigurationGenerationTest
{
[Theory]
Expand Down
1 change: 0 additions & 1 deletion source/Nuke.Common.Tests/ChangelogTasksTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

namespace Nuke.Common.Tests;

[UsesVerify]
public class ChangelogTasksTest
{
private static AbsolutePath RootDirectory => Constants.TryGetRootDirectoryFrom(EnvironmentInfo.WorkingDirectory).NotNull();
Expand Down
24 changes: 22 additions & 2 deletions source/Nuke.Common/Attributes/LatestGitHubReleaseAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
using System;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using JetBrains.Annotations;
using NuGet.Versioning;
using Nuke.Common.Git;
using Nuke.Common.Tools.GitHub;
using Nuke.Common.Utilities;
using Nuke.Common.ValueInjection;

namespace Nuke.Common.Tooling;
Expand All @@ -23,11 +26,28 @@ public LatestGitHubReleaseAttribute(string identifier)
}

public bool IncludePrerelease { get; set; }
public bool TrimPrefix { get; set; }
public bool UseTagName { get; set; }

[RegexPattern]
public string Pattern { get; set; } = @"v?(?<version>\d+\.\d+(?:\.\d+)?(?:\.\d+)?(?:-\w+)?)";

public override object GetValue(MemberInfo member, object instance)
{
var repository = GitRepository.FromUrl($"https://github.com/{_identifier}");
return repository.GetLatestRelease(IncludePrerelease, TrimPrefix).GetAwaiter().GetResult();
var releases = GitHubTasks.GitHubClient.Repository.Release
.GetAll(repository.GetGitHubOwner(), repository.GetGitHubName()).GetAwaiter().GetResult();
var versions = releases
.Select(x => Regex.Match((!UseTagName ? x.Name : x.TagName).NotNullOrWhiteSpace(), Pattern))
.Select(x => x.Groups["version"].Value)
.Select(NuGetVersion.Parse)
.OrderByDescending(x => x);

if (member.GetMemberType() == typeof(NuGetVersion[]))
return versions.ToArray();

var latestVersion = versions.FirstOrDefault(x => !x.IsPrerelease || IncludePrerelease);
return member.GetMemberType() == typeof(NuGetVersion)
? latestVersion
: latestVersion?.ToString();
}
}
10 changes: 5 additions & 5 deletions source/Nuke.Common/Nuke.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.10.4" />
<PackageReference Include="Azure.Security.KeyVault.Certificates" Version="4.5.1" />
<PackageReference Include="Azure.Security.KeyVault.Keys" Version="4.5.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.5.0" />
<PackageReference Include="Octokit" Version="9.1.1" />
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Azure.Security.KeyVault.Certificates" Version="4.6.0" />
<PackageReference Include="Azure.Security.KeyVault.Keys" Version="4.6.0" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.6.0" />
<PackageReference Include="Octokit" Version="12.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(_IsPacking)' == 'True'">
Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Components/ISignPackages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public interface ISignPackages : INukeBuild
.Executes(async () =>
{
SignPathRequestDirectory.CreateOrCleanDirectory();
SignPathPackages.ForEach(x => CopyFileToDirectory(x, SignPathRequestDirectory));
SignPathPackages.ForEach(x => x.CopyToDirectory(SignPathRequestDirectory));
SignPathRequestDirectory.ZipTo(SignPathRequestArchive);

AppVeyor.PushArtifact(SignPathRequestArchive);
Expand Down Expand Up @@ -114,7 +114,7 @@ await DownloadSignedArtifactFromUrl(
x => Path.GetFileName(x),
x => Path.GetFileName(x),
(x, y) => (SignedPackage: x, UnsignedPackage: y))
.ForEach(x => CopyFile(x.SignedPackage, x.UnsignedPackage, FileExistsPolicy.Overwrite));
.ForEach(x => x.SignedPackage.Copy(x.UnsignedPackage, ExistsPolicy.FileOverwrite));
}
});
}
1 change: 0 additions & 1 deletion source/Nuke.GlobalTool.Tests/CakeConversionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Nuke.GlobalTool.Tests;

[UsesVerify]
public class CakeConversionTests
{
private static AbsolutePath RootDirectory => Constants.TryGetRootDirectoryFrom(EnvironmentInfo.WorkingDirectory);
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.GlobalTool.Tests/Nuke.GlobalTool.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Nuke.GlobalTool.Tests;

[UsesVerify]
public class UpdateSolutionFileContentTests
{
[Theory]
Expand Down
8 changes: 4 additions & 4 deletions source/Nuke.GlobalTool/Nuke.GlobalTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RollForward>LatestMajor</RollForward>
<PackAsTool>true</PackAsTool>
<ToolCommandName>nuke</ToolCommandName>
Expand All @@ -15,9 +15,9 @@

<ItemGroup>
<PackageReference Include="matkoch.spectre.console" Version="0.46.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="4.10.0" />
</ItemGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions source/Nuke.MSBuildTasks/Nuke.MSBuildTasks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NuGet.Packaging" Version="6.9.1" />
<PackageReference Include="NuGet.Packaging" Version="6.10.0" />
</ItemGroup>

<ItemGroup>
<!-- MSBuild and dependencies only acquired through MSBuild shall not make it into the final package -->
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="16.9.0" CopyLocal="false" Publish="false" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Framework" Version="16.9.0" CopyLocal="false" Publish="false" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.10.4" CopyLocal="false" Publish="false" ExcludeAssets="runtime" />
<PackageReference Include="Microsoft.Build.Framework" Version="17.10.4" CopyLocal="false" Publish="false" ExcludeAssets="runtime" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.ProjectModel.Tests/ProjectModelTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public void ProjectTest()

project.GetTargetFrameworks().Should().Equal("net6.0", "net7.0", "net8.0");
project.HasPackageReference("Microsoft.Build.Locator").Should().BeTrue();
project.GetPackageReferenceVersion("Microsoft.Build.Locator").Should().Be("1.6.10");
project.GetPackageReferenceVersion("Microsoft.Build.Locator").Should().Be("1.7.8");
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion source/Nuke.ProjectModel/Nuke.ProjectModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Locator" Version="1.6.10" />
<PackageReference Include="Microsoft.Build.Locator" Version="1.7.8" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="4.10.0" />
<PackageReference Include="Verify.SourceGenerators" Version="2.2.0" />
<PackageReference Include="Basic.Reference.Assemblies.NetStandard20" Version="1.4.5" />
<PackageReference Include="Basic.Reference.Assemblies.NetStandard20" Version="1.7.2" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

namespace Nuke.SourceGenerators.Tests;

[UsesVerify]
public class StronglyTypedSolutionGeneratorTest
{
[Fact]
Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Tooling.Generator/Nuke.Tooling.Generator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="HtmlAgilityPack" Version="1.11.54" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.61" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Humanizer" Version="2.14.1" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="Serilog" Version="4.0.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions source/Nuke.Tooling.Tests/ArgumentStringHandlerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void TestUnquote()
ArgsToString($"{"start end"}").Should().Be("start end");
ArgsToString($"start {"spaced end"}").Should().Be("start \"spaced end\"");
ArgsToString($"{"spaced start"} end").Should().Be("\"spaced start\" end");
ArgsToString($"{"spaced start"} {"spaced end"}").Should().Be("\"spaced start\" \"spaced end\"");
}

[Fact]
Expand Down
5 changes: 4 additions & 1 deletion source/Nuke.Tooling/ArgumentStringHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@ public void AppendFormatted(IEnumerable<IAbsolutePathHolder> paths, int alignmen

public string ToStringAndClear()
{
return _builder.ToStringAndClear().TrimMatchingDoubleQuotes();
var value = _builder.ToStringAndClear();
return value.IndexOf(value: '"', startIndex: 1) == value.Length - 1
? value.TrimMatchingDoubleQuotes()
: value;
}

public Func<string, string> GetFilter()
Expand Down
4 changes: 2 additions & 2 deletions source/Nuke.Tooling/Nuke.Tooling.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NuGet.Packaging" Version="6.9.1" />
<PackageReference Include="Serilog" Version="3.1.1" />
<PackageReference Include="NuGet.Packaging" Version="6.10.0" />
<PackageReference Include="Serilog" Version="4.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="YamlDotNet" Version="13.7.1" />
<PackageReference Include="YamlDotNet" Version="15.1.6" />
</ItemGroup>

</Project>
30 changes: 15 additions & 15 deletions source/Nuke.Utilities/IO/AbsolutePath.MoveCopy.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 Maintainers of NUKE.
// Copyright 2023 Maintainers of NUKE.
// Distributed under the MIT License.
// https://github.com/nuke-build/nuke/blob/master/LICENSE

Expand Down Expand Up @@ -83,6 +83,20 @@ public static AbsolutePath MoveToDirectory(
return source.Move(target / source.Name, policy, createDirectories);
}

/// <summary>
/// Copies the file or directory to another directory.
/// </summary>
public static AbsolutePath CopyToDirectory(
this AbsolutePath source,
AbsolutePath target,
ExistsPolicy policy = ExistsPolicy.Fail,
Func<AbsolutePath, bool> excludeDirectory = null,
Func<AbsolutePath, bool> excludeFile = null,
bool createDirectories = true)
{
return source.Copy(target / source.Name, policy, excludeDirectory, excludeFile, createDirectories);
}

/// <summary>
/// Moves the file or directory.
/// </summary>
Expand Down Expand Up @@ -116,20 +130,6 @@ public static AbsolutePath Move(
throw new Exception("Unreachable");
}

/// <summary>
/// Copies the file or directory to another directory.
/// </summary>
public static AbsolutePath CopyToDirectory(
this AbsolutePath source,
AbsolutePath target,
ExistsPolicy policy = ExistsPolicy.Fail,
Func<AbsolutePath, bool> excludeDirectory = null,
Func<AbsolutePath, bool> excludeFile = null,
bool createDirectories = true)
{
return source.Copy(target / source.Name, policy, excludeDirectory, excludeFile, createDirectories);
}

/// <summary>
/// Copies the file or directory.
/// </summary>
Expand Down

0 comments on commit 0c5bf7d

Please sign in to comment.