@@ 0,0 1,77 @@
+#! /bin/bash
+#
+# This command runs the Uno hot reload server, downloading and
+# building it if necessary.
+#
+# The server requires that you specify an HTTP port on which to
+# run, via the --httpPort=<port> argument. Once it's running, you
+# can build and run your Uno project (such as Skia GTK) with:
+#
+# $ dotnet build -property:UnoRemoteControlPort=<port> && dotnet run --no-build
+#
+# Once it's running, the hot reload functionality should work as normal.
+#
+# Note: at time of writing, the server requires .NET Core 3.1, even though Uno
+# supports up to .NET 5. If you're using the `asdf` SDK manager with the .NET
+# Core plugin, you should be able to ensure you're using the correct version
+# with:
+#
+# $ asdf shell dotnet-core 3.1.401 # make sure it's installed
+# $ source ~/.asdf/plugins/dotnet-core/set-dotnet-home.bash
+# $ uno-hot-reload --httpPort=<port>
+#
+
+set -o errexit
+set -o nounset
+
+version="3.8.6"
+install_only=false
+
+if [[ -z "${DOTNET_ROOT:-}" ]]; then
+ echo "DOTNET_ROOT is not set"
+ exit 1
+fi
+
+usage() {
+ echo "usage: uno-hot-reload [options] --httpPort=<port>
+
+ --install Install, but don't run"
+ exit 0
+}
+
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --install) install_only=true; shift;;
+ --help) usage;;
+ *) break;;
+ esac
+done
+
+cache_dir="${XDG_CACHE_HOME:-${HOME}/.cache}"
+hot_reload_home="${cache_dir}/uno-remote-host"
+
+{
+ if [[ "${install_only}" = true ]]; then
+ rm -rf "${hot_reload_home}"
+ fi
+
+ if [ ! -d "${hot_reload_home}" ]; then
+ echo 'Installing uno-remote-host on first use... (will take a moment)'
+ mkdir "${hot_reload_home}"
+ tmp="$(mktemp -d)"
+ pushd "${tmp}"
+ git clone --depth=1 --single-branch --branch "${version}" \
+ https://github.com/unoplatform/uno .
+ pushd src/Uno.UI.RemoteControl.Host
+ "${DOTNET_ROOT}/dotnet" build
+ cp bin/Debug/*/* "${hot_reload_home}"
+ popd
+ popd
+ fi
+
+ if [[ "${install_only}" = true ]]; then
+ exit 0
+ fi
+} 1>&2
+
+"${hot_reload_home}"/Uno.UI.RemoteControl.Host "$@"