diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 10501dfa..b2ab266c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -90,10 +90,6 @@ jobs: id: moveUnshippedToShipped run: | dotnet .build/bin/Debug/.build.dll --target MoveUnshippedToShipped --skip LintPublicApiAnalyzers --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}" - - name: Regenerate Build Configurations - id: regenerateBuildConfigurations - run: | - dotnet .build/bin/Debug/.build.dll --target RegenerateBuildConfigurations --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}" - name: Prettier id: prettier run: | @@ -106,6 +102,10 @@ jobs: id: jetBrainsCleanupCode run: | dotnet .build/bin/Debug/.build.dll --target JetBrainsCleanupCode --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}" + - name: Regenerate Build Configurations + id: regenerateBuildConfigurations + run: | + dotnet .build/bin/Debug/.build.dll --target RegenerateBuildConfigurations --ThisIsAOtherVariable "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAnotherVariable "${{ vars.THIS_IS_ANOTHER_VARIABLE }}" --THIS_IS_A_VARIABLE "${{ vars.THIS_IS_A_VARIABLE }}" --ThisIsAEnv "${{ env.THIS_IS_A_ENV || 'test' }}" --ThisIsASecret "${{ secrets.THIS_IS_A_SECRET }}" --GitHubToken "${{ secrets.GITHUB_TOKEN }}" - name: Generate Solution Items id: generateSolutionItems run: | diff --git a/src/Nuke/ICanRegenerateBuildConfiguration.cs b/src/Nuke/ICanRegenerateBuildConfiguration.cs index 471f7195..b7ce0e5e 100644 --- a/src/Nuke/ICanRegenerateBuildConfiguration.cs +++ b/src/Nuke/ICanRegenerateBuildConfiguration.cs @@ -1,7 +1,6 @@ using System.Reflection; using Nuke.Common.CI; using Nuke.Common.IO; -using Nuke.Common.Tooling; using Nuke.Common.Tools.DotNet; using Serilog; @@ -19,6 +18,7 @@ public interface ICanRegenerateBuildConfiguration : ICanLint public Target RegenerateBuildConfigurations => t => t .TriggeredBy(static z => z.Lint) + .TryAfter(static z => z.PostLint) .Executes( () => { @@ -40,7 +40,7 @@ public interface ICanRegenerateBuildConfiguration : ICanLint Log.Logger.Information("Regenerating {HostName} configuration id {Name}", host.HostName, host.Id); - DotNetTasks.DotNet( + _ = DotNetTasks.DotNet( args.RenderForExecution(), RootDirectory, EnvironmentInfo.Variables.AddIfMissing("NUKE_INTERNAL_INTERCEPTOR", "1"), diff --git a/src/Nuke/ResolvedToolsManifest.cs b/src/Nuke/ResolvedToolsManifest.cs index 6de48db7..2af731f0 100644 --- a/src/Nuke/ResolvedToolsManifest.cs +++ b/src/Nuke/ResolvedToolsManifest.cs @@ -40,47 +40,48 @@ private static void DefaultLogger(OutputType kind, string message) // ReSharper restore TemplateIsNotCompileTimeConstantProblem } + private static Tool CreateHandler(string command) => (arguments, directory, variables, timeout, output, invocation, logger, handler) => + { + var newArgs = new ArgumentStringHandler(); + newArgs.AppendLiteral(command); + newArgs.AppendLiteral(" "); + newArgs.AppendLiteral(arguments.ToStringAndClear().TrimMatchingDoubleQuotes()); + arguments.AppendLiteral( + newArgs.ToStringAndClear().TrimMatchingDoubleQuotes().Replace("\\\"", "\"") + ); + return DotNetTasks.DotNet( + arguments, + directory, + variables, + timeout, + output, + invocation, + // ReSharper disable once TemplateIsNotCompileTimeConstantProblem + logger ?? DefaultLogger, + process => + { + if (handler is null) + { + return process.AssertZeroExitCode(); + } + + handler.Invoke(process); + return process; + } + ); + }; + public bool IsInstalled(string commandName) => commandDefinitions.ContainsKey(commandName) || toolDefinitions.ContainsKey(commandName); - public ToolDefinition GetToolDefinition(string nugetPackageName) => ( toolDefinitions.TryGetValue(nugetPackageName, out var tool) ) + public ToolDefinition GetToolDefinition(string nugetPackageName) => toolDefinitions.TryGetValue(nugetPackageName, out var tool) ? tool : throw new InvalidOperationException($"Tool {nugetPackageName} is not installed"); - public Tool GetTool(string nugetPackageName) => ( toolDefinitions.TryGetValue(nugetPackageName, out var tool) ) + public Tool GetTool(string nugetPackageName) => toolDefinitions.TryGetValue(nugetPackageName, out var tool) ? CreateHandler(tool.Commands.First()) - : ( commandDefinitions.TryGetValue(nugetPackageName, out var command) ) + : commandDefinitions.TryGetValue(nugetPackageName, out var command) ? CreateHandler(command.Command) : throw new InvalidOperationException($"Tool {nugetPackageName} is not installed"); public Tool GetProperTool(string nugetPackageName) => GetTool(nugetPackageName); - - private static Tool CreateHandler(string command) => (arguments, directory, variables, timeout, output, invocation, logger, handler) => - { - var newArgs = new ArgumentStringHandler(); - newArgs.AppendLiteral(command); - newArgs.AppendLiteral(" "); - newArgs.AppendLiteral(arguments.ToStringAndClear().TrimMatchingDoubleQuotes()); - arguments.AppendLiteral(newArgs.ToStringAndClear()); - return DotNetTasks.DotNet( - arguments, - directory, - variables, - timeout, - output, - invocation, - // ReSharper disable once TemplateIsNotCompileTimeConstantProblem - logger ?? DefaultLogger, - process => - { - if (handler is null) - { - return process.AssertZeroExitCode(); - } - - handler.Invoke(process); - return process; - - } - ); - }; }