Skip to content

Commit

Permalink
Merge pull request #4 from ChrisPulman/AddSDKSupportForDotNet3
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisPulman authored Jul 29, 2023
2 parents 14748e6 + 7b3e62f commit 413b91a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
2 changes: 1 addition & 1 deletion build/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ public class Configuration : Enumeration
public static Configuration Release = new() { Value = nameof(Release) };

public static implicit operator string(Configuration configuration) =>
configuration?.Value;
configuration?.Value!;
}
35 changes: 29 additions & 6 deletions src/CP.Nuke.BuildTools/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

using System.Text.Json.Nodes;
using Nuke.Common;
using Nuke.Common.IO;
using Nuke.Common.ProjectModel;
using Nuke.Common.Tooling;
using Nuke.Common.Tools.Git;
using Serilog;

namespace CP.BuildTools
Expand Down Expand Up @@ -64,15 +66,15 @@ public static void RestoreProjectWorkload(this Project project) =>
/// Restores the solution workloads.
/// </summary>
/// <param name="solution">The solution.</param>
public static void RestoreSolutionWorkloads(this Nuke.Common.ProjectModel.Solution solution) =>
public static void RestoreSolutionWorkloads(this Solution solution) =>
ProcessTasks.StartShell($"dotnet workload restore {solution}").AssertZeroExitCode();

/// <summary>
/// Gets the packable projects.
/// </summary>
/// <param name="solution">The solution.</param>
/// <returns>A List of Projects.</returns>
public static List<Project>? GetPackableProjects(this Nuke.Common.ProjectModel.Solution solution) =>
public static List<Project>? GetPackableProjects(this Solution solution) =>
solution?.AllProjects.Where(x => x.GetProperty<bool>("IsPackable")).ToList();

/// <summary>
Expand All @@ -82,6 +84,30 @@ public static void RestoreSolutionWorkloads(this Nuke.Common.ProjectModel.Soluti
/// <returns>A List of Projects.</returns>
public static List<Project>? GetTestProjects(this Solution solution) =>
solution?.AllProjects.Where(x => x.GetProperty<bool>("IsTestProject")).ToList();
/// <summary>
/// Gets the project by Name.
/// </summary>
/// <param name="solution">The solution.</param>
/// <param name="projectName">The name of the project to find.</param>
/// <returns>The Project.</returns>
public static Project? GetProject(this Solution solution, string projectName) =>
solution?.Projects.FirstOrDefault(x => x.Name == projectName);

/// <summary>
/// Check out the source at the specified url and transfer it to the path.
/// </summary>
/// <param name="path">The output path.</param>
/// <param name="url">The Url to load the source from.</param>
public static void Checkout(this AbsolutePath path, string url)
{
if (string.IsNullOrWhiteSpace(path) || string.IsNullOrWhiteSpace(url))
{
return;
}

GitTasks.Git($"clone -s -n {url} {path.ToString("dn")}");
GitTasks.Git("checkout", path.ToString("dn"));
}

/// <summary>
/// Installs the DotNet SDK.
Expand Down Expand Up @@ -164,10 +190,7 @@ public static async Task InstallDotNetSdk(this NukeBuild _, params string[] vers
throw;
}

if (!File.Exists("dotnet-install.ps1"))
{
ProcessTasks.StartShell("pwsh -NoProfile -ExecutionPolicy unrestricted -Command Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1';").AssertZeroExitCode();
}
ProcessTasks.StartShell("pwsh -NoProfile -ExecutionPolicy unrestricted -Command Invoke-WebRequest 'https://dot.net/v1/dotnet-install.ps1' -OutFile 'dotnet-install.ps1';").AssertZeroExitCode();

foreach (var version in versionsToInstall.Select(arr => $"{arr[0]}.{arr[1]}.{arr[2].ToString().First().ToString()}xx").ToArray())
{
Expand Down

0 comments on commit 413b91a

Please sign in to comment.