diff --git a/src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs b/src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs index adc68a3e23dc0..4c42a30373f09 100644 --- a/src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs +++ b/src/mono/wasm/Wasm.Build.Tests/PInvokeTableGeneratorTests.cs @@ -462,9 +462,21 @@ public static void Main() """; + string tasksDir = Path.Combine(s_buildEnv.WorkloadPacksDir, + "Microsoft.NET.Runtime.WebAssembly.Sdk", + s_buildEnv.GetRuntimePackVersion(DefaultTargetFramework), + "tasks"); + if (!Directory.Exists(tasksDir)) + throw new DirectoryNotFoundException($"Could not find tasks directory {tasksDir}"); + + string? taskPath = Directory.EnumerateFiles(tasksDir, "WasmAppBuilder.dll", SearchOption.AllDirectories) + .FirstOrDefault(); + if (string.IsNullOrEmpty(taskPath)) + throw new FileNotFoundException($"Could not find WasmAppBuilder.dll in {tasksDir}"); + projectCode = projectCode .Replace("###WasmPInvokeModule###", AddAssembly("System.Private.CoreLib") + AddAssembly("System.Runtime") + AddAssembly(libraryBuildArgs.ProjectName)) - .Replace("###WasmAppBuilder###", Path.Combine(s_buildEnv.WorkloadPacksDir, "Microsoft.NET.Runtime.WebAssembly.Sdk", s_buildEnv.GetRuntimePackVersion(), "tasks", DefaultTargetFramework, "WasmAppBuilder.dll")); + .Replace("###WasmAppBuilder###", taskPath); buildArgs = buildArgs with { ProjectName = $"icall_enum_{buildArgs.Config}_{id}", ProjectFileContents = projectCode };