@@ -258,10 +258,23 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies
258258 if not ( assemblies.ContainsKey( referenceName)) then
259259 try
260260 if File.Exists( path) then
261- // System.Private.CoreLib doesn't load with reflection
262- if referenceName = " System.Private.CoreLib" then
261+ match referenceName with
262+ | " System.Runtime.WindowsRuntime"
263+ | " System.Runtime.WindowsRuntime.UI.Xaml" ->
264+ // The Windows compatibility pack included in the runtime contains a reference to
265+ // System.Runtime.WindowsRuntime, but to properly use that type the runtime also needs a
266+ // reference to the Windows.md meta-package, which isn't referenced by default. To avoid
267+ // a bug where types from `Windows, Version=255.255.255.255` can't be found we're going to
268+ // not default include this assembly. It can still be manually referenced if it's needed
269+ // via the System.Runtime.WindowsRuntime NuGet package.
270+ //
271+ // In the future this branch can be removed because WinRT support is being removed from the
272+ // .NET 5 SDK (https://github.com/dotnet/runtime/pull/36715)
273+ ()
274+ | " System.Private.CoreLib" ->
275+ // System.Private.CoreLib doesn't load with reflection
263276 assemblies.Add( referenceName, path)
264- else
277+ | _ ->
265278 try
266279 let asm = System.Reflection.Assembly.LoadFrom( path)
267280 assemblies.Add( referenceName, path)
0 commit comments