Skip to content

Commit

Permalink
Fixed null reference exception on compilation results moving (#2795)
Browse files Browse the repository at this point in the history
As the tooltip says, the array may contain null-references:

![image](https://github.com/user-attachments/assets/e00c8430-bcaf-4ef7-a2cc-8bf1993c8950)

Now, if it does, the Seq.filter below without null-check dies and kills the whole run for "Null reference exception".
Check added to skip nulls.

Also when "file already exists", added trace message which file.
  • Loading branch information
Thorium committed Aug 30, 2024
1 parent 7ef3837 commit 2d3420d
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/app/Fake.Runtime/CompileRunner.fs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ let tryRunCached (c: CoreCacheInfo) (context: FakeContext) : RunResult =

match
types
|> Seq.filter (fun t -> parseName t.FullName |> Option.isSome)
|> Seq.filter (fun t -> not (isNull t) && parseName t.FullName |> Option.isSome)
|> Seq.map (fun t ->
t.GetMethod("main@", BindingFlags.InvokeMethod ||| BindingFlags.Public ||| BindingFlags.Static))
|> Seq.filter (isNull >> not)
Expand Down Expand Up @@ -241,7 +241,12 @@ let runUncached (context: FakeContext) : ResultCoreCacheInfo * RunResult =

if returnCode = 0 then
// here we will move the result of compilation to FAKE script directory instead of temporary directory
File.Move(compilerAssemblyTempPath, wishPath)
try
File.Move(compilerAssemblyTempPath, wishPath)
with :? System.IO.IOException ->
traceError ("Moving to destination " + wishPath)
reraise ()

File.Move(compilerPdbTempPath, pdbWishPath)

use execContext =
Expand Down

0 comments on commit 2d3420d

Please sign in to comment.