Skip to content

Commit 9e1ec23

Browse files
azchohfiCopilot
andcommitted
Keep msstore package stdout clean, and print an absolute path
Follow-up from self-review of the previous commit. Making `package` treat stdout as its machine-readable result exposed two other writers on that same path that still went through the static Spectre console (which targets stdout): - `WinUIProjectConfigurator` hosted its "Building MSIX..." status on the static `AnsiConsole` — the only configurator that did; every sibling uses the injected stderr console, and the block already reported success via `ctx.SuccessStatus(ErrorAnsiConsole, ...)`. When stdout is redirected Spectre falls back to `FallbackStatusRenderer`, which writes the description permanently rather than clearing it, so the status text landed in the piped output ahead of the path. - `ValidateImagesAsync` takes an `IAnsiConsole` and forwards it to `ProjectImagesHelper`, but used the static console for its own two warning lines, so the default-images warning went to stdout. Both now use the console they already had in hand. Also print `outputDirectory.FullName` rather than `ToString()`. `DirectoryInfo.ToString()` returns the original, unnormalised path, and `PWAProjectConfigurator.PackageAsync` returns `new DirectoryInfo(pathOrUrl)` built straight from the command argument — so `msstore package .` emitted a bare `.`, which is useless to a caller consuming stdout. The other five packagers derive their result from `FileInfo(...).Directory`, whose path is already absolute, so this is a no-op for them. Tests now assert that `package` writes exactly one line to stdout, which is what pins the behaviour these fixes restore. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: af8e5c71-6935-4efa-b777-64b180bb20c7
1 parent 92c76b2 commit 9e1ec23

4 files changed

Lines changed: 12 additions & 12 deletions

File tree

MSStore.CLI.UnitTests/PackageCommandUnitTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public async Task PackageCommandForUWPAppsShouldCallMSBuildWithOutputParameterIf
9999
]);
100100

101101
result.Error.Should().Contain("The packaged app is here:");
102-
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle(line => line.Contains(customPath));
102+
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle().Which.Should().Contain(customPath);
103103

104104
ExternalCommandExecutor.VerifyAll();
105105
}
@@ -216,7 +216,7 @@ public async Task PackageCommandForWinUIAppsShouldCallMSBuildWithOutputParameter
216216
]);
217217

218218
result.Error.Should().Contain("The packaged app is here:");
219-
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle(line => line.Contains(customPath));
219+
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle().Which.Should().Contain(customPath);
220220

221221
ExternalCommandExecutor.VerifyAll();
222222
}
@@ -295,7 +295,7 @@ public async Task PackageCommandForMauiAppsShouldCallMSBuildWithOutputParameterI
295295
]);
296296

297297
result.Error.Should().Contain("The packaged app is here:");
298-
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle(line => line.Contains(customPath));
298+
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle().Which.Should().Contain(customPath);
299299

300300
ExternalCommandExecutor.VerifyAll();
301301
}
@@ -375,7 +375,7 @@ public async Task PackageCommandForFlutterAppsShouldCallFlutter()
375375
]);
376376

377377
result.Error.Should().Contain("The packaged app is here:");
378-
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle(line => line.Contains(path));
378+
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle().Which.Should().Contain(path);
379379
}
380380

381381
[TestMethod]
@@ -426,7 +426,7 @@ public async Task PackageCommandForFlutterAppsShouldCallFlutterWithOutputParamet
426426
]);
427427

428428
result.Error.Should().Contain("The packaged app is here:");
429-
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle(line => line.Contains(customPath));
429+
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle().Which.Should().Contain(customPath);
430430
}
431431

432432
private void SetupPubGet(DirectoryInfo dirInfo)
@@ -478,7 +478,7 @@ public async Task PackageCommandForElectronNpmAppsShouldCallElectronNpm()
478478
]);
479479

480480
result.Error.Should().Contain("The packaged app is here:");
481-
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle(line => line.Contains(path));
481+
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle().Which.Should().Contain(path);
482482
}
483483

484484
[TestMethod]
@@ -514,7 +514,7 @@ public async Task PackageCommandForElectronYarnAppsShouldCallElectronYarn()
514514
]);
515515

516516
result.Error.Should().Contain("The packaged app is here:");
517-
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle(line => line.Contains(path));
517+
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle().Which.Should().Contain(path);
518518
}
519519

520520
[TestMethod]
@@ -566,7 +566,7 @@ public async Task PackageCommandForReactNativeNpmAppsShouldCallMSBuild(string ma
566566
]);
567567

568568
result.Error.Should().Contain("The packaged app is here:");
569-
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle(line => line.Contains(path));
569+
result.Output.Split(['\r', '\n'], StringSplitOptions.RemoveEmptyEntries).Should().ContainSingle().Which.Should().Contain(path);
570570
}
571571
}
572572
}

MSStore.CLI/Commands/PackageCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public override async Task<int> InvokeAsync(ParseResult parseResult, Cancellatio
100100
if (returnCode == 0 && outputDirectory != null)
101101
{
102102
_ansiConsole.WriteLine($"The packaged app is here:");
103-
StandardOutput.WriteLine(outputDirectory.ToString());
103+
StandardOutput.WriteLine(outputDirectory.FullName);
104104
}
105105

106106
return await _telemetryClient.TrackCommandEventAsync<Handler>(returnCode, props, ct);

MSStore.CLI/Helpers/IProjectConfiguratorExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ internal static async Task ValidateImagesAsync(this IProjectConfigurator configu
2121
var defaultImages = ProjectImagesHelper.GetDefaultImagesUsedByApp(ansiConsole, appImages, projectSpecificDefaultImages, imageConverter, logger);
2222
if (defaultImages.Count > 0)
2323
{
24-
AnsiConsole.MarkupLine($"[bold yellow]The following images are using the default values and should be updated:[/]");
24+
ansiConsole.MarkupLine($"[bold yellow]The following images are using the default values and should be updated:[/]");
2525
foreach (var image in defaultImages)
2626
{
27-
AnsiConsole.MarkupLine($"[bold yellow] {image}[/]");
27+
ansiConsole.MarkupLine($"[bold yellow] {image}[/]");
2828
}
2929
}
3030
}

MSStore.CLI/ProjectConfigurators/WinUIProjectConfigurator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public override async Task<bool> CanConfigureAsync(string pathOrUrl, Cancellatio
7171

7272
version = AppXManifestManager.UpdateManifestVersion(manifestFile.FullName, version);
7373

74-
var bundleUploadFile = await AnsiConsole.Status().StartAsync("Building MSIX...", async ctx =>
74+
var bundleUploadFile = await ErrorAnsiConsole.Status().StartAsync("Building MSIX...", async ctx =>
7575
{
7676
try
7777
{

0 commit comments

Comments
 (0)