Skip to content

Fix winapp run/package building a referenced library twice (APPX1101/PRI252) - #1032

Merged
Zach Teutsch (zateutsch) merged 29 commits into
mainfrom
nmetulev-fluentstore-winapp-run-debug
Oct 15, 2026
Merged

Zach Teutsch (zateutsch) merged 29 commits into
mainfrom
nmetulev-fluentstore-winapp-run-debug

Conversation

@nmetulev

@nmetulev Nikola Metulev (nmetulev) commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

What and why

winapp run and winapp package could fail on a WinUI app that references class libraries, even though the same solution builds in Visual Studio. FluentStore is a real example.

Cause: winapp builds with -r win-<arch>. For a library that doesn't depend on a runtime identifier, .NET marks the reference "build without the RID", so the library is built once. The Windows App SDK packaging step lists references without that marker. It builds the library a second time with the RID, then finds two copies (APPX1101) or looks for a file that was never written (PRI175/PRI252, MSB3030), depending on the Windows App SDK version.

Fix: winapp keeps its build arguments exactly as before. It now gives the dotnet processes it starts (the run build and the package publish) a small MSBuild file through the CustomAfterDirectoryBuildTargets environment variable. That file makes the packaging step use the same reference list as the rest of the build, so each library is built once. It also lets a project whose earlier build failed this way recover without a clean.

Nothing is written into the project. Visual Studio, plain dotnet build and other tools aren't affected. A project that sets CustomAfterDirectoryBuildTargets itself keeps its own value; one that appends to it gets both files.

Before / after

winapp package FluentStore.App\FluentStore.App.csproj --no-sign on a clean checkout (arm64):

Before (v0.7.1)

📦 Packaging FluentStore.App.csproj (Release | arm64)...
Microsoft.Build.Msix.Packaging.targets(1616,5): error APPX1101: Payload contains two or more files with the same destination path 'FluentStore.SDK.pdb'. Source files:
  FluentStore.SDK\bin\arm64\Release\net8.0-windows10.0.22621.0\FluentStore.SDK.pdb
  FluentStore.SDK\obj\arm64\Release\net8.0-windows10.0.22621.0\win-arm64\FluentStore.SDK.pdb

After

📦 Packaging FluentStore.App.csproj (Release | arm64)...
📦 Package: ...\fluentstore.msix
✅ MSIX package creation completed.

winapp run FluentStore.App fails the same way on v0.7.1; with this change, the "Fluent Store" window opens.

Not tested / risks

  • Projects that set the property "only if it's empty": such a project won't load its own file under winapp. A GitHub search found none. Public projects that set this property either append to it (.NET for iOS/Mac and several SDKs; both files load) or replace it (Electron.NET; that project builds exactly as before).
  • Bundles built on every build: an app with GenerateAppxPackageOnBuild and AppxBundle=Always still fails with NETSDK1134, as on v0.7.1. Workaround: -p AppxBundle=Never.
  • Visual Studio IDE: not tested in the IDE itself, only Build Tools. Visual Studio doesn't pass -r, so it doesn't hit this bug.

Checklist

  • Tests added or updated
  • Tested locally on Windows
Notes for reviewers

Upstream: the underlying bug is in the Windows App SDK / MSIX packaging targets. GetPriOutputs and GetPackagingOutputs use @(ProjectReferenceWithConfiguration) instead of the SDK-prepared references. This workaround can be removed once that's fixed upstream.

Tests:

  • tests/project-references: 8 real builds, run as a step in the existing e2e-test-ui job.
    • Covers Windows App SDK 1.6, 1.8 and 2.x, a FluentStore-style graph, a library with its own CustomAfterDirectoryBuildTargets, package on a clean checkout, and recovery after a failed build.
    • On v0.7.1, 7 of 8 fail; the 8th is the no-regression check. All pass with this change.
  • Unit tests cover the delivery for run, package and the native MSIX publish, plus path escaping and appending to an inherited value.

Validation (arm64 dev box):

Check Result
Related unit tests (ProjectRun, RunCommand, PackageCommand, MsBuildPropertyReader, DotNetService) 1063 passed
tests/project-references 8/8 (v0.7.1: 7 failures, as designed)
Windows App SDK 1.6 cases on .NET SDK 8.0.426 run and package pass
winapp run on WinUI Gallery, AI Dev Gallery, FluentStore and 11 local apps FluentStore now works; every other app matches v0.7.1
.\scripts\test-samples.ps1 (winui-app, winui-solution, winui-unpackaged-app, wpf-app, dotnet-app) 52 passed, 3 skipped

Abandoned approaches:

  • Building without -r regressed several project shapes.
  • Passing -p:CustomAfterMicrosoftCommonTargets overrode projects' own values.
  • Writing the file into obj persisted, so package only worked after a run.

winapp run passed a global -r win-<arch>. The Windows App SDK MSIX/MRT
packaging targets query project references without removing that RID, so
RID-agnostic libraries that enable MSIX tooling were built twice and
packaging failed with APPX1101/PRI175/PRI252/MSB3030 (for example,
FluentStore).

winapp run builds now convey the architecture with -p:Platform alone, as
Visual Studio does. Projects that set their own RuntimeIdentifier, enable
dynamic platform resolution, or pass a Platform that doesn't match --arch
keep the RID. winapp pack and --aot are unchanged.

Adds tests/project-arch, a generated-project matrix that runs the real CLI
and launches each app, as a sharded CI job.

Co-authored-by: Copilot App <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 16:15
@nmetulev Nikola Metulev (nmetulev) added the agent-preparing Agent is addressing feedback or completing required validation and CI label Oct 8, 2026

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.

🟡 Changes recommended

The RID-required fallback can still suppress the RID for a split reference graph, reproducibly causing NETSDK1032.

1 open finding
What changed in this PR

Fixes multi-project winapp run builds by using MSBuild Platform instead of a global RID, with compatibility fallbacks and expanded regression coverage.

Changes:

  • Adds Platform-only architecture resolution with RID fallbacks.
  • Adds a generated 44-fixture architecture matrix and CI gate.
  • Updates tests, samples, documentation, and plugin guidance.
File Description
tests/​project-arch/​README.md Documents the architecture matrix.
tests/​project-arch/​ProjectArch.Tests.ps1 Runs and validates generated fixtures.
tests/​project-arch/​ProjectArch.psm1 Generates fixture projects and executes the CLI.
src/​winapp-CLI/​WinApp.Cli/​Services/​ProjectRunService.Platform.cs Resolves Platform-only versus RID builds.
src/​winapp-CLI/​WinApp.Cli/​Services/​ProjectRunService.cs Integrates resolution and output fallbacks.
src/​winapp-CLI/​WinApp.Cli/​Models/​ProjectRunModels.cs Updates architecture option contracts.
src/​winapp-CLI/​WinApp.Cli/​Commands/​RunCommand.cs Updates architecture option help.
src/​winapp-CLI/​WinApp.Cli.Tests/​ProjectRunServiceTests.cs Tests architecture resolution behavior.
src/​winapp-CLI/​WinApp.Cli.Tests/​ProjectRunServicePublishProfileTests.cs Tests profile selection under Platform builds.
scripts/​tests/​artifact-workflow.Tests.ps1 Validates the new CI dependency.
samples/​winui-solution/​README.md Updates multi-project behavior guidance.
samples/​winui-solution/​App.Core/​App.Core.csproj Updates the regression explanation.
samples/​winui-app/​test.Tests.ps1 Tests Platform-based profile selection.
plugins/​winapp/​skills/​winapp-setup/​SKILL.md Updates shipped setup guidance.
plugins/​winapp/​com.github.copilot/​agents/​winapp.agent.md Updates agent command guidance.
docs/​usage.md Documents revised option semantics.
docs/​guides/​dotnet.md Updates multi-project build guidance.
AGENTS.md Documents the architecture test workflow.
.github/​workflows/​build-package.yml Adds the four-shard CI matrix.

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Build Metrics Report

Validation passed. All required build and validation jobs succeeded.

Binary Sizes

Artifact Baseline Current Delta
CLI (ARM64) 59.48 MB 59.48 MB 📈 +4.0 KB (+0.01%)
CLI (x64) 59.46 MB 59.46 MB 📈 +4.0 KB (+0.01%)
MSIX (ARM64) 24.71 MB 24.71 MB 📉 -1.2 KB (-0.00%)
MSIX (x64) 26.20 MB 26.20 MB 📉 -2.8 KB (-0.01%)
NPM Package 51.51 MB 51.52 MB 📈 +7.5 KB (+0.01%)
NuGet Package 51.63 MB 51.63 MB 📈 +3.9 KB (+0.01%)

.NET Test Results (TRX reports)

Other suites are reflected in the overall validation status above.

✅ 8676 passed, 39 skipped out of 8715 tests in 1437.8s (+8 tests, -81.4s vs. baseline)

Test Coverage

✅ 87.5% line coverage, 81.9% branch coverage · ✅ no change vs. baseline

CLI Startup Time

60ms median (x64, winapp --version) · 📉 -11ms 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))) 1032
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 1032

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


Updated 2026-10-15 04:02:36 UTC · commit 3494e35 · workflow run

…winapp-run-debug

# Conflicts:
#	plugins/winapp/com.github.copilot/agents/winapp.agent.md
A project that sets its own RuntimeIdentifier falls back to the RID path,
but the legacy resolution drops the RID for a reference graph that removes
it, so the project's RID won and the build failed with NETSDK1032.

Co-authored-by: Copilot App <[email protected]>
@nmetulev Nikola Metulev (nmetulev) added ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Oct 8, 2026

@zateutsch Zach Teutsch (zateutsch) 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.

🤖 AI-generated review (winappcli pr-review skill) — verify before acting.

Changes requested. The main fix works. I copied samples\winui-solution and ran winapp run WinUISolution.slnx with a published CLI from this branch on arm64. It built with -p:Platform=ARM64 and no -r, wrote output to bin\ARM64\Debug\<tfm>\, and registered and launched the app. The targeted unit tests (RunBuild, RunNoBuild, PublishProfile) pass 46/46.

I reproduced one regression against the released v0.7.1. Details are in the inline comment on ProjectRunService.Platform.cs; the fix is about two lines.

Must fix

  • Projects that enable EnableDynamicPlatformResolution get -r win-<arch> added back, even where v0.7.1 had dropped it. A graph that reaches the same reference both with and without the RID then fails with MSB3030. v0.7.1 builds that graph successfully.

Non-blocking

  • The new project-arch job runs on every PR and blocks build-and-package. See the inline comment on the workflow.

Not exercised: the full tests/project-arch suite and x64 or cross-arch runs. CI covers x64.

Comment thread .github/workflows/build-package.yml Resolved
Only a project's own conflicting RuntimeIdentifier needs the RID forced
back. Doing it for EnableDynamicPlatformResolution re-added -r to graphs
that remove RuntimeIdentifier on one edge, which builds the shared
reference twice and fails with MSB3030, while v0.7.1 built them.

Run the architecture matrix on PRs only when they touch project-mode
build/run code; main pushes and manual runs still always run it.

Co-authored-by: Copilot App <[email protected]>
@nmetulev Nikola Metulev (nmetulev) added agent-preparing Agent is addressing feedback or completing required validation and CI and removed ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge labels Oct 8, 2026
@nmetulev Nikola Metulev (nmetulev) added ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Oct 8, 2026

@zateutsch Zach Teutsch (zateutsch) 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.

🤖 AI-generated review (winappcli pr-review skill) — verify before acting.

Changes requested. Thanks for the quick turnaround. Both earlier comments are fixed, and I checked them with a CLI published from 4e1984e5:

  • R17-edpr-rid-split builds with -p:Platform=ARM64 only and succeeds.
  • R16 still gets -r win-arm64, and R08 passes.
  • The project-arch-changes gate is correct: the required check still fails if the filter job fails or is cancelled.
  • Targeted unit tests pass (45/45), and artifact-workflow.Tests.ps1 passes (26/26).

Must fix: one new regression, which I reproduced against v0.7.1. Building for a different architecture than the machine now breaks apps that reference a source generator project. Details are in the inline comment.

Not exercised: an x64 host and the full tests/project-arch suite.

…alyzers

A global Platform also reaches analyzer and source-generator project
references, so a cross-architecture build compiled the generator for the
target architecture and the compiler (running on the SDK's architecture)
couldn't load it: CS8034, then CS0103. v0.7.1 built these with the RID.

When --arch differs from the .NET SDK's architecture and the reference
graph has a build-only project reference, use the existing RID-based
resolution. Native builds keep the Platform-only path.

Co-authored-by: Copilot App <[email protected]>
…winapp-run-debug

# Conflicts:
#	docs/usage.md
@nmetulev Nikola Metulev (nmetulev) added agent-preparing Agent is addressing feedback or completing required validation and CI and removed ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge labels Oct 9, 2026
@nmetulev Nikola Metulev (nmetulev) removed the agent-preparing Agent is addressing feedback or completing required validation and CI label Oct 9, 2026
@nmetulev Nikola Metulev (nmetulev) added agent-preparing Agent is addressing feedback or completing required validation and CI and removed ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge labels Oct 12, 2026
Replace the Platform-only default and its reference-graph probe with a
targeted fix. `winapp run` again passes v0.7.1's build arguments
(including -r win-<arch>), plus a small MSBuild file through
-p:CustomAfterMicrosoftCommonTargets:

- WinAppSDK/MSIX PRI and packaging targets query the raw
  ProjectReferenceWithConfiguration items, which lack the .NET SDK's
  "build without the RID" marker for RID-agnostic references. They then
  build a referenced library a second time with the RID, and packaging
  fails with APPX1101, PRI175/PRI252 or MSB3030 (FluentStore). The file
  hands those targets the SDK-prepared reference items.
- After such a failed build, the cached pri.resfiles still names the
  missing file; the file deletes it when it lists files that don't exist.

winapp leaves the build unchanged when it already sets
CustomAfterMicrosoftCommonTargets (user -p, the app's evaluated value,
or a referenced project/Directory.Build.* naming it), reusing the
publish-profile preflight evaluation. `winapp pack` and --aot are
unchanged.

project-arch now checks the file is imported (or kept out when the
project sets the property, R27 via an imported file), adds a
failed-build recovery test, a SetPlatform reference fixture (R26), and
drops the bundle fixture, which fails as on v0.7.1.

Co-authored-by: Copilot App <[email protected]>
@nmetulev Nikola Metulev (nmetulev) changed the title Build winapp run projects with Platform instead of a global RID Fix winapp run packaging a referenced library twice (APPX1101/PRI252) Oct 13, 2026
Filter references with Where, catch only the exceptions XDocument.Load
throws for unreadable or malformed project files, and use Path.Join in
the new test.

Co-authored-by: Copilot App <[email protected]>
@nmetulev Nikola Metulev (nmetulev) added ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Oct 13, 2026

@zateutsch Zach Teutsch (zateutsch) 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.

🤖 AI-generated review (winappcli pr-review skill) — verify before acting.

Thanks for the redesign. Keeping v0.7.1's build arguments and fixing only how packaging references are resolved works well here. I ran all 71 test apps in the PR's suite with a CLI built from this branch on an ARM64 machine and saw no build regressions. The 8 x86 apps built but stopped at an error dialog when launched, because this machine has no x86 .NET runtime. The ProjectRunService and MsBuildPropertyReader unit tests all passed (419/419).

I have one remaining request, in the inline comment: a referenced library that sets CustomAfterMicrosoftCommonTargets through its own import can have that setting overridden.

Nikola Metulev (nmetulev) added a commit that referenced this pull request Oct 13, 2026
> Independent of #1032. The FluentStore output and recording below were
captured with #1032 applied, because FluentStore only builds with that
fix: on `main` alone it fails with APPX1101, before and after this PR.
The output changes here apply either way.

## Description

On an interactive terminal, `winapp run <project>` printed much more
than `dotnet build` for the same build:

- Every warning appeared twice, once inline and once in the summary.
winapp let the build restore itself, so it had to stream the build
through the classic logger (`-tl:off`) to redact authenticated NuGet
feed URLs.
- When a whole-solution restore failed (for example, a solution that
lists projects from an uninitialized git submodule), winapp restored
**every** listed project one at a time. Each one printed a banner, a
long wrapped `dotnet restore` command and NuGet output, and the missing
projects each failed with `MSB1009`.
- The full injected `dotnet` command was printed for every step.

Now:

- **Interactive terminal:** restore runs on its own, through winapp
(feed credentials stay redacted), behind a spinner. It reports one line
plus any warnings, once each. The build then runs with `--no-restore`
and dotnet's terminal logger, so it looks exactly like `dotnet build`:
one line per project, each warning once, one summary line.
- **Solutions:** projects that aren't on disk are skipped with one note.
The solution's other .NET projects restore in a **single** invocation
through a temporary solution filter (`.slnf`) that lists only the
projects winapp resolved to local files, so missing, native and UNC
entries are left out. The solution itself is never handed to `dotnet
restore`, so MSBuild can't open entries winapp skipped. A solution that
lists `.etp` or `%`-escaped entries, which MSBuild would follow even
through a filter, restores its projects one by one. winapp also retries
project by project if the filtered restore fails for a reason other than
a NuGet package error. A package error leaves the other projects
restored, so retrying them would only repeat it.
- **Commands:** full `dotnet`/MSBuild command lines appear only with
`--verbose`, or after a step fails (`Command: …`) together with its full
output. If the failed step was the solution-filter restore, winapp keeps
the temporary `.slnf` so the printed command can be rerun.
- **Other modes:**
- **Single-file (`winapp run app.cs`):** behaves like a project on an
interactive terminal. It restores through winapp with one summary line,
then runs a `--no-restore` build with dotnet's terminal logger.
- **`winapp pack` and `--aot`:** their restores use the same one-line
summary on an interactive terminal. `dotnet publish` output still
streams.
- **`--no-restore`:** the build replays warnings from an earlier restore
that winapp never saw, and those can quote a feed credential. So in both
project and single-file mode it streams plain text through winapp's
redaction.
- **C++:** only the command display changed. A failure prints the exact
MSBuild command.
  - **Agents, CI and redirected output:** still get plain streamed text.
- **`--json` and `--quiet`:** `--json` keeps stdout pure JSON, with
diagnostics and failed commands on stderr. `--quiet` stays quiet.
- **Redaction scope:** dotnet gets the console only when nothing NuGet
or winapp adds can quote a secret. That means a separate restore whose
output needed no redaction, and no credential in the arguments.
Otherwise the build streams through winapp's redaction. Text that a
project's own targets choose to print appears as it would under `dotnet
build`.

## Usage Example

Observed in a real terminal, `winapp run .\FluentStore.App --no-launch`
on [FluentStore](https://github.com/yoshiask/FluentStore). FluentStore's
`.sln` lists 4 projects from an uninitialized submodule. The warnings
come from FluentStore itself and also appear in `dotnet build`. Long
lines are trimmed with `…`.

**Before** (80 columns, incremental build):

```
🔎 FluentStore.App.csproj  ·  Debug | arm64  ·  FluentStore.sln
🔄 Restoring FluentStore.sln dependencies...
   dotnet restore D:\FluentStore\FluentStore.sln -p:Configuration=Debug
-p:SolutionDir=D:\FluentStore\ -p:SolutionPath=D:\FluentStore\FluentStore.sln
-p:SolutionName=FluentStore -p:SolutionFileName=FluentStore.sln
-p:SolutionExt=.sln
…NuGet.targets(521,5): error MSB3202: The project file "…\Cabinet.csproj" was not found. […]
   (×4)
⚠ Solution restore failed (exit code 1); retrying managed dependencies
individually.
🔄 Restoring Microsoft.Marketplace.Storefront.Contracts.csproj dependencies...
   dotnet restore
D:\FluentStore\API\MicrosoftStore\Microsoft.Marketplace.Storefront.Contracts.csp
roj -p:Configuration=Debug -p:Platform=arm64 -p:SolutionDir=D:\FluentStore\
…
  Determining projects to restore...
  All projects are up-to-date for restore.
   … the same block for every listed project, NU1901 repeated each time, and
     MSB1009 "Project file does not exist" for each submodule project …
🔧 Building FluentStore.App.csproj (Debug | arm64)...
   dotnet build D:\FluentStore\FluentStore.App\FluentStore.App.csproj -c Debug
-v minimal -tl:off -p:Platform=arm64 …
   … every warning inline (full length), then all of them again after "Build succeeded." …
    11 Warning(s)
    0 Error(s)
✅ Built FluentStore.App in 11.9s
```

**After** (109 columns):

```
🔎 FluentStore.App.csproj  ·  Debug | arm64  ·  FluentStore.sln
ℹ Skipping 4 projects listed in FluentStore.sln that aren't on disk
(API\UUPMediaCreator\src\Cabinet\Cabinet.csproj and 3 more).
✅ Restored FluentStore.App and 20 solution projects with 2 warning(s) in 3.7s
    D:\FluentStore\FluentStore.SDK\FluentStore.SDK.csproj : warning NU1901: Package 'NuGet.Packaging' 6.14.0 …
    D:\FluentStore\FluentStore.SDK\FluentStore.SDK.csproj : warning NU1901: Package 'NuGet.Protocol' 6.14.0 …
🔧 Building FluentStore.App.csproj (Debug | arm64)...
…Microsoft.UI.Xaml.Markup.Compiler.BeforeCommon.targets(31,3): warning MSB4011: … (×4, evaluation warnings, as in dotnet build)
  FluentStore.Services net8.0-windows10.0.22621.0 succeeded (0.1s) → …
  …
  FluentStore.SDK net8.0-windows10.0.22621.0 succeeded with 2 warning(s) (0.4s) → …
    …warning NU1901: … (×2)
  …
  FluentStore.App net8.0-windows10.0.22621.0 succeeded with 3 warning(s) …
    …warning NETSDK1198 / APPX0102 / APPX0107 …

Build succeeded with 9 warning(s) in 7.0s
✅ Built FluentStore.App in 7.2s
✅ 52374YoshiAskharoun.FluentStore_7sdtne7r32rbe registered (AUMID: …!App)
```

A failing step still shows everything needed to reproduce it. Here, the
restore used a feed URL that carries a user name, password and `sig=`
token, and all three are redacted:

```
…FailApp.csproj : error NU1301: Failed to retrieve information about 'Winapp.Does.Not.Exist' from remote source 'https://invalid.example/v3/index.json?<redacted>'.
  Failed to restore …\FailApp.csproj (in 2.45 sec).
   Command: dotnet restore …\FailApp.csproj -p:Configuration=Debug -p:Platform=arm64
-p:RestoreSources=https://invalid.example/v3/index.json?<redacted>
❌ Restore failed for 'FailApp.csproj' (exit code 1).
```

A build failure (`-p WarningsAsErrors=NETSDK1198` on FluentStore) ends
with `Build failed with 1 error(s) and 8 warning(s)`, then `Command:
dotnet build … --no-restore …` and `❌ Build failed for
FluentStore.App.csproj (exit code 1).`

## Related Issue

Related to #1032: the FluentStore demo depends on it; the code doesn't.

## Type of Change

- 🐛 Bug fix
- 🧪 Test update
- 📝 Documentation

## Checklist

- [x] New tests added for new functionality (if applicable)
- [x] Tested locally on Windows
- [x] [docs/usage.md](../docs/usage.md) updated (if CLI commands
changed)
- [x] [Language-specific guides](../docs/guides) updated (if applicable)
- [x] Shipped skills updated in `plugins/winapp/skills/` (if CLI
commands/workflows changed)

## Screenshots / Demo

Recording in Windows Terminal at 140×42, all three on an incremental
FluentStore build (with #1032 applied), back to back: (1) `dotnet build
.\FluentStore.App -p:Platform=arm64` for reference, (2) `winapp run
.\FluentStore.App --no-launch` without this PR, (3) the same command
with this PR. Watch the live behavior, not only the final screen: (2)
scrolls through the restore cascade and a classic-logger build, while
(3) shows one restore spinner line, then the same live per-project
progress as (1).


https://github.com/user-attachments/assets/62f00a72-753c-404d-9460-e7957193f667

The final counts differ for a reason: `dotnet build` reports `11
warning(s)` because its two restore warnings (NU1901) are counted in the
build summary. This PR reports those two on the restore line and `9
warning(s)` for the build; the build itself lists the same warnings in
both.

## Additional Notes

Validation (local, ARM64 dev box, unless noted). These ran on the
earlier stacked branch, whose commits are the same apart from conflict
resolutions in docs, the C++ build output and one sample assertion:

- `.\scripts\build-cli.ps1 -SkipTests -SkipDocs`: passed.
- `.\scripts\test-samples.ps1 -Samples
winui-app,winui-solution,winui-unpackaged-app,wpf-app,dotnet-app
-WinappPath .\artifacts`: 51/51 passed. Successful runs no longer print
the build command, so the `winui-app` assertion that reads it now runs
with `--verbose`.
- `Invoke-Pester .\tests\project-arch\ProjectArch.Tests.ps1`: 46/46
passed.
- CI on the stacked branch (Build and Package): all validate-tests
shards, all four project-arch shards, docs and UI e2e passed
([run](https://github.com/microsoft/winappCli/actions/runs/37879298232)).
- Full `WinApp.Cli.Tests` (Debug): one unrelated failure,
`AnalyzeDumpAsync_ManagedDumpWithDeepStack_DetectsStackOverflowShape`
("the .NET runtime in the dump does not match the host architecture
(Arm64)").

After the rebase onto `main`:

- `dotnet run --project
src\winapp-CLI\WinApp.Cli.Tests\WinApp.Cli.Tests.csproj -c Release --
--filter
"FullyQualifiedName~ProjectRunService|FullyQualifiedName~RunCommand|FullyQualifiedName~PackageCommand"`:
878/878 passed.
- A solution listing an irregularly formatted UNC entry (`"Evil" ,
"\\localhost\nonexistent$\Evil.csproj"`; Release CLI build,
`--verbose`): winapp restores only through the `.slnf` and never runs
`dotnet restore App.sln`; the entry never appears in the output, and the
app builds.
- A solution with a missing project and a sibling referencing a
nonexistent package (published CLI): the solution-filter restore fails
with `NU1101`. The `.slnf` named in the printed `Command:` line still
exists after the failure, and rerunning that command reproduces
`NU1101`.
- FluentStore on `main` with this PR, in a real terminal: one restore
line, then dotnet's terminal logger. The build then fails with APPX1101,
the bug #1032 fixes, followed by `Command: dotnet build …`.
- PR CI (Build and Package, including samples and UI e2e) passed.

Project restores now pass `-p:RuntimeIdentifier=<rid>` alongside `-r
<rid>`. `dotnet restore -r` only fills `RuntimeIdentifiers`, while
`dotnet build -r` restores with `RuntimeIdentifier` set, so a
`RuntimeIdentifier`-conditioned `PackageReference` was missing from the
assets file a `--no-restore` build reads. For the same reason, the
target always restores on its own rather than relying on a
solution-scoped restore. Reproduced: `restore -r win-arm64`, then `build
-r win-arm64 --no-restore`, fails with CS0103; with the property, it
succeeds.

After the redaction and review follow-ups:

- `dotnet run --project
src\winapp-CLI\WinApp.Cli.Tests\WinApp.Cli.Tests.csproj -c Release --
--filter
"FullyQualifiedName~ProjectRunService|FullyQualifiedName~RunCommand|FullyQualifiedName~PackageCommand"`:
898/898 passed, and no `winapp-restore-*.slnf` files were left in
`%TEMP%`.
- Each new behavior test failed with its fix temporarily reverted:
single-file redaction and separate restore, `--json` C++ and native MSIX
`Command:` lines, and package preparation stopping on a solution package
error.
- With the .NET SDK 10.0.401 on a `net10.0` project, `--no-restore -f
net8.0` fails with NETSDK1005 after an unpinned restore and builds after
a restore pinned with `-p:TargetFramework`. A multi-targeting project
also builds.
- Real terminal: `winapp run hello.cs --no-launch` printed `✅ Restored
hello in 0.8s`, then dotnet's terminal logger (`hello.cs net10.0
win-arm64 succeeded`, `Build succeeded in 0.5s`).

---------

Co-authored-by: Nikola Metulev <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Zach Teutsch <[email protected]>
Passing -p:CustomAfterMicrosoftCommonTargets applied winapp's targets to
every project in the build and replaced any project's own value of that
property. A referenced library that sets it through an imported file
lost its own build step (review repro: a code generator -> CS0103), and
v0.7.1 builds it.

winapp run now writes the same targets to
$(MSBuildProjectExtensionsPath)<project>.winapp.g.targets, next to the
app's NuGet-generated files. MSBuild imports that file for the app
only, so build arguments are exactly v0.7.1's and no project's
properties are touched. The file is only rewritten when its content
changes, keeping incremental builds incremental. This removes the
property detection (evaluated value, default-path comparison, static
reference scan) and the default-file re-import.

Adds fixture R28 (library sets CustomAfterMicrosoftCommonTargets via its
own import to generate code: CS0103 with the previous -p approach,
passes on v0.7.1 and now) and checks the file in every fixture.

Co-authored-by: Copilot App <[email protected]>
…winapp-run-debug

# Conflicts:
#	scripts/tests/artifact-workflow.Tests.ps1
The obj\<project>.winapp.g.targets file persisted after `winapp run`, so
`winapp package` passed or failed depending on whether `run` had run
first (it still failed on a clean checkout), and later builds silently
changed. Replace it with a content-named temp file passed through the
CustomAfterDirectoryBuildTargets environment variable of the dotnet
build/publish processes winapp starts (run, package publish, native MSIX
publish, --aot). Nothing is written into the project; an inherited value
is appended to; a project's own assignment still wins. The path is
MSBuild-escaped ('%XX', ';').

Remove the obj-path evaluation plumbing and restore main's build
argument and publish-profile code. Replace the 72-fixture project-arch
matrix and its 4-shard CI job with tests/project-references: 8 real-build
tests (Windows App SDK 1.6/1.8/2.x, FluentStore graph, a library with its
own CustomAfterDirectoryBuildTargets, `package` on a clean checkout,
failed-build recovery) run as a step in the e2e-test-ui job. 7 of 8 fail
on v0.7.1; all pass now. The full matrix remains in commit 934cb43.

Co-authored-by: Copilot App <[email protected]>
@nmetulev Nikola Metulev (nmetulev) changed the title Fix winapp run packaging a referenced library twice (APPX1101/PRI252) Fix winapp run/package building a referenced library twice (APPX1101/PRI252) Oct 14, 2026
@nmetulev Nikola Metulev (nmetulev) added agent-preparing Agent is addressing feedback or completing required validation and CI and removed ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge labels Oct 14, 2026
@nmetulev Nikola Metulev (nmetulev) added ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge and removed agent-preparing Agent is addressing feedback or completing required validation and CI labels Oct 14, 2026
@zateutsch
Zach Teutsch (zateutsch) enabled auto-merge (squash) October 15, 2026 03:29
@zateutsch
Zach Teutsch (zateutsch) merged commit 67c262b into main Oct 15, 2026
42 checks passed
@zateutsch
Zach Teutsch (zateutsch) deleted the nmetulev-fluentstore-winapp-run-debug branch October 15, 2026 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Agent work and technical checks complete; awaiting review or re-review, not approval or merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants