Skip to content

Fix CsWinRTAuthoringWinUI.sln build ordering for C++ consumers#644

Open
qiutongMS wants to merge 1 commit into
release/experimentalfrom
chore/customcontrols-sln-project-deps
Open

Fix CsWinRTAuthoringWinUI.sln build ordering for C++ consumers#644
qiutongMS wants to merge 1 commit into
release/experimentalfrom
chore/customcontrols-sln-project-deps

Conversation

@qiutongMS

Copy link
Copy Markdown

Description

Adds an explicit sln-level GlobalSection(ProjectDependencies) = postSolution so that CppApp, CppAppUnpackaged, and CsApp are built after WinUIComponentCs.

The C# projects CsApp and WinUIComponentCs already share a project reference, so MSBuild orders them correctly. However the two C++ projects consume WinUIComponentCs via the projected C++/WinRT header winrt/WinUIComponentCs.h and the runtime .dll — they cannot use a managed <ProjectReference>. Without the sln-level declaration, MSBuild has no ordering signal and can race the C++ compile against the still-missing header/winmd from WinUIComponentCs, producing intermittent C1083: Cannot open include file 'winrt/WinUIComponentCs.h' failures.

Reproduced locally: reverting just the sln block resurrects the C1083 error on a clean build; with the block, the C# half (CsApp) builds and runs cleanly and dependency ordering is correct end-to-end.

This is a build-correctness fix only — no source code, no API surface, no scenario behavior changes.

Target Release

N/A — sln/build fix.

Checklist

  • Samples build and run using the Visual Studio versions listed in the Windows development docs.
  • Sample builds clean (CsApp verified via winapp run end-to-end).
  • Samples build and run on all supported platforms (x64, x86, ARM64) and configurations (Debug, Release). Verified x64/Debug; the change is configuration-agnostic.
  • Samples set the minimum supported OS version to Windows 10 version 1809. (Unchanged.)
  • Sample builds clean with no warnings or errors. (CsApp; CppApp/CppAppUnpackaged have a preexisting CppWinRT/CsWinRT version mismatch tracked separately.)

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

…g sample

The three consumer apps in CsWinRTAuthoringWinUI.sln (CppApp,
CppAppUnpackaged, CsApp) all load the WinUIComponentCs.dll at
runtime, but only CsApp can express that through a managed
<ProjectReference>; the two C++ projects cannot ProjectReference a
C# project. Without an explicit dependency, MSBuild may build the
consumers in parallel with the component and copy stale or missing
binaries, producing intermittent build failures.

Add a sln-level GlobalSection(ProjectDependencies) so all three
consumers wait for WinUIComponentCs to finish before they build.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

This PR fixes intermittent build-order races in the CsWinRTAuthoringWinUI sample solution by adding explicit solution-level project dependencies so the C++ consumer projects build after WinUIComponentCs, ensuring the projected winrt/WinUIComponentCs.h (and related build outputs) exist before C++ compilation.

Changes:

  • Adds a GlobalSection(ProjectDependencies) = postSolution block to enforce build ordering.
  • Declares CppApp, CppAppUnpackaged, and CsApp as depending on WinUIComponentCs at the solution level.

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.

2 participants