private static void downloadPackage(string prefix, ResourceType resourceType, string resourceName, string version) { try { // check that resource is on server var availableResources = NetworkUtils.getAvailableResources(prefix, resourceType); if (!availableResources.resourceDescriptions.ContainsKey(resourceName)) { CLIInterface.logError($"Could not find {resourceType.ToString()} resource with name {resourceName} on server"); return; } // check that resource on server has specified version var versionInfo = NetworkUtils.getResourceVersions(prefix, resourceType, resourceName); if (!versionInfo.versions.ContainsKey(version)) { CLIInterface.logError( $"Could not find version {version} on server. These are the version(s) available: {string.Join(", ", versionInfo.versions.Keys.ToList())}" ); return; } using (FileStream resourceFileStream = FSOps.createResourceFile(resourceType, resourceName)) using (StreamWriter versionFileStream = FSOps.createOrOverwriteResourceVersionFile(resourceType, resourceName)) { Task resourceFileTask = NetworkUtils.downloadResource(prefix, resourceType, resourceName, version, resourceFileStream); Task resourceVersionTask = Task.Factory.StartNew(() => { versionFileStream.WriteLine(version); }); Task.WaitAll(resourceFileTask, resourceVersionTask); } CLIInterface.logLine($"{resourceType} resource {resourceName} added"); } catch (NetworkUtils.NetworkUtilsException ex) { CLIInterface.logError($"Network Error: {ex.Message}"); } catch (FSOps.FSOpsException ex) { CLIInterface.logError($"File System Error: " + ex.Message); } }