CopyReferencedAssemblies Optmization

Hi,
My script project includes a lot of DLL references. When I call I ScriptRun.ScriptHost.CopyReferencedAssemblies() the implementation always copy and override the files and the execution take a few seconds.
Could we have a version of CopyReferencedAssemblies that only copy the missing references (if any)?
Thanks
Hi,
You can use such approach:
class MyScriptHost : RoslynScriptHost
{
public MyScriptHost(IScriptRun scriptRun) : base(scriptRun)
{
}

private static void CopyFile(string source, string destination)
{
if (string.Compare(source, destination, true) == 0)
return;
try
{
File.Copy(source, destination, true);
}
catch
{
}
}
private static void CopyFileIfNewer(string source, string destination)
{
var sourceFileInfo = new FileInfo(source);
var destinationFileInfo = new FileInfo(destination);
if (!sourceFileInfo.Exists)
throw new InvalidOperationException();
if (destinationFileInfo.Exists &&
sourceFileInfo.LastWriteTime <= destinationFileInfo.LastWriteTime)
return;
CopyFile(source, destination);
}
public override void CopyReferencedAssemblies()
{
var references = GetReferencesToCopy();
var includePdb = ScriptRun.ScriptMode == ScriptMode.Debug;
foreach (var reference in references)
{
if (File.Exists(reference))
{
if (IsAssemblyFromGac(reference))
continue;
if (!Directory.Exists(AssemblyPath))
Directory.CreateDirectory(AssemblyPath);
try
{
CopyFileIfNewer(reference, Path.Combine(AssemblyPath, Path.GetFileName(reference)));
if (includePdb)
{
var pdb = Path.ChangeExtension(reference, ".pdb");
if (File.Exists(pdb))
CopyFileIfNewer(pdb, Path.Combine(AssemblyPath, Path.GetFileName(pdb)));
}
}
catch
{
}
}
}
}
}

We will include this optimization in our source code as well.
Regards,
Andrew
Thank you! Best support as usual.