Skip to content

fix(restore): no-op gracefully when winapp.yaml is missing on non-.NET projects#483

Merged
nmetulev merged 3 commits into
mainfrom
fix/issue-474-init-no-sdks-yaml
Apr 21, 2026
Merged

fix(restore): no-op gracefully when winapp.yaml is missing on non-.NET projects#483
nmetulev merged 3 commits into
mainfrom
fix/issue-474-init-no-sdks-yaml

Conversation

@nmetulev
Copy link
Copy Markdown
Member

@nmetulev nmetulev commented Apr 20, 2026

Fixes #474

What was broken

Running winapp restore on a project with no winapp.yaml exited 1 with ""winapp.yaml not found"". This bit Rust / Tauri users especially hard: the Rust guide tells them to pick ""Do not setup SDKs"" during init (because Rust uses the windows crate, not C++ headers), which leaves the project without a yaml — so any later winapp restore failed.

Path not taken (and why)

The first attempt was to make winapp init --setup-sdks none write an empty winapp.yaml. Rejected: an empty file invites the user to delete it (""this is empty, why is it here?""), putting us right back in the broken state. The fragile contract is the file's existence; better to fix the consumer.

Fix

Treat restore as idempotent. A non-.NET project with no winapp.yaml has nothing to restore — print an informational message and exit 0. This mirrors the existing behavior of update, which already no-ops in this scenario (UpdateCommand.cs:117-120).

Before:

> winapp restore
winapp.yaml not found in <dir>
Run 'winapp init' to initialize a new workspace or navigate to a directory with winapp.yaml
[exit 1]

After:

> winapp restore
📝 No winapp.yaml found in <dir>. Nothing to restore.
If this project needs Windows SDK packages, run 'winapp init' to set them up.
✅ Restore completed successfully
[exit 0]

The .NET-project-without-yaml case is unaffected: still rejected with the existing dedicated message in SetupWorkspaceAsync (line 70-75) telling the user to run dotnet restore.

Tests

  • Updated SetupWorkspace_WithRequireExistingConfig_FailsWhenConfigMissing...NoOpsWhenConfigMissing to match the new contract.
  • Full test suite passes (764/764).

Manual verification

End-to-end Rust scenario from the guide:

  • cargo newwinapp init --setup-sdks nonewinapp manifest add-aliascargo buildwinapp run --with-aliaswinapp pack — all succeed.
  • winapp restore on a fresh project (no yaml): exit 0, friendly message.
  • winapp restore on a project with a populated yaml: still installs packages normally.

Copilot AI review requested due to automatic review settings April 20, 2026 22:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes winapp init for non-.NET projects so that winapp.yaml is still created when the user opts to skip SDK setup (--setup-sdks none), preventing subsequent winapp restore from failing due to a missing config file (Fixes #474).

Changes:

  • Adjusts config-save gating so non-.NET init can write winapp.yaml independent of SDK setup.
  • Writes an empty winapp.yaml when SDK setup is skipped, but only if no config existed before (to avoid clobbering).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 20, 2026

Build Metrics Report

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 30.66 MB 30.66 MB 📉 -0.5 KB (-0.00%)
CLI (x64) 31.02 MB 31.02 MB ✅ 0.0 KB (0.00%)
MSIX (ARM64) 12.93 MB 12.94 MB 📈 +1.3 KB (+0.01%)
MSIX (x64) 13.74 MB 13.74 MB 📈 +0.1 KB (+0.00%)
NPM Package 26.89 MB 26.89 MB 📉 -0.5 KB (-0.00%)
NuGet Package 26.98 MB 26.98 MB 📈 +0.3 KB (+0.00%)
VS Code Extension 19.72 MB 19.72 MB 📈 +0.9 KB (+0.00%)

Test Results

773 passed, 1 skipped out of 774 tests in 553.7s (+122.2s vs. baseline)

Test Coverage

21.4% line coverage, 36.4% branch coverage · ✅ no change vs. baseline

CLI Startup Time

33ms median (x64, winapp --version) · ✅ -6ms vs. baseline


Updated 2026-04-21 18:06:32 UTC · commit 65b025c · workflow run

Previously `winapp restore` exited 1 with ""winapp.yaml not found"" when no
config existed. This was a problem for projects that don't use the C++ SDK
flow (Rust, Tauri) — the Rust guide tells users to pick `--setup-sdks none`
during init, which leaves no winapp.yaml, so any later `winapp restore` call
errored out.

The first attempt (creating an empty winapp.yaml during init) was rejected
because an empty file invites the user to delete it, putting us right back
in the broken state.

Better fix: treat `restore` as idempotent. A non-.NET project with no
winapp.yaml has nothing to restore — print an informational message and exit 0.
This mirrors the existing behavior of `update`, which already no-ops when
no yaml is present (UpdateCommand.cs:117-120).

The .NET-project-without-yaml case is unaffected: it's still rejected with
the existing dedicated message in SetupWorkspaceAsync (line 70-75) telling
the user to run `dotnet restore`.

Updated the existing test
`SetupWorkspace_WithRequireExistingConfig_FailsWhenConfigMissing` to
`...NoOpsWhenConfigMissing` to match the new contract.

Fixes #474

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nmetulev nmetulev force-pushed the fix/issue-474-init-no-sdks-yaml branch from c47b7ad to 17ba840 Compare April 20, 2026 22:50
@nmetulev nmetulev changed the title fix(init): always create winapp.yaml for non-.NET projects, including when SDK setup is skipped fix(restore): no-op gracefully when winapp.yaml is missing on non-.NET projects Apr 20, 2026
When --setup-sdks none is used (e.g., for Rust/Tauri projects that bring
their own SDK bindings via the windows crate), no winapp.yaml is created
because there are no SDK package versions to track for restore/update.

- InitCommand description now spells out this behavior
- usage.md notes the conditional yaml creation
- Tauri and Rust guides add a callout explaining why no yaml appears

Related to #474.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nmetulev nmetulev merged commit 1affd55 into main Apr 21, 2026
10 checks passed
@nmetulev nmetulev deleted the fix/issue-474-init-no-sdks-yaml branch April 21, 2026 17:46
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.

[Bug]: winapp init doesn't create winapp.yml file for tauri

3 participants