diff --git a/src/AddIns/Uno.UI.Lottie/LottieVisualSourceBase.wasm.cs b/src/AddIns/Uno.UI.Lottie/LottieVisualSourceBase.wasm.cs
index 512ef33f0d26..cc1339cef829 100644
--- a/src/AddIns/Uno.UI.Lottie/LottieVisualSourceBase.wasm.cs
+++ b/src/AddIns/Uno.UI.Lottie/LottieVisualSourceBase.wasm.cs
@@ -13,8 +13,6 @@ namespace Microsoft.Toolkit.Uwp.UI.Lottie
{
partial class LottieVisualSourceBase
{
- private static readonly string? UNO_BOOTSTRAP_APP_BASE = global::System.Environment.GetEnvironmentVariable(nameof(UNO_BOOTSTRAP_APP_BASE));
-
private AnimatedVisualPlayer? _initializedPlayer;
private Uri? _lastSource;
private Size _compositionSize = new Size(0, 0);
@@ -101,9 +99,7 @@ void OnJsonChanged(string updatedJson, string updatedCacheKey)
}
else
{
- var documentPath = string.IsNullOrEmpty(UNO_BOOTSTRAP_APP_BASE)
- ? UriSource?.PathAndQuery
- : UNO_BOOTSTRAP_APP_BASE + UriSource?.PathAndQuery;
+ var documentPath = Windows.Storage.Helpers.AssetsPathBuilder.BuildAssetUri(UriSource?.PathAndQuery);
_domLoaded = false;
js = new[]
diff --git a/src/AddIns/Uno.UI.Lottie/Uno.UI.Lottie.Wasm.csproj b/src/AddIns/Uno.UI.Lottie/Uno.UI.Lottie.Wasm.csproj
index 78b2ae8c84e6..128cbfc91d57 100644
--- a/src/AddIns/Uno.UI.Lottie/Uno.UI.Lottie.Wasm.csproj
+++ b/src/AddIns/Uno.UI.Lottie/Uno.UI.Lottie.Wasm.csproj
@@ -3,8 +3,8 @@
netstandard2.0
-
-
+
+
$(NoWarn);NU1701
@@ -28,6 +28,7 @@
+
diff --git a/src/Uno.UI/UI/Xaml/Media/Imaging/BitmapImage.wasm.cs b/src/Uno.UI/UI/Xaml/Media/Imaging/BitmapImage.wasm.cs
index 4a854d11756e..8bae4685c94c 100644
--- a/src/Uno.UI/UI/Xaml/Media/Imaging/BitmapImage.wasm.cs
+++ b/src/Uno.UI/UI/Xaml/Media/Imaging/BitmapImage.wasm.cs
@@ -9,6 +9,7 @@
using Uno.Extensions;
using Uno.Foundation;
using Windows.Graphics.Display;
+using Windows.Storage.Helpers;
using Windows.Storage.Streams;
using Path = global::System.IO.Path;
@@ -16,8 +17,6 @@ namespace Windows.UI.Xaml.Media.Imaging
{
public sealed partial class BitmapImage : BitmapSource
{
- private static readonly string UNO_BOOTSTRAP_APP_BASE = Environment.GetEnvironmentVariable(nameof(UNO_BOOTSTRAP_APP_BASE));
-
internal ResolutionScale? ScaleOverride { get; set; }
internal string ContentType { get; set; } = "application/octet-stream";
@@ -72,7 +71,7 @@ internal static class AssetResolver
private static async Task> GetAssets()
{
- var assetsUri = !string.IsNullOrEmpty(UNO_BOOTSTRAP_APP_BASE) ? $"{UNO_BOOTSTRAP_APP_BASE}/uno-assets.txt" : "uno-assets.txt";
+ var assetsUri = AssetsPathBuilder.BuildAssetUri("uno-assets.txt");
var assets = await WebAssemblyRuntime.InvokeAsync($"fetch('{assetsUri}').then(r => r.text())");
@@ -137,14 +136,12 @@ private static string GetScaledPath(string path, HashSet assets, Resolut
if (assets.Contains(filePath))
{
- return !string.IsNullOrEmpty(UNO_BOOTSTRAP_APP_BASE) ?
- $"{UNO_BOOTSTRAP_APP_BASE}/{filePath}" :
- filePath;
+ return AssetsPathBuilder.BuildAssetUri(filePath);
}
}
}
- return !string.IsNullOrEmpty(UNO_BOOTSTRAP_APP_BASE) ? $"{UNO_BOOTSTRAP_APP_BASE}/{path}" : path;
+ return AssetsPathBuilder.BuildAssetUri(path);
}
return path;
diff --git a/src/Uno.UI/UI/Xaml/Media/Imaging/SvgImageSource.wasm.cs b/src/Uno.UI/UI/Xaml/Media/Imaging/SvgImageSource.wasm.cs
index 4634d03ed507..bad80208a130 100644
--- a/src/Uno.UI/UI/Xaml/Media/Imaging/SvgImageSource.wasm.cs
+++ b/src/Uno.UI/UI/Xaml/Media/Imaging/SvgImageSource.wasm.cs
@@ -8,13 +8,12 @@
using Uno.Extensions;
using Uno.Logging;
using static Windows.UI.Xaml.Media.Imaging.BitmapImage;
+using Windows.Storage.Helpers;
namespace Windows.UI.Xaml.Media.Imaging
{
partial class SvgImageSource
{
- private static readonly string UNO_BOOTSTRAP_APP_BASE = Environment.GetEnvironmentVariable(nameof(UNO_BOOTSTRAP_APP_BASE));
-
internal string ContentType { get; set; } = "image/svg+xml";
partial void InitPartial()
@@ -52,7 +51,7 @@ private protected override bool TryOpenSourceSync(int? targetWidth, int? targetH
}
else
{
- var path = Path.Combine(UNO_BOOTSTRAP_APP_BASE, uri.OriginalString);
+ var path = AssetsPathBuilder.BuildAssetUri(uri.OriginalString);
image = new ImageData
{
Kind = ImageDataKind.Url,
diff --git a/src/Uno.UWP/Storage/Helpers/AssetsManager.wasm.cs b/src/Uno.UWP/Storage/Helpers/AssetsManager.wasm.cs
index df15ba80f960..4463dd856cb4 100644
--- a/src/Uno.UWP/Storage/Helpers/AssetsManager.wasm.cs
+++ b/src/Uno.UWP/Storage/Helpers/AssetsManager.wasm.cs
@@ -24,14 +24,12 @@ namespace Windows.Storage.Helpers
{
internal partial class AssetsManager
{
- private static readonly string UNO_BOOTSTRAP_APP_BASE = Environment.GetEnvironmentVariable(nameof(UNO_BOOTSTRAP_APP_BASE)) ?? "";
-
private static readonly Lazy>> _assets = new Lazy>>(() => GetAssets(CancellationToken.None));
private static readonly ConcurrentEntryManager _assetsGate = new ConcurrentEntryManager();
private static async Task> GetAssets(CancellationToken ct)
{
- var assetsUri = !string.IsNullOrEmpty(UNO_BOOTSTRAP_APP_BASE) ? $"{UNO_BOOTSTRAP_APP_BASE}/uno-assets.txt" : "uno-assets.txt";
+ var assetsUri = AssetsPathBuilder.BuildAssetUri("uno-assets.txt");
var assets = await WebAssemblyRuntime.InvokeAsync($"Windows.Storage.AssetManager.DownloadAssetsManifest(\'{assetsUri}\')");
@@ -45,13 +43,13 @@ public static async Task DownloadAsset(CancellationToken ct, string asse
if (assetSet.Contains(updatedPath))
{
- var localPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, ".assetsCache", UNO_BOOTSTRAP_APP_BASE, updatedPath);
+ var localPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, ".assetsCache", AssetsPathBuilder.UNO_BOOTSTRAP_APP_BASE, updatedPath);
using var assetLock = await _assetsGate.LockForAsset(ct, updatedPath);
if (!File.Exists(localPath))
{
- var assetUri = !string.IsNullOrEmpty(UNO_BOOTSTRAP_APP_BASE) ? $"{UNO_BOOTSTRAP_APP_BASE}/{updatedPath}" : updatedPath;
+ var assetUri = AssetsPathBuilder.BuildAssetUri(updatedPath);
var assetInfo = await WebAssemblyRuntime.InvokeAsync($"Windows.Storage.AssetManager.DownloadAsset(\'{assetUri}\')");
var parts = assetInfo.Split(';');
diff --git a/src/Uno.UWP/Storage/Helpers/AssetsPathBuilder.wasm.cs b/src/Uno.UWP/Storage/Helpers/AssetsPathBuilder.wasm.cs
new file mode 100644
index 000000000000..865510f15d8c
--- /dev/null
+++ b/src/Uno.UWP/Storage/Helpers/AssetsPathBuilder.wasm.cs
@@ -0,0 +1,25 @@
+#nullable enable
+
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Windows.Storage.Helpers
+{
+ ///
+ /// WebAssembly assets path builder
+ ///
+ internal static class AssetsPathBuilder
+ {
+ public static readonly string UNO_BOOTSTRAP_APP_BASE = Environment.GetEnvironmentVariable(nameof(UNO_BOOTSTRAP_APP_BASE)) ?? "";
+ private static readonly string UNO_BOOTSTRAP_WEBAPP_BASE_PATH = Environment.GetEnvironmentVariable(nameof(UNO_BOOTSTRAP_WEBAPP_BASE_PATH)) ?? "";
+
+ ///
+ /// Builds an actual asset path
+ ///
+ public static string? BuildAssetUri(string? contentRelativePath)
+ => !string.IsNullOrEmpty(UNO_BOOTSTRAP_APP_BASE)
+ ? $"{UNO_BOOTSTRAP_WEBAPP_BASE_PATH}{UNO_BOOTSTRAP_APP_BASE}/{contentRelativePath}"
+ : contentRelativePath;
+ }
+}