diff --git a/.nuke/build.schema.json b/.nuke/build.schema.json index 956ab15ae..719ef126d 100644 --- a/.nuke/build.schema.json +++ b/.nuke/build.schema.json @@ -46,14 +46,8 @@ "type": "string", "default": "Secrets must be entered via 'nuke :secrets [profile]'" }, - "SignPathOrganizationId": { - "type": "string" - }, - "SignPathPolicySlug": { - "type": "string" - }, - "SignPathProjectSlug": { - "type": "string" + "SignPathSettings": { + "$ref": "#/definitions/SignPathSettings" }, "SlackWebhook": { "type": "string", @@ -108,6 +102,29 @@ "VSCode" ] }, + "SignPathSettings": { + "type": "object", + "properties": { + "OrganizationId": { + "type": [ + "null", + "string" + ] + }, + "ProjectSlug": { + "type": [ + "null", + "string" + ] + }, + "PolicySlug": { + "type": [ + "null", + "string" + ] + } + } + }, "ExecutableTarget": { "type": "string", "enum": [ diff --git a/.nuke/parameters.json b/.nuke/parameters.json index 95beed393..0ca1a709e 100644 --- a/.nuke/parameters.json +++ b/.nuke/parameters.json @@ -1,21 +1,9 @@ { "$schema": "./build.schema.json", "Solution": "nuke-common.sln", - "SignPathOrganizationId": "0fdaf334-6910-41f4-83d2-e58e4cccb087", - "SignPathProjectSlug": "nuke", - "SignPathPolicySlug": "release-signing", - "Data2": [ - { - "FirstName": "foo", - "Nested": { - "FirstName": "bar" - } - }, - { - "FirstName": "foo2", - "Nested": { - "FirstName": "bar2" - } - } - ] + "SignPathSettings": { + "OrganizationId": "0fdaf334-6910-41f4-83d2-e58e4cccb087", + "ProjectSlug": "nuke", + "PolicySlug": "release-signing" + } } diff --git a/.teamcity/settings.kts b/.teamcity/settings.kts index 8d2007c6e..62b866404 100644 --- a/.teamcity/settings.kts +++ b/.teamcity/settings.kts @@ -47,12 +47,6 @@ project { value = "Release", options = listOf("Debug" to "Debug", "Release" to "Release"), display = ParameterDisplay.NORMAL) - text ( - "env.Data2", - label = "Data2", - value = "Build+Data Build+Data", - allowEmpty = true, - display = ParameterDisplay.NORMAL) checkbox ( "env.IgnoreFailedSources", label = "IgnoreFailedSources", @@ -69,21 +63,9 @@ project { unchecked = "False", display = ParameterDisplay.NORMAL) text ( - "env.SignPathOrganizationId", - label = "SignPathOrganizationId", - value = "0fdaf334-6910-41f4-83d2-e58e4cccb087", - allowEmpty = true, - display = ParameterDisplay.NORMAL) - text ( - "env.SignPathPolicySlug", - label = "SignPathPolicySlug", - value = "release-signing", - allowEmpty = true, - display = ParameterDisplay.NORMAL) - text ( - "env.SignPathProjectSlug", - label = "SignPathProjectSlug", - value = "nuke", + "env.SignPathSettings", + label = "SignPathSettings", + value = "", allowEmpty = true, display = ParameterDisplay.NORMAL) text ( diff --git a/build/Build.cs b/build/Build.cs index 67b1a25e5..62f3cb4bd 100644 --- a/build/Build.cs +++ b/build/Build.cs @@ -50,20 +50,6 @@ partial class Build /// - Microsoft VSCode https://nuke.build/vscode public static int Main() => Execute(x => ((IPack)x).Pack); - public class Data - { - public string FirstName; - public Data Nested; - } - - [Parameter] readonly Data[] Data2; - - Target Foo => _ => _ - .Executes(() => - { - Console.WriteLine(Data2); - }); - [CI] readonly TeamCity TeamCity; [CI] readonly AzurePipelines AzurePipelines; [CI] readonly AppVeyor AppVeyor; diff --git a/nuke-common.sln.DotSettings b/nuke-common.sln.DotSettings index 08232f1f4..ece833ace 100644 --- a/nuke-common.sln.DotSettings +++ b/nuke-common.sln.DotSettings @@ -1,5 +1,5 @@  - Copyright $CURRENT_YEAR$ Maintainers of NUKE. + Copyright ${CurrentDate.Year} Maintainers of NUKE. Distributed under the MIT License. https://github.com/nuke-build/nuke/blob/master/LICENSE <Policy Inspect="True" Prefix="" Suffix="" Style="AaBb_AaBb" /> @@ -17,4 +17,5 @@ https://github.com/nuke-build/nuke/blob/master/LICENSE 3 True 1 + True diff --git a/source/Nuke.Build.Tests/ParameterServiceTest.cs b/source/Nuke.Build.Tests/ParameterServiceTest.cs index 59f94c307..5ca5c5468 100644 --- a/source/Nuke.Build.Tests/ParameterServiceTest.cs +++ b/source/Nuke.Build.Tests/ParameterServiceTest.cs @@ -48,12 +48,11 @@ public void TestNotSupplied(Type destinationType, object expectedValue) public void TestEnvironmentVariables(string parameter, Type destinationType, object expectedValue) { var service = GetService( - new[] - { + [ "-arg1", "value1", "-switch1" - }, + ], new Dictionary { { "arg1", "value2" }, @@ -68,15 +67,14 @@ public void TestEnvironmentVariables(string parameter, Type destinationType, obj public void TestExpression() { var service = GetService( - new[] - { + [ "--string", "--set", "1", "2", "3", "--interface-param" - }); + ]); var build = new TestBuild(); @@ -98,12 +96,12 @@ public void TestValueSet() { var build = new TestBuild(); var verbosities = new[] - { - (nameof(Verbosity.Minimal), Verbosity.Minimal), - (nameof(Verbosity.Normal), Verbosity.Normal), - (nameof(Verbosity.Quiet), Verbosity.Quiet), - (nameof(Verbosity.Verbose), Verbosity.Verbose), - }; + { + (nameof(Verbosity.Minimal), Verbosity.Minimal), + (nameof(Verbosity.Normal), Verbosity.Normal), + (nameof(Verbosity.Quiet), Verbosity.Quiet), + (nameof(Verbosity.Verbose), Verbosity.Verbose), + }; ParameterService.GetParameterValueSet(GetMemberInfo(() => NukeBuild.Verbosity), instance: null) .Should().BeEquivalentTo(verbosities); ParameterService.GetParameterValueSet(GetMemberInfo(() => build.Verbosities), instance: null) @@ -118,13 +116,13 @@ public void TestPrecedence() var environmentVariables = new Dictionary { ["string"] = "environmentVariables" }; var commandLineArguments = new ArgumentParser("--string commandLine"); - var parameterFileArguments = new ArgumentParser("--string parameterFile"); + var parameterFileArguments = new Func((_, _) => "parameterFile"); var commitMessageArguments = new ArgumentParser("--string commitMessage"); var service = new ParameterService(() => emptyArguments, () => emptyEnvironmentVariables) - { - ArgumentsFromFilesService = parameterFileArguments - }; + { + ArgumentsFromFilesService = parameterFileArguments + }; service.GetParameter("string", typeof(string), separator: null).Should().Be("parameterFile"); service = new ParameterService(() => emptyArguments, () => environmentVariables) { ArgumentsFromFilesService = parameterFileArguments }; @@ -134,10 +132,10 @@ public void TestPrecedence() service.GetParameter("string", typeof(string), separator: null).Should().Be("commandLine"); service = new ParameterService(() => emptyArguments, () => emptyEnvironmentVariables) - { - ArgumentsFromFilesService = parameterFileArguments, - ArgumentsFromCommitMessageService = commitMessageArguments - }; + { + ArgumentsFromFilesService = parameterFileArguments, + ArgumentsFromCommitMessageService = commitMessageArguments + }; service.GetParameter("string", typeof(string), separator: null).Should().Be("commitMessage"); } diff --git a/source/Nuke.Build/Execution/Extensions/ArgumentsFromParametersFileAttribute.cs b/source/Nuke.Build/Execution/Extensions/ArgumentsFromParametersFileAttribute.cs index 8bfb6e4db..2baaff2dc 100644 --- a/source/Nuke.Build/Execution/Extensions/ArgumentsFromParametersFileAttribute.cs +++ b/source/Nuke.Build/Execution/Extensions/ArgumentsFromParametersFileAttribute.cs @@ -10,7 +10,6 @@ using Newtonsoft.Json.Linq; using Nuke.Common.CI; using Nuke.Common.IO; -using Nuke.Common.ProjectModel; using Nuke.Common.Utilities; using Nuke.Common.Utilities.Collections; using Nuke.Common.ValueInjection; @@ -76,10 +75,8 @@ string DecryptValue(string profile, string name, string value) var member = parameterMembers.SingleOrDefault(x => ParameterService.GetParameterMemberName(x).EqualsOrdinalIgnoreCase(parameter)); var scalarType = member?.GetMemberType().GetScalarType(); - if (scalarType == typeof(AbsolutePath) || - typeof(Solution).IsAssignableFrom(scalarType) || - scalarType == typeof(Project)) - return NukeBuild.RootDirectory / property.Value.ToObject(); + if (typeof(IAbsolutePathHolder).IsAssignableFrom(scalarType)) + return property.Value.ToObject().Apply(x => !PathConstruction.HasPathRoot(x) ? NukeBuild.RootDirectory / x : (AbsolutePath)x); if ((member?.HasCustomAttribute() ?? false) && !BuildServerConfigurationGeneration.IsActive) diff --git a/source/Nuke.Components/ISignPackages.cs b/source/Nuke.Components/ISignPackages.cs index 94e85dafc..6f5b9f43d 100644 --- a/source/Nuke.Components/ISignPackages.cs +++ b/source/Nuke.Components/ISignPackages.cs @@ -52,16 +52,19 @@ public interface ISignPackages : INukeBuild { public const string SignPath = nameof(SignPath); + public record SignPathSettings( + string OrganizationId, + string ProjectSlug, + string PolicySlug); + + [Parameter] SignPathSettings Settings => TryGetValue(() => Settings); [Parameter] [Secret] string ApiToken => TryGetValue(() => ApiToken); - [Parameter] string OrganizationId => TryGetValue(() => OrganizationId); - [Parameter] string ProjectSlug => TryGetValue(() => ProjectSlug); - [Parameter] string PolicySlug => TryGetValue(() => PolicySlug); AbsolutePath SignPathTemporaryDirectory => TemporaryDirectory / "signpath"; AbsolutePath SignPathRequestDirectory => SignPathTemporaryDirectory / "signing-request"; AbsolutePath SignPathResponseDirectory => SignPathTemporaryDirectory / "signing-response"; - AbsolutePath SignPathRequestArchive => Path.ChangeExtension(SignPathRequestDirectory, ".zip"); - AbsolutePath SignPathResponseArchive => Path.ChangeExtension(SignPathResponseDirectory, ".zip"); + AbsolutePath SignPathRequestArchive => SignPathRequestDirectory.WithExtension(".zip"); + AbsolutePath SignPathResponseArchive => SignPathResponseDirectory.WithExtension(".zip"); IEnumerable SignPathPackages { get; } bool SignPathReplacePackages => true; @@ -72,10 +75,8 @@ public interface ISignPackages : INukeBuild .TryDependsOn() .TryDependentFor() .OnlyWhenStatic(() => AppVeyor != null) + .Requires(() => Settings) .Requires(() => ApiToken) - .Requires(() => OrganizationId) - .Requires(() => ProjectSlug) - .Requires(() => PolicySlug) .Executes(async () => { SignPathRequestDirectory.CreateOrCleanDirectory(); @@ -86,9 +87,9 @@ public interface ISignPackages : INukeBuild var signingRequestUrl = await GetSigningRequestUrlViaAppVeyor( ApiToken, - OrganizationId, - ProjectSlug, - PolicySlug); + Settings.OrganizationId, + Settings.ProjectSlug, + Settings.PolicySlug); ReportSummary(_ => _ .AddPair("Approve/Deny Request", signingRequestUrl.Replace("api/v1", "Web")));