Seems like there is some directx library missing.
1>------ Build started: Project: MemoryProfiler2, Configuration: Release Any CPU ------
1>MemoryProfiler2 -> E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\MemoryProfiler2\bin\Release\net6.0-windows\MemoryProfiler2.dll
2>------ Build started: Project: UE5ProgramRules, Configuration: Release Any CPU ------
2>E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\ShaderCompileWorker\ShaderCompileWorker.Build.cs(34,28,34,35): error CS0103: The name 'DirectX' does not exist in the current context
2>E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\Shared\EpicGames.Perforce.Native\DotNetPerforceLib.Build.cs(5,14,5,31): warning CA1050: Declare types in namespaces
2>E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\Shared\EpicGames.Perforce.Native\DotNetPerforceLib.Target.cs(5,14,5,37): warning CA1050: Declare types in namespaces
2>E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\Enterprise\Datasmith\DatasmithRhinoExporter\DatasmithRhino7.Target.cs(20,11,20,118): warning CA1416: This call site is reachable on all platforms. 'Registry.GetValue(string, string?, object?)' is only supported on: 'windows'.
2>E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\Enterprise\Datasmith\DatasmithSolidworksExporter\DatasmithSolidworks2021.Target.cs(25,21,25,45): warning CA1416: This call site is reachable on all platforms. 'RegistryKey.GetValueNames()' is only supported on: 'windows'.
2>E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\Enterprise\Datasmith\DatasmithSolidworksExporter\DatasmithSolidworks2021.Target.cs(22,26,22,104): warning CA1416: This call site is reachable on all platforms. 'RegistryKey.OpenSubKey(string)' is only supported on: 'windows'.
2>E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\Enterprise\Datasmith\DatasmithSolidworksExporter\DatasmithSolidworks2021.Target.cs(31,14,31,52): warning CA1416: This call site is reachable on all platforms. 'RegistryKey.GetValue(string?)' is only supported on: 'windows'.
2>E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\Enterprise\Datasmith\DatasmithSolidworksExporter\DatasmithSolidworks2021.Target.cs(22,26,22,47): warning CA1416: This call site is reachable on all platforms. 'Registry.LocalMachine' is only supported on: 'windows'.
2>E:\UnrealEngine-5.2-preview-1\Engine\Source\Programs\Enterprise\Datasmith\DatasmithRhinoExporter\DatasmithRhino6.Target.cs(166,11,166,118): warning CA1416: This call site is reachable on all platforms. 'Registry.GetValue(string, string?, object?)' is only supported on: 'windows'.
2>Done building project "UE5ProgramRules.csproj" -- FAILED.