Repository: electron/electron
Pull request: fix: fix Windows MSIX release build errors

#### Description of Change

Follow up to https://github.com/electron/electron/pull/49230

This PR fixes an error on release builds that seems to be caused by the new MSIX logic.

#### Checklist
<!-- Remove items that do not apply. For completed items, change [ ] to [x]. -->

- [ ] PR description included
- [ ] `npm test` passes
- [ ] tests are [changed or added](https://github.com/electron/electron/blob/main/docs/development/testing.md)
- [ ] relevant API documentation, tutorials, and examples are updated and follow the [documentation style guide](https://github.com/electron/electron/blob/main/docs/development/style-guide.md)
- [ ] [PR release notes](https://github.com/electron/clerk/blob/main/README.md) describe the change in a way relevant to app developers, and are [capitalized, punctuated, and past tense](https://github.com/electron/clerk/blob/main/README.md#examples).

#### Release Notes

Notes: Fixed an error with Windows release builds after MSIX merger.


Changed files:
filename: BUILD.gn
patch: @@ -420,6 +420,37 @@ action("electron_generate_node_defines") {
   args = [ rebase_path(target_gen_dir) ] + rebase_path(inputs)
 }
 
+# MSIX updater needs to be in a separate source_set because it uses C++/WinRT
+# headers that require exceptions to be enabled.
+source_set("electron_msix_updater") {
+  sources = [
+    "shell/browser/api/electron_api_msix_updater.cc",
+    "shell/browser/api/electron_api_msix_updater.h",
+  ]
+
+  configs += [ "//third_party/electron_node:node_external_config" ]
+
+  public_configs = [ ":electron_lib_config" ]
+
+  if (is_win) {
+    cflags_cc = [
+      "/EHsc",  # Enable C++ exceptions for C++/WinRT
+      "-Wno-c++98-compat-extra-semi",  #Suppress C++98 compatibility warnings
+    ]
+
+    include_dirs = [ "//third_party/nearby/src/internal/platform/implementation/windows/generated" ]
+  }
+
+  deps = [
+    "//base",
+    "//content/public/browser",
+    "//gin",
+    "//third_party/electron_node/deps/simdjson",
+    "//third_party/electron_node/deps/uv",
+    "//v8",
+  ]
+}
+
 source_set("electron_lib") {
   configs += [
     "//v8:external_startup_data",
@@ -435,6 +466,7 @@ source_set("electron_lib") {
     ":electron_fuses",
     ":electron_generate_node_defines",
     ":electron_js2c",
+    ":electron_msix_updater",
     ":electron_version_header",
     ":resources",
     "buildflags",

filename: filenames.gni
patch: @@ -279,8 +279,6 @@ filenames = {
     "shell/browser/api/electron_api_in_app_purchase.h",
     "shell/browser/api/electron_api_menu.cc",
     "shell/browser/api/electron_api_menu.h",
-    "shell/browser/api/electron_api_msix_updater.cc",
-    "shell/browser/api/electron_api_msix_updater.h",
     "shell/browser/api/electron_api_native_theme.cc",
     "shell/browser/api/electron_api_native_theme.h",
     "shell/browser/api/electron_api_net_log.cc",

filename: shell/browser/api/electron_api_msix_updater.cc
patch: @@ -33,13 +33,14 @@
 #include <windows.foundation.metadata.h>
 #include <windows.h>
 #include <windows.management.deployment.h>
-#include <winrt/base.h>
-#include <winrt/windows.applicationmodel.core.h>
-#include <winrt/windows.applicationmodel.h>
-#include <winrt/windows.foundation.collections.h>
-#include <winrt/windows.foundation.h>
-#include <winrt/windows.foundation.metadata.h>
-#include <winrt/windows.management.deployment.h>
+// Use pre-generated C++/WinRT headers from //third_party/nearby instead of the
+// SDK's cppwinrt headers, which are missing implementation files.
+#include "third_party/nearby/src/internal/platform/implementation/windows/generated/winrt/Windows.ApplicationModel.h"
+#include "third_party/nearby/src/internal/platform/implementation/windows/generated/winrt/Windows.Foundation.Collections.h"
+#include "third_party/nearby/src/internal/platform/implementation/windows/generated/winrt/Windows.Foundation.Metadata.h"
+#include "third_party/nearby/src/internal/platform/implementation/windows/generated/winrt/Windows.Foundation.h"
+#include "third_party/nearby/src/internal/platform/implementation/windows/generated/winrt/Windows.Management.Deployment.h"
+#include "third_party/nearby/src/internal/platform/implementation/windows/generated/winrt/base.h"
 
 #include "base/win/scoped_com_initializer.h"
 #endif