private bool TryToGetToolDirForFxVersion(string toolFileName, TCallbackTool getToolPath, ref string toolDirectory) { Version frameworkVersion = GetFrameworkVersion(); if (frameworkVersion.Major < 1) { return(false); } if (getToolPath != null) { string path = getToolPath(frameworkVersion, toolFileName); if (path != null && File.Exists(path)) { toolDirectory = Path.GetDirectoryName(path); return(true); } this._ActualTask.Log.LogError(string.Format(Resources.ToolLocationHelperTypeName_could_not_find_1, (object)"Microsoft.Build.Utilities.ToolLocationHelper", (object)toolFileName)); return(false); } if (!(frameworkVersion >= ExportTaskImplementation <TTask> ._VersionUsingToolLocationHelper)) { return(false); } this._ActualTask.Log.LogError(string.Format(Resources.Cannot_get_a_reference_to_ToolLocationHelper, (object)"Microsoft.Build.Utilities.ToolLocationHelper")); return(false); }
private bool CopyIfNotExists(string file, string dir, string paths, TCallbackTool toolp) { string dest = Path.Combine(dir, file); if (File.Exists(dest)) { return(true); } string found; if (ValidateToolPath(file, paths, toolp, out found)) { File.Copy(Path.Combine(found, file), dest); return(true); } return(false); }
private bool ValidateToolPath(string toolFileName, string currentValue, TCallbackTool getToolPath, out string foundPath) { // via user values, e.g.: $(TargetFrameworkSDKToolsDirectory);... if (PropertyHasValue(currentValue) && TrySearchToolPath(currentValue, toolFileName, out foundPath)) { return(true); } // via ToolLocationHelper if (PropertyHasValue(TargetFrameworkVersion)) { string toolDirectory = currentValue; if (TryToGetToolDirForFxVersion(toolFileName, getToolPath, ref toolDirectory)) { foundPath = toolDirectory; return(true); } } foundPath = null; return(false); }