@@ -3,7 +3,7 @@ open System
3
3
open FileSystem
4
4
open FSharp.Compiler .CodeAnalysis
5
5
6
- // the Assembly attribute to build output as net5.0
6
+ // the Assembly attribute to build output as net5.0/net6.0
7
7
8
8
let netAttr =
9
9
#if NET6_ 0
@@ -22,10 +22,10 @@ do ()
22
22
23
23
#endif
24
24
25
- let netAttrName = " Net50AssemblyAttr .fs"
25
+ let netAttrName = " NetAssemblyAttr .fs"
26
26
27
- // check the net5.0 assembly attribute file exists or create it
28
- let ensureNet5Attr asmPath =
27
+ // check the net5.0/net6.0 assembly attribute file exists or create it
28
+ let ensureNetAttr asmPath =
29
29
let filePath = dir asmPath </> netAttrName
30
30
if not ( IO.File.Exists filePath) then
31
31
IO.File.WriteAllText( filePath, netAttr)
@@ -36,16 +36,20 @@ let ensureNet5Attr asmPath =
36
36
let compile ( path : string ) ( asmPath : string ) =
37
37
let checker = FSharpChecker.Create( keepAssemblyContents = true )
38
38
39
- // fin net5.0 assembly path
40
- let net50Path =
39
+ // find .net assembly path
40
+ let netPath =
41
41
let runtimeDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
42
42
#if NET6_ 0
43
- IO.Path.GetFullPath( runtimeDir </> " ../../../packs/Microsoft.NETCore.App.Ref/6.0.0/ref/net6.0/" )
43
+
44
+ let packDir =
45
+ IO.Directory.GetDirectories( runtimeDir </> " ../../../packs/Microsoft.NETCore.App.Ref/" , " 6.0.*" )
46
+ |> Seq.max
47
+ IO.Path.GetFullPath( packDir </> " ref/net6.0" )
44
48
#else
45
49
IO.Path.GetFullPath( runtimeDir </> " ../../../packs/Microsoft.NETCore.App.Ref/5.0.0/ref/net5.0/" )
46
50
#endif
47
51
48
- let attrfile = ensureNet5Attr asmPath
52
+ let attrfile = ensureNetAttr asmPath
49
53
50
54
let diag , _ =
51
55
checker.Compile([| " fsc.exe"
@@ -72,7 +76,7 @@ let compile (path: string) (asmPath: string) =
72
76
" --define:NETCOREAPP3_0_OR_GREATER"
73
77
" --define:NETCOREAPP3_1_OR_GREATER"
74
78
" --optimize+"
75
- for f in IO.Directory.EnumerateFiles( net50Path , " *.dll" ) do
79
+ for f in IO.Directory.EnumerateFiles( netPath , " *.dll" ) do
76
80
$" -r:{f}"
77
81
|])
78
82
|> Async.RunSynchronously
0 commit comments