From 9480250a33f46544820f576139daf2bc7a866c14 Mon Sep 17 00:00:00 2001 From: Alexander Zekelin Date: Wed, 3 Jun 2026 05:50:48 +0200 Subject: [PATCH] feat: add --publish flag to env solution import --- .../Solution/SolutionImportCliCommand.cs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/TALXIS.CLI.Features.Environment/Solution/SolutionImportCliCommand.cs b/src/TALXIS.CLI.Features.Environment/Solution/SolutionImportCliCommand.cs index b2288b13..495298cf 100644 --- a/src/TALXIS.CLI.Features.Environment/Solution/SolutionImportCliCommand.cs +++ b/src/TALXIS.CLI.Features.Environment/Solution/SolutionImportCliCommand.cs @@ -46,6 +46,9 @@ public class SolutionImportCliCommand : ProfiledCliCommand [CliOption(Name = "--managed", Description = "When importing from a folder, pack as managed solution.", Required = false)] public bool Managed { get; set; } + [CliOption(Name = "--publish", Description = "Publish all customizations after the import completes (implies waiting for the import to finish).", Required = false)] + public bool Publish { get; set; } + protected override async Task ExecuteAsync() { string solutionPath = Path.GetFullPath(SolutionZip); @@ -115,13 +118,18 @@ protected override async Task ExecuteAsync() solutionPath = tempZipPath; } + // Publishing requires a completed import — otherwise PublishAll fails with + // "Cannot start PublishAll because Import is running". So --publish forces a + // synchronous (waited) import regardless of --wait. + bool waitForCompletion = Wait || Publish; + var options = new SolutionImportOptions( StageAndUpgrade: StageAndUpgrade, ForceOverwrite: ForceOverwrite, PublishWorkflows: PublishWorkflows, SkipDependencyCheck: SkipDependencyCheck, SkipLowerVersion: SkipLowerVersion, - Async: !Wait); + Async: !waitForCompletion); var service = TxcServices.Get(); var result = await service.ImportAsync(Profile, solutionPath, options, CancellationToken.None).ConfigureAwait(false); @@ -156,6 +164,21 @@ protected override async Task ExecuteAsync() #pragma warning restore TXC003 }); + if (Publish) + { + Logger.LogInformation("Publishing all customizations..."); + var publishService = TxcServices.Get(); + await publishService.PublishAsync(Profile, null, CancellationToken.None).ConfigureAwait(false); +#pragma warning disable TXC003 + OutputWriter.WriteLine("Published all customizations."); +#pragma warning restore TXC003 + } + else if (!waitForCompletion) + { + Logger.LogInformation( + "Import queued — customizations are NOT published yet. Run `txc env solution publish` after it completes (or re-run import with --publish) to make changes visible."); + } + return ExitSuccess; } finally