Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Bug in the C++/WinRT Windows Runtime Component VS Template causes cppwinrt file generate to fail. #1437

Closed
laultman opened this issue Sep 30, 2024 · 9 comments

Comments

@laultman
Copy link

Version

v2.0.230511.6

Summary

The template for the C++/WinRT Windows Runtime Component at line 129 is missing a "" backslash character. This causes the directory name to merge with the file name. This affects the GeneratedFiles directory structure making the tool chain fail.
Incorrect : <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
Corrected: <ClCompile Include="$(GeneratedFilesDir)\module.g.cpp" />
"-----------------------------------------------------------| "

Reproducible example

Open a new C++/WinRT Windows Runtime Component project. After it opens in Visual Studio, use some other tool to inspect the vcxproj file. Go to line 129 and observe the missing "\" backslash as shown in the discussion above.

Expected behavior

I expected the template to have been tested and to have worked. I expected the Thermometer code walkthrough at this link to work as described in the article.

Actual behavior

Fails to build projects. Source files are not generated. Module.g.cpp is not generated.

Additional comments

No response

@laultman laultman changed the title Bug: Bug in the C++/WinRT Windows Runtim Component VS Template causes cppwinrt file generate to fail. Bug: Bug in the C++/WinRT Windows Runtime Component VS Template causes cppwinrt file generate to fail. Sep 30, 2024
@kennykerr
Copy link
Collaborator

We don't have anyone working the VS templates at the moment. Feel free to contribute a fix and I'll see if I can get someone familiar with that code to review it.

@dmachaj
Copy link
Contributor

dmachaj commented Sep 30, 2024

That property already includes a trailing slash so it is not necessary to add another one. I just created an empty cppwinrt project using the Visual Studio templates and added a target to dump this property.

<Target AfterTargets="PrepareForBuild" Name="TemporaryDebugTarget">
    <Message Importance="high" Text="GeneratedFilesDir is $(GeneratedFilesDir)"/>
</Target>

And the output when building is:

1>GeneratedFilesDir is CppwinrtTestApp\x64\Debug\Generated Files\

@laultman
Copy link
Author

laultman commented Oct 2, 2024

@dmachaj That's well and good for the field name. But that does not mean the syntax is correct in the template. You are correct it does have resolve to the correct name but the syntax in the line requires the backslash before a file name.

@dmachaj
Copy link
Contributor

dmachaj commented Oct 2, 2024

There must be a subtlety that I am missing here. If the variable expands to the correct thing when msbuild runs a build, then that should be all that matters.

The statement "the syntax in the line requires the backslash before a file name" does not align with that. What tool says the syntax requires a slash here? It doesn't seem to be msbuild.

If there is some sort of error message please include it.

@laultman
Copy link
Author

laultman commented Oct 3, 2024

Apparently, we are talking about different things.
When the project is created with using the template. Simply look through the vcproj XML and find this line.
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />

Then go follow the ThermometerWRC instructions. In the end you must fix the path or module.g.cpp is never built.

@sylveon
Copy link
Contributor

sylveon commented Oct 3, 2024

I just created a brand new C++/WinRT runtime component project, and I see module.g.cpp getting built just fine:

Build started at 16:01...
1>------ Build started: Project: RuntimeComponent1, Configuration: Debug x64 ------
1>64 bit MIDLRT Processing Z:\Throwaway\RuntimeComponent1\Class.idl
1>Class.idl
1>64 bit MIDLRT Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\winrtbase.idl
1>winrtbase.idl
1>64 bit MIDLRT Processing C:\Program Files (x86)\Windows Kits\10\Include\10.0.22621.0\winrt\midlbase.idl
1>midlbase.idl
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.ai.machinelearning.machinelearningcontract\5.0.0.0\windows.ai.machinelearning.machinelearningcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.ai.machinelearning.preview.machinelearningpreviewcontract\2.0.0.0\windows.ai.machinelearning.preview.machinelearningpreviewcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.applicationmodel.calls.background.callsbackgroundcontract\4.0.0.0\windows.applicationmodel.calls.background.callsbackgroundcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.applicationmodel.calls.callsphonecontract\7.0.0.0\windows.applicationmodel.calls.callsphonecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.applicationmodel.calls.callsvoipcontract\4.0.0.0\windows.applicationmodel.calls.callsvoipcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.applicationmodel.communicationblocking.communicationblockingcontract\2.0.0.0\windows.applicationmodel.communicationblocking.communicationblockingcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.applicationmodel.socialinfo.socialinfocontract\2.0.0.0\windows.applicationmodel.socialinfo.socialinfocontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.applicationmodel.startuptaskcontract\3.0.0.0\windows.applicationmodel.startuptaskcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.devices.custom.customdevicecontract\1.0.0.0\windows.devices.custom.customdevicecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.devices.deviceslowlevelcontract\3.0.0.0\windows.devices.deviceslowlevelcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.devices.printers.printerscontract\1.0.0.0\windows.devices.printers.printerscontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.devices.smartcards.smartcardbackgroundtriggercontract\3.0.0.0\windows.devices.smartcards.smartcardbackgroundtriggercontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.devices.smartcards.smartcardemulatorcontract\6.0.0.0\windows.devices.smartcards.smartcardemulatorcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.foundation.foundationcontract\4.0.0.0\windows.foundation.foundationcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.foundation.universalapicontract\15.0.0.0\windows.foundation.universalapicontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.gaming.xboxlive.storageapicontract\1.0.0.0\windows.gaming.xboxlive.storageapicontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.graphics.printing3d.printing3dcontract\4.0.0.0\windows.graphics.printing3d.printing3dcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.networking.connectivity.wwancontract\2.0.0.0\windows.networking.connectivity.wwancontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.networking.sockets.controlchanneltriggercontract\3.0.0.0\windows.networking.sockets.controlchanneltriggercontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.security.isolation.isolatedwindowsenvironmentcontract\4.0.0.0\windows.security.isolation.isolatedwindowsenvironmentcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.services.maps.guidancecontract\3.0.0.0\windows.services.maps.guidancecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.services.maps.localsearchcontract\4.0.0.0\windows.services.maps.localsearchcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.services.store.storecontract\4.0.0.0\windows.services.store.storecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.services.targetedcontent.targetedcontentcontract\1.0.0.0\windows.services.targetedcontent.targetedcontentcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.storage.provider.cloudfilescontract\7.0.0.0\windows.storage.provider.cloudfilescontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.system.profile.profilehardwaretokencontract\1.0.0.0\windows.system.profile.profilehardwaretokencontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.system.profile.profileretailinfocontract\1.0.0.0\windows.system.profile.profileretailinfocontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.system.profile.profilesharedmodecontract\2.0.0.0\windows.system.profile.profilesharedmodecontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.system.profile.systemmanufacturers.systemmanufacturerscontract\3.0.0.0\windows.system.profile.systemmanufacturers.systemmanufacturerscontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.system.systemmanagementcontract\7.0.0.0\windows.system.systemmanagementcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.ui.uiautomation.uiautomationcontract\2.0.0.0\windows.ui.uiautomation.uiautomationcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.ui.viewmanagement.viewmanagementviewscalingcontract\1.0.0.0\windows.ui.viewmanagement.viewmanagementviewscalingcontract.winmd
1>Processing WinMD c:\program files (x86)\windows kits\10\references\10.0.22621.0\windows.ui.xaml.core.direct.xamldirectcontract\5.0.0.0\windows.ui.xaml.core.direct.xamldirectcontract.winmd
1>Microsoft(R) Metadata Merge Utility Version 10.0.49.
1>
1>
1>Processing input metadata file RuntimeC.6cb17413\x64\Debug\Unmerged\Class.winmd.
1>Saved output metadata file RuntimeComponent1.winmd.
1>Validating metadata file RuntimeC.6cb17413\x64\Debug\Merged\RuntimeComponent1.winmd.
1>pch.cpp
1>Class.cpp
1>module.g.cpp
1>   Creating library Z:\Throwaway\RuntimeComponent1\x64\Debug\RuntimeComponent1\RuntimeComponent1.lib and object Z:\Throwaway\RuntimeComponent1\x64\Debug\RuntimeComponent1\RuntimeComponent1.exp
1>RuntimeComponent1.vcxproj -> Z:\Throwaway\RuntimeComponent1\x64\Debug\RuntimeComponent1\RuntimeComponent1.dll
1>'pwsh.exe' is not recognized as an internal or external command,
1>operable program or batch file.
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========
========== Build completed at 16:02 and took 07.093 seconds ==========

@laultman
Copy link
Author

laultman commented Oct 4, 2024

OK, here we go again. Just reinstalled Windows, and reinstalling VS for the 3d time this month. Maybe I'll get lucky and it will work.

Copy link

This issue is stale because it has been open 10 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@laultman
Copy link
Author

I disregarded the comments as my solution was to add the backslash and it works. Don't care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants