/// <summary> /// This method will resolve the cache/lock file paths for the tool if available in the cache /// This method will set the CacheFilePath and the LockFilePath in the RestoreMetadat if a matching tool is available /// </summary> public static void UpdateRequestBestMatchingToolPathsIfAvailable(RestoreRequest request) { if (request.ProjectStyle == ProjectStyle.DotnetCliTool) { // Resolve the lock file path if it exists var toolPathResolver = new ToolPathResolver(request.PackagesDirectory); var toolDirectory = toolPathResolver.GetBestToolDirectoryPath( ToolRestoreUtility.GetToolIdOrNullFromSpec(request.Project), request.Project.TargetFrameworks.First().Dependencies.First().LibraryRange.VersionRange, request.Project.TargetFrameworks.SingleOrDefault().FrameworkName); if (toolDirectory != null) // Only set the paths if a good enough match was found. { request.Project.RestoreMetadata.CacheFilePath = NoOpRestoreUtilities.GetToolCacheFilePath(toolDirectory, ToolRestoreUtility.GetToolIdOrNullFromSpec(request.Project)); request.LockFilePath = toolPathResolver.GetLockFilePath(toolDirectory); } } }