/// <summary>
        /// Gets the path to a specified installation, or null if it is not installed.
        /// </summary>
        /// <param name="version">The version number required.</param>
        /// <param name="pro">Whether the pro version should be used.</param>
        /// <param name="platform">Whether the .NET Standard build should be used.</param>
        /// <returns>The path to the installation, or null, if it is not installed.</returns>
        public DarkRiftInstallation GetInstallation(string version, ServerTier tier, ServerPlatform platform)
        {
            string path = GetInstallationPath(version, tier, platform);

            if (fileUtility.DirectoryExists(path))
            {
                return(new DarkRiftInstallation(version, tier, platform, path));
            }

            return(null);
        }
示例#2
0
        /// <summary>
        /// Gets the path to a specified installation, or null if it is not installed.
        /// </summary>
        /// <param name="version">The version number required.</param>
        /// <returns>The path to the installation, or null, if it is not installed.</returns>
        public DocumentationInstallation GetInstallation(string version)
        {
            string path = GetInstallationPath(version);

            if (fileUtility.DirectoryExists(path))
            {
                return(new DocumentationInstallation(version, path));
            }

            return(null);
        }
示例#3
0
        /// <summary>
        /// Downloads and installs a DarkRift version.
        /// </summary>
        /// <param name="version">The version to be installed</param>
        /// <param name="tier">The tier</param>
        /// <param name="platform">The platform</param>
        /// <param name="downloadDirectory">The directory to download the release to</param>
        /// <returns>True if installed successfully otherwise false</returns>
        public bool DownloadVersionTo(string version, ServerTier tier, string platform, string downloadDirectory)
        {
            string stagingPath = fileUtility.GetTempFileName();

            string uri = $"/DarkRift2/Releases/{version}/{tier}/{platform}/";

            if (tier == ServerTier.Pro)
            {
                string invoiceNumber = invoiceManager.GetInvoiceNumber();
                if (invoiceNumber == null)
                {
                    Console.Error.WriteLine(Output.Red($"You must provide an invoice number in order to download Pro DarkRift releases."));
                    return(false);
                }

                uri += $"?invoice={invoiceNumber}";
            }

            try
            {
                webClientUtility.DownloadFile(uri, stagingPath);
            }
            catch (WebException e)
            {
                Console.Error.WriteLine(Output.Red($"Could not download DarkRift {version} - {tier} (.NET {platform}):\n\t{e.Message}"));
                return(false);
            }

            Console.WriteLine($"Extracting package...");

            try
            {
                fileUtility.ExtractZipTo(stagingPath, downloadDirectory);
            }
            catch (Exception)
            {
                // Make sure we don't leave a partial install
                if (fileUtility.DirectoryExists(downloadDirectory))
                {
                    fileUtility.Delete(downloadDirectory);
                }

                throw;
            }
            finally
            {
                fileUtility.Delete(stagingPath);
            }

            Console.WriteLine(Output.Green($"Successfully downloaded DarkRift {version} - {tier} (.NET {platform})."));

            return(true);
        }