Skip to content

Commit 4259878

Browse files
committed
scriptcs#538 Changing logic to display a single warning if a load failure occurs
1 parent f3e52d5 commit 4259878

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/ScriptCs.Hosting/RuntimeServices.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ protected override IContainer CreateContainer()
6868
var assemblies = assemblyResolver.GetAssemblyPaths(currentDirectory);
6969

7070
var aggregateCatalog = new AggregateCatalog();
71+
bool assemblyLoadFailures = false;
72+
7173
foreach (var assembly in assemblies)
7274
{
7375
try
@@ -78,11 +80,17 @@ protected override IContainer CreateContainer()
7880
}
7981
catch(Exception ex)
8082
{
81-
this.Logger.WarnFormat("Failed loading Assembly {0}", assembly);
82-
this.Logger.Debug(ex.Message);
83+
assemblyLoadFailures = true;
84+
Logger.DebugFormat("Failure loading assembly: {0}. Exception: {1}", assembly, ex.Message);
8385
}
8486
}
85-
87+
if (assemblyLoadFailures)
88+
{
89+
if (_scriptName == null || _scriptName.Length == 0)
90+
Logger.Warn("Some assemblies failed to load. Launch with '-repl -loglevel debug' to see the details");
91+
else
92+
Logger.Warn("Some assemblies failed to load. Launch with '-loglevel debug' to see the details");
93+
}
8694
builder.RegisterComposablePartCatalog(aggregateCatalog);
8795
}
8896

0 commit comments

Comments
 (0)