Bug: Incremental build with C++/WinRT 3.0 modules loses CppWinRTPlatformWinMDReferences, causing Windows.Foundation.Point could not be found
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Công nghệ
- cpp
- Lĩnh vực
- build-system, devtools
Hướng nghiên cứu
Kiểm tra Microsoft.Windows.CppWinRT.targets quanh CppWinRTMakeReferenceProjection và các đầu vào CppWinRTPlatformWinMDReferences. Tái hiện cả build sạch và build tăng dần cho một module provider sử dụng CppWinRTConsumeModule, sau đó so sánh nội dung cppwinrt_ref.rsp được tạo ra. Được xem là hoàn tất khi các build tăng dần bao gồm các tham chiếu WinMD của contract Windows SDK và không còn thất bại khi phân giải Windows.Foundation.Point.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Version
3.0.260520.1
Summary
I am migrating a WinAppSDK C++/WinRT project to the new C++/WinRT 3.0 module build.
The solution uses a dedicated module provider project:
<ProjectReference Include="..\..\CppWinRTModules\CppWinRTModules.vcxproj">
<Project>{...}</Project>
<CppWinRTConsumeModule>true</CppWinRTConsumeModule>
</ProjectReference>
A clean/rebuild works, but an incremental build fails during the C++/WinRT reference projection step.
The failure occurs when cppwinrt processes Microsoft.Graphics.winmd from the WinAppSDK experimental packages:
cppwinrt : error Type 'Windows.Foundation.Point' could not be found
method: RedPrimary
type: Microsoft.Graphics.Display.IDisplayAdvancedColorInfo
database: ...\packages\Microsoft.WindowsAppSDK.InteractiveExperiences.2.0.14-experimental\metadata\10.0.18362.0\Microsoft.Graphics.winmd
The project does not use RedPrimary directly. This appears to happen while processing the metadata database.
Environment
Visual Studio: 18 Professional
MSVC: 14.51.36231
C++/WinRT NuGet: Microsoft.Windows.CppWinRT 3.0.260520.1
Windows SDK: 10.0.26100.0
Configuration: x64 Release / x64 Debug
WindowsAppSDK packages include:
Microsoft.WindowsAppSDK.2.1.4-experimental8
Microsoft.WindowsAppSDK.Foundation.2.0.22-experimental
Microsoft.WindowsAppSDK.WinUI.2.1.1-experimental
Microsoft.WindowsAppSDK.InteractiveExperiences.2.0.14-experimental
Microsoft.WindowsAppSDK.AI.2.1.13-experimental
Microsoft.WindowsAppSDK.Search.2.1.13-experimental
Microsoft.WindowsAppSDK.Widgets.2.0.6-experimental
Reproducible example
Expected behavior
During the failing incremental build, the C++/WinRT diagnostic output shows that the direct WinMD references are present, but the platform WinMD references are empty:
CppWinRTPlatformWinMDReferences:
CppWinRTDirectWinMDReferences:
...\Microsoft.Graphics.winmd
...\Microsoft.UI.winmd
...\Microsoft.UI.Xaml.winmd
...
Then the generated command runs:
cppwinrt @"x64\Release\CppWinRTModules.vcxproj.cppwinrt_ref.rsp"
The tool output shows many in: entries for WinAppSDK package WinMDs, but no corresponding Windows SDK ref: entries. Therefore Microsoft.Graphics.winmd cannot resolve Windows.Foundation.Point.
After adding a workaround target, the same build succeeds. The log then shows CppWinRTPlatformWinMDReferences and CppWinRTPlatformWinMDInputs populated with the Windows SDK contract WinMDs such as Windows.Foundation.FoundationContract.winmd, Windows.Foundation.UniversalApiContract.winmd, Windows.Networking.Connectivity.WwanContract.winmd, etc.
Actual behavior
Clean/rebuild succeeds.
Incremental build fails because CppWinRTPlatformWinMDReferences is empty when CppWinRTMakeReferenceProjection runs, causing cppwinrt_ref.rsp to omit Windows SDK references.
Additional comments
Workaround
Adding this target to the project repairs the incremental build:
<Target Name="ForceCppWinRTPlatformWinMDReferences"
BeforeTargets="CppWinRTMakeReferenceProjection">
<ItemGroup Condition="'@(CppWinRTPlatformWinMDReferences)' == ''">
<CppWinRTPlatformWinMDReferences Include="$(WindowsSDK_MetadataPathVersioned)\**\*.winmd" />
</ItemGroup>
<Message Text="Forced CppWinRTPlatformWinMDReferences from $(WindowsSDK_MetadataPathVersioned)"
Importance="High"
Condition="'@(CppWinRTPlatformWinMDReferences)' != ''" />
</Target>
After this, the build succeeds because the Windows SDK WinMDs are passed into the C++/WinRT projection step.
Notes
I also tried:
<CppWinRTEnableReferenceProjection>false</CppWinRTEnableReferenceProjection>
but that is not viable because the module provider then no longer generates required modules such as:
import winrt.Microsoft.UI;
import winrt.Microsoft.UI.Dispatching;
import winrt.Microsoft.UI.Xaml;
import winrt.Microsoft.UI.Xaml.Controls;
import winrt.Microsoft.UI.Xaml.Media;
I also tried excluding Microsoft.Graphics.Display, but that caused the module provider to generate almost no WinRT namespace modules, so that is not a usable workaround either.
The issue seems to be specifically that the incremental CppWinRTMakeReferenceProjection path does not populate CppWinRTPlatformWinMDReferences, while clean/rebuild does.
Minimal question
Is this expected behavior for C++/WinRT 3.0 module provider projects using true?
If not, should Microsoft.Windows.CppWinRT.targets ensure that CppWinRTPlatformWinMDReferences is populated before CppWinRTMakeReferenceProjection during incremental builds?
- Ngôn ngữ chính
- C++
- Star
- 1.9k
- Fork
- 281
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/cppwinrt
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
base_macros.h disables warnings without push/pop, leaking them into consumer translation units Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 20/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 48/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
Tất cả issue của microsoft/cppwinrt
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
google/libultrahdr#485 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
godotengine/godot#123776 ·
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 60/100
-
good first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
ros2/common_interfaces#344 ·