Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic assembly handling for caching #884

Merged
merged 2 commits into from
Jul 25, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions src/app/FakeLib/FSIHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,17 @@ let internal runFAKEScriptWithFsiArgsAndRedirectMessages printDetails (FsiArgs(f
let assemVersionValidCount =
cacheConfig.Value.Assemblies
|> Seq.map(fun assemInfo ->
let assem =
if assemInfo.Location <> "" then
Reflection.Assembly.LoadFrom(assemInfo.Location)
else
Reflection.Assembly.Load(assemInfo.FullName)
assem.GetName().Version.ToString() = assemInfo.Version)
try
let assem =
if assemInfo.Location <> "" then
Reflection.Assembly.LoadFrom(assemInfo.Location)
else
Reflection.Assembly.Load(assemInfo.FullName)
assem.GetName().Version.ToString() = assemInfo.Version
with
| ex ->
if printDetails then tracef "Unable to find assembly %A" assemInfo
false)
|> Seq.filter(fun x -> x = true)
|> Seq.length

Expand Down Expand Up @@ -337,14 +342,21 @@ let internal runFAKEScriptWithFsiArgsAndRedirectMessages printDetails (FsiArgs(f
if File.Exists("FSI-ASSEMBLY.pdb") then
File.Delete("FSI-ASSEMBLY.pdb")

let refedAssemblies =
System.AppDomain.CurrentDomain.GetAssemblies()
|> Seq.filter(fun assem -> not assem.IsDynamic)
let dynamicAssemblies =
System.AppDomain.CurrentDomain.GetAssemblies()
|> Seq.filter(fun assem -> assem.IsDynamic)
|> Seq.filter(fun assem -> assem.GetName().Name <> "FSI-ASSEMBLY")
if dynamicAssemblies |> Seq.length > 0 then
if printDetails then
trace "Dynamic assemblies were generated during evaluation of script.\nCan not save cache."
else
let assemblies =
System.AppDomain.CurrentDomain.GetAssemblies()
|> Seq.filter(fun assem -> not assem.IsDynamic)

let cacheConfig : XDocument = Cache.create refedAssemblies
cacheConfig.Save(cacheConfigPath.Value)

if printDetails then trace (System.Environment.NewLine + "Saved cache")
let cacheConfig : XDocument = Cache.create assemblies
cacheConfig.Save(cacheConfigPath.Value)
if printDetails then trace (System.Environment.NewLine + "Saved cache")
with
| ex ->
handleException ex
Expand Down