Skip to content

Invoke the CLI directly instead of building command strings in package-msix.ps1 - #725

Merged
Nikola Metulev (nmetulev) merged 2 commits into
mainfrom
azchohfi-package-msix-direct-invocation
Aug 11, 2026
Merged

Invoke the CLI directly instead of building command strings in package-msix.ps1#725
Nikola Metulev (nmetulev) merged 2 commits into
mainfrom
azchohfi-package-msix-direct-invocation

Conversation

@azchohfi

Copy link
Copy Markdown
Contributor

What

The four CLI invocations in scripts/package-msix.ps1 built a command string by interpolation and then executed it through Invoke-Expression:

$X64PackageCmd = "& `"$CliExe`" package `"$X64LayoutPath`" --name `"...`" ... $CertParam"
Invoke-Expression $X64PackageCmd

Layout paths, package names, and the certificate path all flowed into that string. Any character with meaning to the PowerShell parser — a quote, semicolon, or ampersand in a path — would be re-interpreted as syntax instead of being passed through as data.

How

Use the call operator with an argument array and splat it:

$X64PackageArgs = @('package', $X64LayoutPath, '--name', $name, '--output', $X64OutputPath) + $CertArgs
& $CliExe @X64PackageArgs

$CertParam (previously the pre-quoted string --cert "path") becomes $CertArgs, a proper array, so the certificate path arrives as a discrete argument rather than a fragment of a larger string that gets re-parsed.

The Write-Host command echoes are kept so build logs still show what ran, but they are now display-only and never executed.

Validation

.\scripts\build-cli.ps1 -SkipTests -SkipNpm runs clean end to end through the full MSIX path — build-tools update, both architecture layouts, and both packages created and signed:

winappcli_0.5.1.30_x64.msix (16.87 MB)   Package has been signed
winappcli_0.5.1.30_arm64.msix (15.88 MB) Package has been signed

No behavior change is intended; this is purely how the arguments reach the CLI.

…e-msix.ps1

The four CLI invocations in package-msix.ps1 built a command string via string
interpolation and then ran it through Invoke-Expression. Paths and package names
flowed into that string, so any character with meaning to the PowerShell parser
(quotes, semicolons, ampersands) would have been re-interpreted rather than
passed through as data.

Use the call operator with an argument array instead, and splat it. $CertParam
becomes $CertArgs so the certificate path is a discrete argument rather than a
pre-quoted fragment of a larger string. The Write-Host command echoes are kept
for build-log readability but are now display-only.
Copilot AI balanced review requested due to automatic review settings August 11, 2026 18:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces Invoke-Expression with direct CLI invocation to prevent PowerShell from reinterpreting argument data.

Changes:

  • Uses the call operator for CLI execution.
  • Passes package and certificate parameters through argument arrays.
  • Retains display-only command logging.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Build Metrics Report

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 38.62 MB 38.62 MB ✅ 0.0 KB (0.00%)
CLI (x64) 38.73 MB 38.73 MB ✅ 0.0 KB (0.00%)
MSIX (ARM64) 16.02 MB 16.02 MB 📉 -0.7 KB (-0.00%)
MSIX (x64) 17.01 MB 17.01 MB 📉 -0.6 KB (-0.00%)
NPM Package 33.42 MB 33.42 MB 📉 -0.6 KB (-0.00%)
NuGet Package 33.45 MB 33.45 MB 📉 -0.4 KB (-0.00%)

Test Results

4549 passed, 5 skipped out of 4554 tests in 608.6s (+81.0s vs. baseline)

Test Coverage

89.1% line coverage, 82.4% branch coverage · ✅ no change vs. baseline

CLI Startup Time

49ms median (x64, winapp --version) · ✅ +7ms vs. baseline

Try This Build

Installs the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing.

& ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 725
Switching between builds often?

Put the tool on your PATH once:

& ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPath

Then this build is just:

winapp-pr 725

Run winapp-pr with no arguments to pick from a list of open PRs.


Updated 2026-08-11 20:42:03 UTC · commit b0fccab · workflow run

@nmetulev
Nikola Metulev (nmetulev) merged commit 62a058c into main Aug 11, 2026
30 checks passed
@nmetulev
Nikola Metulev (nmetulev) deleted the azchohfi-package-msix-direct-invocation branch August 11, 2026 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants