0

My understanding is that the WinRT APIs are available from JavaScript code running in a special sort of bundled PWA.

Microsoft's Create a "Hello World" app (JS) tutorial shows a script simply accessing APIs via a global Windows object. Likewise this guide explains how I might take an existing web app and run it. Unfortunately those both use the "shortcut" of an app template created and launched via Visual Studio; I cannot install anything but the "core" of Visual Studio because the system disk on my Windows laptop is too small. (The likeliest "workflow" option requires a huge ASP.NET component.)

If I load the following very simple "PWA" index.html implementation in MS Edge, of course it does not work since the WinRT APIs are not exposed to untrusted code running in the browser:

<!doctype html>
<html><head>
  <meta charset="utf-8">
  <title>Testing WinRT</title>
</head><body>
<script>
  var messageDialog = new Windows.UI.Popups.MessageDialog("Hello, world!", "Alert");
  messageDialog.showAsync();
</script>
</body>

Without Visual Studio, is there any way to run the above HTML file as a working UWP app? Do I need to somehow package and/or sign this "code", or is there a tool I can use to preview some local HTML/JS/CSS files ± as-is? At this point I am just looking for an easy way to test out the WinRT APIs — any technique does not have to be "production grade".

natevw
  • 16,807
  • 8
  • 66
  • 90
  • I think it's going to be a very complicated thing without using visual studio. If you want to call winRT APIs in js code, you would have to make it run in app container. Using Visual Studio to create a UWP project to wrap it is the simplest way. – Xie Steven Mar 01 '19 at 08:54
  • @XavierXie-MSFT What steps does Visual Studio take to make an app container? Are the tools it uses available for separate install? Or can I just make some sort of manifest file and then zip things up or something? Using Visual Studio is not "the simplest way" if it requires a new laptop… – natevw Mar 01 '19 at 17:41
  • `What steps does Visual Studio take to make an app container?` The document [Create a "Hello World" app (JS)](https://learn.microsoft.com/en-us/windows/uwp/get-started/create-a-hello-world-app-js-uwp) shows steps that using visual studio create a javascript UWP project. – Xie Steven Mar 04 '19 at 03:28
  • @XavierXie-MSFT You do not understand. For example on Mac I could say, "to make an app, what Xcode does for you is output a folder with name ending in .app and inside an Info.plist which needs at least A/B/C metadata, etc. etc. and then signs it using codesign. You can do same manually with only X/Y tools and these steps if you do not have Xcode". That is a lot different than saying "here is a tutorial to make an app with Xcode". Same here for Visual Studio — I **cannot** install it, so how do I make an app anyway? – natevw Mar 04 '19 at 18:02
  • I did understand. You could use [MakeAppx.exe tool](https://learn.microsoft.com/en-us/windows/uwp/packaging/create-app-package-with-makeappx-tool) to create an app package. If you don't have visual studio installed, then you need to install the windows SDK at least. To create the package, you also need to manually create the relevant files at least like the visual studio has done for you. [Screenshoot](https://1drv.ms/u/s!AoI4pKdRYn8KnG_EPB-ym9n9ibXq) – Xie Steven Mar 05 '19 at 02:55
  • @XavierXie-MSFT Okay, thank you! That screenshot and confirmation that MakeAppx can do this is the sort of answer I was looking for. – natevw Mar 06 '19 at 18:04

0 Answers0