fix(restore): no-op gracefully when winapp.yaml is missing on non-.NET projects#483
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.yamlindependent of SDK setup. - Writes an empty
winapp.yamlwhen 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.
Contributor
Build Metrics ReportBinary Sizes
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 Time33ms median (x64, Updated 2026-04-21 18:06:32 UTC · commit |
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>
c47b7ad to
17ba840
Compare
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>
chiaramooney
approved these changes
Apr 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #474
What was broken
Running
winapp restoreon a project with nowinapp.yamlexited 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 thewindowscrate, not C++ headers), which leaves the project without a yaml — so any laterwinapp restorefailed.Path not taken (and why)
The first attempt was to make
winapp init --setup-sdks nonewrite an emptywinapp.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
restoreas 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 ofupdate, which already no-ops in this scenario (UpdateCommand.cs:117-120).Before:
After:
The .NET-project-without-yaml case is unaffected: still rejected with the existing dedicated message in
SetupWorkspaceAsync(line 70-75) telling the user to rundotnet restore.Tests
SetupWorkspace_WithRequireExistingConfig_FailsWhenConfigMissing→...NoOpsWhenConfigMissingto match the new contract.Manual verification
End-to-end Rust scenario from the guide:
cargo new→winapp init --setup-sdks none→winapp manifest add-alias→cargo build→winapp run --with-alias→winapp pack— all succeed.winapp restoreon a fresh project (no yaml): exit 0, friendly message.winapp restoreon a project with a populated yaml: still installs packages normally.