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

support caching even when running RazorEngine as part of the build script. #979

Merged
merged 2 commits into from
Oct 14, 2015
Merged
Changes from 1 commit
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
20 changes: 16 additions & 4 deletions src/app/FakeLib/FSIHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -353,16 +353,28 @@ let internal runFAKEScriptWithFsiArgsAndRedirectMessages printDetails (FsiArgs(f
File.Delete("FSI-ASSEMBLY.dll.mdb")

let dynamicAssemblies =
System.AppDomain.CurrentDomain.GetAssemblies()
System.AppDomain.CurrentDomain.GetAssemblies()
|> Seq.filter(fun assem -> assem.IsDynamic)
|> Seq.filter(fun assem -> assem.GetName().Name <> "FSI-ASSEMBLY")
|> Seq.map(fun assem -> assem.GetName().Name)
|> Seq.filter(fun assem -> assem <> "FSI-ASSEMBLY")
// General Reflection.Emit helper (most likely harmless to ignore)
|> Seq.filter(fun assem -> assem <> "Anonymously Hosted DynamicMethods Assembly")
// RazorEngine generated
|> Seq.filter(fun assem -> assem <> "RazorEngine.Compilation.ImpromptuInterfaceDynamicAssembly")
|> Seq.cache
if dynamicAssemblies |> Seq.length > 0 then
if printDetails then
trace "Dynamic assemblies were generated during evaluation of script.\nCan not save cache."
if printDetails then
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should always show a message when caching was not possible instead of only with --printdetails. (Which means I think we should removing this line)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

let msg =
sprintf "Dynamic assemblies were generated during evaluation of script (%s).\nCan not save cache."
(System.String.Join(", ", dynamicAssemblies))
trace msg

else
let assemblies =
System.AppDomain.CurrentDomain.GetAssemblies()
|> Seq.filter(fun assem -> not assem.IsDynamic)
// They are not dynamic, but can't be re-used either.
|> Seq.filter(fun assem -> not <| assem.GetName().Name.StartsWith("CompiledRazorTemplates.Dynamic.RazorEngine_"))

let cacheConfig : XDocument = Cache.create assemblies
cacheConfig.Save(cacheConfigPath.Value)
Expand Down