Skip to content

Commit 5f7b215

Browse files
authored
Exclude root file from metadata (#32)
1 parent 4c6dc1a commit 5f7b215

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Queil.FSharp.FscHost/FscHost.fs

+7-6
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,16 @@ module CompilerHost =
131131

132132
let short (s: string) = s[0..10].ToLowerInvariant()
133133

134-
let deepSourceHash sourceFiles =
134+
let deepSourceHash rootContentHash sourceFiles =
135135

136136
let fileHash filePath = File.ReadAllText filePath |> sha256
137137

138138
let combinedHash =
139139
sourceFiles
140140
|> Seq.map fileHash
141141
|> Seq.sort
142-
|> Seq.reduce (fun a b -> a + b)
142+
|> Seq.fold (fun a b -> a + b) String.Empty
143+
|> (+) rootContentHash
143144
|> sha256
144145

145146
short combinedHash
@@ -194,7 +195,7 @@ module CompilerHost =
194195

195196
let outputDllName =
196197
if options.UseCache then
197-
let hash = Hash.deepSourceHash metadata.SourceFiles
198+
let hash = Hash.deepSourceHash (rootFilePath |> File.ReadAllText |> Hash.sha256 |> Hash.short) metadata.SourceFiles
198199
Path.Combine(options.OutputDir.TrimEnd('\\', '/'), $"{hash}.dll")
199200
else
200201
$"{Path.GetTempFileName()}.dll"
@@ -271,9 +272,9 @@ module CompilerHost =
271272
let metadata =
272273
{ ScriptCache.Default with
273274
FilePath = cacheDepsFilePath
274-
SourceFiles = projOptions.SourceFiles |> Seq.toList }
275+
SourceFiles = projOptions.SourceFiles |> Seq.except [rootFilePath] |> Seq.toList }
275276
log "Source files:"
276-
for sf in metadata.SourceFiles do
277+
for sf in projOptions.SourceFiles do
277278
log $" %s{sf}"
278279

279280
if options.Compiler.Standalone then
@@ -283,7 +284,7 @@ module CompilerHost =
283284
Ok(
284285
{ metadata with
285286
NuGets =
286-
metadata.SourceFiles
287+
projOptions.SourceFiles
287288
|> Seq.filter (fun p ->
288289
p.Contains("/.packagemanagement/nuget/")
289290
|| p.Contains("/.paket/load/"))

0 commit comments

Comments
 (0)