From 26a12cb531161e1fc3d6ec1f2a241e1c516ca775 Mon Sep 17 00:00:00 2001 Patch-Source: https://src.fedoraproject.org/rpms/dotnet6.0/blob/src/msbuild/rawhide/f/msbuild-no-systemconfiguration.patch From: Antoine Martin Date: Fri, 21 Oct 2022 14:13:04 -0400 Subject: [PATCH 1/2] optional-systemconfiguration Fix mono-specific runtime crashes running msbuild. CoreCLR does not load types that are not actually used/invoked at runtime, while mono does. System.Configuration and System.Security are missing in source-build builds, which breaks msbuild. --- src/Build/Definition/ProjectCollection.cs | 4 ++++ src/Build/Definition/ToolsetReader.cs | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/src/msbuild/src/Build/Definition/ProjectCollection.cs b/src/msbuild/src/Build/Definition/ProjectCollection.cs index 8629bd943..6a550e32d 100644 --- a/src/msbuild/src/Build/Definition/ProjectCollection.cs +++ b/src/msbuild/src/Build/Definition/ProjectCollection.cs @@ -1754,7 +1754,11 @@ namespace Microsoft.Build.Evaluation #if FEATURE_WIN32_REGISTRY ToolsetRegistryReader registryReader = null, #endif +#if FEATURE_SYSTEM_CONFIGURATION ToolsetConfigurationReader configReader = null +#else + object configReader = null +#endif ) { _toolsets = new Dictionary(StringComparer.OrdinalIgnoreCase); diff --git a/src/msbuild/src/Build/Definition/ToolsetReader.cs b/src/msbuild/src/Build/Definition/ToolsetReader.cs index 869b3318e..c6b95d3cf 100644 --- a/src/msbuild/src/Build/Definition/ToolsetReader.cs +++ b/src/msbuild/src/Build/Definition/ToolsetReader.cs @@ -101,7 +101,11 @@ namespace Microsoft.Build.Evaluation #if FEATURE_WIN32_REGISTRY ToolsetRegistryReader registryReader, #endif +#if FEATURE_SYSTEM_CONFIGURATION ToolsetConfigurationReader configurationReader, +#else + object _configurationReader, +#endif PropertyDictionary environmentProperties, PropertyDictionary globalProperties, ToolsetDefinitionLocations locations @@ -120,6 +124,7 @@ namespace Microsoft.Build.Evaluation if ((locations & ToolsetDefinitionLocations.ConfigurationFile) == ToolsetDefinitionLocations.ConfigurationFile) { +#if FEATURE_SYSTEM_CONFIGURATION if (configurationReader == null) { configurationReader = new ToolsetConfigurationReader(environmentProperties, globalProperties); @@ -129,6 +134,9 @@ namespace Microsoft.Build.Evaluation defaultToolsVersionFromConfiguration = configurationReader.ReadToolsets(toolsets, globalProperties, initialProperties, true /* accumulate properties */, out overrideTasksPathFromConfiguration, out defaultOverrideToolsVersionFromConfiguration); +#else + throw new InvalidOperationException("ToolsetDefinitionLocations.ConfigurationFile not supported"); +#endif } string defaultToolsVersionFromRegistry = null; -- 2.36.3