Repository navigation
Support C++ (.vcxproj) projects in winapp run - #984
Conversation
winapp run now accepts a .vcxproj, a folder whose only runnable app is a .vcxproj, or a solution whose only runnable app is a .vcxproj. It locates Visual Studio's MSBuild with vswhere (requiring the MSVC tools for the target architecture), restores packages.config, builds, evaluates OutDir/TargetPath/ AppX properties, and reuses the existing packaged/unpackaged launch paths. Missing VS/Build Tools, platform toolset (MSB8020) and Windows SDK (MSB8036) produce actionable errors. The Windows App SDK version for runtime provisioning is read from packages.config. Adds the cpp-winui-app sample (VS WinUI Blank App (Packaged) C++/WinRT template with XAML UI), its Pester test and CI matrix entry. Part of #680. Co-authored-by: Copilot App <[email protected]>
…xproj, require MSBuild 17.8 Co-authored-by: Copilot App <[email protected]>
…ring C++ Debug packaged apps depend on Microsoft.VCLibs.140.00.Debug.UWPDesktop. Visual Studio installs it on deploy; winapp now installs any recipe-resolved framework package that is missing or older, so registration doesn't fail with 0x80073CF3. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Build Metrics ReportValidation passed. All required build and validation jobs succeeded. Binary Sizes
.NET Test Results (TRX reports)Other suites are reflected in the overall validation status above. ✅ 8163 passed, 37 skipped out of 8200 tests in 1396.7s (+52 tests, +304.7s vs. baseline) Test Coverage✅ 86.5% line coverage, 81.1% branch coverage · ✅ no change vs. baseline CLI Startup Time49ms median (x64, Try This BuildInstalls 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))) 984Switching between builds often?Put the tool on your PATH once: & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPathThen this build is just: winapp-pr 984Run Updated 2026-10-08 02:20:44 UTC · commit |
Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Architecture overrides and manifest-based framework discovery can currently provision the wrong dependencies or fail registration.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Extends winapp run to build and launch C++ .vcxproj applications using Visual Studio MSBuild.
Changes:
- Adds C++ project discovery, MSBuild execution, package resolution, and prerequisite guidance.
- Installs framework packages referenced by generated app recipes.
- Adds comprehensive tests, documentation, CI coverage, and a C++/WinUI sample.
| File | Description |
|---|---|
src/winapp-npm/src/winapp-commands.ts |
Regenerates TypeScript wrappers. |
src/winapp-CLI/WinApp.Cli/Services/ProjectRunService.Input.cs |
Resolves C++ projects and solutions. |
src/winapp-CLI/WinApp.Cli/Services/ProjectRunService.cs |
Routes C++ builds to MSBuild. |
src/winapp-CLI/WinApp.Cli/Services/ProjectRunService.Cpp.cs |
Implements C++ build and output resolution. |
src/winapp-CLI/WinApp.Cli/Services/MsixService.Identity.cs |
Installs recipe framework dependencies. |
src/winapp-CLI/WinApp.Cli/Services/MSBuildService.cs |
Locates and invokes Visual Studio MSBuild. |
src/winapp-CLI/WinApp.Cli/Services/IProjectRunService.cs |
Documents .vcxproj inputs. |
src/winapp-CLI/WinApp.Cli/Services/IMSBuildService.cs |
Defines the MSBuild service contract. |
src/winapp-CLI/WinApp.Cli/Services/IDotNetService.cs |
Documents native package discovery. |
src/winapp-CLI/WinApp.Cli/Services/DotNetService.cs |
Reads C++ packages.config. |
src/winapp-CLI/WinApp.Cli/Models/ProjectRunModels.cs |
Carries evaluated configuration and platform. |
src/winapp-CLI/WinApp.Cli/Helpers/PackagesConfigReader.cs |
Parses native NuGet package pins. |
src/winapp-CLI/WinApp.Cli/Helpers/HostBuilderExtensions.cs |
Registers the MSBuild service. |
src/winapp-CLI/WinApp.Cli/Commands/RunCommand.ProjectMode.cs |
Handles C++-specific run semantics. |
src/winapp-CLI/WinApp.Cli/Commands/RunCommand.cs |
Advertises .vcxproj support. |
src/winapp-CLI/WinApp.Cli.Tests/RunCommandTests.cs |
Updates folder-mode diagnostics tests. |
src/winapp-CLI/WinApp.Cli.Tests/ProjectRunServiceTests.cs |
Injects the MSBuild test fake. |
src/winapp-CLI/WinApp.Cli.Tests/ProjectRunServiceSingleFileTests.cs |
Updates service construction. |
src/winapp-CLI/WinApp.Cli.Tests/ProjectRunServicePublishProfileTests.cs |
Updates service construction. |
src/winapp-CLI/WinApp.Cli.Tests/ProjectRunServiceCppTests.cs |
Tests C++ resolution, builds, and packages. |
src/winapp-CLI/WinApp.Cli.Tests/ProjectRunServiceAotTests.cs |
Updates service construction. |
src/winapp-CLI/WinApp.Cli.Tests/FakeMSBuildService.cs |
Adds an MSBuild test double. |
scripts/tests/artifact-workflow.Tests.ps1 |
Updates expected sample coverage. |
samples/cpp-winui-app/test.Tests.ps1 |
Exercises the sample workflow. |
samples/cpp-winui-app/README.md |
Documents sample usage. |
samples/cpp-winui-app/pch.h |
Adds precompiled C++ headers. |
samples/cpp-winui-app/pch.cpp |
Compiles the precompiled header. |
samples/cpp-winui-app/packages.config |
Pins native dependencies. |
samples/cpp-winui-app/Package.appxmanifest |
Defines sample package identity. |
samples/cpp-winui-app/MainWindow.xaml.h |
Declares the sample window. |
samples/cpp-winui-app/MainWindow.xaml.cpp |
Implements identity display. |
samples/cpp-winui-app/MainWindow.xaml |
Defines the sample UI. |
samples/cpp-winui-app/MainWindow.idl |
Defines the WinRT window type. |
samples/cpp-winui-app/CppWinUIApp.vcxproj.filters |
Organizes Visual Studio files. |
samples/cpp-winui-app/CppWinUIApp.vcxproj |
Defines the C++/WinUI build. |
samples/cpp-winui-app/CppWinUIApp.slnx |
Adds the sample solution. |
samples/cpp-winui-app/App.xaml.h |
Declares the application type. |
samples/cpp-winui-app/App.xaml.cpp |
Implements application startup. |
samples/cpp-winui-app/App.xaml |
Defines application resources. |
samples/cpp-winui-app/app.manifest |
Configures desktop compatibility. |
samples/cpp-winui-app/.gitignore |
Excludes generated outputs. |
samples/cpp-winui-app/Assets/LockScreenLogo.scale-200.png |
Adds sample artwork. |
samples/cpp-winui-app/Assets/SplashScreen.scale-200.png |
Adds sample artwork. |
samples/cpp-winui-app/Assets/Square150x150Logo.scale-200.png |
Adds sample artwork. |
samples/cpp-winui-app/Assets/Square44x44Logo.scale-200.png |
Adds sample artwork. |
samples/cpp-winui-app/Assets/Square44x44Logo.targetsize-24_altform-unplated.png |
Adds sample artwork. |
samples/cpp-winui-app/Assets/StoreLogo.png |
Adds sample artwork. |
samples/cpp-winui-app/Assets/Wide310x150Logo.scale-200.png |
Adds sample artwork. |
README.md |
Lists the new sample. |
plugins/winapp/skills/winapp-troubleshoot/SKILL.md |
Updates troubleshooting guidance. |
plugins/winapp/skills/winapp-setup/SKILL.md |
Documents C++ project mode. |
docs/usage.md |
Documents .vcxproj workflows. |
docs/npm-usage.md |
Regenerates npm API documentation. |
docs/guides/cpp.md |
Links Visual Studio C++ guidance. |
docs/cli-schema.json |
Regenerates the CLI schema. |
.github/workflows/test-samples.yml |
Adds the sample to CI. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
dotnet can't build a .vcxproj (MSB4278). Detect one in the ProjectReference closure before restoring and say to build with Visual Studio/MSBuild, then re-run with --no-build (verified to work). Co-authored-by: Copilot App <[email protected]>
dotnet publish --no-build still loads project references, so package advice is to package the MSBuild output folder. Conditional references (e.g. VS-only) are skipped so builds dotnet completes today aren't blocked. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…ng -p Platform Co-authored-by: Copilot App <[email protected]>
Zach Teutsch (zateutsch)
left a comment
There was a problem hiding this comment.
🤖 AI-generated review (winappcli pr-review skill) — verify before acting.
C++ support works end to end: the cpp-winui-app sample built, installed VCLibs Debug, registered, and launched on ARM64 with Build Tools 2026, and the ProjectRunService*/RunCommand* tests pass (631/631). One resolution gap contradicts the new docs.
Must fix
winapp run . ignores the C++ app when the folder also has a C# library
- What is wrong: If the folder has any
.csproj, only C# projects are considered. When none of them is runnable, winapp falls back to folder mode and never tries the.vcxproj. - Show me: a folder with
CppWinUIApp.vcxprojand a libraryShared.csproj(OutputType=Library):winapp run . --no-build --no-launch→❌ The manifest contains a placeholder for the executable but no .exe files were found in the input folder…- Expected: run the C++ app, as
winapp run CppWinUIApp.vcxproj --no-build --no-launchdoes.
- Why it matters:
docs/usage.mdsays the folder only needs one runnable app, and a C# helper library next to a C++ app is a common layout. Users hit the same misleading error this PR set out to remove. - Smallest fix: when no runnable C# app is found, fall through to the
.vcxprojcandidates. Or narrow the docs to "a folder with a.vcxprojand no.csproj". - Location:
src/winapp-CLI/WinApp.Cli/Services/ProjectRunService.Input.cs(directory resolution, ~L91-178)
Non-blocking
Shipped Copilot agent doesn't know run accepts .vcxproj
- What is wrong:
plugins/winapp/com.github.copilot/agents/winapp.agent.md(L49, L227, L248) describesrunproject mode as.csproj/.slnbuilt withdotnet build, needing the .NET SDK. - Why it matters: agent users asking how to run a
.vcxprojwon't be pointed at the new feature. The troubleshoot skill already covers it. - Smallest fix: add
.vcxprojand the Visual Studio/Build Tools C++ prerequisite to the decision tree and the project-mode Purpose and Requires lines.
- Build quietly (warnings/errors only) with a spinner in terminals; --verbose shows MSBuild's full output and exact command - Echo a short MSBuild command instead of the full plumbing - -p Platform selects the architecture when --arch/--runtime aren't given - winapp's MSB8020/MSB8036 explanation replaces the raw line in terminals - A folder with only a C++ library explains there is nothing to run - A folder with a C++ app plus C# libraries/tests runs the C++ app - Copilot agent knows run accepts .vcxproj Co-authored-by: Copilot App <[email protected]>
|
Zach Teutsch (@zateutsch) thanks — both findings addressed in bb45b49.
Tests: Copilot agent doesn't know |
…er .vcxproj selectors - Fall back to a C++ app only when no C# app is runnable (two C# apps stay ambiguous) - Report a library-only C++ folder in the run command, only when no manifest is available from --manifest, the folder, or the current directory - --project Foo.vcxproj prefers the .vcxproj over a same-named .csproj - --project mismatch lists C++ apps too Co-authored-by: Copilot App <[email protected]>

Description
winapp runonly built.csprojprojects. Pointing it at a Visual Studio C++ project failed, because the .NET SDK has no C++ project system.Now
winapp runaccepts:.vcxproj,.vcxproj(C# libraries or test projects beside it don't get in the way),.sln/.slnxwhose only runnable app is a.vcxproj. If the solution also has a runnable C# app, the C# app is still picked (C# test projects don't outrank a C++ app);--project <name>selects the C++ one.winapp finds Visual Studio's
MSBuild.exewithvswhere(VS/Build Tools 2022 17.8+, the first with-getProperty, with the MSVC tools for the target architecture; for a WinUI/UWP project, the newest install whose MSBuild has the "Windows Store" C++ application type), restorespackages.config, builds, readsOutDir/TargetPath/AppX properties, and then uses the existing packaged (loose-layout register + AUMID) or unpackaged (launchTargetPath) path.-c,--arch(→x64/ARM64/Win32;-p Platform=ARM64also selects the architecture when--archisn't given),-p,--no-build,--no-restore,--detachand--jsonwork as for.csproj. The Windows App Runtime version comes frompackages.config. C++ inputs don't need the .NET SDK.--aotand--frameworkare rejected as .NET-only.Build output is quiet: MSBuild runs at quiet verbosity (warnings and errors only), with a spinner and elapsed time in a real terminal, and a short command echo.
--verboseshows MSBuild's full output and the exact command. (C++/WinRT logs ~500 lines on a first build atminimal.)Before registering a packaged layout, winapp now also installs framework packages the build's
.appxreciperesolved and the manifest depends on, when missing or older — as Visual Studio's deploy does. C++ Debug apps depend onMicrosoft.VCLibs.140.00.Debug.UWPDesktop; without it, registration on a clean machine (CI) failed with0x80073CF3. Self-contained apps are unaffected (their manifest has no runtime dependency). Package locations on network shares or mapped network drives are ignored without being probed, so a crafted recipe can't make winapp authenticate to a remote host.A C# app that references a C++ project (e.g. a native DLL, transitively and including
ReferenceOutputAssembly="false"references) still can't be built bydotnet(MSB4278). winapp now detects it before restoring and says what works instead of surfacing the raw error. Conditional references (e.g. a Visual Studio-only native reference) are ignored, since dotnet skips them.winapp packagesuggests packaging the MSBuild output folder instead of--no-build, becausedotnet publish --no-buildstill loads the C++ reference.Before this PR the same command printed only
error MSB4278: The imported file "$(VCTargetsPath)\Microsoft.Cpp.Default.props" does not exist ....Missing prerequisites produce actionable errors: no VS/Build Tools or no C++ tools (with a
wingetcommand for Build Tools), and build failures caused by a missing platform toolset (MSB8020) or Windows SDK (MSB8036).ProjectRunResolutionnow carries the evaluatedConfigurationandPlatformalongside the existingTargetDir/AppxRecipePath/AppxManifestPath, so later work (e.g. DevTools XAML source mapping) can locate C++ build artifacts the same way it does for.csproj.New sample
samples/cpp-winui-app: the Visual Studio WinUI Blank App (Packaged) C++/WinRT template (XAML UI,packages.config, WinAppSDK 2.3.1) with a button that shows the package identity, plus a Pester test and CI matrix entry.Usage Example
Observed on this machine (VS 2026 Enterprise, x64). Before:
After (sample folder):
The launched app's XAML UI works with identity (via
winapp ui, no real input):Missing prerequisites (VS hidden by pointing
%ProgramFiles(x86)%elsewhere; toolset/SDK via-p):Unpackaged C++ console app (hand-written minimal
.vcxproj):Related Issue
Part of #680. Covers
.vcxprojas the entry project. For a C# app that references a C++ project, winapp now detects it and says what to do; actually building that mix with MSBuild is a follow-up, as is the NativeAOT-publish preflight from the issue comment.Type of Change
Checklist
ProjectRunServiceCppTests: input resolution, MSBuild arguments, packaging, prerequisite errors, vswhere discovery, packages.config, recipe frameworks, C# → C++ reference detection)cpp.mdpointer)cpp-winui-app+ Pester test + CI matrix)plugins/winapp/skills/(winapp-setup,winapp-troubleshoot)Screenshots / Demo
CLI change; textual output above.
Additional Notes
Validation (local):
scripts\build-cli.ps1(warnings-as-errors test build):WinApp.Cli.Tests7129 total, 0 failed.WinApp.UIAutomation.Testshad 1 failure,RecordAsync_FirstScreenFrame_AcceptsAModalDialogTheTargetOwns, which also fails when run alone on this shared desktop; this PR doesn't touch UIAutomation.validate-plugin-package.ps1passes. After merging Stop tracking generated command wrappers and schema snapshots #997 (generated schema and npm wrappers are no longer tracked), this PR changes no generated files. After review fixes:ProjectRunService*/RunCommand*/PackageCommand*/MsixService*tests 1144 total, 0 failed (WAE build).samples\cpp-winui-app\test.Tests.ps1with the locally built npm package (isolated npm prefix): 4/4 passed — build + register + detached launch with a visible window,--no-build --no-launch, missing-VS error, and a plain MSBuild build of the sample.scripts\tests\artifact-workflow.Tests.ps1: 25/25.samples / cpp-winui-apponwindows-latest(VS 2022) failed registration with0x80073CF3(missingMicrosoft.VCLibs.140.00.Debug.UWPDesktop) before the framework step and passes 4/4 with it (the test runs--json, which hides the install status line). Locally, the install path was exercised by raising the recipe's VCLibs version:📦 Installing framework package Microsoft.VCLibs.140.00.Debug.UWPDesktop 14.0.99999.0...followed by successful registration.--json; afterMSBuild.exethe--no-buildrun printedNative Add(2,3) = 5.Limitations / observations:
wingetBuild Tools command was not executed (multi-GB install on a shared machine); its component IDs come from the Build Tools workload/component reference.Microsoft.Windows.SDK.BuildTools.MSIXtask fails withMSB4061("Type must be a type provided by the runtime") when the project sits under a long path (reproduced at ~157-char project dir; works from%TEMP%\cwa). That's an MSBuild/MSIX tooling issue independent of winapp — the samemsbuildcommand fails the same way — so live runs used a short path.-p Platformand library-folder changes came from reviewing those screenshots.