Skip to content

Commit

Permalink
Merge pull request #12 from thinkbeforecoding/fix/refload
Browse files Browse the repository at this point in the history
Fix loading of net6.0 6.0.x
  • Loading branch information
thinkbeforecoding authored Jan 28, 2022
2 parents cffa5d5 + d5850c8 commit 2dd840e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 1.2.1
* Support for net6.0 version 6.0.1

# 1.1.0
* Support for net 6.0

Expand Down
22 changes: 13 additions & 9 deletions src/fasmi/Compilation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ open System
open FileSystem
open FSharp.Compiler.CodeAnalysis

// the Assembly attribute to build output as net5.0
// the Assembly attribute to build output as net5.0/net6.0

let netAttr =
#if NET6_0
Expand All @@ -22,10 +22,10 @@ do ()

#endif

let netAttrName = "Net50AssemblyAttr.fs"
let netAttrName = "NetAssemblyAttr.fs"

// check the net5.0 assembly attribute file exists or create it
let ensureNet5Attr asmPath =
// check the net5.0/net6.0 assembly attribute file exists or create it
let ensureNetAttr asmPath =
let filePath = dir asmPath </> netAttrName
if not (IO.File.Exists filePath) then
IO.File.WriteAllText(filePath, netAttr)
Expand All @@ -36,16 +36,20 @@ let ensureNet5Attr asmPath =
let compile (path: string) (asmPath: string) =
let checker = FSharpChecker.Create(keepAssemblyContents = true)

// fin net5.0 assembly path
let net50Path =
// find .net assembly path
let netPath =
let runtimeDir = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
#if NET6_0
IO.Path.GetFullPath(runtimeDir </> "../../../packs/Microsoft.NETCore.App.Ref/6.0.0/ref/net6.0/")

let packDir =
IO.Directory.GetDirectories(runtimeDir </> "../../../packs/Microsoft.NETCore.App.Ref/", "6.0.*")
|> Seq.max
IO.Path.GetFullPath(packDir </> "ref/net6.0")
#else
IO.Path.GetFullPath(runtimeDir </> "../../../packs/Microsoft.NETCore.App.Ref/5.0.0/ref/net5.0/")
#endif

let attrfile = ensureNet5Attr asmPath
let attrfile = ensureNetAttr asmPath

let diag,_ =
checker.Compile([| "fsc.exe"
Expand All @@ -72,7 +76,7 @@ let compile (path: string) (asmPath: string) =
"--define:NETCOREAPP3_0_OR_GREATER"
"--define:NETCOREAPP3_1_OR_GREATER"
"--optimize+"
for f in IO.Directory.EnumerateFiles(net50Path,"*.dll") do
for f in IO.Directory.EnumerateFiles(netPath,"*.dll") do
$"-r:{f}"
|])
|> Async.RunSynchronously
Expand Down
2 changes: 1 addition & 1 deletion src/fasmi/fasmi.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageProjectUrl>https://github.com/d-edge/fasmi</PackageProjectUrl>
<RepositoryUrl>https://github.com/d-edge/fasmi</RepositoryUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>1.2.0</Version>
<Version>1.2.1</Version>
</PropertyGroup>
<ItemGroup>
<Compile Include="FileSystem.fs" />
Expand Down

0 comments on commit 2dd840e

Please sign in to comment.