Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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<int> ExecuteAsync()
{
string solutionPath = Path.GetFullPath(SolutionZip);
Expand Down Expand Up @@ -115,13 +118,18 @@ protected override async Task<int> 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<ISolutionImportService>();
var result = await service.ImportAsync(Profile, solutionPath, options, CancellationToken.None).ConfigureAwait(false);
Expand Down Expand Up @@ -156,6 +164,21 @@ protected override async Task<int> ExecuteAsync()
#pragma warning restore TXC003
});

if (Publish)
{
Logger.LogInformation("Publishing all customizations...");
var publishService = TxcServices.Get<ISolutionPublishService>();
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
Expand Down