microsoft / cppwinrt

C++/WinRT
MIT License
1.66k stars 239 forks source link

Bug: Suggestion for easier consumption from non msbuild projects #1322

Closed tdrakedoron closed 1 year ago

tdrakedoron commented 1 year ago

Version

2.0.230524.4

Summary

Background

The windows API includes a version of the winrt headers that causes build errors for C++ versions newer than C++17.

My software build involves C++20, CMake, and Ninja.

Problem

To generate a version of the winrt headers compatible with C++20, I needed to download a release of the nuget package, rename the extension to .zip, extract it, and run the included cppwinrt.exe binary from there.

This process was not an obvious one for me, and I only arrived at it after trying several other fixes. The functionality I wanted from the winrt headers is available through C-APIs, so I nearly gave up while trying to get my project to build.

Potential Solution

Publish a bare cppwinrt.exe executable alongside the nuget package for each release. (Or maybe provide a generated folder of winrt headers?)

Add a cautionary paragraph to somewhere on https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/intro-to-using-cpp-with-winrt indicating that the winrt version included in the windows API only supports C++17--and that getting started with a newer version of C++ will require either using the nuget package (and therefore msbuild) or manually generating headers with a newer version of cppwinrt.exe.

Reproducible example

No response

Expected behavior

No response

Actual behavior

No response

Additional comments

Thank you for your time :)

kennykerr commented 1 year ago

Yes, I'd love to see the binary available as part of https://github.com/microsoft/cppwinrt/releases but that release is created by an internal build that I'm reluctant to mess with, but perhaps @DefaultRyan can squeeze that in next time he's working on the build.

github-actions[bot] commented 1 year ago

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.

sylveon commented 1 year ago

Is the internal build script available? If so, I could maybe look into this, assuming it's just adding an extra artifact.

kennykerr commented 1 year ago

Nope.

sylveon commented 1 year ago

Fair enough. Maybe reopening and preventing the stale bot until @DefaultRyan has time to take a look wouldn't be a bad idea.

kennykerr commented 1 year ago

Actually, the build script was recently made public: https://github.com/microsoft/cppwinrt/blob/master/.pipelines/build.yml

But the subsequent release pipeline that produces the GitHub release is not public.

DefaultRyan commented 1 year ago

Correct, but I can tell you that the "Publish" artifact is the folder that is used to populate the GitHub release artifacts.

It's created here: https://github.com/microsoft/cppwinrt/blob/297454ee285476f16bf11425bd60daf4593b66ee/.pipelines/build.yml#L633

And looks like it's simply the contents of whatever gets put into $(Build.ArtifactStagingDirectory). So if you dropped a nupkg renamed to zip there, I expect it would get picked up in the GitHub release.

(Aside: that display name of "Publish VSIX" is no longer accurate).

kennykerr commented 1 year ago

The release already contains the nuget package - I think it would only be beneficial if you could pop the cppwinrt.exe itself into that directory.

sylveon commented 1 year ago

Looks like they already are staged (at least, the x86 binary): https://github.com/microsoft/cppwinrt/blob/297454ee285476f16bf11425bd60daf4593b66ee/.pipelines/build.yml#L396-L408

Whatever makes the GitHub release doesn't appear to be in this repo