/// <summary> /// Creates a PreparedCoreClrVersion with the given version as /// the "original" version and using the original version's path as /// the path. /// </summary> /// <param name="version">The original version</param> public PreparedCoreClrVersion(CoreClrVersion version) { Debug.Assert(!version.IsPartial); OriginalVersion = version; Path = version.Path; m_createdATempDirectory = false; }
/// <summary> /// Creates a PreparedCoreClrVersion with the given version as the /// "original" version and a path to the "fixed" version. /// </summary> /// <param name="version">The original version</param> /// <param name="path">Path to the directory created for this version. /// Must be a temporary path and will be deleted by this class upon disposal.</param> public PreparedCoreClrVersion(CoreClrVersion version, string path) { Debug.Assert(version.IsPartial); OriginalVersion = version; Path = path; m_createdATempDirectory = true; }
private static bool FixSingleCoreClrVersion(CoreClrVersion version, RunSettings settings, out PreparedCoreClrVersion preparedVersion) { // is this a fully-specified version (i.e. the user gave us a full directory)? if so, there's nothing // to do here. if (!version.IsPartial) { Logger.LogVerbose($"Version {version.Name} is complete and needs no additional processing"); preparedVersion = new PreparedCoreClrVersion(version); return(true); } // otherwise, we're going to need to create a new directory and populate it. // the idea here is to use the SharedBinaryFolder option given to us to populate // the new folder we create and then copy the user provided files on top of it. // // we need settings.SharedBinaryFolder to be present for this, so we error here // if it's not. if (string.IsNullOrEmpty(settings.SharedBinaryFolder)) { Logger.LogError("The SharedBinaryFolder settings key was required and not provided. See the documentation for more information."); preparedVersion = null; return(false); } if (!Directory.Exists(settings.SharedBinaryFolder)) { Logger.LogError("The SharedBinaryFolder settings key referred to a folder that does not exist. See the documentation for more information."); preparedVersion = null; return(false); } Debug.Assert(Path.IsPathRooted(settings.SharedBinaryFolder)); var tempPath = Path.Combine(Path.GetTempPath(), "CoreGCBench.Runner", Guid.NewGuid().ToString()); Logger.LogVerbose($"Version {version.Name} is partial, using temp directory {tempPath}"); Directory.CreateDirectory(tempPath); Logger.LogVerbose($"Copying files from {settings.SharedBinaryFolder} to {tempPath}"); CopyDirectory(version.Path, tempPath); foreach (var file in version.Files) { Logger.LogVerbose($"Copying file {file} from {version.Path} to {tempPath}"); string filePath = Path.Combine(version.Path, file); if (!File.Exists(filePath)) { Logger.LogError($"File {file} for version {version.Name} does not exist at location {version.Path}"); preparedVersion = null; return(false); } string targetPath = filePath.Replace(version.Path, tempPath); File.Copy(filePath, targetPath); } Logger.LogVerbose($"Successfully created temporary version folder at {tempPath}"); preparedVersion = new PreparedCoreClrVersion(version, tempPath); return(true); }