From 6bb8c65a38f787f7965cfd7c475791fa2ef5ee1b Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Tue, 20 Jul 2021 12:49:24 -0400 Subject: [PATCH 01/29] Initial change for adding runtimeconfig to wasm --- src/mono/wasm/runtime/driver.c | 28 +++++++++++++++++++ .../AndroidAppBuilder/Templates/monodroid.c | 8 +++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/mono/wasm/runtime/driver.c b/src/mono/wasm/runtime/driver.c index ca98e347dd120..dbc94b4ebe626 100644 --- a/src/mono/wasm/runtime/driver.c +++ b/src/mono/wasm/runtime/driver.c @@ -92,6 +92,8 @@ void mono_trace_init (void); static MonoDomain *root_domain; +#define RUNTIMECONFIG_BIN_FILE "runtimeconfig.bin" + static MonoString* mono_wasm_invoke_js (MonoString *str, int *is_exception) { @@ -476,6 +478,13 @@ mono_wasm_register_bundled_satellite_assemblies () void mono_wasm_link_icu_shim (void); +void +cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data) +{ + free (args); + free (user_data); +} + EMSCRIPTEN_KEEPALIVE void mono_wasm_load_runtime (const char *unused, int debug_level) { @@ -502,6 +511,25 @@ mono_wasm_load_runtime (const char *unused, int debug_level) appctx_values [0] = "/"; appctx_values [1] = "browser-wasm"; + char *file_name = RUNTIMECONFIG_BIN_FILE; + int str_len = strlen (file_name) + 1; // +1 is for the "/" + char *file_path = (char *)malloc (sizeof (char) * (str_len +1)); // +1 is for the terminating null character + int num_char = snprintf (file_path, (str_len + 1), "/%s", file_name); + struct stat buffer; + + //LOG_INFO ("file_path: %s\n", file_path); + assert (num_char > 0 && num_char == str_len); + + if (stat (file_path, &buffer) == 0) { + MonovmRuntimeConfigArguments *arg = (MonovmRuntimeConfigArguments *)malloc (sizeof (MonovmRuntimeConfigArguments)); + arg->kind = 0; + arg->runtimeconfig.name.path = file_path; + monovm_runtimeconfig_initialize (arg, cleanup_runtime_config, file_path); + } else { + free (file_path); + } + + monovm_initialize (2, appctx_keys, appctx_values); mini_parse_debug_option ("top-runtime-invoke-unhandled"); diff --git a/src/tasks/AndroidAppBuilder/Templates/monodroid.c b/src/tasks/AndroidAppBuilder/Templates/monodroid.c index 4ed02eb216693..2e6f93f43a5d0 100644 --- a/src/tasks/AndroidAppBuilder/Templates/monodroid.c +++ b/src/tasks/AndroidAppBuilder/Templates/monodroid.c @@ -234,13 +234,13 @@ mono_droid_runtime_init (const char* executable, int managed_argc, char* managed appctx_values[1] = bundle_path; char *file_name = RUNTIMECONFIG_BIN_FILE; - int str_len = strlen (bundle_path) + strlen (file_name) + 2; - char *file_path = (char *)malloc (sizeof (char) * str_len); - int num_char = snprintf (file_path, str_len, "%s/%s", bundle_path, file_name); + int str_len = strlen (bundle_path) + strlen (file_name) + 1; // +1 is for the "/" + char *file_path = (char *)malloc (sizeof (char) * (str_len +1)); // +1 is for the terminating null character + int num_char = snprintf (file_path, (str_len + 1), "%s/%s", bundle_path, file_name); struct stat buffer; LOG_INFO ("file_path: %s\n", file_path); - assert (num_char > 0 && num_char < str_len); + assert (num_char > 0 && num_char == str_len); if (stat (file_path, &buffer) == 0) { MonovmRuntimeConfigArguments *arg = (MonovmRuntimeConfigArguments *)malloc (sizeof (MonovmRuntimeConfigArguments)); From 6336f0a668b9271593d70d93a4ba0d0c715f7284 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 22 Jul 2021 14:53:24 -0400 Subject: [PATCH 02/29] Add runtimeconfig support to wasm --- src/mono/wasm/build/WasmApp.InTree.targets | 3 ++ src/mono/wasm/build/WasmApp.LocalBuild.props | 3 ++ .../wasm/build/WasmApp.LocalBuild.targets | 4 ++ src/mono/wasm/build/WasmApp.targets | 24 +++++++++- src/mono/wasm/runtime/driver.c | 2 +- .../Console/RuntimeConfig/Program.cs | 14 ++++++ ...Assembly.Console.RuntimeConfig.Test.csproj | 44 +++++++++++++++++++ .../RuntimeConfig/runtimeconfig.template.json | 6 +++ 8 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/Program.cs create mode 100644 src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/WebAssembly.Console.RuntimeConfig.Test.csproj create mode 100644 src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/runtimeconfig.template.json diff --git a/src/mono/wasm/build/WasmApp.InTree.targets b/src/mono/wasm/build/WasmApp.InTree.targets index 1537277f087d8..4395755818e8b 100644 --- a/src/mono/wasm/build/WasmApp.InTree.targets +++ b/src/mono/wasm/build/WasmApp.InTree.targets @@ -1,6 +1,9 @@ + diff --git a/src/mono/wasm/build/WasmApp.LocalBuild.props b/src/mono/wasm/build/WasmApp.LocalBuild.props index ea87a8bb8ec0e..d92024f720d46 100644 --- a/src/mono/wasm/build/WasmApp.LocalBuild.props +++ b/src/mono/wasm/build/WasmApp.LocalBuild.props @@ -35,6 +35,7 @@ $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmAppBuilder', 'Debug', '$(_NetCoreAppToolCurrent)', 'publish')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'WasmBuildTasks', 'Debug', '$(_NetCoreAppToolCurrent)', 'publish')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'MonoAOTCompiler', 'Debug', '$(_NetCoreAppToolCurrent)')) + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'RuntimeConfigParser', 'Debug', '$(_NetCoreAppToolCurrent)')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'JsonToItemsTaskFactory', 'Debug', '$(_NetCoreAppToolCurrent)')) $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'mono', '$(TargetOS).$(TargetArchitecture).$(RuntimeConfig)')) @@ -47,6 +48,7 @@ $([MSBuild]::NormalizeDirectory($(BuildBaseDir), 'microsoft.netcore.app.runtime.browser-wasm')) $([MSBuild]::NormalizeDirectory($(BuildBaseDir), 'MonoAOTCompiler')) + $([MSBuild]::NormalizeDirectory($(BuildBaseDir), 'RuntimeConfigParser')) $([MSBuild]::NormalizeDirectory($(BuildBaseDir), 'JsonToItemsTaskFactory')) $([MSBuild]::NormalizeDirectory($(BuildBaseDir), 'WasmAppBuilder')) $([MSBuild]::NormalizeDirectory($(BuildBaseDir), 'WasmBuildTasks')) @@ -65,6 +67,7 @@ $([MSBuild]::NormalizePath('$(WasmAppBuilderDir)', 'WasmAppBuilder.dll')) $([MSBuild]::NormalizePath('$(WasmBuildTasksDir)', 'WasmBuildTasks.dll')) $([MSBuild]::NormalizePath('$(MonoAOTCompilerDir)', 'MonoAOTCompiler.dll')) + $([MSBuild]::NormalizePath('$(RuntimeConfigParserDir)', 'RuntimeConfigParser.dll')) $([MSBuild]::NormalizePath('$(JsonToItemsTaskFactoryDir)', 'JsonToItemsTaskFactory.dll')) diff --git a/src/mono/wasm/build/WasmApp.LocalBuild.targets b/src/mono/wasm/build/WasmApp.LocalBuild.targets index c5f431d7d6993..ce6425b49a65d 100644 --- a/src/mono/wasm/build/WasmApp.LocalBuild.targets +++ b/src/mono/wasm/build/WasmApp.LocalBuild.targets @@ -22,6 +22,9 @@ + true @@ -64,6 +67,7 @@ $([MSBuild]::NormalizePath('$(WasmAppBuilderDir)', 'WasmAppBuilder.dll')) $([MSBuild]::NormalizePath('$(WasmBuildTasksDir)', 'WasmBuildTasks.dll')) $([MSBuild]::NormalizePath('$(MonoAOTCompilerDir)', 'MonoAOTCompiler.dll')) + $([MSBuild]::NormalizePath('$(RuntimeConfigParserDir)', 'RuntimeConfigParser.dll')) $([MSBuild]::NormalizePath('$(JsonToItemsTaskFactoryDir)', 'JsonToItemsTaskFactory.dll')) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 7de0e166aa0ff..0d7ca7fb437fc 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -136,7 +136,26 @@ - + + + $(TargetDir)publish\$([System.IO.Path]::GetFileNameWithoutExtension('$(WasmMainAssemblyFileName)')).runtimeconfig.json + $(TargetDir)publish\runtimeconfig.bin + + + + + + + + + + + + + @@ -153,6 +172,9 @@ + + + #include #include +#include #include #include @@ -517,7 +518,6 @@ mono_wasm_load_runtime (const char *unused, int debug_level) int num_char = snprintf (file_path, (str_len + 1), "/%s", file_name); struct stat buffer; - //LOG_INFO ("file_path: %s\n", file_path); assert (num_char > 0 && num_char == str_len); if (stat (file_path, &buffer) == 0) { diff --git a/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/Program.cs b/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/Program.cs new file mode 100644 index 0000000000000..51a21899b497c --- /dev/null +++ b/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/Program.cs @@ -0,0 +1,14 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; + +public class Program +{ + public static int Main(string[] args) + { + Console.WriteLine("Hello, World!"); + int result = ((string)AppContext.GetData("test_runtimeconfig_json")).Equals("25") ? 42 : 1; + return result; + } +} \ No newline at end of file diff --git a/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/WebAssembly.Console.RuntimeConfig.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/WebAssembly.Console.RuntimeConfig.Test.csproj new file mode 100644 index 0000000000000..3090c235b821b --- /dev/null +++ b/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/WebAssembly.Console.RuntimeConfig.Test.csproj @@ -0,0 +1,44 @@ + + + true + false + false + true + 42 + runtime.js + false + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/runtimeconfig.template.json b/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/runtimeconfig.template.json new file mode 100644 index 0000000000000..e7cd22b984a40 --- /dev/null +++ b/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/runtimeconfig.template.json @@ -0,0 +1,6 @@ +{ + "configProperties": { + "abc": "4", + "test_runtimeconfig_json": "25" + } +} \ No newline at end of file From 593ca12802aa5798e1f0cab1d97fa4394180045b Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 22 Jul 2021 15:46:51 -0400 Subject: [PATCH 03/29] Move test folder and update runtimeconifg task name --- src/mono/wasm/build/WasmApp.targets | 4 +- .../RuntimeConfig/Program.cs | 0 ...ssembly.Browser.RuntimeConfig.Test.csproj} | 1 + .../Browser/RuntimeConfig/index.html | 55 +++++++++++++++++++ .../Browser/RuntimeConfig/runtime.js | 47 ++++++++++++++++ .../RuntimeConfig/runtimeconfig.template.json | 0 6 files changed, 105 insertions(+), 2 deletions(-) rename src/tests/FunctionalTests/WebAssembly/{Console => Browser}/RuntimeConfig/Program.cs (100%) rename src/tests/FunctionalTests/WebAssembly/{Console/RuntimeConfig/WebAssembly.Console.RuntimeConfig.Test.csproj => Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj} (98%) create mode 100644 src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/index.html create mode 100644 src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtime.js rename src/tests/FunctionalTests/WebAssembly/{Console => Browser}/RuntimeConfig/runtimeconfig.template.json (100%) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 0d7ca7fb437fc..c3c7d920cc760 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -136,7 +136,7 @@ - + $(TargetDir)publish\$([System.IO.Path]::GetFileNameWithoutExtension('$(WasmMainAssemblyFileName)')).runtimeconfig.json $(TargetDir)publish\runtimeconfig.bin @@ -155,7 +155,7 @@ - + diff --git a/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/Program.cs b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs similarity index 100% rename from src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/Program.cs rename to src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs diff --git a/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/WebAssembly.Console.RuntimeConfig.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj similarity index 98% rename from src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/WebAssembly.Console.RuntimeConfig.Test.csproj rename to src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj index 3090c235b821b..043704745df54 100644 --- a/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/WebAssembly.Console.RuntimeConfig.Test.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj @@ -4,6 +4,7 @@ false false true + WasmTestOnBrowser 42 runtime.js false diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/index.html b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/index.html new file mode 100644 index 0000000000000..ad7cc2164ba48 --- /dev/null +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/index.html @@ -0,0 +1,55 @@ + + + + + + TESTS + + + + + + Result from Sample.Test.TestMeaning: + + + + + + + diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtime.js b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtime.js new file mode 100644 index 0000000000000..94f1a36a41073 --- /dev/null +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtime.js @@ -0,0 +1,47 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +var Module = { + + config: null, + + preInit: async function() { + await MONO.mono_wasm_load_config("./mono-config.json"); // sets Module.config implicitly + }, + + onRuntimeInitialized: function () { + if (!Module.config || Module.config.error) { + console.log("No config found"); + test_exit(1); + throw(Module.config.error); + } + + Module.config.loaded_cb = function () { + try { + App.init (); + } catch (error) { + test_exit(1); + throw (error); + } + }; + Module.config.fetch_file_cb = function (asset) { + return fetch (asset, { credentials: 'same-origin' }); + } + + if (Module.config.environment_variables !== undefined) { + console.log ("expected environment variables to be undefined, but they're: ", Module.config.environment_variables); + test_exit(1); + } + Module.config.environment_variables = { + "DOTNET_MODIFIABLE_ASSEMBLIES": "debug" + }; + + try + { + MONO.mono_load_runtime_and_bcl_args (Module.config); + } catch (error) { + test_exit(1); + throw(error); + } + }, +}; diff --git a/src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/runtimeconfig.template.json b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtimeconfig.template.json similarity index 100% rename from src/tests/FunctionalTests/WebAssembly/Console/RuntimeConfig/runtimeconfig.template.json rename to src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtimeconfig.template.json From 2a00cd75a35a45f426ffaf07f84a79efdc5d44fe Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 22 Jul 2021 16:09:57 -0400 Subject: [PATCH 04/29] Fix test --- .../Browser/RuntimeConfig/Program.cs | 19 ++++++++++++++----- .../Browser/RuntimeConfig/index.html | 2 +- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs index 51a21899b497c..0e64998842ad1 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs @@ -2,13 +2,22 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Runtime.CompilerServices; -public class Program +namespace Sample { - public static int Main(string[] args) + public class Test { - Console.WriteLine("Hello, World!"); - int result = ((string)AppContext.GetData("test_runtimeconfig_json")).Equals("25") ? 42 : 1; - return result; + public static void Main(string[] args) + { + Console.WriteLine ("Hello, World!"); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public static int TestMeaning() + { + int result = ((string)AppContext.GetData("test_runtimeconfig_json")).Equals("25") ? 42 : 1; + return result; + } } } \ No newline at end of file diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/index.html b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/index.html index ad7cc2164ba48..9da181f4b3f09 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/index.html +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/index.html @@ -36,7 +36,7 @@ var App = { init: function () { - var exit_code = BINDING.call_static_method("[WebAssembly.Browser.HotReload.Test] Sample.Test:TestMeaning", []); + var exit_code = BINDING.call_static_method("[WebAssembly.Browser.RuntimeConfig.Test] Sample.Test:TestMeaning", []); document.getElementById("out").innerHTML = exit_code; if (is_testing) From f1d71a2dd84e26f7e3ab664a3e5d5a56b1811ef6 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Wed, 28 Jul 2021 14:54:13 -0400 Subject: [PATCH 05/29] Fix test csproj file --- ...Assembly.Browser.RuntimeConfig.Test.csproj | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj index 043704745df54..925350f051239 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj @@ -14,8 +14,15 @@ + + Always + + + + + @@ -26,20 +33,5 @@ Include="%(ResolvedFileToPublish.FullPath)" /> - - - - - - - - - - From b17864faaed7c92c098c682b31f6d4dbc87a2976 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Wed, 28 Jul 2021 15:16:55 -0400 Subject: [PATCH 06/29] Use the right var for main dll name --- src/mono/wasm/build/WasmApp.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index c3c7d920cc760..e2594a0424582 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -138,7 +138,7 @@ - $(TargetDir)publish\$([System.IO.Path]::GetFileNameWithoutExtension('$(WasmMainAssemblyFileName)')).runtimeconfig.json + $(TargetDir)publish\$(AssemblyName).runtimeconfig.json $(TargetDir)publish\runtimeconfig.bin From 905ae911ab25a3742c1e676e8070af397b5c4579 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 29 Jul 2021 10:35:47 -0400 Subject: [PATCH 07/29] Resolve review feedback part 1 --- src/mono/wasm/build/WasmApp.targets | 6 ++-- src/mono/wasm/runtime/driver.c | 35 +++++++++---------- .../Browser/RuntimeConfig/Program.cs | 3 +- ...Assembly.Browser.RuntimeConfig.Test.csproj | 16 --------- .../Browser/RuntimeConfig/runtime.js | 8 ----- 5 files changed, 22 insertions(+), 46 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index e2594a0424582..6dd03f932a9f8 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -136,7 +136,7 @@ - + $(TargetDir)publish\$(AssemblyName).runtimeconfig.json $(TargetDir)publish\runtimeconfig.bin @@ -147,7 +147,7 @@ - + - + diff --git a/src/mono/wasm/runtime/driver.c b/src/mono/wasm/runtime/driver.c index 44b6d84757e0e..83244ce145837 100644 --- a/src/mono/wasm/runtime/driver.c +++ b/src/mono/wasm/runtime/driver.c @@ -482,8 +482,8 @@ void mono_wasm_link_icu_shim (void); void cleanup_runtime_config (MonovmRuntimeConfigArguments *args, void *user_data) { - free (args); - free (user_data); + free (args); + free (user_data); } EMSCRIPTEN_KEEPALIVE void @@ -513,22 +513,21 @@ mono_wasm_load_runtime (const char *unused, int debug_level) appctx_values [1] = "browser-wasm"; char *file_name = RUNTIMECONFIG_BIN_FILE; - int str_len = strlen (file_name) + 1; // +1 is for the "/" - char *file_path = (char *)malloc (sizeof (char) * (str_len +1)); // +1 is for the terminating null character - int num_char = snprintf (file_path, (str_len + 1), "/%s", file_name); - struct stat buffer; - - assert (num_char > 0 && num_char == str_len); - - if (stat (file_path, &buffer) == 0) { - MonovmRuntimeConfigArguments *arg = (MonovmRuntimeConfigArguments *)malloc (sizeof (MonovmRuntimeConfigArguments)); - arg->kind = 0; - arg->runtimeconfig.name.path = file_path; - monovm_runtimeconfig_initialize (arg, cleanup_runtime_config, file_path); - } else { - free (file_path); - } - + int str_len = strlen (file_name) + 1; // +1 is for the "/" + char *file_path = (char *)malloc (sizeof (char) * (str_len +1)); // +1 is for the terminating null character + int num_char = snprintf (file_path, (str_len + 1), "/%s", file_name); + struct stat buffer; + + assert (num_char > 0 && num_char == str_len); + + if (stat (file_path, &buffer) == 0) { + MonovmRuntimeConfigArguments *arg = (MonovmRuntimeConfigArguments *)malloc (sizeof (MonovmRuntimeConfigArguments)); + arg->kind = 0; + arg->runtimeconfig.name.path = file_path; + monovm_runtimeconfig_initialize (arg, cleanup_runtime_config, file_path); + } else { + free (file_path); + } monovm_initialize (2, appctx_keys, appctx_values); diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs index 0e64998842ad1..6d1ae322e7e71 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/Program.cs @@ -16,7 +16,8 @@ public static void Main(string[] args) [MethodImpl(MethodImplOptions.NoInlining)] public static int TestMeaning() { - int result = ((string)AppContext.GetData("test_runtimeconfig_json")).Equals("25") ? 42 : 1; + var config = AppContext.GetData("test_runtimeconfig_json"); + int result = ((string)config).Equals("25") ? 42 : 1; return result; } } diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj index 925350f051239..1c6b45b707b82 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj @@ -1,15 +1,10 @@ - true - false - false true WasmTestOnBrowser 42 runtime.js false - - @@ -22,16 +17,5 @@ - - - - - - - diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtime.js b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtime.js index 94f1a36a41073..b5227472674c6 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtime.js +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/runtime.js @@ -28,14 +28,6 @@ var Module = { return fetch (asset, { credentials: 'same-origin' }); } - if (Module.config.environment_variables !== undefined) { - console.log ("expected environment variables to be undefined, but they're: ", Module.config.environment_variables); - test_exit(1); - } - Module.config.environment_variables = { - "DOTNET_MODIFIABLE_ASSEMBLIES": "debug" - }; - try { MONO.mono_load_runtime_and_bcl_args (Module.config); From ad3e28515dbdda33e56afed15dda7258b89ed24a Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 29 Jul 2021 16:01:33 -0400 Subject: [PATCH 08/29] Resolve review feedbacks part 2 --- eng/testing/linker/trimmingTests.targets | 1 + src/libraries/sendtohelixhelp.proj | 1 + src/mono/wasm/build/WasmApp.InTree.targets | 4 +--- src/mono/wasm/build/WasmApp.LocalBuild.targets | 4 +--- src/mono/wasm/build/WasmApp.targets | 3 ++- src/mono/wasm/runtime/driver.c | 3 ++- src/tests/Common/wasm-test-runner/WasmTestRunner.proj | 1 + src/tests/Directory.Build.targets | 5 +++++ .../WebAssembly.Browser.RuntimeConfig.Test.csproj | 1 - 9 files changed, 14 insertions(+), 9 deletions(-) diff --git a/eng/testing/linker/trimmingTests.targets b/eng/testing/linker/trimmingTests.targets index 539053c71e330..f1759616bd73b 100644 --- a/eng/testing/linker/trimmingTests.targets +++ b/eng/testing/linker/trimmingTests.targets @@ -97,6 +97,7 @@ .Replace('{MonoProjectRoot}', '$(MonoProjectRoot)') .Replace('{MonoAOTCompilerTasksAssemblyPath}', '$(MonoAOTCompilerTasksAssemblyPath)') .Replace('{JsonToItemsTaskFactoryTasksAssemblyPath}', '$(JsonToItemsTaskFactoryTasksAssemblyPath)') + .Replace('{RuntimeConfigParserTasksAssemblyPath}', '$(RuntimeConfigParserTasksAssemblyPath)') .Replace('{WasmAppBuilderTasksAssemblyPath}', '$(WasmAppBuilderTasksAssemblyPath)') .Replace('{MicrosoftNetCoreAppRuntimePackRidDir}', '$(MicrosoftNetCoreAppRuntimePackRidDir)'))" Overwrite="true" /> diff --git a/src/libraries/sendtohelixhelp.proj b/src/libraries/sendtohelixhelp.proj index 08bdf4fdb0702..e9ddef9735eaf 100644 --- a/src/libraries/sendtohelixhelp.proj +++ b/src/libraries/sendtohelixhelp.proj @@ -370,6 +370,7 @@ + diff --git a/src/mono/wasm/build/WasmApp.InTree.targets b/src/mono/wasm/build/WasmApp.InTree.targets index 4395755818e8b..b345da95cf93c 100644 --- a/src/mono/wasm/build/WasmApp.InTree.targets +++ b/src/mono/wasm/build/WasmApp.InTree.targets @@ -1,9 +1,7 @@ - + diff --git a/src/mono/wasm/build/WasmApp.LocalBuild.targets b/src/mono/wasm/build/WasmApp.LocalBuild.targets index ce6425b49a65d..23f5249786d66 100644 --- a/src/mono/wasm/build/WasmApp.LocalBuild.targets +++ b/src/mono/wasm/build/WasmApp.LocalBuild.targets @@ -22,9 +22,7 @@ - + true diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 6dd03f932a9f8..b3b9c68407308 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -142,6 +142,8 @@ $(TargetDir)publish\runtimeconfig.bin + + @@ -173,7 +175,6 @@ - diff --git a/src/mono/wasm/runtime/driver.c b/src/mono/wasm/runtime/driver.c index 83244ce145837..c880196ebf915 100644 --- a/src/mono/wasm/runtime/driver.c +++ b/src/mono/wasm/runtime/driver.c @@ -503,7 +503,8 @@ mono_wasm_load_runtime (const char *unused, int debug_level) // corlib assemblies. monoeg_g_setenv ("COMPlus_DebugWriteToStdErr", "1", 0); #endif - + // When the list of app context properties changes, please update RuntimeConfigReservedProperties for + // target _WasmGenerateRuntimeConfig in WasmApp.targets file const char *appctx_keys[2]; appctx_keys [0] = "APP_CONTEXT_BASE_DIRECTORY"; appctx_keys [1] = "RUNTIME_IDENTIFIER"; diff --git a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj index f9479f9674623..5f4d4f084d13b 100644 --- a/src/tests/Common/wasm-test-runner/WasmTestRunner.proj +++ b/src/tests/Common/wasm-test-runner/WasmTestRunner.proj @@ -14,6 +14,7 @@ $(CORE_ROOT)\WasmAppBuilder\WasmAppBuilder.dll $(CORE_ROOT)\MonoAOTCompiler\MonoAOTCompiler.dll $(CORE_ROOT)\JsonToItemsTaskFactory\JsonToItemsTaskFactory.dll + $(CORE_ROOT)\RuntimeConfigParser\RuntimeConfigParser.dll diff --git a/src/tests/Directory.Build.targets b/src/tests/Directory.Build.targets index 4bf4c58589776..8ab2ab3cd3121 100644 --- a/src/tests/Directory.Build.targets +++ b/src/tests/Directory.Build.targets @@ -381,6 +381,11 @@ Include="$(ArtifactsBinDir)\JsonToItemsTaskFactory\Debug\$(NetCoreAppToolCurrent)\**" TargetDir="JsonToItemsTaskFactory/"/> + + + diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj index 1c6b45b707b82..19825018f9434 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj @@ -4,7 +4,6 @@ WasmTestOnBrowser 42 runtime.js - false From 2965386595bda077db6e3a288fa163cf17be3c7b Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 29 Jul 2021 16:18:32 -0400 Subject: [PATCH 09/29] Add doc for updating dependencies when adding new tasks --- src/mono/wasm/build/README.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/mono/wasm/build/README.md b/src/mono/wasm/build/README.md index ea7b73ebe2214..854ea041398fa 100644 --- a/src/mono/wasm/build/README.md +++ b/src/mono/wasm/build/README.md @@ -49,3 +49,29 @@ The various task inputs correspond to properties as: This should be a step towards eventually having this build as a sdk. Refer to `WasmApp.targets` for more information about the properties/items used as inputs to the process. + +## Updating dependencies needed for building wasm apps + +For example, if the wasm targets are using a new task, then references to that +need to be updated in a few places. Essentially, look for existing references +to `MonoAOTCompiler`, or `WasmAppBuilder` in the relevant files, and duplicate +them for the new task assembly. + +1. The task assembly dir, and its path need to be in two properties: + ```xml + $([MSBuild]::NormalizeDirectory('$(ArtifactsBinDir)', 'JsonToItemsTaskFactory', 'Debug', '$(NetCoreAppToolCurrent)')) + $([MSBuild]::NormalizePath('$(JsonToItemsTaskFactoryDir)', 'JsonToItemsTaskFactory.dll')) + ``` + + And this needs to be set in: + - `Directory.Build.props` + - `src/mono/wasm/build/WasmApp.LocalBuild.props` + - `src/mono/wasm/build/WasmApp.LocalBuild.targets` + - `src/tests/Common/wasm-test-runner/WasmTestRunner.proj` + +2. The new dependency (eg. task assembly) needs to be sent to helix as a payload, see `src/libraries/sendtohelixhelp.proj`. Use `MonoAOTCompiler` as an example. + +3. Make changes similar to the one for existing dependent tasks in + - `eng/testing/linker/trimmingTests.targets`, + - `src/tests/Common/wasm-test-runner/WasmTestRunner.proj` + - `src/tests/Directory.Build.targets` \ No newline at end of file From b65538cfb863de3c86cc04de189873017b30c47d Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Fri, 30 Jul 2021 11:04:27 -0400 Subject: [PATCH 10/29] Remove redundant condition and redundant copy --- eng/testing/tests.mobile.targets | 2 +- src/mono/wasm/build/WasmApp.targets | 6 +++++- .../WebAssembly.Browser.RuntimeConfig.Test.csproj | 5 +---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index 3beee87d76049..e525483f764d9 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -60,7 +60,7 @@ $(PublishDir)runtimeconfig.bin - + diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index b3b9c68407308..2034f85bf0444 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -144,7 +144,7 @@ - + @@ -155,6 +155,10 @@ OutputFile="$(ParsedRuntimeConfigFilePath)" RuntimeConfigReservedProperties="@(RuntimeConfigReservedProperties)"> + + + + diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj index 19825018f9434..4efa17aab45d9 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/RuntimeConfig/WebAssembly.Browser.RuntimeConfig.Test.csproj @@ -8,13 +8,10 @@ - - Always - - + From ad3757391e1f184b3e002a3c1a9f7bdf38b401d5 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Fri, 30 Jul 2021 16:48:04 -0400 Subject: [PATCH 11/29] There is no runtimeconfig.json file to parse, when OutputType is library. So skip it. --- src/mono/wasm/build/WasmApp.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 2034f85bf0444..a44a93072d9db 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -136,7 +136,7 @@ - + $(TargetDir)publish\$(AssemblyName).runtimeconfig.json $(TargetDir)publish\runtimeconfig.bin From eb65cc2f65017694c9e0bbef31dce6f482dc5467 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Fri, 30 Jul 2021 16:49:48 -0400 Subject: [PATCH 12/29] Skip for Android tests as well. --- eng/testing/tests.mobile.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index e525483f764d9..d896e024580b0 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -54,7 +54,7 @@ AssemblyFile="$(RuntimeConfigParserTasksAssemblyPath)" Condition="'$(RuntimeConfigParserTasksAssemblyPath)' != ''" /> - + $(PublishDir)$(AssemblyName).runtimeconfig.json $(PublishDir)runtimeconfig.bin From 093c0a4144680053ebc2e692d86a289d3f222469 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Fri, 30 Jul 2021 19:40:10 -0400 Subject: [PATCH 13/29] Remove the wrong locatioin of WasmFilesToIncludeInFileSystem --- src/mono/wasm/build/WasmApp.targets | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index a44a93072d9db..7934ac87c96a1 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -157,7 +157,7 @@ - + @@ -178,8 +178,6 @@ - - Date: Fri, 30 Jul 2021 20:08:25 -0400 Subject: [PATCH 14/29] Update runtimeconfig file path --- src/mono/wasm/build/WasmApp.targets | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 7934ac87c96a1..667f6faf3afaa 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -138,8 +138,9 @@ - $(TargetDir)publish\$(AssemblyName).runtimeconfig.json - $(TargetDir)publish\runtimeconfig.bin + <_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll'">%(WasmAssembliesToBundle.Identity) + $([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) + $([System.IO.Path]::GetDirectoryName($(_MainAssemblyPath)))\runtimeconfig.bin From 9d2f53c37831c55a6094f0d7c47d4daee9982807 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Fri, 30 Jul 2021 20:12:29 -0400 Subject: [PATCH 15/29] Add RuntimeConfigParserTasksAssemblyPath to linker test project template --- eng/testing/linker/project.csproj.template | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/testing/linker/project.csproj.template b/eng/testing/linker/project.csproj.template index c9eeb18f2718c..e3a89acd65329 100644 --- a/eng/testing/linker/project.csproj.template +++ b/eng/testing/linker/project.csproj.template @@ -7,6 +7,7 @@ {MonoAOTCompilerTasksAssemblyPath} {WasmAppBuilderTasksAssemblyPath} {JsonToItemsTaskFactoryTasksAssemblyPath} + {RuntimeConfigParserTasksAssemblyPath} {MicrosoftNetCoreAppRuntimePackRidDir} {RepositoryEngineeringDir} {TestTargetFramework} From b7bc84cbc0c972db3ff436239731bf5d73850e21 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Mon, 2 Aug 2021 17:38:26 -0400 Subject: [PATCH 16/29] Fix test failures on WASM EAT and AOT lanes --- eng/testing/tests.mobile.targets | 2 +- eng/testing/tests.wasm.targets | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/eng/testing/tests.mobile.targets b/eng/testing/tests.mobile.targets index d896e024580b0..572213ee2c783 100644 --- a/eng/testing/tests.mobile.targets +++ b/eng/testing/tests.mobile.targets @@ -54,7 +54,7 @@ AssemblyFile="$(RuntimeConfigParserTasksAssemblyPath)" Condition="'$(RuntimeConfigParserTasksAssemblyPath)' != ''" /> - + $(PublishDir)$(AssemblyName).runtimeconfig.json $(PublishDir)runtimeconfig.bin diff --git a/eng/testing/tests.wasm.targets b/eng/testing/tests.wasm.targets index 8618fdb73e3c5..8d6829e47b338 100644 --- a/eng/testing/tests.wasm.targets +++ b/eng/testing/tests.wasm.targets @@ -75,9 +75,15 @@ AssemblyFile="$(WasmBuildTasksAssemblyPath)" /> + + <_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll'">%(WasmAssembliesToBundle.Identity) + $([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) + + + @@ -99,6 +105,7 @@ <_WasmPropertyNames Include="WasmLinkIcalls" /> <_WasmPropertyNames Include="WasmDedup" /> <_WasmPropertyNames Include="IncludeSatelliteAssembliesInVFS" /> + <_WasmPropertyNames Include="AssemblyName" /> <_WasmPropertiesToPass Include="$(%(_WasmPropertyNames.Identity))" From e8bfc59563ad291c2daadfb43318d7322944be2e Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 3 Aug 2021 17:37:02 -0400 Subject: [PATCH 17/29] [wasm] Add a test for reading runtimeconfig.json --- .../Wasm.Build.Tests/WasmBuildAppTest.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs index 59b82318a1242..b604d2e34820b 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs @@ -85,6 +85,43 @@ public void Bug49588_RegressionTest_NativeRelinking(BuildArgs buildArgs, RunHost extraProperties: "true", dotnetWasmFromRuntimePack: false); + [Theory] + [BuildAndRun] + public void PropertiesFromRuntimeConfigJson(BuildArgs buildArgs, RunHost host, string id) + { + buildArgs = buildArgs with { ProjectName = $"runtime_config_{buildArgs.Config}_{buildArgs.AOT}" }; + buildArgs = ExpandBuildArgs(buildArgs); + + string programText = @" + using System; + using System.Runtime.CompilerServices; + + var config = AppContext.GetData(""test_runtimeconfig_json""); + Console.WriteLine ($""test_runtimeconfig_json: {(string)config}""); + return 42; + "; + + string runtimeConfigTemplateJson = @" + { + ""configProperties"": { + ""abc"": ""4"", + ""test_runtimeconfig_json"": ""25"" + } + }"; + + BuildProject(buildArgs, + initProject: () => + { + File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), programText); + File.WriteAllText(Path.Combine(_projectDir!, "runtimeconfig.template.json"), runtimeConfigTemplateJson); + }, + id: id, + dotnetWasmFromRuntimePack: !(buildArgs.AOT || buildArgs.Config == "Release")); + + RunAndTestWasmApp(buildArgs, expectedExitCode: 42, + test: output => Assert.Contains("test_runtimeconfig_json: 25", output), host: host, id: id); + } + void TestMain(string projectName, string programText, BuildArgs buildArgs, From 2cfc3de091a6b43be5bf7a90f1c196c922f60bc2 Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Tue, 3 Aug 2021 17:46:08 -0400 Subject: [PATCH 18/29] improve error reporting slightly --- src/mono/wasm/build/WasmApp.targets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 667f6faf3afaa..5fbd432924cce 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -143,7 +143,8 @@ $([System.IO.Path]::GetDirectoryName($(_MainAssemblyPath)))\runtimeconfig.bin - + + From 034887c5cef856c9b0bc3fb5a7da34b68b6d977b Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Tue, 3 Aug 2021 18:31:53 -0400 Subject: [PATCH 19/29] Enable tests --- .../System.Diagnostics.DiagnosticSource.Switches.Tests.csproj | 1 - src/libraries/System.Text.Encoding/tests/Encoding/Encoding.cs | 2 -- .../tests/Encoding/EncodingGetEncodingTests.cs | 3 --- .../tests/UTF7Encoding/UTF7EncodingEncode.cs | 1 - .../tests/UTF7Encoding/UTF7EncodingTests.cs | 1 - 5 files changed, 8 deletions(-) diff --git a/src/libraries/System.Diagnostics.DiagnosticSource/tests/TestWithConfigSwitches/System.Diagnostics.DiagnosticSource.Switches.Tests.csproj b/src/libraries/System.Diagnostics.DiagnosticSource/tests/TestWithConfigSwitches/System.Diagnostics.DiagnosticSource.Switches.Tests.csproj index ea4a7ff67293d..0662b27d73c5a 100644 --- a/src/libraries/System.Diagnostics.DiagnosticSource/tests/TestWithConfigSwitches/System.Diagnostics.DiagnosticSource.Switches.Tests.csproj +++ b/src/libraries/System.Diagnostics.DiagnosticSource/tests/TestWithConfigSwitches/System.Diagnostics.DiagnosticSource.Switches.Tests.csproj @@ -2,7 +2,6 @@ $(NetCoreAppCurrent) true - true diff --git a/src/libraries/System.Text.Encoding/tests/Encoding/Encoding.cs b/src/libraries/System.Text.Encoding/tests/Encoding/Encoding.cs index e7640cbea8c8b..9ae2917806b66 100644 --- a/src/libraries/System.Text.Encoding/tests/Encoding/Encoding.cs +++ b/src/libraries/System.Text.Encoding/tests/Encoding/Encoding.cs @@ -64,7 +64,6 @@ public static void GetEncodingsTest() } } - [ActiveIssue("https://github.com/dotnet/runtime/issues/38433", TestPlatforms.Browser)] // wasm doesn't honor runtimeconfig.json [Theory] [MemberData(nameof(Encoding_TestData))] public static void VerifyCodePageAttributes(int codepage, string name, string bodyName, string headerName, bool isBrowserDisplay, @@ -81,7 +80,6 @@ public static void VerifyCodePageAttributes(int codepage, string name, string bo Assert.Equal(windowsCodePage, encoding.WindowsCodePage); } - [ActiveIssue("https://github.com/dotnet/runtime/issues/38433", TestPlatforms.Browser)] // wasm doesn't honor runtimeconfig.json [Theory] [MemberData(nameof(Normalization_TestData))] public static void NormalizationTest(int codepage, bool normalized, bool normalizedC, bool normalizedD, bool normalizedKC, bool normalizedKD) diff --git a/src/libraries/System.Text.Encoding/tests/Encoding/EncodingGetEncodingTests.cs b/src/libraries/System.Text.Encoding/tests/Encoding/EncodingGetEncodingTests.cs index 6a5fc49cf2eb8..2589dd1af4cdd 100644 --- a/src/libraries/System.Text.Encoding/tests/Encoding/EncodingGetEncodingTests.cs +++ b/src/libraries/System.Text.Encoding/tests/Encoding/EncodingGetEncodingTests.cs @@ -88,7 +88,6 @@ public CodePageMapping(string name, int codepage) new CodePageMapping("x-unicode-2-0-utf-8", 65001) }; - [ActiveIssue("https://github.com/dotnet/runtime/issues/38433", TestPlatforms.Browser)] // wasm doesn't honor runtimeconfig.json [Fact] public void TestEncodingNameAndCopdepageNumber() { @@ -99,7 +98,6 @@ public void TestEncodingNameAndCopdepageNumber() } } - [ActiveIssue("https://github.com/dotnet/runtime/issues/38433", TestPlatforms.Browser)] // wasm doesn't honor runtimeconfig.json [Fact] public void GetEncoding_EncodingName() { @@ -119,7 +117,6 @@ public void GetEncoding_EncodingName() } } - [ActiveIssue("https://github.com/dotnet/runtime/issues/38433", TestPlatforms.Browser)] // wasm doesn't honor runtimeconfig.json [Fact] public void GetEncoding_WebName() { diff --git a/src/libraries/System.Text.Encoding/tests/UTF7Encoding/UTF7EncodingEncode.cs b/src/libraries/System.Text.Encoding/tests/UTF7Encoding/UTF7EncodingEncode.cs index 781c8447ff1d3..a2e9654be83e0 100644 --- a/src/libraries/System.Text.Encoding/tests/UTF7Encoding/UTF7EncodingEncode.cs +++ b/src/libraries/System.Text.Encoding/tests/UTF7Encoding/UTF7EncodingEncode.cs @@ -6,7 +6,6 @@ namespace System.Text.Tests { - [ActiveIssue("https://github.com/dotnet/runtime/issues/38433", TestPlatforms.Browser)] // wasm doesn't honor runtimeconfig.json public class UTF7EncodingEncode { public static IEnumerable Encode_Basic_TestData() diff --git a/src/libraries/System.Text.Encoding/tests/UTF7Encoding/UTF7EncodingTests.cs b/src/libraries/System.Text.Encoding/tests/UTF7Encoding/UTF7EncodingTests.cs index c8d628ceca1c7..841dc5e83fb91 100644 --- a/src/libraries/System.Text.Encoding/tests/UTF7Encoding/UTF7EncodingTests.cs +++ b/src/libraries/System.Text.Encoding/tests/UTF7Encoding/UTF7EncodingTests.cs @@ -6,7 +6,6 @@ namespace System.Text.Tests { - [ActiveIssue("https://github.com/dotnet/runtime/issues/38433", TestPlatforms.Browser)] // wasm doesn't honor runtimeconfig.json public class UTF7EncodingTests { [Fact] From de4284a08818ddd7ba7867378c4ee94a334a1999 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Tue, 3 Aug 2021 19:45:15 -0400 Subject: [PATCH 20/29] One more thing to enable tests --- src/libraries/tests.proj | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libraries/tests.proj b/src/libraries/tests.proj index ebb11e10aa8b6..4e60c6278c020 100644 --- a/src/libraries/tests.proj +++ b/src/libraries/tests.proj @@ -253,9 +253,6 @@ - - - From f0b1fded10322a0f238251b0ea7061ea39ca689b Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Wed, 4 Aug 2021 13:33:23 -0400 Subject: [PATCH 21/29] Run target _WasmGenerateRuntimeConfig when runtimeconfig.json file exists --- src/mono/wasm/build/WasmApp.targets | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index 5fbd432924cce..d4fab9784c621 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -83,6 +83,8 @@ false <_BeforeWasmBuildAppDependsOn /> + + <_RuntimeConfigJsonFileExistance>false @@ -122,8 +124,14 @@ $(TargetFileName) $([MSBuild]::NormalizeDirectory($(WasmAppDir))) + + <_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll'">%(WasmAssembliesToBundle.Identity) + <_WasmRuntimeConfigFilePath>$([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) + <_RuntimeConfigJsonFileExistance Condition="Exists('$(_WasmRuntimeConfigFilePath)')">true + + <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" /> @@ -136,16 +144,11 @@ - + - <_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll'">%(WasmAssembliesToBundle.Identity) - $([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) $([System.IO.Path]::GetDirectoryName($(_MainAssemblyPath)))\runtimeconfig.bin - - - @@ -153,7 +156,7 @@ From e2845812c748035e7ea8c580807bc15cde46678a Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Wed, 4 Aug 2021 17:28:36 -0400 Subject: [PATCH 22/29] Add a test for configure runtime using msbuild properties --- .../Wasm.Build.Tests/BuildTestBase.cs | 8 ++- .../Wasm.Build.Tests/WasmBuildAppTest.cs | 56 +++++++++++++++++-- 2 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index 6d08fe8512461..c8a41fa7f946a 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -271,7 +271,8 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp bool hasIcudt = true, bool useCache = true, bool expectSuccess = true, - bool createProject = true) + bool createProject = true, + bool createCsProject = true) { if (useCache && _buildContext.TryGetBuildFor(buildArgs, out BuildProduct? product)) { @@ -291,7 +292,10 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp InitProjectDir(_projectDir); initProject?.Invoke(); - File.WriteAllText(Path.Combine(_projectDir, $"{buildArgs.ProjectName}.csproj"), buildArgs.ProjectFileContents); + if (createCsProject) + { + File.WriteAllText(Path.Combine(_projectDir, $"{buildArgs.ProjectName}.csproj"), buildArgs.ProjectFileContents); + } File.Copy(Path.Combine(AppContext.BaseDirectory, "runtime-test.js"), Path.Combine(_projectDir, "runtime-test.js")); } else if (_projectDir is null) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs index b604d2e34820b..e44000141da45 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs @@ -103,11 +103,11 @@ public void PropertiesFromRuntimeConfigJson(BuildArgs buildArgs, RunHost host, s string runtimeConfigTemplateJson = @" { - ""configProperties"": { - ""abc"": ""4"", - ""test_runtimeconfig_json"": ""25"" - } - }"; + ""configProperties"": { + ""abc"": ""4"", + ""test_runtimeconfig_json"": ""25"" + } + }"; BuildProject(buildArgs, initProject: () => @@ -122,6 +122,52 @@ public void PropertiesFromRuntimeConfigJson(BuildArgs buildArgs, RunHost host, s test: output => Assert.Contains("test_runtimeconfig_json: 25", output), host: host, id: id); } + [Theory] + [BuildAndRun] + public void PropertiesFromCsproj(BuildArgs buildArgs, RunHost host, string id) + { + buildArgs = buildArgs with { ProjectName = $"runtime_config_csproj_{buildArgs.Config}_{buildArgs.AOT}" }; + buildArgs = ExpandBuildArgs(buildArgs); + + string programText = @" + using System; + using System.Runtime.CompilerServices; + + var config = AppContext.GetData(""System.Threading.ThreadPool.MaxThreads""); + Console.WriteLine ($""System.Threading.ThreadPool.MaxThreads: {(string)config}""); + return 42; + "; + + string csprojFile = @" + + + net6.0 + Exe + true + runtime-test.js + 20 + + + + + + + "; + + BuildProject(buildArgs, + initProject: () => + { + File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), programText); + File.WriteAllText(Path.Combine(_projectDir!, $"{buildArgs.ProjectName}.csproj"), csprojFile); + }, + id: id, + dotnetWasmFromRuntimePack: !(buildArgs.AOT || buildArgs.Config == "Release"), + createCsProject: false); + + RunAndTestWasmApp(buildArgs, expectedExitCode: 42, + test: output => Assert.Contains("System.Threading.ThreadPool.MaxThreads: 20", output), host: host, id: id); + } + void TestMain(string projectName, string programText, BuildArgs buildArgs, From bef52dea7f5258619cea1d172c3b1dc96dc4e310 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 5 Aug 2021 10:38:02 -0400 Subject: [PATCH 23/29] Fix runtime test failures --- src/mono/wasm/build/WasmApp.targets | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index d4fab9784c621..d805ffc44249b 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -130,8 +130,6 @@ <_RuntimeConfigJsonFileExistance Condition="Exists('$(_WasmRuntimeConfigFilePath)')">true - - <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" /> From 9bcb10a6a821d138806167659870e2c7bababbe0 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 5 Aug 2021 14:27:10 -0400 Subject: [PATCH 24/29] Update tests base on feedback --- .../Wasm.Build.Tests/BuildTestBase.cs | 8 ++----- .../Wasm.Build.Tests/WasmBuildAppTest.cs | 22 ++----------------- 2 files changed, 4 insertions(+), 26 deletions(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs index c8a41fa7f946a..6d08fe8512461 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/BuildTestBase.cs @@ -271,8 +271,7 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp bool hasIcudt = true, bool useCache = true, bool expectSuccess = true, - bool createProject = true, - bool createCsProject = true) + bool createProject = true) { if (useCache && _buildContext.TryGetBuildFor(buildArgs, out BuildProduct? product)) { @@ -292,10 +291,7 @@ protected static BuildArgs ExpandBuildArgs(BuildArgs buildArgs, string extraProp InitProjectDir(_projectDir); initProject?.Invoke(); - if (createCsProject) - { - File.WriteAllText(Path.Combine(_projectDir, $"{buildArgs.ProjectName}.csproj"), buildArgs.ProjectFileContents); - } + File.WriteAllText(Path.Combine(_projectDir, $"{buildArgs.ProjectName}.csproj"), buildArgs.ProjectFileContents); File.Copy(Path.Combine(AppContext.BaseDirectory, "runtime-test.js"), Path.Combine(_projectDir, "runtime-test.js")); } else if (_projectDir is null) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs index e44000141da45..f02f9959f8e7e 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs @@ -127,7 +127,7 @@ public void PropertiesFromRuntimeConfigJson(BuildArgs buildArgs, RunHost host, s public void PropertiesFromCsproj(BuildArgs buildArgs, RunHost host, string id) { buildArgs = buildArgs with { ProjectName = $"runtime_config_csproj_{buildArgs.Config}_{buildArgs.AOT}" }; - buildArgs = ExpandBuildArgs(buildArgs); + buildArgs = ExpandBuildArgs(buildArgs, extraProperties: "20"); string programText = @" using System; @@ -138,31 +138,13 @@ public void PropertiesFromCsproj(BuildArgs buildArgs, RunHost host, string id) return 42; "; - string csprojFile = @" - - - net6.0 - Exe - true - runtime-test.js - 20 - - - - - - - "; - BuildProject(buildArgs, initProject: () => { File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), programText); - File.WriteAllText(Path.Combine(_projectDir!, $"{buildArgs.ProjectName}.csproj"), csprojFile); }, id: id, - dotnetWasmFromRuntimePack: !(buildArgs.AOT || buildArgs.Config == "Release"), - createCsProject: false); + dotnetWasmFromRuntimePack: !(buildArgs.AOT || buildArgs.Config == "Release"); RunAndTestWasmApp(buildArgs, expectedExitCode: 42, test: output => Assert.Contains("System.Threading.ThreadPool.MaxThreads: 20", output), host: host, id: id); From ee244bae787a731e6d57b243bf7039414fd540f5 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 5 Aug 2021 15:42:27 -0400 Subject: [PATCH 25/29] Add missing ")" --- src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs index f02f9959f8e7e..412bf4a3da2ea 100644 --- a/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs +++ b/src/tests/BuildWasmApps/Wasm.Build.Tests/WasmBuildAppTest.cs @@ -144,7 +144,7 @@ public void PropertiesFromCsproj(BuildArgs buildArgs, RunHost host, string id) File.WriteAllText(Path.Combine(_projectDir!, "Program.cs"), programText); }, id: id, - dotnetWasmFromRuntimePack: !(buildArgs.AOT || buildArgs.Config == "Release"); + dotnetWasmFromRuntimePack: !(buildArgs.AOT || buildArgs.Config == "Release")); RunAndTestWasmApp(buildArgs, expectedExitCode: 42, test: output => Assert.Contains("System.Threading.ThreadPool.MaxThreads: 20", output), host: host, id: id); From c909ef2249098fbcc2c37818d6251f8df9b452a5 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 5 Aug 2021 20:02:27 -0400 Subject: [PATCH 26/29] Add one more condition --- src/mono/wasm/build/WasmApp.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index d805ffc44249b..f4fe307eab4b7 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -125,7 +125,7 @@ $([MSBuild]::NormalizeDirectory($(WasmAppDir))) - <_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll'">%(WasmAssembliesToBundle.Identity) + <_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll' and $(WasmGenerateAppBundle) == 'true'">%(WasmAssembliesToBundle.Identity) <_WasmRuntimeConfigFilePath>$([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) <_RuntimeConfigJsonFileExistance Condition="Exists('$(_WasmRuntimeConfigFilePath)')">true From c0a7981e677e6882bd8dd9b9e3f885322c612804 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 5 Aug 2021 20:24:45 -0400 Subject: [PATCH 27/29] More format changes --- src/mono/wasm/build/WasmApp.targets | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index f4fe307eab4b7..bffbb412fb03a 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -83,8 +83,6 @@ false <_BeforeWasmBuildAppDependsOn /> - - <_RuntimeConfigJsonFileExistance>false @@ -127,9 +125,10 @@ <_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll' and $(WasmGenerateAppBundle) == 'true'">%(WasmAssembliesToBundle.Identity) <_WasmRuntimeConfigFilePath>$([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) - <_RuntimeConfigJsonFileExistance Condition="Exists('$(_WasmRuntimeConfigFilePath)')">true + + <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" /> @@ -142,25 +141,25 @@ - + - $([System.IO.Path]::GetDirectoryName($(_MainAssemblyPath)))\runtimeconfig.bin + <_ParsedRuntimeConfigFilePath>$([System.IO.Path]::GetDirectoryName($(_MainAssemblyPath)))\runtimeconfig.bin - - + <_RuntimeConfigReservedProperties Include="RUNTIME_IDENTIFIER"/> + <_RuntimeConfigReservedProperties Include="APP_CONTEXT_BASE_DIRECTORY"/> + OutputFile="$(_ParsedRuntimeConfigFilePath)" + RuntimeConfigReservedProperties="@(_RuntimeConfigReservedProperties)"> - + From 29818f50a5023944f757b073606495b8bbeef7b4 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Thu, 5 Aug 2021 22:34:46 -0400 Subject: [PATCH 28/29] Better error handling --- src/mono/wasm/build/WasmApp.targets | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets index bffbb412fb03a..32c55ee12bf6b 100644 --- a/src/mono/wasm/build/WasmApp.targets +++ b/src/mono/wasm/build/WasmApp.targets @@ -124,10 +124,12 @@ $([MSBuild]::NormalizeDirectory($(WasmAppDir))) <_MainAssemblyPath Condition="'%(WasmAssembliesToBundle.FileName)' == $(AssemblyName) and '%(WasmAssembliesToBundle.Extension)' == '.dll' and $(WasmGenerateAppBundle) == 'true'">%(WasmAssembliesToBundle.Identity) - <_WasmRuntimeConfigFilePath>$([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) + <_WasmRuntimeConfigFilePath Condition="$(_MainAssemblyPath) != ''">$([System.IO.Path]::ChangeExtension($(_MainAssemblyPath), '.runtimeconfig.json')) - + + <_WasmAssembliesInternal Include="@(WasmAssembliesToBundle->Distinct())" /> From 2fddcba6e1c83fe337c0702f56bac6d16b4decaa Mon Sep 17 00:00:00 2001 From: Ankit Jain Date: Fri, 6 Aug 2021 00:43:53 -0400 Subject: [PATCH 29/29] [wasm] Fix build for a test support project This fixes the build for ApplyUpdateReferencedAssembly.csproj, which is a support project for HotReload wasm functional test. ``` D:\workspace\_work\1\s\src\mono\wasm\build\WasmApp.targets(131,5): error : Could not find D:\workspace\_work\1\s\artifacts\bin\ApplyUpdateReferencedAssembly\net6.0-Release\browser-wasm\publish\ApplyUpdateReferencedAssembly.runtimeconfig.json for D:\workspace\_work\1\s\artifacts\bin\ApplyUpdateReferencedAssembly\net6.0-Release\browser-wasm\publish\ApplyUpdateReferencedAssembly.dll. [D:\workspace\_work\1\s\src\tests\FunctionalTests\WebAssembly\Browser\HotReload\ApplyUpdateReferencedAssembly\ApplyUpdateReferencedAssembly.csproj] ``` The wasm targets should be run at all for this project. But they are run because they get imported by tests.wasm.targets, which gets imported because `$(IsTestProject)=true`. The csproj has `$(IsTestProject)=false`, and `$(IsTestSupportProject)=true`, which should mean that the test.props/targets don't get imported. But the import is conditioned on `$(EnableTestSupport)`, which gets set in `src/libraries/Directory.Build.props`. And that means setting `$(IsTestProject)=true` in the csproj is too late. So, instead, set that in a `Directory.Build.props`. And also, ensure that the `Directory.Build.props` for functional tests doesn't override the value! --- src/tests/FunctionalTests/Directory.Build.props | 2 +- .../ApplyUpdateReferencedAssembly.csproj | 2 -- .../ApplyUpdateReferencedAssembly/Directory.Build.props | 7 +++++++ 3 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 src/tests/FunctionalTests/WebAssembly/Browser/HotReload/ApplyUpdateReferencedAssembly/Directory.Build.props diff --git a/src/tests/FunctionalTests/Directory.Build.props b/src/tests/FunctionalTests/Directory.Build.props index a85fa69ca8edd..ca9552dc7812c 100644 --- a/src/tests/FunctionalTests/Directory.Build.props +++ b/src/tests/FunctionalTests/Directory.Build.props @@ -3,7 +3,7 @@ false false true - true + true true diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/ApplyUpdateReferencedAssembly/ApplyUpdateReferencedAssembly.csproj b/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/ApplyUpdateReferencedAssembly/ApplyUpdateReferencedAssembly.csproj index a7a21112bfc49..b32d3ba167d61 100644 --- a/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/ApplyUpdateReferencedAssembly/ApplyUpdateReferencedAssembly.csproj +++ b/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/ApplyUpdateReferencedAssembly/ApplyUpdateReferencedAssembly.csproj @@ -3,8 +3,6 @@ true deltascript.json library - false - true false true diff --git a/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/ApplyUpdateReferencedAssembly/Directory.Build.props b/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/ApplyUpdateReferencedAssembly/Directory.Build.props new file mode 100644 index 0000000000000..1a524b2700d53 --- /dev/null +++ b/src/tests/FunctionalTests/WebAssembly/Browser/HotReload/ApplyUpdateReferencedAssembly/Directory.Build.props @@ -0,0 +1,7 @@ + + + false + true + + +