From 5bab843103f2f3d147d939e7af1ab1682bb55bb6 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 18 Jun 2021 16:51:01 -0400 Subject: [PATCH 01/49] Work in progress: new Sdk that selects mono runtime components --- ...ime.MonoRuntimeComponentSelect.Sdk.pkgproj | 47 ++++++++++++++++ .../Sdk/Sdk.targets | 3 + .../Sdk/component-manifest.props.in | 10 ++++ .../Sdk/component-manifest.sample.proj | 31 +++++++++++ .../Sdk/component-manifest.targets | 55 +++++++++++++++++++ 5 files changed, 146 insertions(+) create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk.pkgproj create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/Sdk.targets create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.sample.proj create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.targets diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk.pkgproj new file mode 100644 index 00000000000000..f62a06fe2dec95 --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk.pkgproj @@ -0,0 +1,47 @@ + + + + + Provides the tasks+targets, for consumption by mono based workloads + + + + + + + + + + + + + + + $(IntermediateOutputPath)WorkloadManifest.json + + + + + + + <_ComponentManifestValue Include="TemplateMonoRuntimeComponentLinking" Value="static" /> + <_ComponentManifestValue Include="TemplateMonoRuntimeComponentSharedLibExt" Value=".dylib" /> + <_ComponentManifestValue Include="TemplateMonoRuntimeComponentStaticLibExt" Value=".a" /> + <_ComponentManifestValue Include="TemplateMonoRuntimeAvailableComponents" Value="hot_reload;diagnostic_tracing" /> + + + + + + + + + + + + + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/Sdk.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/Sdk.targets new file mode 100644 index 00000000000000..b5350d17f1553a --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/Sdk.targets @@ -0,0 +1,3 @@ + + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in new file mode 100644 index 00000000000000..57f87a4cad8a4a --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in @@ -0,0 +1,10 @@ + + + <_MonoRuntimeComponentLinking>${TemplateMonoRuntimeComponentLinking} + <_MonoRuntimeComponentSharedLibExt>${TemplateMonoRuntimeComponentSharedLibExt}<_MonoRuntimeComponentSharedLibExt> + <_MonoRuntimeComponentStaticLibExt>${TemplateMonoRuntimeComponentStaticLibExt}<_MonoRuntimeComponentStaticLibExt> + + + <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" /> + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.sample.proj b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.sample.proj new file mode 100644 index 00000000000000..ee5aeed4597da5 --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.sample.proj @@ -0,0 +1,31 @@ + + + <_MonoRuntimeComponentSharedLibExt>.dylib + <_MonoRuntimeComponentStaticLibExt>.a + <_MonoRuntimeComponentLinking Condition="'$(_MonoRuntimeComponentLinking)' == ''">dynamic + + + + + <_MonoRuntimeAvailableComponents Include="hot_reload;diagnostics_tracing" /> + + + + + + + + <_MonoComponent Include="hot_reload"/> + + + + + + + + + + + + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.targets new file mode 100644 index 00000000000000..0c5adba04f40a4 --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.targets @@ -0,0 +1,55 @@ + + + + + + + <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> + libmono-component-%(Identity)(_MonoRuntimeComponentSharedLibExt) + + + + <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> + libmono-component-%(Identity)$(_MonoRuntimeComponentStaticLibExt) + libmono-component-%(Identity)-stub$(_MonoRuntimeComponentStaticLibExt) + + + + + + + + + + + + + + + + + <_MonoRuntimeSelectedComponents Include="@(_MonoRuntimeComponentName)" Condition="'@(_MonoRuntimeComponentName)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> + <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedComponents.ComponentLib)"> + $(_MonoRuntimeComponentLinking) + false + %(_MonoRuntimeSelectedComponents.Identity) + + + <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentName)" /> + + + + + <_MonoRuntimeSelectedStubComponents Include="@(_MonoRuntimeComponentName)" Exclude="@(_MonoComponent)" /> + <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedStubComponents.ComponentStubLib)"> + $(_MonoRuntimeComponentLinking) + true + %(_MonoRuntimeSelectedStubComponents.Identity) + + + + + + + From fad61015fdf36947cea20b117698fb785868570a Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Mon, 21 Jun 2021 10:38:33 -0400 Subject: [PATCH 02/49] Add props and targets description to the components doc --- docs/design/mono/components.md | 48 ++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/docs/design/mono/components.md b/docs/design/mono/components.md index 2dc982dbeaaf1a..4bf6c6a2291805 100644 --- a/docs/design/mono/components.md +++ b/docs/design/mono/components.md @@ -164,10 +164,10 @@ To implement `feature_X` as a component. Carry out the following steps: { feature_X_cleanup }, feature_X_hello, }; - + MonoComponentFeatureX * mono_component_feature_X_init (void) { return &fn_table; } - + void feature_X_cleanup (MonoComponent *self) { static int cleaned = 0; @@ -207,10 +207,10 @@ To implement `feature_X` as a component. Carry out the following steps: { feature_X_cleanup }, feature_X_hello, }; - + MonoComponentFeatureX * mono_component_feature_X_init (void) { return &fn_table; } - + void feature_X_cleanup (MonoComponent *self) { static int cleaned = 0; @@ -229,7 +229,7 @@ To implement `feature_X` as a component. Carry out the following steps: ```c MonoComponentFeatureX* mono_component_feature_X (void); - + ... MonoComponentFeatureX* mono_component_feature_X_stub_init (void); @@ -238,7 +238,7 @@ To implement `feature_X` as a component. Carry out the following steps: * Add an entry to the `components` list to load the component to `mono/metadata/components.c`, and also implement the getter for the component: ```c static MonoComponentFeatureX *feature_X = NULL; - + MonoComponentEntry components[] = { ... {"feature_X", "feature_X", COMPONENT_INIT_FUNC (feature_X), (MonoComponent**)&feature_X, NULL }, @@ -265,16 +265,30 @@ To implement `feature_X` as a component. Carry out the following steps: ## Detailed design - Packaging and runtime packs The components are building blocks to put together a functional runtime. The -runtime pack includes the base runtime and the components and additional -properties and targets that enable the workload to construct a runtime for -various scenarios. - -In each runtime pack we include: +runtime pack includes the base runtime and the components. The mono workload +includes the runtime pack and additional tasks, properties and targets that +enable the workload to construct a runtime for various scenarios. + +For the target RID, we expose: + +- `$(_MonoRuntimeComponentLinking)` set to either `'static'` or `'dynamic'` + depending on whether the current runtime pack for the current target includes + runtime components as static archives or as shared libraries, respectively. +- `$(_MonoRuntimeComponentSharedLibExt)` and `$(_MonoRuntimeComponentStaticLibExt)` set to the file extension of the runtime components for the current target (ie, `'.a', '.so', '.dylib'` etc). +- `@(_MonoRuntimeAvailableComponents)` a list of component names without the + `lib` prefix (if any) or file extensions. For example: `'hot_reload; + diagnostics_tracing'`. +- The target `_MonoSelectRuntimeComponents` that has the following inputs and outputs: + - input `@(_MonoComponent)` : a list of components that a workload wants to use for the current app. It is an error + if this specifies any unknown component name. + - output `@(_MonoRuntimeSelectedComponents)` and `@(_MonoRuntimeSelectedStubComponents)` The names of the components + that were (resp, were not) selected. For example `'hot_reload; diagnostics_tracing'`. Each item has two metadata + properties `ComponentLib` and `ComponentStubLib` (which may be empty) that specify the name of the static or dynamic + library of the compponent. This is not the main output of the target, it's primarily for debugging. + - output `@(_MonoRuntimeComponentLink)` a list of library names (relative to the `native/` subdirectory of the runtime + pack) that (for dynamic components) must be placed next to the runtime in the application bundle, or (for static + components) that must be linked with the runtime to enable the components' functionality. Each item in the list has + metadata `ComponentName` (e.g. `'hot_reload'`), `IsStub` (`true` or `false`), `Linking` (`'static'` or `'dynamic'`). + This output should be used by the workloads when linking the app and runtime. -- The compiled compnents for the apropriate host architectures in a well-known subdirectory -- An MSBuild props file that defines an item group that list each component name and has metadata that indicates: - - the path to the component in the runtime pack - - the path to the stub component in the runtime pack (if components are static) -- An MSBuild targets file that defines targets to copy a specified set of components to the app publish folder (if components are dynamic); or to link the runtime together with stubs and a set of enabled components (if components are static) -** TODO ** Write this up in more detail From cb34023469957d1f744719f57ff1f454329674a8 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 22 Jun 2021 10:36:53 -0400 Subject: [PATCH 03/49] condition the _MonoRuntimeAvailableComponents by RuntimeIdentifier --- .../Sdk/component-manifest.props.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in index 57f87a4cad8a4a..5fc0834151c9aa 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in @@ -4,7 +4,7 @@ <_MonoRuntimeComponentSharedLibExt>${TemplateMonoRuntimeComponentSharedLibExt}<_MonoRuntimeComponentSharedLibExt> <_MonoRuntimeComponentStaticLibExt>${TemplateMonoRuntimeComponentStaticLibExt}<_MonoRuntimeComponentStaticLibExt> - + <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" /> From efc5caf8fe26e5507f9bfa6ed6fa505f8788a376 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 22 Jun 2021 21:37:27 -0400 Subject: [PATCH 04/49] [cmake] Write a component-manifest.props file during build If we're not building a mono aot cross compiler, generate a component-manifest.props file in artifacts/obj/mono// that indicates if the host will use static or dynamic components, and a list of the available components, and the properties for constructing their names. --- src/mono/mono/component/CMakeLists.txt | 19 +++++++++++++++++++ .../component/component-manifest.props.in | 10 ++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/mono/mono/component/component-manifest.props.in diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 62ab5b34528328..6869901b9b91f7 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -172,6 +172,25 @@ foreach(component IN LISTS components) list(APPEND mono-components-stub-objects $) endforeach() +if(NOT MONO_CROSS_COMPILE) + # Write a component-manifest.props file in the artifacts/obj/mono// directory + set(TemplateMonoRuntimeComponentSharedLibExt "${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(TemplateMonoRuntimeComponentStaticLibExt "${CMAKE_STATIC_LIBRARY_SUFFIX}") + file(READ "${MONO_COMPONENT_PATH}/component-manifest.props.in" MONO_COMPONENT_MANIFEST_STR) + if(DISABLE_COMPONENTS) + set(TemplateMonoRuntimeComponentLinking "static") + set(TemplateMonoRuntimeAvailableComponents "") + else() + list(JOIN components ";" TemplateMonoRuntimeAvailableComponents) + if(STATIC_COMPONENTS) + set(TemplateMonoRuntimeComponentLinking "static") + else() + set(TemplateMonoRuntimeComponentLinking "dynamic") + endif() + endif() + # without the ../.. the file would go in artifacts/obj/mono//mono/mini + file(CONFIGURE OUTPUT ../../component-manifest.props CONTENT ${MONO_COMPONENT_MANIFEST_STR}) +endif() # component tests set(MONO_EVENTPIPE_TEST_SOURCE_PATH "${MONO_EVENTPIPE_SHIM_SOURCE_PATH}/test") diff --git a/src/mono/mono/component/component-manifest.props.in b/src/mono/mono/component/component-manifest.props.in new file mode 100644 index 00000000000000..ed715ec7db717c --- /dev/null +++ b/src/mono/mono/component/component-manifest.props.in @@ -0,0 +1,10 @@ + + + <_MonoRuntimeComponentLinking>${TemplateMonoRuntimeComponentLinking} + <_MonoRuntimeComponentSharedLibExt>${TemplateMonoRuntimeComponentSharedLibExt}<_MonoRuntimeComponentSharedLibExt> + <_MonoRuntimeComponentStaticLibExt>${TemplateMonoRuntimeComponentStaticLibExt}<_MonoRuntimeComponentStaticLibExt> + + + <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" /> + + From d974927a92ac5d902e1d4fd6ef175615ad6aa7bc Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 22 Jun 2021 23:08:39 -0400 Subject: [PATCH 05/49] Build Microsoft.NETCore.App.Runtime.Mono..Sdk shared framework nuget It seems to also generate a symbols nuget. And in the nuget there's a tools/mono-sdk-what-is-this.deps.json file from the SharedFrameworkHostFileNameOverride property. It would be nice to exclude that stuff. --- eng/Subsets.props | 1 + .../Microsoft.NETCore.App.Mono.Sdk.sfxproj | 28 ++++++++++ .../Microsoft.NETCoreApp.Mono.Sdk.Sdk.props | 4 ++ .../Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets | 55 +++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj create mode 100644 src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.props create mode 100644 src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets diff --git a/eng/Subsets.props b/eng/Subsets.props index 105b34254c6c2b..4dc8bc4e6c71c1 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -321,6 +321,7 @@ + diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj new file mode 100644 index 00000000000000..912d5c87eeb376 --- /dev/null +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj @@ -0,0 +1,28 @@ + + + + + true + true + RuntimePack + Microsoft.NETCore.App.Mono.Sdk + Microsoft.NETCore.App.Runtime.Mono.$(RuntimeIdentifier).Sdk + + dotnet-mono-sdk + + mono-sdk-what-is-this + + false + false + tools/ + true + $([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'mono', '$(TargetOS).$(TargetArchitecture).$(MonoConfiguration)')) + + + + + + + + + diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.props new file mode 100644 index 00000000000000..a8da6f76b7171c --- /dev/null +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.props @@ -0,0 +1,4 @@ + + + + diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets new file mode 100644 index 00000000000000..0c5adba04f40a4 --- /dev/null +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets @@ -0,0 +1,55 @@ + + + + + + + <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> + libmono-component-%(Identity)(_MonoRuntimeComponentSharedLibExt) + + + + <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> + libmono-component-%(Identity)$(_MonoRuntimeComponentStaticLibExt) + libmono-component-%(Identity)-stub$(_MonoRuntimeComponentStaticLibExt) + + + + + + + + + + + + + + + + + <_MonoRuntimeSelectedComponents Include="@(_MonoRuntimeComponentName)" Condition="'@(_MonoRuntimeComponentName)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> + <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedComponents.ComponentLib)"> + $(_MonoRuntimeComponentLinking) + false + %(_MonoRuntimeSelectedComponents.Identity) + + + <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentName)" /> + + + + + <_MonoRuntimeSelectedStubComponents Include="@(_MonoRuntimeComponentName)" Exclude="@(_MonoComponent)" /> + <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedStubComponents.ComponentStubLib)"> + $(_MonoRuntimeComponentLinking) + true + %(_MonoRuntimeSelectedStubComponents.Identity) + + + + + + + From cc468e384e47348870d67bb3d3a1da162fcfb1ed Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 22 Jun 2021 23:52:09 -0400 Subject: [PATCH 06/49] put the compoonent-manifest.targets into the Sdk --- .../Microsoft.NETCore.App.Mono.Sdk.sfxproj | 1 + .../Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets | 54 +----------------- src/mono/mono/component/CMakeLists.txt | 2 + .../mono/component/component-manifest.targets | 55 +++++++++++++++++++ 4 files changed, 59 insertions(+), 53 deletions(-) create mode 100644 src/mono/mono/component/component-manifest.targets diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj index 912d5c87eeb376..4fdff4d9aa05b5 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj @@ -23,6 +23,7 @@ + diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets index 0c5adba04f40a4..b5350d17f1553a 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets @@ -1,55 +1,3 @@ - - - - - - <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)(_MonoRuntimeComponentSharedLibExt) - - - - <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)$(_MonoRuntimeComponentStaticLibExt) - libmono-component-%(Identity)-stub$(_MonoRuntimeComponentStaticLibExt) - - - - - - - - - - - - - - - - - <_MonoRuntimeSelectedComponents Include="@(_MonoRuntimeComponentName)" Condition="'@(_MonoRuntimeComponentName)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> - <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedComponents.ComponentLib)"> - $(_MonoRuntimeComponentLinking) - false - %(_MonoRuntimeSelectedComponents.Identity) - - - <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentName)" /> - - - - - <_MonoRuntimeSelectedStubComponents Include="@(_MonoRuntimeComponentName)" Exclude="@(_MonoComponent)" /> - <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedStubComponents.ComponentStubLib)"> - $(_MonoRuntimeComponentLinking) - true - %(_MonoRuntimeSelectedStubComponents.Identity) - - - - - - + diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 6869901b9b91f7..9f76a8c8a5d592 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -190,6 +190,8 @@ if(NOT MONO_CROSS_COMPILE) endif() # without the ../.. the file would go in artifacts/obj/mono//mono/mini file(CONFIGURE OUTPUT ../../component-manifest.props CONTENT ${MONO_COMPONENT_MANIFEST_STR}) + # without the .. this goes to artifacts/obj/mono//out/ + install(FILES "${MONO_COMPONENT_PATH}/component-manifest.targets" DESTINATION ..) endif() # component tests diff --git a/src/mono/mono/component/component-manifest.targets b/src/mono/mono/component/component-manifest.targets new file mode 100644 index 00000000000000..0c5adba04f40a4 --- /dev/null +++ b/src/mono/mono/component/component-manifest.targets @@ -0,0 +1,55 @@ + + + + + + + <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> + libmono-component-%(Identity)(_MonoRuntimeComponentSharedLibExt) + + + + <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> + libmono-component-%(Identity)$(_MonoRuntimeComponentStaticLibExt) + libmono-component-%(Identity)-stub$(_MonoRuntimeComponentStaticLibExt) + + + + + + + + + + + + + + + + + <_MonoRuntimeSelectedComponents Include="@(_MonoRuntimeComponentName)" Condition="'@(_MonoRuntimeComponentName)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> + <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedComponents.ComponentLib)"> + $(_MonoRuntimeComponentLinking) + false + %(_MonoRuntimeSelectedComponents.Identity) + + + <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentName)" /> + + + + + <_MonoRuntimeSelectedStubComponents Include="@(_MonoRuntimeComponentName)" Exclude="@(_MonoComponent)" /> + <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedStubComponents.ComponentStubLib)"> + $(_MonoRuntimeComponentLinking) + true + %(_MonoRuntimeSelectedStubComponents.Identity) + + + + + + + From d5aae8fc8f9fe11add949311bfab72dc9f5cf6c9 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 22 Jun 2021 23:53:40 -0400 Subject: [PATCH 07/49] delete WIP in mono/nuget/ --- ...ime.MonoRuntimeComponentSelect.Sdk.pkgproj | 47 ---------------- .../Sdk/Sdk.targets | 3 - .../Sdk/component-manifest.props.in | 10 ---- .../Sdk/component-manifest.sample.proj | 31 ----------- .../Sdk/component-manifest.targets | 55 ------------------- 5 files changed, 146 deletions(-) delete mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk.pkgproj delete mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/Sdk.targets delete mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in delete mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.sample.proj delete mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.targets diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk.pkgproj deleted file mode 100644 index f62a06fe2dec95..00000000000000 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk.pkgproj +++ /dev/null @@ -1,47 +0,0 @@ - - - - - Provides the tasks+targets, for consumption by mono based workloads - - - - - - - - - - - - - - - $(IntermediateOutputPath)WorkloadManifest.json - - - - - - - <_ComponentManifestValue Include="TemplateMonoRuntimeComponentLinking" Value="static" /> - <_ComponentManifestValue Include="TemplateMonoRuntimeComponentSharedLibExt" Value=".dylib" /> - <_ComponentManifestValue Include="TemplateMonoRuntimeComponentStaticLibExt" Value=".a" /> - <_ComponentManifestValue Include="TemplateMonoRuntimeAvailableComponents" Value="hot_reload;diagnostic_tracing" /> - - - - - - - - - - - - - - diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/Sdk.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/Sdk.targets deleted file mode 100644 index b5350d17f1553a..00000000000000 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/Sdk.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in deleted file mode 100644 index 5fc0834151c9aa..00000000000000 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.props.in +++ /dev/null @@ -1,10 +0,0 @@ - - - <_MonoRuntimeComponentLinking>${TemplateMonoRuntimeComponentLinking} - <_MonoRuntimeComponentSharedLibExt>${TemplateMonoRuntimeComponentSharedLibExt}<_MonoRuntimeComponentSharedLibExt> - <_MonoRuntimeComponentStaticLibExt>${TemplateMonoRuntimeComponentStaticLibExt}<_MonoRuntimeComponentStaticLibExt> - - - <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" /> - - diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.sample.proj b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.sample.proj deleted file mode 100644 index ee5aeed4597da5..00000000000000 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.sample.proj +++ /dev/null @@ -1,31 +0,0 @@ - - - <_MonoRuntimeComponentSharedLibExt>.dylib - <_MonoRuntimeComponentStaticLibExt>.a - <_MonoRuntimeComponentLinking Condition="'$(_MonoRuntimeComponentLinking)' == ''">dynamic - - - - - <_MonoRuntimeAvailableComponents Include="hot_reload;diagnostics_tracing" /> - - - - - - - - <_MonoComponent Include="hot_reload"/> - - - - - - - - - - - - - diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.targets deleted file mode 100644 index 0c5adba04f40a4..00000000000000 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoRuntimeComponentSelect.Sdk/Sdk/component-manifest.targets +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)(_MonoRuntimeComponentSharedLibExt) - - - - <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)$(_MonoRuntimeComponentStaticLibExt) - libmono-component-%(Identity)-stub$(_MonoRuntimeComponentStaticLibExt) - - - - - - - - - - - - - - - - - <_MonoRuntimeSelectedComponents Include="@(_MonoRuntimeComponentName)" Condition="'@(_MonoRuntimeComponentName)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> - <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedComponents.ComponentLib)"> - $(_MonoRuntimeComponentLinking) - false - %(_MonoRuntimeSelectedComponents.Identity) - - - <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentName)" /> - - - - - <_MonoRuntimeSelectedStubComponents Include="@(_MonoRuntimeComponentName)" Exclude="@(_MonoComponent)" /> - <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedStubComponents.ComponentStubLib)"> - $(_MonoRuntimeComponentLinking) - true - %(_MonoRuntimeSelectedStubComponents.Identity) - - - - - - - From b213b70bb33f7cb47c0dc8f19ca6a901744a6493 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 23 Jun 2021 00:01:27 -0400 Subject: [PATCH 08/49] fixup static component names in component-manifest.targets --- src/mono/mono/component/component-manifest.targets | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/component/component-manifest.targets b/src/mono/mono/component/component-manifest.targets index 0c5adba04f40a4..b786af3a19a189 100644 --- a/src/mono/mono/component/component-manifest.targets +++ b/src/mono/mono/component/component-manifest.targets @@ -10,8 +10,8 @@ <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)$(_MonoRuntimeComponentStaticLibExt) - libmono-component-%(Identity)-stub$(_MonoRuntimeComponentStaticLibExt) + libmono-component-%(Identity)-static$(_MonoRuntimeComponentStaticLibExt) + libmono-component-%(Identity)-stub-static$(_MonoRuntimeComponentStaticLibExt) From 731a4191c61d60bf1a9471beb3739591bc939eab Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 23 Jun 2021 00:02:48 -0400 Subject: [PATCH 09/49] delete fixed fixme --- .../Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj index 4fdff4d9aa05b5..dcd9efcd99e9ac 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj @@ -20,7 +20,6 @@ - From 82dd4f2b721de5fb6a5b0080092cf9ad9e74acd4 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 23 Jun 2021 00:06:03 -0400 Subject: [PATCH 10/49] add missing $ --- src/mono/mono/component/component-manifest.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/component/component-manifest.targets b/src/mono/mono/component/component-manifest.targets index b786af3a19a189..36d17e33a3a454 100644 --- a/src/mono/mono/component/component-manifest.targets +++ b/src/mono/mono/component/component-manifest.targets @@ -5,7 +5,7 @@ <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)(_MonoRuntimeComponentSharedLibExt) + libmono-component-%(Identity)$(_MonoRuntimeComponentSharedLibExt) From a0a3803506ae83a4be1aecc6f99d8c1970d09586 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 23 Jun 2021 00:10:08 -0400 Subject: [PATCH 11/49] fix whitespace --- .../mono/component/component-manifest.targets | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/mono/mono/component/component-manifest.targets b/src/mono/mono/component/component-manifest.targets index 36d17e33a3a454..b0a2553dc7daae 100644 --- a/src/mono/mono/component/component-manifest.targets +++ b/src/mono/mono/component/component-manifest.targets @@ -5,13 +5,13 @@ <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)$(_MonoRuntimeComponentSharedLibExt) + libmono-component-%(Identity)$(_MonoRuntimeComponentSharedLibExt) <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)-static$(_MonoRuntimeComponentStaticLibExt) - libmono-component-%(Identity)-stub-static$(_MonoRuntimeComponentStaticLibExt) + libmono-component-%(Identity)-static$(_MonoRuntimeComponentStaticLibExt) + libmono-component-%(Identity)-stub-static$(_MonoRuntimeComponentStaticLibExt) @@ -30,9 +30,9 @@ <_MonoRuntimeSelectedComponents Include="@(_MonoRuntimeComponentName)" Condition="'@(_MonoRuntimeComponentName)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedComponents.ComponentLib)"> - $(_MonoRuntimeComponentLinking) - false - %(_MonoRuntimeSelectedComponents.Identity) + $(_MonoRuntimeComponentLinking) + false + %(_MonoRuntimeSelectedComponents.Identity) <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentName)" /> @@ -42,14 +42,14 @@ <_MonoRuntimeSelectedStubComponents Include="@(_MonoRuntimeComponentName)" Exclude="@(_MonoComponent)" /> <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedStubComponents.ComponentStubLib)"> - $(_MonoRuntimeComponentLinking) - true - %(_MonoRuntimeSelectedStubComponents.Identity) + $(_MonoRuntimeComponentLinking) + true + %(_MonoRuntimeSelectedStubComponents.Identity) + Text="_MonoComponent item list includes components '@(_MonoRuntimeSelectedMissingComponents)' which are not defined in the runtime pack. Runtime pack includes '@(_MonoRuntimeComponentName)'" /> From a440aa2520389ef857e6e1d56d8c6937d3469cf5 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 23 Jun 2021 09:05:04 -0400 Subject: [PATCH 12/49] [cmake] switch to configure_file instead of file(CONFIGURE) --- src/mono/mono/component/CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 9f76a8c8a5d592..628df7b32b408c 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -173,10 +173,8 @@ foreach(component IN LISTS components) endforeach() if(NOT MONO_CROSS_COMPILE) - # Write a component-manifest.props file in the artifacts/obj/mono// directory set(TemplateMonoRuntimeComponentSharedLibExt "${CMAKE_SHARED_LIBRARY_SUFFIX}") set(TemplateMonoRuntimeComponentStaticLibExt "${CMAKE_STATIC_LIBRARY_SUFFIX}") - file(READ "${MONO_COMPONENT_PATH}/component-manifest.props.in" MONO_COMPONENT_MANIFEST_STR) if(DISABLE_COMPONENTS) set(TemplateMonoRuntimeComponentLinking "static") set(TemplateMonoRuntimeAvailableComponents "") @@ -188,8 +186,9 @@ if(NOT MONO_CROSS_COMPILE) set(TemplateMonoRuntimeComponentLinking "dynamic") endif() endif() + # Write a component-manifest.props file in the artifacts/obj/mono// directory # without the ../.. the file would go in artifacts/obj/mono//mono/mini - file(CONFIGURE OUTPUT ../../component-manifest.props CONTENT ${MONO_COMPONENT_MANIFEST_STR}) + configure_file( "${MONO_COMPONENT_PATH}/component-manifest.props.in" "../../component-manifest.props") # without the .. this goes to artifacts/obj/mono//out/ install(FILES "${MONO_COMPONENT_PATH}/component-manifest.targets" DESTINATION ..) endif() From 434a38b1d8a729bf423a286cbafe29c76b7c68a0 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 23 Jun 2021 09:05:30 -0400 Subject: [PATCH 13/49] add missing trailing slashes in .props.in file --- src/mono/mono/component/component-manifest.props.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/component/component-manifest.props.in b/src/mono/mono/component/component-manifest.props.in index ed715ec7db717c..b87b183efb5aa3 100644 --- a/src/mono/mono/component/component-manifest.props.in +++ b/src/mono/mono/component/component-manifest.props.in @@ -1,8 +1,8 @@ <_MonoRuntimeComponentLinking>${TemplateMonoRuntimeComponentLinking} - <_MonoRuntimeComponentSharedLibExt>${TemplateMonoRuntimeComponentSharedLibExt}<_MonoRuntimeComponentSharedLibExt> - <_MonoRuntimeComponentStaticLibExt>${TemplateMonoRuntimeComponentStaticLibExt}<_MonoRuntimeComponentStaticLibExt> + <_MonoRuntimeComponentSharedLibExt>${TemplateMonoRuntimeComponentSharedLibExt} + <_MonoRuntimeComponentStaticLibExt>${TemplateMonoRuntimeComponentStaticLibExt} <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" /> From 71c2376959beccf4b900e4632616775270696b77 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 23 Jun 2021 11:35:38 -0400 Subject: [PATCH 14/49] Add new Sdk packs to the workload manifest --- .../WorkloadManifest.json.in | 76 ++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in index 059efeed70ceaa..4aaa309cde2a81 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in @@ -8,6 +8,7 @@ "description": "Browser Runtime native performance tools", "packs": [ "Microsoft.NET.Runtime.WebAssembly.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.browser-wasm.Sdk", "Microsoft.NETCore.App.Runtime.Mono.browser-wasm", "Microsoft.NETCore.App.Runtime.AOT.Cross.browser-wasm", "Microsoft.NET.Runtime.Emscripten.Node", @@ -21,6 +22,10 @@ "abstract": true, "description": "Android Mono Runtime", "packs": [ + "Microsoft.NETCore.App.Runtime.Mono.android-arm.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.android-arm64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.android-x86.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.android-x64.Sdk", "Microsoft.NETCore.App.Runtime.Mono.android-arm", "Microsoft.NETCore.App.Runtime.Mono.android-arm64", "Microsoft.NETCore.App.Runtime.Mono.android-x64", @@ -45,6 +50,10 @@ "abstract": true, "description": "iOS Mono Runtime and AOT Workload", "packs": [ + "Microsoft.NETCore.App.Runtime.Mono.ios-arm.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Sdk", "Microsoft.NETCore.App.Runtime.Mono.ios-arm", "Microsoft.NETCore.App.Runtime.Mono.ios-arm64", "Microsoft.NETCore.App.Runtime.Mono.iossimulator", @@ -61,6 +70,8 @@ "abstract": true, "description": "MacCatalyst Mono Runtime and AOT Workload", "packs": [ + "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Sdk", "Microsoft.NETCore.App.Runtime.Mono.maccatalyst", "Microsoft.NETCore.App.Runtime.AOT.Cross.maccatalyst" ], @@ -71,6 +82,9 @@ "abstract": true, "description": "tvOS Mono Runtime and AOT Workload", "packs": [ + "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-arm64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-x64.Sdk", "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64", "Microsoft.NETCore.App.Runtime.Mono.tvossimulator", "Microsoft.NETCore.App.Runtime.AOT.Cross.tvos-arm64", @@ -117,6 +131,22 @@ "kind": "framework", "version": "${PackageVersion}" }, + "Microsoft.NETCore.App.Runtime.Mono.android-arm.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.android-arm64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.android-x86.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.android-x64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, "Microsoft.NETCore.App.Runtime.AOT.Cross.android-x86": { "kind": "Sdk", "version": "${PackageVersion}", @@ -157,6 +187,14 @@ "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.android-arm64" } }, + "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, "Microsoft.NETCore.App.Runtime.Mono.maccatalyst": { "kind": "framework", "version": "${PackageVersion}", @@ -173,6 +211,22 @@ "kind": "framework", "version": "${PackageVersion}" }, + "Microsoft.NETCore.App.Runtime.Mono.ios-arm.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, "Microsoft.NETCore.App.Runtime.Mono.iossimulator" : { "kind": "framework", "version": "${PackageVersion}", @@ -188,6 +242,22 @@ "osx-x64": "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86" } }, + "Microsoft.NETCore.App.Runtime.Mono.tvos-arm.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-arm64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, + "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-x64.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, "Microsoft.NETCore.App.Runtime.AOT.Cross.tvos-arm64": { "kind": "Sdk", "version": "${PackageVersion}", @@ -265,9 +335,13 @@ "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.browser-wasm" } }, + "Microsoft.NETCore.App.Runtime.Mono.browser-wasm.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, "Microsoft.NETCore.App.Runtime.Mono.browser-wasm" : { "kind": "framework", "version": "${PackageVersion}" }, } -} \ No newline at end of file +} From 3fe371b41b24f33128bffbd6c28a1d56ec61d57a Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Thu, 24 Jun 2021 22:44:33 -0400 Subject: [PATCH 15/49] rework component-manifest.targets to use ItemGroups; move to new SDK --- src/mono/mono.proj | 3 ++ src/mono/mono/component/CMakeLists.txt | 5 ++- .../component/component-manifest.props.in | 12 +++--- ...rosoft.NET.Runtime.MonoTargets.Sdk.pkgproj | 15 ++++++++ .../Sdk/Sdk.props | 2 + .../Sdk/Sdk.targets | 3 ++ .../Sdk}/component-manifest.targets | 37 +++++++++++-------- 7 files changed, 54 insertions(+), 23 deletions(-) create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.targets rename src/mono/{mono/component => nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk}/component-manifest.targets (61%) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index e459f872177169..004e57e4ea0634 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -431,6 +431,9 @@ <_MonoCMakeArgs Include="-DSTATIC_COMPONENTS=1" /> + + <_MonoCMakeArgs Include="-DMONO_COMPONENTS_RID=$(TargetOS)-$(TargetArchitecture)" /> + <_MonoCFLAGSOption>-DCMAKE_C_FLAGS="@(_MonoCPPFLAGS, ' ') @(_MonoCFLAGS, ' ')" diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 628df7b32b408c..755523032854a0 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -82,6 +82,7 @@ set(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-dependencies #define a library for each component and component stub function(define_component_libs) + # NOTE: keep library naming pattern in sync with component-manifest.targets if (NOT DISABLE_LIBS) foreach(component IN LISTS components) add_library("mono-component-${component}-static" STATIC $) @@ -121,6 +122,7 @@ endforeach() if(NOT DISABLE_COMPONENTS AND NOT STATIC_COMPONENTS) # define a shared library for each component foreach(component IN LISTS components) + # NOTE: keep library naming pattern in sync with component-manifest.targets if(HOST_WIN32) add_library("mono-component-${component}" SHARED "${${component}-sources}") target_compile_definitions("mono-component-${component}" PRIVATE -DCOMPILING_COMPONENT_DYNAMIC;-DMONO_DLL_IMPORT) @@ -175,6 +177,7 @@ endforeach() if(NOT MONO_CROSS_COMPILE) set(TemplateMonoRuntimeComponentSharedLibExt "${CMAKE_SHARED_LIBRARY_SUFFIX}") set(TemplateMonoRuntimeComponentStaticLibExt "${CMAKE_STATIC_LIBRARY_SUFFIX}") + set(TemplateRuntimeIdentifier "${MONO_COMPONENTS_RID}") if(DISABLE_COMPONENTS) set(TemplateMonoRuntimeComponentLinking "static") set(TemplateMonoRuntimeAvailableComponents "") @@ -189,8 +192,6 @@ if(NOT MONO_CROSS_COMPILE) # Write a component-manifest.props file in the artifacts/obj/mono// directory # without the ../.. the file would go in artifacts/obj/mono//mono/mini configure_file( "${MONO_COMPONENT_PATH}/component-manifest.props.in" "../../component-manifest.props") - # without the .. this goes to artifacts/obj/mono//out/ - install(FILES "${MONO_COMPONENT_PATH}/component-manifest.targets" DESTINATION ..) endif() # component tests diff --git a/src/mono/mono/component/component-manifest.props.in b/src/mono/mono/component/component-manifest.props.in index b87b183efb5aa3..d666adb1466a76 100644 --- a/src/mono/mono/component/component-manifest.props.in +++ b/src/mono/mono/component/component-manifest.props.in @@ -1,10 +1,10 @@ - - <_MonoRuntimeComponentLinking>${TemplateMonoRuntimeComponentLinking} - <_MonoRuntimeComponentSharedLibExt>${TemplateMonoRuntimeComponentSharedLibExt} - <_MonoRuntimeComponentStaticLibExt>${TemplateMonoRuntimeComponentStaticLibExt} - - <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" /> + <_MonoRuntimeComponentLinking Include="${TemplateMonoRuntimeComponentLinking}" RuntimeIdentifier="${TemplateRuntimeIdentifier}" /> + <_MonoRuntimeComponentSharedLibExt Include="${TemplateMonoRuntimeComponentSharedLibExt}" RuntimeIdentifier="${TemplateRuntimeIdentifier}" /> + <_MonoRuntimeComponentStaticLibExt Include="${TemplateMonoRuntimeComponentStaticLibExt}" RuntimeIdentifier="${TemplateRuntimeIdentifier}" /> + + + <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" RuntimeIdentifier="${TemplateRuntimeIdenfifier}" /> diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj new file mode 100644 index 00000000000000..d306c137dd5b84 --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj @@ -0,0 +1,15 @@ + + + + + Provides the tasks+targets, for consumption by mono-based workloads + + + + + + + + + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props new file mode 100644 index 00000000000000..8c119d5413b585 --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props @@ -0,0 +1,2 @@ + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.targets new file mode 100644 index 00000000000000..b5350d17f1553a --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.targets @@ -0,0 +1,3 @@ + + + diff --git a/src/mono/mono/component/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets similarity index 61% rename from src/mono/mono/component/component-manifest.targets rename to src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets index b0a2553dc7daae..e16859cda73a25 100644 --- a/src/mono/mono/component/component-manifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets @@ -3,15 +3,20 @@ - - <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)$(_MonoRuntimeComponentSharedLibExt) + + <_MonoRuntimeComponentCurrentSharedLibExt>@(_MonoRuntimeComponentSharedLibExt->WithMetadataValue('RuntimeIdentifier', '$(RuntimeIdentifier)')) + <_MonoRuntimeComponentCurrentStaticLibExt>@(_MonoRuntimeComponentStaticLibExt->WithMetadataValue('RuntimeIdentifier', '$(RuntimeIdentifier)')) + <_MonoRuntimeComponentCurrentLinking>@(_MonoRuntimeComponentLinking->WithMetadataValue('RuntimeIdentifier', '$(RuntimeIdentifier)')) + + + <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)" Condition="'%(RuntimeIdentifier)' == '$(RuntimeIdentifier)'"> + libmono-component-%(Identity)$(_MonoRuntimeComponentCurrentSharedLibExt) - - <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)"> - libmono-component-%(Identity)-static$(_MonoRuntimeComponentStaticLibExt) - libmono-component-%(Identity)-stub-static$(_MonoRuntimeComponentStaticLibExt) + + <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)" Condition="'%(RuntimeIdentifier)' == '$(RuntimeIdentifier)'"> + libmono-component-%(Identity)-static$(_MonoRuntimeComponentCurrentStaticLibExt) + libmono-component-%(Identity)-stub-static$(_MonoRuntimeComponentCurrentStaticLibExt) @@ -25,31 +30,33 @@ - + - <_MonoRuntimeSelectedComponents Include="@(_MonoRuntimeComponentName)" Condition="'@(_MonoRuntimeComponentName)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> + <_MonoRuntimeComponentNameForRid Include="@(_MonoRuntimeComponentName)" Condition="'%(RuntimeIdentifier)' == '$(RuntimeIdentifier)'" /> + <_MonoRuntimeSelectedComponents Include="@(_MonoRuntimeComponentNameForRid)" Condition="'@(_MonoRuntimeComponentNameForRid)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedComponents.ComponentLib)"> - $(_MonoRuntimeComponentLinking) + $(_MonoRuntimeComponentCurrentLinking) false %(_MonoRuntimeSelectedComponents.Identity) - <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentName)" /> + <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentNameForRid)" /> - + - <_MonoRuntimeSelectedStubComponents Include="@(_MonoRuntimeComponentName)" Exclude="@(_MonoComponent)" /> + <_MonoRuntimeSelectedStubComponents Include="@(_MonoRuntimeComponentNameForRid)" Exclude="@(_MonoComponent)" /> <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedStubComponents.ComponentStubLib)"> - $(_MonoRuntimeComponentLinking) + $(_MonoRuntimeComponentCurrentLinking) true %(_MonoRuntimeSelectedStubComponents.Identity) + + Text="_MonoComponent item list includes components '@(_MonoRuntimeSelectedMissingComponents)' which are not defined in the runtime pack. Runtime pack includes '@(_MonoRuntimeComponentNameForRid)'" /> From d3bc25047e22062120b7bf8805e51de4e93881cf Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Thu, 24 Jun 2021 23:01:32 -0400 Subject: [PATCH 16/49] Rename shared framework to Microsoft.NETCore.App.Runtime.Mono..Props.Sdk And only include component-manifest.props, not the targets --- ...ops => Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props} | 0 ...xproj => Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj} | 8 +++----- .../Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets | 3 --- 3 files changed, 3 insertions(+), 8 deletions(-) rename src/installer/pkg/sfx/Microsoft.NETCore.App/{Microsoft.NETCoreApp.Mono.Sdk.Sdk.props => Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props} (100%) rename src/installer/pkg/sfx/Microsoft.NETCore.App/{Microsoft.NETCore.App.Mono.Sdk.sfxproj => Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj} (72%) delete mode 100644 src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props similarity index 100% rename from src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.props rename to src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj similarity index 72% rename from src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj rename to src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj index dcd9efcd99e9ac..95aca1aa76682e 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Sdk.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj @@ -5,8 +5,8 @@ true true RuntimePack - Microsoft.NETCore.App.Mono.Sdk - Microsoft.NETCore.App.Runtime.Mono.$(RuntimeIdentifier).Sdk + Microsoft.NETCore.App.Mono.Props.Sdk + Microsoft.NETCore.App.Runtime.Mono.$(RuntimeIdentifier).Props.Sdk dotnet-mono-sdk @@ -21,8 +21,6 @@ - - - + diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets deleted file mode 100644 index b5350d17f1553a..00000000000000 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCoreApp.Mono.Sdk.Sdk.targets +++ /dev/null @@ -1,3 +0,0 @@ - - - From 8b5fd0af73f2a3e62c838a131b729a74d676d033 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Thu, 24 Jun 2021 23:12:46 -0400 Subject: [PATCH 17/49] Update manifest to include the new Props.Sdk and MonoTargets.Sdk --- eng/Subsets.props | 2 +- .../WorkloadManifest.json.in | 63 ++++++++++--------- .../WorkloadManifest.targets | 18 ++++++ src/mono/nuget/mono-packages.proj | 4 ++ 4 files changed, 57 insertions(+), 30 deletions(-) diff --git a/eng/Subsets.props b/eng/Subsets.props index 4dc8bc4e6c71c1..93145c12dd71d5 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -321,7 +321,7 @@ - + diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in index 4aaa309cde2a81..3f9714c6842523 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in @@ -8,7 +8,7 @@ "description": "Browser Runtime native performance tools", "packs": [ "Microsoft.NET.Runtime.WebAssembly.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.browser-wasm.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.browser-wasm.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.browser-wasm", "Microsoft.NETCore.App.Runtime.AOT.Cross.browser-wasm", "Microsoft.NET.Runtime.Emscripten.Node", @@ -22,10 +22,10 @@ "abstract": true, "description": "Android Mono Runtime", "packs": [ - "Microsoft.NETCore.App.Runtime.Mono.android-arm.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.android-arm64.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.android-x86.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.android-x64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.android-arm.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.android-arm64.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.android-x86.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.android-x64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.android-arm", "Microsoft.NETCore.App.Runtime.Mono.android-arm64", "Microsoft.NETCore.App.Runtime.Mono.android-x64", @@ -50,10 +50,10 @@ "abstract": true, "description": "iOS Mono Runtime and AOT Workload", "packs": [ - "Microsoft.NETCore.App.Runtime.Mono.ios-arm.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.ios-arm.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.ios-arm", "Microsoft.NETCore.App.Runtime.Mono.ios-arm64", "Microsoft.NETCore.App.Runtime.Mono.iossimulator", @@ -70,8 +70,8 @@ "abstract": true, "description": "MacCatalyst Mono Runtime and AOT Workload", "packs": [ - "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.maccatalyst", "Microsoft.NETCore.App.Runtime.AOT.Cross.maccatalyst" ], @@ -82,9 +82,9 @@ "abstract": true, "description": "tvOS Mono Runtime and AOT Workload", "packs": [ - "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-arm64.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-x64.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-arm64.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-x64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64", "Microsoft.NETCore.App.Runtime.Mono.tvossimulator", "Microsoft.NETCore.App.Runtime.AOT.Cross.tvos-arm64", @@ -99,6 +99,7 @@ "packs": [ "Microsoft.NET.Runtime.RuntimeConfigParser.Task", "Microsoft.NET.Runtime.MonoAOTCompiler.Task", + "Microsoft.NET.Runtime.MonoTargets.Sdk", ], } }, @@ -111,6 +112,10 @@ "kind": "Sdk", "version": "${PackageVersion}" }, + "Microsoft.NET.Runtime.MonoTargets.Sdk": { + "kind": "Sdk", + "version": "${PackageVersion}" + }, "Microsoft.NET.Runtime.WebAssembly.Sdk": { "kind": "Sdk", "version": "${PackageVersion}" @@ -131,19 +136,19 @@ "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.android-arm.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.android-arm.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.android-arm64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.android-arm64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.android-x86.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.android-x86.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.android-x64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.android-x64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, @@ -187,11 +192,11 @@ "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.android-arm64" } }, - "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, @@ -211,19 +216,19 @@ "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.ios-arm.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.ios-arm.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, @@ -242,19 +247,19 @@ "osx-x64": "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86" } }, - "Microsoft.NETCore.App.Runtime.Mono.tvos-arm.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.tvos-arm.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-arm64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-arm64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-x64.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-x64.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, @@ -335,7 +340,7 @@ "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.browser-wasm" } }, - "Microsoft.NETCore.App.Runtime.Mono.browser-wasm.Sdk": { + "Microsoft.NETCore.App.Runtime.Mono.browser-wasm.Props.Sdk": { "kind": "framework", "version": "${PackageVersion}" }, diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets index 4176041469bc17..aa7fda970360a4 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets @@ -16,6 +16,10 @@ + + + + @@ -25,6 +29,8 @@ + + @@ -32,6 +38,8 @@ + + @@ -39,11 +47,21 @@ + + + + + + + + + + diff --git a/src/mono/nuget/mono-packages.proj b/src/mono/nuget/mono-packages.proj index 9403ca9fb34bf0..8950967d93b4d6 100644 --- a/src/mono/nuget/mono-packages.proj +++ b/src/mono/nuget/mono-packages.proj @@ -18,4 +18,8 @@ + + + + From dd03117992a0f113d80ae4afcbb76cb05dc17414 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 25 Jun 2021 14:31:53 -0400 Subject: [PATCH 18/49] Move RuntimeConfigParserTask into Microsoft.NET.Runtime.MonoTargets.Sdk Consolidate all platform-independent tasks and targets into a single Sdk --- ...rosoft.NET.Runtime.MonoTargets.Sdk.pkgproj | 6 +++ .../README.md | 38 +++++++++++++++++++ .../Sdk/RuntimeConfigParserTask.props} | 0 .../Sdk/Sdk.props | 1 + ...crosoft.NET.Runtime.MonoTargets.Sdk.props} | 0 ...T.Runtime.RuntimeConfigParser.Task.pkgproj | 16 -------- .../README.md | 29 -------------- .../WorkloadManifest.json.in | 5 --- .../WorkloadManifest.targets | 12 +----- src/mono/nuget/mono-packages.proj | 1 - 10 files changed, 46 insertions(+), 62 deletions(-) create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/README.md rename src/mono/nuget/{Microsoft.NET.Runtime.RuntimeConfigParser.Task/Sdk/Sdk.props => Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeConfigParserTask.props} (100%) rename src/mono/nuget/{Microsoft.NET.Runtime.RuntimeConfigParser.Task/build/Microsoft.NET.Runtime.RuntimeConfigParser.Task.props => Microsoft.NET.Runtime.MonoTargets.Sdk/build/Microsoft.NET.Runtime.MonoTargets.Sdk.props} (100%) delete mode 100644 src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/Microsoft.NET.Runtime.RuntimeConfigParser.Task.pkgproj delete mode 100644 src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/README.md diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj index d306c137dd5b84..93a323d72b905c 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj @@ -5,9 +5,15 @@ Provides the tasks+targets, for consumption by mono-based workloads + + + + + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/README.md b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/README.md new file mode 100644 index 00000000000000..9fe42f938d3a6d --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/README.md @@ -0,0 +1,38 @@ +# Mono Runtime Host support targets + +This Sdk provides additional tasks and targets for workloads hosting the MonoVM .NET runtime. + +## component-manifest.targets + +See https://github.com/dotnet/runtime/blob/main/docs/design/mono/components.md + +## RuntimeConfigParserTask +The `RuntimeConfigParserTask` task converts a json `runtimeconfig.json` to a binary blob for MonoVM's `monovm_runtimeconfig_initialize` API. +To use the task in a project, reference the NuGet package, with the appropriate nuget source. + +### NuGet.config +``` + + + + + + +``` + +### In the project file +``` + + + + + + + + + + +``` diff --git a/src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/Sdk/Sdk.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeConfigParserTask.props similarity index 100% rename from src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/Sdk/Sdk.props rename to src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeConfigParserTask.props diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props index 8c119d5413b585..40fe4e9f53d797 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props @@ -1,2 +1,3 @@ + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/build/Microsoft.NET.Runtime.RuntimeConfigParser.Task.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/build/Microsoft.NET.Runtime.MonoTargets.Sdk.props similarity index 100% rename from src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/build/Microsoft.NET.Runtime.RuntimeConfigParser.Task.props rename to src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/build/Microsoft.NET.Runtime.MonoTargets.Sdk.props diff --git a/src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/Microsoft.NET.Runtime.RuntimeConfigParser.Task.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/Microsoft.NET.Runtime.RuntimeConfigParser.Task.pkgproj deleted file mode 100644 index 9591b89b4b9c56..00000000000000 --- a/src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/Microsoft.NET.Runtime.RuntimeConfigParser.Task.pkgproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Provides the RuntimeConfigParser task - - - - - - - - - - - diff --git a/src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/README.md b/src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/README.md deleted file mode 100644 index 1d55762a69d637..00000000000000 --- a/src/mono/nuget/Microsoft.NET.Runtime.RuntimeConfigParser.Task/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# RuntimeConfigParser MSBuild Task NuPkg -The `RuntimeConfigParser` MSBuild task is also useful outside the context of `dotnet/runtime`. The task is made available through a NuGet Package containing the `RuntimeConfigParser.dll` assembly produced from building `RuntimeConfigParser.csproj`. To use the task in a project, reference the NuGet package, with the appropriate nuget source. - -## NuGet.config -``` - - - - - - -``` - -## In the project file -``` - - - - - - - - - - -``` diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in index 3f9714c6842523..fc4a896a88fd17 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in @@ -97,17 +97,12 @@ "abstract": true, "description": "Shared native build tooling for Mono runtime", "packs": [ - "Microsoft.NET.Runtime.RuntimeConfigParser.Task", "Microsoft.NET.Runtime.MonoAOTCompiler.Task", "Microsoft.NET.Runtime.MonoTargets.Sdk", ], } }, "packs": { - "Microsoft.NET.Runtime.RuntimeConfigParser.Task": { - "kind": "Sdk", - "version": "${PackageVersion}" - }, "Microsoft.NET.Runtime.MonoAOTCompiler.Task": { "kind": "Sdk", "version": "${PackageVersion}" diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets index aa7fda970360a4..e7eb1f7c9ce7b0 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets @@ -10,7 +10,7 @@ - + @@ -22,9 +22,6 @@ - - - @@ -33,25 +30,18 @@ - - - - - - - diff --git a/src/mono/nuget/mono-packages.proj b/src/mono/nuget/mono-packages.proj index 8950967d93b4d6..a56c63f8827642 100644 --- a/src/mono/nuget/mono-packages.proj +++ b/src/mono/nuget/mono-packages.proj @@ -16,7 +16,6 @@ - From 12cd2a6db5ba2c9f3cb0585c9bfb03e39589f7be Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 25 Jun 2021 15:27:56 -0400 Subject: [PATCH 19/49] Add iossimulator-x86 props --- .../WorkloadManifest.json.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in index fc4a896a88fd17..47ea45379b0cf2 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in @@ -52,6 +52,7 @@ "packs": [ "Microsoft.NETCore.App.Runtime.Mono.ios-arm.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Props.Sdk", + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.ios-arm", @@ -227,6 +228,10 @@ "kind": "framework", "version": "${PackageVersion}" }, + "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86.Props.Sdk": { + "kind": "framework", + "version": "${PackageVersion}" + }, "Microsoft.NETCore.App.Runtime.Mono.iossimulator" : { "kind": "framework", "version": "${PackageVersion}", From e6651b24ca627c22f4c74d49b3c6587f1fb051a9 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 25 Jun 2021 15:32:06 -0400 Subject: [PATCH 20/49] update components design doc --- docs/design/mono/components.md | 43 ++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 18 deletions(-) diff --git a/docs/design/mono/components.md b/docs/design/mono/components.md index 4bf6c6a2291805..dd5c5cf1f9342f 100644 --- a/docs/design/mono/components.md +++ b/docs/design/mono/components.md @@ -271,24 +271,31 @@ enable the workload to construct a runtime for various scenarios. For the target RID, we expose: -- `$(_MonoRuntimeComponentLinking)` set to either `'static'` or `'dynamic'` - depending on whether the current runtime pack for the current target includes - runtime components as static archives or as shared libraries, respectively. -- `$(_MonoRuntimeComponentSharedLibExt)` and `$(_MonoRuntimeComponentStaticLibExt)` set to the file extension of the runtime components for the current target (ie, `'.a', '.so', '.dylib'` etc). -- `@(_MonoRuntimeAvailableComponents)` a list of component names without the - `lib` prefix (if any) or file extensions. For example: `'hot_reload; - diagnostics_tracing'`. +- `@(_MonoRuntimeComponentLinking)` set to either `'static'` or `'dynamic'` depending on whether the + current runtime pack for the current target includes runtime components as static archives or as + shared libraries, respectively. +- `@(_MonoRuntimeComponentSharedLibExt)` and `@(_MonoRuntimeComponentStaticLibExt)` set to the file + extension of the runtime components for the current target (ie, `'.a', '.so', '.dylib'` etc). +- `@(_MonoRuntimeAvailableComponents)` a list of component names without the `lib` prefix (if any) + or file extensions. For example: `'hot_reload; diagnostics_tracing'`. + +Each of the above item lists has `RuntimeIdentifier` metadata. For technical reasons the mono +workload will provide a single `@(_MonoRuntimeAvailableComponent)` item list for all platforms. We +use the `RuntimeIdentifier` metadata to filter out the details applicable for the current platform. + - The target `_MonoSelectRuntimeComponents` that has the following inputs and outputs: - - input `@(_MonoComponent)` : a list of components that a workload wants to use for the current app. It is an error - if this specifies any unknown component name. - - output `@(_MonoRuntimeSelectedComponents)` and `@(_MonoRuntimeSelectedStubComponents)` The names of the components - that were (resp, were not) selected. For example `'hot_reload; diagnostics_tracing'`. Each item has two metadata - properties `ComponentLib` and `ComponentStubLib` (which may be empty) that specify the name of the static or dynamic - library of the compponent. This is not the main output of the target, it's primarily for debugging. - - output `@(_MonoRuntimeComponentLink)` a list of library names (relative to the `native/` subdirectory of the runtime - pack) that (for dynamic components) must be placed next to the runtime in the application bundle, or (for static - components) that must be linked with the runtime to enable the components' functionality. Each item in the list has - metadata `ComponentName` (e.g. `'hot_reload'`), `IsStub` (`true` or `false`), `Linking` (`'static'` or `'dynamic'`). - This output should be used by the workloads when linking the app and runtime. + - input `@(_MonoComponent)` : a list of components that a workload wants to use for the current + app. It is an error if this specifies any unknown component name. + - output `@(_MonoRuntimeSelectedComponents)` and `@(_MonoRuntimeSelectedStubComponents)` The names + of the components that were (resp, were not) selected. For example `'hot_reload; + diagnostics_tracing'`. Each item has two metadata properties `ComponentLib` and + `ComponentStubLib` (which may be empty) that specify the name of the static or dynamic library + of the compponent. This is not the main output of the target, it's primarily for debugging. + - output `@(_MonoRuntimeComponentLink)` a list of library names (relative to the `native/` + subdirectory of the runtime pack) that (for dynamic components) must be placed next to the + runtime in the application bundle, or (for static components) that must be linked with the + runtime to enable the components' functionality. Each item in the list has metadata + `ComponentName` (e.g. `'hot_reload'`), `IsStub` (`true` or `false`), `Linking` (`'static'` or + `'dynamic'`). This output should be used by the workloads when linking the app and runtime. From 8d1e6743fc014fb63ed50c5fc3fc465c0510e037 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 29 Jun 2021 12:41:40 -0400 Subject: [PATCH 21/49] Fix typo --- src/mono/mono/component/component-manifest.props.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/component/component-manifest.props.in b/src/mono/mono/component/component-manifest.props.in index d666adb1466a76..ed3d0cf9c6001b 100644 --- a/src/mono/mono/component/component-manifest.props.in +++ b/src/mono/mono/component/component-manifest.props.in @@ -5,6 +5,6 @@ <_MonoRuntimeComponentStaticLibExt Include="${TemplateMonoRuntimeComponentStaticLibExt}" RuntimeIdentifier="${TemplateRuntimeIdentifier}" /> - <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" RuntimeIdentifier="${TemplateRuntimeIdenfifier}" /> + <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" RuntimeIdentifier="${TemplateRuntimeIdentifier}" /> From b9be77feeb2e4cda1daf56f4044fb65d48a2454f Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 29 Jun 2021 12:54:50 -0400 Subject: [PATCH 22/49] improve docs --- docs/design/mono/components.md | 19 +++++++++++++++++-- .../Sdk/component-manifest.targets | 6 ++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/docs/design/mono/components.md b/docs/design/mono/components.md index dd5c5cf1f9342f..be29e3792fa8bf 100644 --- a/docs/design/mono/components.md +++ b/docs/design/mono/components.md @@ -284,7 +284,7 @@ workload will provide a single `@(_MonoRuntimeAvailableComponent)` item list for use the `RuntimeIdentifier` metadata to filter out the details applicable for the current platform. - The target `_MonoSelectRuntimeComponents` that has the following inputs and outputs: - - input `@(_MonoComponent)` : a list of components that a workload wants to use for the current + - input `@(_MonoComponent)` (to be set by the workload) : a list of components that a workload wants to use for the current app. It is an error if this specifies any unknown component name. - output `@(_MonoRuntimeSelectedComponents)` and `@(_MonoRuntimeSelectedStubComponents)` The names of the components that were (resp, were not) selected. For example `'hot_reload; @@ -298,4 +298,19 @@ use the `RuntimeIdentifier` metadata to filter out the details applicable for th `ComponentName` (e.g. `'hot_reload'`), `IsStub` (`true` or `false`), `Linking` (`'static'` or `'dynamic'`). This output should be used by the workloads when linking the app and runtime. - +Example fragment (assuming the mono workload has been imported): + +```xml + + + + + + + + + + + +``` diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets index e16859cda73a25..bf66d84f455a89 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets @@ -22,14 +22,16 @@ - - + + + + From db6a828ad072cea8e74168fb580e205b20c61cf4 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 29 Jun 2021 13:19:28 -0400 Subject: [PATCH 23/49] Add _MonoRuntimeComponentDontLink target output --- docs/design/mono/components.md | 16 +++++++- .../Sdk/component-manifest.targets | 40 ++++++++++++++++--- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/docs/design/mono/components.md b/docs/design/mono/components.md index be29e3792fa8bf..97244f56859e60 100644 --- a/docs/design/mono/components.md +++ b/docs/design/mono/components.md @@ -296,7 +296,18 @@ use the `RuntimeIdentifier` metadata to filter out the details applicable for th runtime in the application bundle, or (for static components) that must be linked with the runtime to enable the components' functionality. Each item in the list has metadata `ComponentName` (e.g. `'hot_reload'`), `IsStub` (`true` or `false`), `Linking` (`'static'` or - `'dynamic'`). This output should be used by the workloads when linking the app and runtime. + `'dynamic'`). This output should be used by the workloads when linking the app and runtime if + the workload uses an allow list of native libraries to link or bundle. + - output `@(_MonoRuntimeComponentDontLink)` a list of library names (relative to the `native/` + subdirectory of the rutnime pack) that should be excluded from the application bundle (for + dynamic linking) or that should not be passed to the native linker (for static linking). This + output should be used by workloads that just link or bundle every native library from `native/` + in order to filter the contents of the subdirectory to exclude the disabled components (and to + exclude the static library stubs for the enabled components when static linking). + +Generally workloads should only use one of `@(_MonoRuntimeComponentLink)` or +`@(_MonoRuntimeComponentDontLink)`, depending on whether they use an allow or block list for the +contents of the `native/` subdirectory. Example fragment (assuming the mono workload has been imported): @@ -311,6 +322,9 @@ Example fragment (assuming the mono workload has been imported): + + + ``` diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets index bf66d84f455a89..ad5bc547000ea6 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets @@ -22,11 +22,29 @@ - - - - - + + + + + + + + @@ -37,11 +55,17 @@ <_MonoRuntimeComponentNameForRid Include="@(_MonoRuntimeComponentName)" Condition="'%(RuntimeIdentifier)' == '$(RuntimeIdentifier)'" /> <_MonoRuntimeSelectedComponents Include="@(_MonoRuntimeComponentNameForRid)" Condition="'@(_MonoRuntimeComponentNameForRid)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> + <_MonoRuntimeUnSelectedComponents Include="@(_MonoRuntimeComponentNameForRid)" Exclude="@(_MonoComponent)" /> <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedComponents.ComponentLib)"> $(_MonoRuntimeComponentCurrentLinking) false %(_MonoRuntimeSelectedComponents.Identity) + <_MonoRuntimeComponentDontLink Include="%(_MonoRuntimeUnSelectedComponents.ComponentLib)"> + $(_MonoRuntimeComponentCurrentLinking) + false + %(_MonoRuntimeUnSelectedComponents.Identity) + <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentNameForRid)" /> @@ -49,11 +73,17 @@ <_MonoRuntimeSelectedStubComponents Include="@(_MonoRuntimeComponentNameForRid)" Exclude="@(_MonoComponent)" /> + <_MonoRuntimeUnSelectedStubComponents Include="@(_MonoRuntimeComponentNameForRid)" Condition="'@(_MonoRuntimeComponentNameForRid)' == '@(_MonoComponent)' and '%(Identity)' != ''" /> <_MonoRuntimeComponentLink Include="%(_MonoRuntimeSelectedStubComponents.ComponentStubLib)"> $(_MonoRuntimeComponentCurrentLinking) true %(_MonoRuntimeSelectedStubComponents.Identity) + <_MonoRuntimeComponentDontLink Include="%(_MonoRuntimeUnSelectedStubComponents.ComponentStubLib)"> + $(_MonoRuntimeComponentCurrentLinking) + true + %(_MonoRuntimeUnSelectedStubComponents.Identity) + From 5c88b3e05abc10ec135fe68513ab21606bb60b0b Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 29 Jun 2021 23:24:46 -0400 Subject: [PATCH 24/49] Drop component-manifest.props into runtime pack build/ directory Remove from the Microsoft.NETCore.App.Mono.Props.Sdk workload nuget --- .../Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props | 1 - .../Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj | 2 -- .../Microsoft.NETCore.App.Runtime.props | 7 +++++++ src/mono/mono.proj | 6 ++++++ src/mono/mono/component/CMakeLists.txt | 4 ++-- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props index a8da6f76b7171c..359fc292a6ed47 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props @@ -1,4 +1,3 @@ - diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj index 95aca1aa76682e..d60c9e8bc2decb 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj @@ -16,11 +16,9 @@ false tools/ true - $([MSBuild]::NormalizeDirectory('$(ArtifactsObjDir)', 'mono', '$(TargetOS).$(TargetArchitecture).$(MonoConfiguration)')) - diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props index 2489544cad8b59..f87d4b2450d957 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props @@ -70,6 +70,13 @@ runtimes/$(RuntimeIdentifier)/native/include/%(RecursiveDir) + + + runtimes/$(RuntimeIdentifier)/build/%(RecursiveDir) + + runtimes/$(CoreCLRCrossTargetComponentDirName)_$(TargetArchitecture)/native diff --git a/src/mono/mono.proj b/src/mono/mono.proj index 004e57e4ea0634..d9344f1fb3439a 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -773,6 +773,7 @@ $(RuntimeBinDir)cross\$(PackageRID)\opt$(ExeExt) <_MonoIncludeArtifacts Include="$(MonoObjDir)out\include\**" /> + <_MonoRuntimeBuildArtifacts Include="$(MonoObjDir)\build\**" /> <_MonoRuntimeArtifacts Condition="'$(_MonoIncludeInterpStaticFiles)' == 'true'" Include="$(MonoObjDir)out\lib\libmono-ee-interp.a"> $(RuntimeBinDir)libmono-ee-interp.a @@ -819,6 +820,11 @@ SkipUnchangedFiles="true" Condition="'$(MonoGenerateOffsetsOSGroups)' == '' and ('$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsBrowser)' == 'true')"/> + + diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 755523032854a0..b85a908defcc1e 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -189,9 +189,9 @@ if(NOT MONO_CROSS_COMPILE) set(TemplateMonoRuntimeComponentLinking "dynamic") endif() endif() - # Write a component-manifest.props file in the artifacts/obj/mono// directory + # Write a component-manifest.props file in the artifacts/obj/mono//build/ directory # without the ../.. the file would go in artifacts/obj/mono//mono/mini - configure_file( "${MONO_COMPONENT_PATH}/component-manifest.props.in" "../../component-manifest.props") + configure_file( "${MONO_COMPONENT_PATH}/component-manifest.props.in" "../../build/component-manifest.props") endif() # component tests From 8a791eac2fee3060d02e9e7ed62cedfd3ffa7545 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 30 Jun 2021 00:15:04 -0400 Subject: [PATCH 25/49] remove Microsoft.NETCore.App.Mono.Props.Sdk --- eng/Subsets.props | 1 - ...osoft.NETCore.App.Mono.Props.Sdk.Sdk.props | 3 - ...crosoft.NETCore.App.Mono.Props.Sdk.sfxproj | 24 ------ .../WorkloadManifest.json.in | 79 ------------------- .../WorkloadManifest.targets | 12 --- 5 files changed, 119 deletions(-) delete mode 100644 src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props delete mode 100644 src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj diff --git a/eng/Subsets.props b/eng/Subsets.props index 93145c12dd71d5..105b34254c6c2b 100644 --- a/eng/Subsets.props +++ b/eng/Subsets.props @@ -321,7 +321,6 @@ - diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props deleted file mode 100644 index 359fc292a6ed47..00000000000000 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.Sdk.props +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj deleted file mode 100644 index d60c9e8bc2decb..00000000000000 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Mono.Props.Sdk.sfxproj +++ /dev/null @@ -1,24 +0,0 @@ - - - - - true - true - RuntimePack - Microsoft.NETCore.App.Mono.Props.Sdk - Microsoft.NETCore.App.Runtime.Mono.$(RuntimeIdentifier).Props.Sdk - - dotnet-mono-sdk - - mono-sdk-what-is-this - - false - false - tools/ - true - - - - - - diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in index 47ea45379b0cf2..9ee301da6890ef 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in @@ -8,7 +8,6 @@ "description": "Browser Runtime native performance tools", "packs": [ "Microsoft.NET.Runtime.WebAssembly.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.browser-wasm.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.browser-wasm", "Microsoft.NETCore.App.Runtime.AOT.Cross.browser-wasm", "Microsoft.NET.Runtime.Emscripten.Node", @@ -22,10 +21,6 @@ "abstract": true, "description": "Android Mono Runtime", "packs": [ - "Microsoft.NETCore.App.Runtime.Mono.android-arm.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.android-arm64.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.android-x86.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.android-x64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.android-arm", "Microsoft.NETCore.App.Runtime.Mono.android-arm64", "Microsoft.NETCore.App.Runtime.Mono.android-x64", @@ -50,11 +45,6 @@ "abstract": true, "description": "iOS Mono Runtime and AOT Workload", "packs": [ - "Microsoft.NETCore.App.Runtime.Mono.ios-arm.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.ios-arm", "Microsoft.NETCore.App.Runtime.Mono.ios-arm64", "Microsoft.NETCore.App.Runtime.Mono.iossimulator", @@ -71,8 +61,6 @@ "abstract": true, "description": "MacCatalyst Mono Runtime and AOT Workload", "packs": [ - "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.maccatalyst", "Microsoft.NETCore.App.Runtime.AOT.Cross.maccatalyst" ], @@ -83,9 +71,6 @@ "abstract": true, "description": "tvOS Mono Runtime and AOT Workload", "packs": [ - "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-arm64.Props.Sdk", - "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-x64.Props.Sdk", "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64", "Microsoft.NETCore.App.Runtime.Mono.tvossimulator", "Microsoft.NETCore.App.Runtime.AOT.Cross.tvos-arm64", @@ -132,22 +117,6 @@ "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.android-arm.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.android-arm64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.android-x86.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.android-x64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, "Microsoft.NETCore.App.Runtime.AOT.Cross.android-x86": { "kind": "Sdk", "version": "${PackageVersion}", @@ -188,14 +157,6 @@ "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.android-arm64" } }, - "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.maccatalyst-x64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, "Microsoft.NETCore.App.Runtime.Mono.maccatalyst": { "kind": "framework", "version": "${PackageVersion}", @@ -212,26 +173,6 @@ "kind": "framework", "version": "${PackageVersion}" }, - "Microsoft.NETCore.App.Runtime.Mono.ios-arm.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.ios-arm64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-arm64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, "Microsoft.NETCore.App.Runtime.Mono.iossimulator" : { "kind": "framework", "version": "${PackageVersion}", @@ -247,22 +188,6 @@ "osx-x64": "Microsoft.NETCore.App.Runtime.Mono.iossimulator-x86" } }, - "Microsoft.NETCore.App.Runtime.Mono.tvos-arm.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.tvos-arm64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-arm64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, - "Microsoft.NETCore.App.Runtime.Mono.tvossimulator-x64.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, "Microsoft.NETCore.App.Runtime.AOT.Cross.tvos-arm64": { "kind": "Sdk", "version": "${PackageVersion}", @@ -340,10 +265,6 @@ "osx-arm64": "Microsoft.NETCore.App.Runtime.AOT.osx-x64.Cross.browser-wasm" } }, - "Microsoft.NETCore.App.Runtime.Mono.browser-wasm.Props.Sdk": { - "kind": "framework", - "version": "${PackageVersion}" - }, "Microsoft.NETCore.App.Runtime.Mono.browser-wasm" : { "kind": "framework", "version": "${PackageVersion}" diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets index e7eb1f7c9ce7b0..516fb0d7a51571 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets @@ -16,41 +16,29 @@ - - - - - - - - - - - - From 016c88a6b055dc44d847b6085d1876102d32ee45 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 30 Jun 2021 00:27:47 -0400 Subject: [PATCH 26/49] Import component-manifest.props from the runtime pack Move the MonoTargets.Sdk import to each target platform that we support --- .../WorkloadManifest.targets | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets index 516fb0d7a51571..495379ceaed213 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets @@ -10,7 +10,11 @@ - + + + + + @@ -19,27 +23,41 @@ + + + + + + + + + + + + + + + - From 49f5a65b2fcb678307e835612f2b48d92879efde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Wed, 30 Jun 2021 11:10:48 -0400 Subject: [PATCH 27/49] Fix typos Co-authored-by: Rolf Bjarne Kvinge --- docs/design/mono/components.md | 6 +++--- .../Sdk/component-manifest.targets | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/design/mono/components.md b/docs/design/mono/components.md index 97244f56859e60..ef17836c8645c5 100644 --- a/docs/design/mono/components.md +++ b/docs/design/mono/components.md @@ -290,7 +290,7 @@ use the `RuntimeIdentifier` metadata to filter out the details applicable for th of the components that were (resp, were not) selected. For example `'hot_reload; diagnostics_tracing'`. Each item has two metadata properties `ComponentLib` and `ComponentStubLib` (which may be empty) that specify the name of the static or dynamic library - of the compponent. This is not the main output of the target, it's primarily for debugging. + of the component. This is not the main output of the target, it's primarily for debugging. - output `@(_MonoRuntimeComponentLink)` a list of library names (relative to the `native/` subdirectory of the runtime pack) that (for dynamic components) must be placed next to the runtime in the application bundle, or (for static components) that must be linked with the @@ -299,7 +299,7 @@ use the `RuntimeIdentifier` metadata to filter out the details applicable for th `'dynamic'`). This output should be used by the workloads when linking the app and runtime if the workload uses an allow list of native libraries to link or bundle. - output `@(_MonoRuntimeComponentDontLink)` a list of library names (relative to the `native/` - subdirectory of the rutnime pack) that should be excluded from the application bundle (for + subdirectory of the runtime pack) that should be excluded from the application bundle (for dynamic linking) or that should not be passed to the native linker (for static linking). This output should be used by workloads that just link or bundle every native library from `native/` in order to filter the contents of the subdirectory to exclude the disabled components (and to @@ -313,7 +313,7 @@ Example fragment (assuming the mono workload has been imported): ```xml - <_MonoComponent Include="hot_reload;diagnostics_tracing" /> diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets index ad5bc547000ea6..bb5b477c2c8b30 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets @@ -28,7 +28,7 @@ in _MonoComponent --> - + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets index bb5b477c2c8b30..39ea15c907314b 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets @@ -43,7 +43,7 @@ _MonoRuntimeComponentDontLink. For example, a workload that doesn't understand the contents of native/ in details will generally bundle every native library from native/. Such a workload should then use DontLink to exclude the disabled components. On the other - hand a workload that explicitly pics the native libraries from native/ should use + hand a workload that explicitly picks the native libraries from native/ should use _MonoRuntimeComponentLink to pick just the needed runtime component artifacts. --> From a217d4e3d400b0b0f35c2a7366924e824dd7de9e Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 2 Jul 2021 14:27:42 -0400 Subject: [PATCH 29/49] Add JsonToItemsTaskFactory --- .../JsonToItemsTaskFactory.cs | 379 ++++++++++++++++++ .../JsonToItemsTaskFactory.csproj | 32 ++ src/tasks/JsonToItemsTaskFactory/README.md | 86 ++++ 3 files changed, 497 insertions(+) create mode 100644 src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs create mode 100644 src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj create mode 100644 src/tasks/JsonToItemsTaskFactory/README.md diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs new file mode 100644 index 00000000000000..b961ab48b3f387 --- /dev/null +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs @@ -0,0 +1,379 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Text.Json; +using System.Text.Json.Serialization; + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +#if NET472 +namespace System.Diagnostics.CodeAnalysis { + [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] + + public class NotNullWhenAttribute : Attribute { + public NotNullWhenAttribute(bool returnValue) => ReturnValue = returnValue; + public bool ReturnValue { get; } + } +} +#endif + +namespace JsonToItemsTaskFactory +{ + + /// Reads a json input blob and populates some output items + /// + /// JSON should follow this structure - the toplevel "properties" and "items" keys are exact, other keys are arbitrary. + /// + /// { + /// "properties" : { + /// "propName1": "value1", + /// "propName2": "value" + /// }, + /// "items" : { + /// "itemName1": [ "stringValue", { "identity": "anotherValue", "metadataKey": "metadataValue", ... }, "thirdValue" ], + /// "itemName2": [ ... ] + /// } + /// + /// + /// A task can be declared by + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// And then used in a target. The `JsonFilePath' attribute is used to specify the json file to read. + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public class JsonToItemsTaskFactory : ITaskFactory + { + private const string JsonFilePath = "JsonFilePath"; + private TaskPropertyInfo[]? _taskProperties; + private string? _taskName; + + private bool logDebugTask; + + public JsonToItemsTaskFactory() {} + + public string FactoryName => "JsonToItemsTaskFactory"; + + public Type TaskType => typeof(JsonToItemsTask); + + public bool Initialize (string taskName, IDictionary parameterGroup, string? taskBody, IBuildEngine taskFactoryLoggingHost) + { + _taskName = taskName; + if (taskBody != null && taskBody.StartsWith("debug", StringComparison.InvariantCultureIgnoreCase)) + logDebugTask = true; + var log = new TaskLoggingHelper(taskFactoryLoggingHost, _taskName); + if (!ValidateParameterGroup (parameterGroup, log)) + return false; + _taskProperties = new TaskPropertyInfo[parameterGroup.Count + 1]; + _taskProperties[0] = new TaskPropertyInfo(nameof(JsonFilePath), typeof(string), output: false, required: true); + parameterGroup.Values.CopyTo(_taskProperties, 1); + return true; + } + + public TaskPropertyInfo[] GetTaskParameters () => _taskProperties!; + + public ITask CreateTask (IBuildEngine taskFactoryLoggingHost) + { + var log = new TaskLoggingHelper(taskFactoryLoggingHost, _taskName); + if (logDebugTask) log.LogMessage("CreateTask called"); + return new JsonToItemsTask(_taskName!, logDebugTask); + } + + public void CleanupTask (ITask task) {} + + internal bool ValidateParameterGroup (IDictionary parameterGroup, TaskLoggingHelper log) + { + bool hasErrors = false; + var taskName = _taskName ?? ""; + foreach (var kvp in parameterGroup) + { + var propName = kvp.Key; + var propInfo = kvp.Value; + if (string.Equals(propName, nameof(JsonFilePath), StringComparison.InvariantCultureIgnoreCase)) + { + log.LogError($"Task {taskName}: {nameof(JsonFilePath)} parameter must not be declared. It is implicitly added by the task."); + hasErrors = true; + continue; + } + + if (!propInfo.Output) + { + log.LogError($"Task {taskName}: parameter {propName} is not an output. All parameters except {nameof(JsonFilePath)} must be outputs"); + hasErrors = true; + continue; + } + if (propInfo.Required) + { + log.LogError($"Task {taskName}: parameter {propName} is an output but is marked required. That's not supported."); + hasErrors = true; + } + if (typeof(ITaskItem[]).IsAssignableFrom(propInfo.PropertyType)) + continue; // ok, an item list + if (typeof(string).IsAssignableFrom(propInfo.PropertyType)) + continue; // ok, a string property + + log.LogError($"Task {taskName}: parameter {propName} is not an output of type System.String or Microsoft.Build.Framework.ITaskItem[]"); + hasErrors = true; + } + return !hasErrors; + } + + public class JsonToItemsTask : IGeneratedTask + { + private IBuildEngine? _buildEngine; + public IBuildEngine BuildEngine { get => _buildEngine!; set { _buildEngine = value; SetBuildEngine(value);} } + public ITaskHost? HostObject { get; set; } + + private TaskLoggingHelper? _log; + private TaskLoggingHelper Log { get => _log!; set { _log = value; } } + + private void SetBuildEngine (IBuildEngine buildEngine) + { + Log = new TaskLoggingHelper(buildEngine, TaskName); + } + + public static JsonSerializerOptions JsonOptions => new() + { + PropertyNameCaseInsensitive = true, + AllowTrailingCommas = true, + }; + private string? jsonFilePath; + + private readonly bool logDebugTask; // print stuff to the log for debugging the task + + private JsonModelRoot? jsonModel; + public string TaskName {get;} + public JsonToItemsTask(string taskName, bool logDebugTask = false) + { + TaskName = taskName; + this.logDebugTask = logDebugTask; + } + + public bool Execute() + { + if (jsonFilePath == null) + { + Log.LogError("no JsonFilePath specified"); + return false; + } + if (!TryGetJson (jsonFilePath, out var json)) + return false; + + if (logDebugTask) + { + LogParsedJson (json); + } + jsonModel = json; + return true; + } + + public bool TryGetJson(string jsonFilePath, [NotNullWhen(true)] out JsonModelRoot? json) + { + FileStream? file = null; + try + { + try + { + file = File.OpenRead(jsonFilePath); + } + catch (FileNotFoundException fnfe) + { + Log.LogErrorFromException(fnfe); + json = null; + return false; + } + json = JsonSerializer.DeserializeAsync(file, JsonOptions).AsTask().Result; + if (json == null) + { + Log.LogError ("Failed to deserialize Json file"); + return false; + } + return true; + } + finally + { + if (file != null) + file.Dispose(); + } + } + + internal void LogParsedJson (JsonModelRoot json) + { + if (json.Properties != null) + { + Log.LogMessage ("json has properties: "); + foreach (var property in json.Properties) + { + Log.LogMessage($" {property.Key} = {property.Value}"); + } + } + if (json.Items != null) + { + Log.LogMessage("items: "); + foreach (var item in json.Items) + { + Log.LogMessage($" {item.Key} = ["); + foreach (var value in item.Value) + { + Log.LogMessage($" {value.Identity}"); + if (value.Metadata != null) + { + Log.LogMessage(" and some metadata, too"); + } + } + Log.LogMessage(" ]"); + } + } + } + + public object? GetPropertyValue (TaskPropertyInfo property) + { + bool isItem = false; + if (typeof(ITaskItem[]).IsAssignableFrom (property.PropertyType)) + { + if (logDebugTask) Log.LogMessage("GetPropertyValue called with @({0})", property.Name); + isItem = true; + } + else + { + if (logDebugTask) Log.LogMessage("GetPropertyValue called with $({0})", property.Name); + } + if (!isItem) + { + if (jsonModel?.Properties != null && jsonModel.Properties.TryGetValue(property.Name, out var value)) + { + return value; + } + Log.LogError("Property {0} not found in {1}", property.Name, jsonFilePath); + throw new Exception(); + } + else + { + if (jsonModel?.Items != null && jsonModel.Items.TryGetValue(property.Name, out var itemModels)) + { + return ConvertItems (itemModels); + } + + } + return null; + } + + public static ITaskItem[] ConvertItems(JsonModelItem[] itemModels) + { + var items = new ITaskItem[itemModels.Length]; + for (int i = 0; i < itemModels.Length; i++) + { + var itemModel = itemModels[i]; + var item = new TaskItem(itemModel.Identity); + if (itemModel.Metadata != null) + { + foreach (var metadata in itemModel.Metadata) + { + if (string.Equals(metadata.Key, "Identity", StringComparison.OrdinalIgnoreCase)) + continue; + item.SetMetadata(metadata.Key, metadata.Value); + } + } + items[i] = item; + } + return items; + } + + public void SetPropertyValue (TaskPropertyInfo property, object? value) + { + if (logDebugTask) Log.LogMessage("SetPropertyValue called with {0}", property.Name); + if (property.Name == "JsonFilePath") + { + jsonFilePath = (string)value!; + } + else + throw new Exception ($"JsonToItemsTask {TaskName} cannot set property {property.Name}"); + } + + } + + public class JsonModelRoot + { + [JsonConverter(typeof(CaseInsensitiveDictionaryConverter))] + public Dictionary? Properties {get; set;} + public Dictionary? Items {get; set;} + + public JsonModelRoot() {} + } + + [JsonConverter(typeof(JsonModelItemConverter))] + public class JsonModelItem + { + public string? Identity {get; set;} + // n.b. will be deserialized case insensitive + public Dictionary? Metadata {get; set; } + } + + public class CaseInsensitiveDictionaryConverter : JsonConverter> + { + public override Dictionary Read (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + var dict = JsonSerializer.Deserialize>(ref reader, options); + if (dict == null) + return null!; + return new Dictionary(dict, StringComparer.OrdinalIgnoreCase); + } + public override void Write (Utf8JsonWriter writer, Dictionary? value, JsonSerializerOptions options) => + JsonSerializer.Serialize(writer, value, options); + } + public class JsonModelItemConverter : JsonConverter + { + public JsonModelItemConverter() {} + + public override JsonModelItem Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + { + switch (reader.TokenType) + { + case JsonTokenType.String: + return new JsonModelItem { Identity = reader.GetString() }; + case JsonTokenType.StartObject: + var item = new JsonModelItem(); + var dict = JsonSerializer.Deserialize>(ref reader, options); + if (dict == null) + return null!; + var idict = new Dictionary (dict, StringComparer.OrdinalIgnoreCase); + if (!idict.TryGetValue("Identity", out var identity) || identity == null) + throw new Exception ("deserialized json dictionary item did not have an Identity metadata"); + item.Identity = identity; + item.Metadata = idict; + return item; + default: + throw new Exception(); + } + } + public override void Write(Utf8JsonWriter writer, JsonModelItem value, JsonSerializerOptions options) + { + if (value.Metadata == null) + JsonSerializer.Serialize(writer, value.Identity!); + else + JsonSerializer.Serialize(writer, value.Metadata); /* assumes Identity is in there */ + } + } + } +} diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj new file mode 100644 index 00000000000000..bf3ea7ade1d2f2 --- /dev/null +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj @@ -0,0 +1,32 @@ + + + $(TargetFrameworkForNETCoreTasks);$(TargetFrameworkForNETFrameworkTasks) + Library + true + false + enable + + $(NoWarn),CS8604,CS8602 + + + + + + + + + + + + + + + + <_PublishFramework Remove="@(_PublishFramework)" /> + <_PublishFramework Include="$(TargetFrameworks)" /> + + + + + + diff --git a/src/tasks/JsonToItemsTaskFactory/README.md b/src/tasks/JsonToItemsTaskFactory/README.md new file mode 100644 index 00000000000000..619991ac13e993 --- /dev/null +++ b/src/tasks/JsonToItemsTaskFactory/README.md @@ -0,0 +1,86 @@ +# JsonToItemsTaskFactory + +A utility for reading json blobs into MSBuild items and properties. + +## Json blob format + +The json data must be a single toplevel dictionary with a `"properties"` or an `"items"` key (both are optional). + +The `"properties"` value must be a dictionary with more string values. The keys are case-insensitive and duplicates are not allowed. + +The `"items"` value must be an array of either string or dictionary elements (or a mix of both). +String elements use the string value as the `Identity`. +Dictionary elements must have strings as values, and must include an `"Identity"` key, and as many other metadata key/value pairs as desired. This dictionary is also case-insensitive and duplicate metadata keys are also not allowed. + +#### Example + +```json +{ + "properties": { + "x1": "val1", + "X2": "val2", + }, + "items" : { + "FunFiles": ["funFile1.txt", "funFile2.txt"], + "FilesWithMeta": [{"identity": "funFile3.txt", "TargetPath": "bin/fun3"}, + "funFile3.and.a.half.txt", + {"identity": "funFile4.txt", "TargetPath": "bin/fun4"}] + } +} +``` + +## UsingTask and Writing Targets + +To use the task, you need to reference the assembly and add the task to the project, as well as declare the task parameters that correspond to the properties and items you want to retrieve from the json blob. + +```xml + + + + + + + +``` + +The parameter group parameters are all optional. They must be non-required outputs of type `System.String` or `Microsoft.Build.Framework.ITaskItem[]`. The former declares properties to capture from the file, while the latter declares item lists. + +The above declares a task `MyJsonReader` which will be used to retries the `X1` property and the `FunFiles` and `FilesWithMeta` items. + +To use the task, a `JsonFilePath` attribute specifies the file to read. + +```xml + + + + + + + + + + + + + + + +``` + +When the target `RunMe` runs, the task will read the json file and populate the outputs. Running the target, the output will be: + +```console +$ dotnet build Example + X1 = val1 + FunFiles = funFile1.txt;funFile2.txt + FilesWithMeta = funFile3.txt TargetPath='bin/fun3' + FilesWithMeta = funFile4.txt TargetPath='bin/fun4' + FilesWithMeta = funFile3.and.a.half.txt (No TargetPath) + +Build succeeded. + 0 Warning(s) + 0 Error(s) +Time Elapsed 00:00:00.15 +``` + From c3cee96c16b89e7ba13abcd41484fdcfda9be790 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 2 Jul 2021 14:59:12 -0400 Subject: [PATCH 30/49] fix whitespace --- .../Microsoft.NETCore.App.Runtime.props | 6 ++--- .../Sdk/component-manifest.targets | 12 +++++----- .../WorkloadManifest.targets | 24 +++++++++---------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props index f87d4b2450d957..0a269851646b67 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props @@ -72,9 +72,9 @@ - runtimes/$(RuntimeIdentifier)/build/%(RecursiveDir) + Include="$(MonoArtifactsPath)\build\**\*.*" + ExcludeFromDataFiles="true"> + runtimes/$(RuntimeIdentifier)/build/%(RecursiveDir) diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets index 39ea15c907314b..76a82b58165f89 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets @@ -62,9 +62,9 @@ %(_MonoRuntimeSelectedComponents.Identity) <_MonoRuntimeComponentDontLink Include="%(_MonoRuntimeUnSelectedComponents.ComponentLib)"> - $(_MonoRuntimeComponentCurrentLinking) - false - %(_MonoRuntimeUnSelectedComponents.Identity) + $(_MonoRuntimeComponentCurrentLinking) + false + %(_MonoRuntimeUnSelectedComponents.Identity) <_MonoRuntimeSelectedMissingComponents Include="@(_MonoComponent)" Exclude="@(_MonoRuntimeComponentNameForRid)" /> @@ -80,9 +80,9 @@ %(_MonoRuntimeSelectedStubComponents.Identity) <_MonoRuntimeComponentDontLink Include="%(_MonoRuntimeUnSelectedStubComponents.ComponentStubLib)"> - $(_MonoRuntimeComponentCurrentLinking) - true - %(_MonoRuntimeUnSelectedStubComponents.Identity) + $(_MonoRuntimeComponentCurrentLinking) + true + %(_MonoRuntimeUnSelectedStubComponents.Identity) diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets index 495379ceaed213..4f8dd1ea305e0e 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets @@ -12,8 +12,8 @@ - - + + @@ -24,40 +24,40 @@ - + - + - + - + - + - + - + - + - + - + From 438f3ec4eb5c7101f583cfd5291208c7e9eb9c7c Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 2 Jul 2021 15:15:48 -0400 Subject: [PATCH 31/49] Do some validation earlier in _MonoComputeAvailableComponentDefinitions --- .../Sdk/component-manifest.targets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets index 76a82b58165f89..25009eba7f4f08 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets @@ -8,6 +8,10 @@ <_MonoRuntimeComponentCurrentStaticLibExt>@(_MonoRuntimeComponentStaticLibExt->WithMetadataValue('RuntimeIdentifier', '$(RuntimeIdentifier)')) <_MonoRuntimeComponentCurrentLinking>@(_MonoRuntimeComponentLinking->WithMetadataValue('RuntimeIdentifier', '$(RuntimeIdentifier)')) + + <_MonoRuntimeComponentName Include="@(_MonoRuntimeAvailableComponents)" Condition="'%(RuntimeIdentifier)' == '$(RuntimeIdentifier)'"> libmono-component-%(Identity)$(_MonoRuntimeComponentCurrentSharedLibExt) From 29420e223a6883c14a43e2ba23f6d6ee950dda80 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 2 Jul 2021 15:37:55 -0400 Subject: [PATCH 32/49] Read component-manifest.json using the JsonToItemsTaskFactory and bundle it in Microsoft.NET.Runtime.MonoTargets.Sdk --- .../Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj | 2 ++ .../Sdk/Sdk.props | 1 + .../Sdk/component-manifest.props | 14 ++++++++++++++ .../Sdk/component-manifest.targets | 13 ++++++++++++- 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj index 93a323d72b905c..8a841aa6f7d4ba 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj @@ -7,6 +7,7 @@ + @@ -14,6 +15,7 @@ + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props index 40fe4e9f53d797..aa61ec01957a76 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props @@ -1,3 +1,4 @@ + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props new file mode 100644 index 00000000000000..685298a166d60f --- /dev/null +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props @@ -0,0 +1,14 @@ + + + $(MSBuildThisFileDirectory)..\tasks\net6.0\JsonToItemsTaskFactory.dll + $(MSBuildThisFileDirectory)..\tasks\net472\JsonToItemsTaskFactory.dll + + + + <_MonoRuntimeComponentSharedLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeComponentStaticLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeComponentCurrentLinking ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeAvailableComponents ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets index 25009eba7f4f08..9f8d9f180181a8 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets @@ -1,5 +1,16 @@ - + + + + + + + + + + + From 58015a0288c69c4681a48133a251444d6d12a58b Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 2 Jul 2021 15:48:38 -0400 Subject: [PATCH 33/49] remove ResolvedRuntimePack import from WorkloadManifest.targets it's too early, and we have the JsonToItemsTaskFactory now to read the manifest --- .../WorkloadManifest.targets | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets index 4f8dd1ea305e0e..c93e50175e9216 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.targets @@ -12,7 +12,6 @@ - @@ -24,7 +23,6 @@ - @@ -33,28 +31,24 @@ - - - - From d3071da3a6a3c8b9215d6c72e9ef9904c77c21ba Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 2 Jul 2021 16:23:58 -0400 Subject: [PATCH 34/49] Generate component-manifest.json in CMakeLists.txt --- src/mono/mono/component/CMakeLists.txt | 5 +++-- .../mono/component/component-manifest.json.in | 16 ++++++++++++++++ .../mono/component/component-manifest.props.in | 10 ---------- 3 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 src/mono/mono/component/component-manifest.json.in delete mode 100644 src/mono/mono/component/component-manifest.props.in diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index b85a908defcc1e..857053c530f0bc 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -182,7 +182,8 @@ if(NOT MONO_CROSS_COMPILE) set(TemplateMonoRuntimeComponentLinking "static") set(TemplateMonoRuntimeAvailableComponents "") else() - list(JOIN components ";" TemplateMonoRuntimeAvailableComponents) + list(TRANSFORM components REPLACE "^(.+)$" "{ \"identity\": \"\\1\", \"RuntimeIdentifier\": \"${TemplateRuntimeIdentifier}\" }," OUTPUT_VARIABLE TemplateMonoRuntimeAvailableComponentsList) + list(JOIN TemplateMonoRuntimeAvailableComponentsList "\n" TemplateMonoRuntimeAvailableComponents) if(STATIC_COMPONENTS) set(TemplateMonoRuntimeComponentLinking "static") else() @@ -191,7 +192,7 @@ if(NOT MONO_CROSS_COMPILE) endif() # Write a component-manifest.props file in the artifacts/obj/mono//build/ directory # without the ../.. the file would go in artifacts/obj/mono//mono/mini - configure_file( "${MONO_COMPONENT_PATH}/component-manifest.props.in" "../../build/component-manifest.props") + configure_file( "${MONO_COMPONENT_PATH}/component-manifest.json.in" "../../build/component-manifest.json") endif() # component tests diff --git a/src/mono/mono/component/component-manifest.json.in b/src/mono/mono/component/component-manifest.json.in new file mode 100644 index 00000000000000..715c5e668861a3 --- /dev/null +++ b/src/mono/mono/component/component-manifest.json.in @@ -0,0 +1,16 @@ +{ + "items": { + "_MonoRuntimeComponentLinking": [ + { "identity": "${TemplateMonoRuntimeComponentLinking}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, + ], + "_MonoRuntimeComponentSharedLibExt": [ + { "identity": "${TemplateMonoRuntimeComponentSharedLibExt}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, + ], + "_MonoRuntimeComponentStaticLibExt": [ + { "identity": "${TemplateMonoRuntimeComponentStaticLibExt}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, + ], + "_MonoRuntimeAvailableComponents": [ + ${TemplateMonoRuntimeAvailableComponents} + ], + } +} diff --git a/src/mono/mono/component/component-manifest.props.in b/src/mono/mono/component/component-manifest.props.in deleted file mode 100644 index ed3d0cf9c6001b..00000000000000 --- a/src/mono/mono/component/component-manifest.props.in +++ /dev/null @@ -1,10 +0,0 @@ - - - <_MonoRuntimeComponentLinking Include="${TemplateMonoRuntimeComponentLinking}" RuntimeIdentifier="${TemplateRuntimeIdentifier}" /> - <_MonoRuntimeComponentSharedLibExt Include="${TemplateMonoRuntimeComponentSharedLibExt}" RuntimeIdentifier="${TemplateRuntimeIdentifier}" /> - <_MonoRuntimeComponentStaticLibExt Include="${TemplateMonoRuntimeComponentStaticLibExt}" RuntimeIdentifier="${TemplateRuntimeIdentifier}" /> - - - <_MonoRuntimeAvailableComponents Include="${TemplateMonoRuntimeAvailableComponents}" RuntimeIdentifier="${TemplateRuntimeIdentifier}" /> - - From 756e5a6ce58beeee2446555e978eb85cf2a9d9f8 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Fri, 2 Jul 2021 16:40:10 -0400 Subject: [PATCH 35/49] Fix some copy-paste nits --- .../JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj index bf3ea7ade1d2f2..42ccd7d6cbd675 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj @@ -6,7 +6,7 @@ false enable - $(NoWarn),CS8604,CS8602 + @@ -19,7 +19,7 @@ - + <_PublishFramework Remove="@(_PublishFramework)" /> From 372df69c0a7b5a00e56f2816ae0208828b6f38ae Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 13:08:09 -0400 Subject: [PATCH 36/49] Use RuntimeFlavor==mono for runtime pack build directory instead of TargetsMobile. We want the build files (mono-components.json) in every mono runtime pack, not just on mobile targets --- .../Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props index 0a269851646b67..4eea2cf850fa0a 100644 --- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props +++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Microsoft.NETCore.App.Runtime.props @@ -70,8 +70,7 @@ runtimes/$(RuntimeIdentifier)/native/include/%(RecursiveDir) - - runtimes/$(RuntimeIdentifier)/build/%(RecursiveDir) From 2cc01b6dc56423c3a3aa155247c8db2e42ed0f25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Wed, 7 Jul 2021 13:48:12 -0400 Subject: [PATCH 37/49] Apply suggestions from code review Co-authored-by: Ankit Jain --- .../Sdk/component-manifest.props | 2 +- .../WorkloadManifest.json.in | 2 +- src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props index 685298a166d60f..7cc5ef89d10bf9 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props @@ -3,7 +3,7 @@ $(MSBuildThisFileDirectory)..\tasks\net6.0\JsonToItemsTaskFactory.dll $(MSBuildThisFileDirectory)..\tasks\net472\JsonToItemsTaskFactory.dll - + <_MonoRuntimeComponentSharedLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> <_MonoRuntimeComponentStaticLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> diff --git a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in index 9ee301da6890ef..e6a7ff1ee2a025 100644 --- a/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in +++ b/src/mono/nuget/Microsoft.NET.Workload.Mono.Toolchain.Manifest/WorkloadManifest.json.in @@ -95,7 +95,7 @@ }, "Microsoft.NET.Runtime.MonoTargets.Sdk": { "kind": "Sdk", - "version": "${PackageVersion}" + "version": "${PackageVersion}" }, "Microsoft.NET.Runtime.WebAssembly.Sdk": { "kind": "Sdk", diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs index b961ab48b3f387..b235902cf859b6 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs @@ -77,7 +77,7 @@ public JsonToItemsTaskFactory() {} public Type TaskType => typeof(JsonToItemsTask); - public bool Initialize (string taskName, IDictionary parameterGroup, string? taskBody, IBuildEngine taskFactoryLoggingHost) + public bool Initialize(string taskName, IDictionary parameterGroup, string? taskBody, IBuildEngine taskFactoryLoggingHost) { _taskName = taskName; if (taskBody != null && taskBody.StartsWith("debug", StringComparison.InvariantCultureIgnoreCase)) @@ -174,7 +174,7 @@ public bool Execute() { if (jsonFilePath == null) { - Log.LogError("no JsonFilePath specified"); + Log.LogError($"no {nameof(JsonFilePath)} specified"); return false; } if (!TryGetJson (jsonFilePath, out var json)) @@ -316,7 +316,7 @@ public void SetPropertyValue (TaskPropertyInfo property, object? value) public class JsonModelRoot { [JsonConverter(typeof(CaseInsensitiveDictionaryConverter))] - public Dictionary? Properties {get; set;} + public Dictionary? Properties {get; set;} public Dictionary? Items {get; set;} public JsonModelRoot() {} From 065a2bb1df7bcc7bad2ada648384b700d826b60a Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 13:16:56 -0400 Subject: [PATCH 38/49] rename component-manifest to RuntimeComponentManifest --- src/mono/mono/component/CMakeLists.txt | 2 +- ...nent-manifest.json.in => RuntimeComponentManifest.json.in} | 0 .../Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj | 4 ++-- ...omponent-manifest.props => RuntimeComponentManifest.props} | 0 ...nent-manifest.targets => RuntimeComponentManifest.targets} | 2 +- .../nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props | 2 +- .../Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.targets | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) rename src/mono/mono/component/{component-manifest.json.in => RuntimeComponentManifest.json.in} (100%) rename src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/{component-manifest.props => RuntimeComponentManifest.props} (100%) rename src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/{component-manifest.targets => RuntimeComponentManifest.targets} (99%) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index 857053c530f0bc..e604bc82b54dce 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -192,7 +192,7 @@ if(NOT MONO_CROSS_COMPILE) endif() # Write a component-manifest.props file in the artifacts/obj/mono//build/ directory # without the ../.. the file would go in artifacts/obj/mono//mono/mini - configure_file( "${MONO_COMPONENT_PATH}/component-manifest.json.in" "../../build/component-manifest.json") + configure_file( "${MONO_COMPONENT_PATH}/RuntimeComponentManifest.json.in" "../../build/RuntimeComponentManifest.json") endif() # component tests diff --git a/src/mono/mono/component/component-manifest.json.in b/src/mono/mono/component/RuntimeComponentManifest.json.in similarity index 100% rename from src/mono/mono/component/component-manifest.json.in rename to src/mono/mono/component/RuntimeComponentManifest.json.in diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj index 8a841aa6f7d4ba..adf1b80c2f3398 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Microsoft.NET.Runtime.MonoTargets.Sdk.pkgproj @@ -15,8 +15,8 @@ - - + + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props similarity index 100% rename from src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.props rename to src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets similarity index 99% rename from src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets rename to src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets index 9f8d9f180181a8..2054540a15c3d4 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/component-manifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets @@ -2,7 +2,7 @@ - + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props index aa61ec01957a76..d292fe15f274a2 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.props @@ -1,4 +1,4 @@ - + diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.targets index b5350d17f1553a..5fdf494324c79a 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/Sdk.targets @@ -1,3 +1,3 @@ - + From 6957bcc00662edf0792cd023329033589430b549 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 13:26:55 -0400 Subject: [PATCH 39/49] fixup nullability annotations --- src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs index b235902cf859b6..df65ead824ae4e 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs @@ -332,7 +332,7 @@ public class JsonModelItem public class CaseInsensitiveDictionaryConverter : JsonConverter> { - public override Dictionary Read (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override Dictionary? Read (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var dict = JsonSerializer.Deserialize>(ref reader, options); if (dict == null) @@ -346,7 +346,7 @@ public class JsonModelItemConverter : JsonConverter { public JsonModelItemConverter() {} - public override JsonModelItem Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override JsonModelItem? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { switch (reader.TokenType) { From dae9aebcc02ad5af84e67e7ed77ac791ac9f377a Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 13:27:10 -0400 Subject: [PATCH 40/49] fix whitespace --- src/mono/mono.proj | 6 ++--- .../RuntimeComponentManifest.json.in | 24 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/mono/mono.proj b/src/mono/mono.proj index d9344f1fb3439a..c26eb9f4e2e545 100644 --- a/src/mono/mono.proj +++ b/src/mono/mono.proj @@ -821,9 +821,9 @@ Condition="'$(MonoGenerateOffsetsOSGroups)' == '' and ('$(TargetsMacCatalyst)' == 'true' or '$(TargetsiOS)' == 'true' or '$(TargetstvOS)' == 'true' or '$(TargetsAndroid)' == 'true' or '$(TargetsBrowser)' == 'true')"/> + DestinationFiles="@(_MonoRuntimeBuildArtifacts->'$(RuntimeBinDir)build\%(RecursiveDir)%(Filename)%(Extension)')" + SkipUnchangedFiles="true" + Condition="'$(BuildMonoAOTCrossCompilerOnly)' != 'true'" /> diff --git a/src/mono/mono/component/RuntimeComponentManifest.json.in b/src/mono/mono/component/RuntimeComponentManifest.json.in index 715c5e668861a3..a7ee6a8a83f6b6 100644 --- a/src/mono/mono/component/RuntimeComponentManifest.json.in +++ b/src/mono/mono/component/RuntimeComponentManifest.json.in @@ -1,16 +1,16 @@ { "items": { - "_MonoRuntimeComponentLinking": [ - { "identity": "${TemplateMonoRuntimeComponentLinking}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, - ], - "_MonoRuntimeComponentSharedLibExt": [ - { "identity": "${TemplateMonoRuntimeComponentSharedLibExt}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, - ], - "_MonoRuntimeComponentStaticLibExt": [ - { "identity": "${TemplateMonoRuntimeComponentStaticLibExt}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, - ], - "_MonoRuntimeAvailableComponents": [ - ${TemplateMonoRuntimeAvailableComponents} - ], + "_MonoRuntimeComponentLinking": [ + { "identity": "${TemplateMonoRuntimeComponentLinking}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, + ], + "_MonoRuntimeComponentSharedLibExt": [ + { "identity": "${TemplateMonoRuntimeComponentSharedLibExt}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, + ], + "_MonoRuntimeComponentStaticLibExt": [ + { "identity": "${TemplateMonoRuntimeComponentStaticLibExt}", "RuntimeIdentifier": "${TemplateRuntimeIdentifier}" }, + ], + "_MonoRuntimeAvailableComponents": [ + ${TemplateMonoRuntimeAvailableComponents} + ], } } From d5e6f0eddb19803f676485e0028c7d8c5dc328a4 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 13:38:15 -0400 Subject: [PATCH 41/49] fix formatting --- .../JsonToItemsTaskFactory.cs | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs index df65ead824ae4e..9de3ae098dce98 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs @@ -69,7 +69,7 @@ public class JsonToItemsTaskFactory : ITaskFactory private TaskPropertyInfo[]? _taskProperties; private string? _taskName; - private bool logDebugTask; + private bool _logDebugTask; public JsonToItemsTaskFactory() {} @@ -81,7 +81,7 @@ public bool Initialize(string taskName, IDictionary pa { _taskName = taskName; if (taskBody != null && taskBody.StartsWith("debug", StringComparison.InvariantCultureIgnoreCase)) - logDebugTask = true; + _logDebugTask = true; var log = new TaskLoggingHelper(taskFactoryLoggingHost, _taskName); if (!ValidateParameterGroup (parameterGroup, log)) return false; @@ -91,18 +91,18 @@ public bool Initialize(string taskName, IDictionary pa return true; } - public TaskPropertyInfo[] GetTaskParameters () => _taskProperties!; + public TaskPropertyInfo[] GetTaskParameters() => _taskProperties!; - public ITask CreateTask (IBuildEngine taskFactoryLoggingHost) + public ITask CreateTask(IBuildEngine taskFactoryLoggingHost) { var log = new TaskLoggingHelper(taskFactoryLoggingHost, _taskName); - if (logDebugTask) log.LogMessage("CreateTask called"); - return new JsonToItemsTask(_taskName!, logDebugTask); + if (_logDebugTask) log.LogMessage("CreateTask called"); + return new JsonToItemsTask(_taskName!, _logDebugTask); } - public void CleanupTask (ITask task) {} + public void CleanupTask(ITask task) {} - internal bool ValidateParameterGroup (IDictionary parameterGroup, TaskLoggingHelper log) + internal bool ValidateParameterGroup(IDictionary parameterGroup, TaskLoggingHelper log) { bool hasErrors = false; var taskName = _taskName ?? ""; @@ -148,7 +148,7 @@ public class JsonToItemsTask : IGeneratedTask private TaskLoggingHelper? _log; private TaskLoggingHelper Log { get => _log!; set { _log = value; } } - private void SetBuildEngine (IBuildEngine buildEngine) + private void SetBuildEngine(IBuildEngine buildEngine) { Log = new TaskLoggingHelper(buildEngine, TaskName); } @@ -160,14 +160,14 @@ private void SetBuildEngine (IBuildEngine buildEngine) }; private string? jsonFilePath; - private readonly bool logDebugTask; // print stuff to the log for debugging the task + private readonly bool _logDebugTask; // print stuff to the log for debugging the task private JsonModelRoot? jsonModel; public string TaskName {get;} public JsonToItemsTask(string taskName, bool logDebugTask = false) { TaskName = taskName; - this.logDebugTask = logDebugTask; + _logDebugTask = logDebugTask; } public bool Execute() @@ -177,12 +177,12 @@ public bool Execute() Log.LogError($"no {nameof(JsonFilePath)} specified"); return false; } - if (!TryGetJson (jsonFilePath, out var json)) + if (!TryGetJson(jsonFilePath, out var json)) return false; - if (logDebugTask) + if (_logDebugTask) { - LogParsedJson (json); + LogParsedJson(json); } jsonModel = json; return true; @@ -206,7 +206,7 @@ public bool TryGetJson(string jsonFilePath, [NotNullWhen(true)] out JsonModelRoo json = JsonSerializer.DeserializeAsync(file, JsonOptions).AsTask().Result; if (json == null) { - Log.LogError ("Failed to deserialize Json file"); + Log.LogError("Failed to deserialize Json file"); return false; } return true; @@ -222,7 +222,7 @@ internal void LogParsedJson (JsonModelRoot json) { if (json.Properties != null) { - Log.LogMessage ("json has properties: "); + Log.LogMessage("json has properties: "); foreach (var property in json.Properties) { Log.LogMessage($" {property.Key} = {property.Value}"); @@ -247,17 +247,17 @@ internal void LogParsedJson (JsonModelRoot json) } } - public object? GetPropertyValue (TaskPropertyInfo property) + public object? GetPropertyValue(TaskPropertyInfo property) { bool isItem = false; - if (typeof(ITaskItem[]).IsAssignableFrom (property.PropertyType)) + if (typeof(ITaskItem[]).IsAssignableFrom(property.PropertyType)) { - if (logDebugTask) Log.LogMessage("GetPropertyValue called with @({0})", property.Name); + if (_logDebugTask) Log.LogMessage("GetPropertyValue called with @({0})", property.Name); isItem = true; } else { - if (logDebugTask) Log.LogMessage("GetPropertyValue called with $({0})", property.Name); + if (_logDebugTask) Log.LogMessage("GetPropertyValue called with $({0})", property.Name); } if (!isItem) { @@ -272,7 +272,7 @@ internal void LogParsedJson (JsonModelRoot json) { if (jsonModel?.Items != null && jsonModel.Items.TryGetValue(property.Name, out var itemModels)) { - return ConvertItems (itemModels); + return ConvertItems(itemModels); } } @@ -300,15 +300,15 @@ public static ITaskItem[] ConvertItems(JsonModelItem[] itemModels) return items; } - public void SetPropertyValue (TaskPropertyInfo property, object? value) + public void SetPropertyValue(TaskPropertyInfo property, object? value) { - if (logDebugTask) Log.LogMessage("SetPropertyValue called with {0}", property.Name); + if (_logDebugTask) Log.LogMessage("SetPropertyValue called with {0}", property.Name); if (property.Name == "JsonFilePath") { jsonFilePath = (string)value!; } else - throw new Exception ($"JsonToItemsTask {TaskName} cannot set property {property.Name}"); + throw new Exception($"JsonToItemsTask {TaskName} cannot set property {property.Name}"); } } @@ -332,14 +332,14 @@ public class JsonModelItem public class CaseInsensitiveDictionaryConverter : JsonConverter> { - public override Dictionary? Read (ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override Dictionary? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var dict = JsonSerializer.Deserialize>(ref reader, options); if (dict == null) return null!; return new Dictionary(dict, StringComparer.OrdinalIgnoreCase); } - public override void Write (Utf8JsonWriter writer, Dictionary? value, JsonSerializerOptions options) => + public override void Write(Utf8JsonWriter writer, Dictionary? value, JsonSerializerOptions options) => JsonSerializer.Serialize(writer, value, options); } public class JsonModelItemConverter : JsonConverter From eb0d0d48eab8be8d3698bb29496d8c27f77e1670 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 13:48:24 -0400 Subject: [PATCH 42/49] Misc fixes to JsonToItemsTaskFactory --- .../JsonToItemsTaskFactory.cs | 31 ++++++++----------- .../JsonToItemsTaskFactory.csproj | 2 +- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs index 9de3ae098dce98..9b187d83652d62 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs @@ -96,7 +96,7 @@ public bool Initialize(string taskName, IDictionary pa public ITask CreateTask(IBuildEngine taskFactoryLoggingHost) { var log = new TaskLoggingHelper(taskFactoryLoggingHost, _taskName); - if (_logDebugTask) log.LogMessage("CreateTask called"); + if (_logDebugTask) log.LogMessage(MessageImportance.Low, "CreateTask called"); return new JsonToItemsTask(_taskName!, _logDebugTask); } @@ -104,7 +104,6 @@ public void CleanupTask(ITask task) {} internal bool ValidateParameterGroup(IDictionary parameterGroup, TaskLoggingHelper log) { - bool hasErrors = false; var taskName = _taskName ?? ""; foreach (var kvp in parameterGroup) { @@ -113,20 +112,17 @@ internal bool ValidateParameterGroup(IDictionary param if (string.Equals(propName, nameof(JsonFilePath), StringComparison.InvariantCultureIgnoreCase)) { log.LogError($"Task {taskName}: {nameof(JsonFilePath)} parameter must not be declared. It is implicitly added by the task."); - hasErrors = true; continue; } if (!propInfo.Output) { log.LogError($"Task {taskName}: parameter {propName} is not an output. All parameters except {nameof(JsonFilePath)} must be outputs"); - hasErrors = true; continue; } if (propInfo.Required) { log.LogError($"Task {taskName}: parameter {propName} is an output but is marked required. That's not supported."); - hasErrors = true; } if (typeof(ITaskItem[]).IsAssignableFrom(propInfo.PropertyType)) continue; // ok, an item list @@ -134,9 +130,8 @@ internal bool ValidateParameterGroup(IDictionary param continue; // ok, a string property log.LogError($"Task {taskName}: parameter {propName} is not an output of type System.String or Microsoft.Build.Framework.ITaskItem[]"); - hasErrors = true; } - return !hasErrors; + return !log.HasLoggedErrors; } public class JsonToItemsTask : IGeneratedTask @@ -206,7 +201,7 @@ public bool TryGetJson(string jsonFilePath, [NotNullWhen(true)] out JsonModelRoo json = JsonSerializer.DeserializeAsync(file, JsonOptions).AsTask().Result; if (json == null) { - Log.LogError("Failed to deserialize Json file"); + Log.LogError($"Failed to deserialize json from file {jsonFilePath}"); return false; } return true; @@ -222,27 +217,27 @@ internal void LogParsedJson (JsonModelRoot json) { if (json.Properties != null) { - Log.LogMessage("json has properties: "); + Log.LogMessage(MessageImportance.Low, "json has properties: "); foreach (var property in json.Properties) { - Log.LogMessage($" {property.Key} = {property.Value}"); + Log.LogMessage(MessageImportance.Low, $" {property.Key} = {property.Value}"); } } if (json.Items != null) { - Log.LogMessage("items: "); + Log.LogMessage(MessageImportance.Low, "items: "); foreach (var item in json.Items) { - Log.LogMessage($" {item.Key} = ["); + Log.LogMessage(MessageImportance.Low, $" {item.Key} = ["); foreach (var value in item.Value) { - Log.LogMessage($" {value.Identity}"); + Log.LogMessage(MessageImportance.Low, $" {value.Identity}"); if (value.Metadata != null) { - Log.LogMessage(" and some metadata, too"); + Log.LogMessage(MessageImportance.Low, " and some metadata, too"); } } - Log.LogMessage(" ]"); + Log.LogMessage(MessageImportance.Low, " ]"); } } } @@ -252,12 +247,12 @@ internal void LogParsedJson (JsonModelRoot json) bool isItem = false; if (typeof(ITaskItem[]).IsAssignableFrom(property.PropertyType)) { - if (_logDebugTask) Log.LogMessage("GetPropertyValue called with @({0})", property.Name); + if (_logDebugTask) Log.LogMessage(MessageImportance.Low, "GetPropertyValue called with @({0})", property.Name); isItem = true; } else { - if (_logDebugTask) Log.LogMessage("GetPropertyValue called with $({0})", property.Name); + if (_logDebugTask) Log.LogMessage(MessageImportance.Low, "GetPropertyValue called with $({0})", property.Name); } if (!isItem) { @@ -302,7 +297,7 @@ public static ITaskItem[] ConvertItems(JsonModelItem[] itemModels) public void SetPropertyValue(TaskPropertyInfo property, object? value) { - if (_logDebugTask) Log.LogMessage("SetPropertyValue called with {0}", property.Name); + if (_logDebugTask) Log.LogMessage(MessageImportance.Low, "SetPropertyValue called with {0}", property.Name); if (property.Name == "JsonFilePath") { jsonFilePath = (string)value!; diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj index 42ccd7d6cbd675..d6df214fce7963 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.csproj @@ -13,7 +13,7 @@ - + From 4874bd439cf4a65cabb99589f4e2ebde285ee166 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 13:57:29 -0400 Subject: [PATCH 43/49] Rename MonoRuntimeComponentManifestReadTask from MonoRuntimeComponentsReadManifestTask --- .../Sdk/RuntimeComponentManifest.props | 2 +- .../Sdk/RuntimeComponentManifest.targets | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props index 7cc5ef89d10bf9..836ff93354dc9b 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props @@ -3,7 +3,7 @@ $(MSBuildThisFileDirectory)..\tasks\net6.0\JsonToItemsTaskFactory.dll $(MSBuildThisFileDirectory)..\tasks\net472\JsonToItemsTaskFactory.dll - + <_MonoRuntimeComponentSharedLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> <_MonoRuntimeComponentStaticLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets index 2054540a15c3d4..411aeec01e563e 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets @@ -1,13 +1,16 @@ - - + + <_MonoRuntimeComponentManifestJsonFilePath Condition="'$(_MonoRuntimeComponentManifestJsonFilePath)' == ''">%(ResolvedRuntimePack.PackageDirectory)\runtimes\$(RuntimeIdentifier)\build\RuntimeComponentManifest.json + + - + From 011e7abed33332a6bc35d39739a1e2f855e633b1 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 14:31:30 -0400 Subject: [PATCH 44/49] undo nullability annotation Build doesn't like it for some reason (probably net472) --- src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs index 9b187d83652d62..33c54acae1fe89 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs @@ -327,7 +327,7 @@ public class JsonModelItem public class CaseInsensitiveDictionaryConverter : JsonConverter> { - public override Dictionary? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override Dictionary Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { var dict = JsonSerializer.Deserialize>(ref reader, options); if (dict == null) @@ -341,7 +341,7 @@ public class JsonModelItemConverter : JsonConverter { public JsonModelItemConverter() {} - public override JsonModelItem? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) + public override JsonModelItem Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { switch (reader.TokenType) { From c332f7bd49e5900cdd0da9cf08caa72a1192aac1 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 14:33:05 -0400 Subject: [PATCH 45/49] fix incorrect task parameter name --- .../Sdk/RuntimeComponentManifest.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props index 836ff93354dc9b..d173ff67c2b882 100644 --- a/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props +++ b/src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.props @@ -7,7 +7,7 @@ <_MonoRuntimeComponentSharedLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> <_MonoRuntimeComponentStaticLibExt ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> - <_MonoRuntimeComponentCurrentLinking ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> + <_MonoRuntimeComponentLinking ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> <_MonoRuntimeAvailableComponents ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="false" Output="true" /> From 7d6ca6d58a5923c769e60afee6f458df9bce45fa Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 14:51:01 -0400 Subject: [PATCH 46/49] Remove Identity metadata from dictionary at json parsing time Also improve nullability a bit by making the properties immutable --- .../JsonToItemsTaskFactory.cs | 31 ++++++++++++------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs index 33c54acae1fe89..78bf70122dab57 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs @@ -283,10 +283,9 @@ public static ITaskItem[] ConvertItems(JsonModelItem[] itemModels) var item = new TaskItem(itemModel.Identity); if (itemModel.Metadata != null) { + // assume Identity key was already removed in JsonModelItem foreach (var metadata in itemModel.Metadata) { - if (string.Equals(metadata.Key, "Identity", StringComparison.OrdinalIgnoreCase)) - continue; item.SetMetadata(metadata.Key, metadata.Value); } } @@ -320,9 +319,15 @@ public JsonModelRoot() {} [JsonConverter(typeof(JsonModelItemConverter))] public class JsonModelItem { - public string? Identity {get; set;} + public string Identity {get;} // n.b. will be deserialized case insensitive - public Dictionary? Metadata {get; set; } + public Dictionary? Metadata {get;} + + public JsonModelItem(string identity, Dictionary? metadata) + { + Identity = identity; + Metadata = metadata; + } } public class CaseInsensitiveDictionaryConverter : JsonConverter> @@ -346,18 +351,20 @@ public override JsonModelItem Read(ref Utf8JsonReader reader, Type typeToConvert switch (reader.TokenType) { case JsonTokenType.String: - return new JsonModelItem { Identity = reader.GetString() }; + var stringItem = reader.GetString(); + if (string.IsNullOrEmpty(stringItem)) + throw new Exception ("deserialized json string item was null or the empty string"); + return new JsonModelItem(stringItem!, metadata: null); case JsonTokenType.StartObject: - var item = new JsonModelItem(); var dict = JsonSerializer.Deserialize>(ref reader, options); if (dict == null) return null!; var idict = new Dictionary (dict, StringComparer.OrdinalIgnoreCase); - if (!idict.TryGetValue("Identity", out var identity) || identity == null) - throw new Exception ("deserialized json dictionary item did not have an Identity metadata"); - item.Identity = identity; - item.Metadata = idict; - return item; + if (!idict.TryGetValue("Identity", out var identity) || string.IsNullOrEmpty(identity)) + throw new Exception ("deserialized json dictionary item did not have a non-empty Identity metadata"); + else + idict.Remove("Identity"); + return new JsonModelItem(identity, metadata: idict); default: throw new Exception(); } @@ -365,7 +372,7 @@ public override JsonModelItem Read(ref Utf8JsonReader reader, Type typeToConvert public override void Write(Utf8JsonWriter writer, JsonModelItem value, JsonSerializerOptions options) { if (value.Metadata == null) - JsonSerializer.Serialize(writer, value.Identity!); + JsonSerializer.Serialize(writer, value.Identity); else JsonSerializer.Serialize(writer, value.Metadata); /* assumes Identity is in there */ } From 174065e850dca83a90fb9bb7879a3879febee8a4 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 15:10:48 -0400 Subject: [PATCH 47/49] Throw correct json deserializer exceptions --- src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs index 78bf70122dab57..67522f22ee152c 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs @@ -353,7 +353,7 @@ public override JsonModelItem Read(ref Utf8JsonReader reader, Type typeToConvert case JsonTokenType.String: var stringItem = reader.GetString(); if (string.IsNullOrEmpty(stringItem)) - throw new Exception ("deserialized json string item was null or the empty string"); + throw new JsonException ("deserialized json string item was null or the empty string"); return new JsonModelItem(stringItem!, metadata: null); case JsonTokenType.StartObject: var dict = JsonSerializer.Deserialize>(ref reader, options); @@ -361,12 +361,12 @@ public override JsonModelItem Read(ref Utf8JsonReader reader, Type typeToConvert return null!; var idict = new Dictionary (dict, StringComparer.OrdinalIgnoreCase); if (!idict.TryGetValue("Identity", out var identity) || string.IsNullOrEmpty(identity)) - throw new Exception ("deserialized json dictionary item did not have a non-empty Identity metadata"); + throw new JsonException ("deserialized json dictionary item did not have a non-empty Identity metadata"); else idict.Remove("Identity"); return new JsonModelItem(identity, metadata: idict); default: - throw new Exception(); + throw new NotSupportedException(); } } public override void Write(Utf8JsonWriter writer, JsonModelItem value, JsonSerializerOptions options) From 5ffc1753b89599ef71fa5b0da43922d7297e6b74 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 15:51:17 -0400 Subject: [PATCH 48/49] Catch JsonException in an async function We get nice error messages now like ``` src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets(8,5): error : Failed to deserialize json from file 'artifacts/bin/mono/iOSSimulator.x64.Release/build/RuntimeComponentManifest.json', JSON Path: $.items._MonoRuntimeAvailableComponents[2], Line: 14, Position: 1 [component-manifest.sample.proj] src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets(8,5): error : JsonException: The JSON value could not be converted to System.Collections.Generic.Dictionary`2[System.String,System.String]. Path: $.identity | LineNumber: 0 | BytePositionInLine: 16. Path: $.items._MonoRuntimeAvailableComponents[2] | LineNumber: 14 | BytePositionInLine: 1. [component-manifest.sample.proj] src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets(8,5): error : InvalidOperationException: Cannot get the value of a token type 'Number' as a string. [component-manifest.sample.proj] src/mono/nuget/Microsoft.NET.Runtime.MonoTargets.Sdk/Sdk/RuntimeComponentManifest.targets(8,5): error : [component-manifest.sample.proj] ``` --- .../JsonToItemsTaskFactory.cs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs index 67522f22ee152c..2f7d1dc7ebfbe8 100644 --- a/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs +++ b/src/tasks/JsonToItemsTaskFactory/JsonToItemsTaskFactory.cs @@ -7,6 +7,7 @@ using System.IO; using System.Text.Json; using System.Text.Json.Serialization; +using System.Threading.Tasks; using Microsoft.Build.Framework; using Microsoft.Build.Utilities; @@ -198,10 +199,11 @@ public bool TryGetJson(string jsonFilePath, [NotNullWhen(true)] out JsonModelRoo json = null; return false; } - json = JsonSerializer.DeserializeAsync(file, JsonOptions).AsTask().Result; + json = GetJsonAsync(jsonFilePath, file).Result; if (json == null) { - Log.LogError($"Failed to deserialize json from file {jsonFilePath}"); + // the async task may have already caught an exception and logged it. + if (!Log.HasLoggedErrors) Log.LogError($"Failed to deserialize json from file {jsonFilePath}"); return false; } return true; @@ -213,6 +215,21 @@ public bool TryGetJson(string jsonFilePath, [NotNullWhen(true)] out JsonModelRoo } } + public async Task GetJsonAsync(string jsonFilePath, FileStream file) + { + JsonModelRoot? json = null; + try + { + json = await JsonSerializer.DeserializeAsync(file, JsonOptions).ConfigureAwait(false); + } + catch (JsonException e) + { + Log.LogError($"Failed to deserialize json from file '{jsonFilePath}', JSON Path: {e.Path}, Line: {e.LineNumber}, Position: {e.BytePositionInLine}"); + Log.LogErrorFromException(e, showStackTrace: false, showDetail: true, file: null); + } + return json; + } + internal void LogParsedJson (JsonModelRoot json) { if (json.Properties != null) From 621306755a71b6a4a117bbe9307ac230eae65c26 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Wed, 7 Jul 2021 15:57:51 -0400 Subject: [PATCH 49/49] fixup comments --- src/mono/mono/component/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/component/CMakeLists.txt b/src/mono/mono/component/CMakeLists.txt index e604bc82b54dce..1bc4eadb672910 100644 --- a/src/mono/mono/component/CMakeLists.txt +++ b/src/mono/mono/component/CMakeLists.txt @@ -82,7 +82,7 @@ set(${MONO_DIAGNOSTICS_TRACING_COMPONENT_NAME}-dependencies #define a library for each component and component stub function(define_component_libs) - # NOTE: keep library naming pattern in sync with component-manifest.targets + # NOTE: keep library naming pattern in sync with RuntimeComponentManifest.targets if (NOT DISABLE_LIBS) foreach(component IN LISTS components) add_library("mono-component-${component}-static" STATIC $) @@ -122,7 +122,7 @@ endforeach() if(NOT DISABLE_COMPONENTS AND NOT STATIC_COMPONENTS) # define a shared library for each component foreach(component IN LISTS components) - # NOTE: keep library naming pattern in sync with component-manifest.targets + # NOTE: keep library naming pattern in sync with RuntimeComponentManifest.targets if(HOST_WIN32) add_library("mono-component-${component}" SHARED "${${component}-sources}") target_compile_definitions("mono-component-${component}" PRIVATE -DCOMPILING_COMPONENT_DYNAMIC;-DMONO_DLL_IMPORT) @@ -190,7 +190,7 @@ if(NOT MONO_CROSS_COMPILE) set(TemplateMonoRuntimeComponentLinking "dynamic") endif() endif() - # Write a component-manifest.props file in the artifacts/obj/mono//build/ directory + # Write a RuntimeComponentManifest.json file in the artifacts/obj/mono//build/ directory # without the ../.. the file would go in artifacts/obj/mono//mono/mini configure_file( "${MONO_COMPONENT_PATH}/RuntimeComponentManifest.json.in" "../../build/RuntimeComponentManifest.json") endif()