Esempio n. 1
0
        protected bool IsVersionInstalled(string lookupVersion, string builtInDir, string dynamicInstallDir)
        {
            var versionsFromDisk = VersionProviderHelper.GetVersionsFromDirectory(builtInDir);

            if (HasVersion(versionsFromDisk))
            {
                return(true);
            }

            versionsFromDisk = VersionProviderHelper.GetVersionsFromDirectory(dynamicInstallDir);
            if (HasVersion(versionsFromDisk))
            {
                // Only if there is a sentinel file we want to indicate that a version exists.
                // This is because a user could kill a build midway which might leave the download of an SDK
                // in a corrupt state.
                var sentinelFile = Path.Combine(
                    dynamicInstallDir,
                    lookupVersion,
                    SdkStorageConstants.SdkDownloadSentinelFileName);

                if (File.Exists(sentinelFile))
                {
                    return(true);
                }
            }

            return(false);

            bool HasVersion(IEnumerable <string> versionsOnDisk)
            {
                return(versionsOnDisk.Any(onDiskVersion
                                          => string.Equals(lookupVersion, onDiskVersion, StringComparison.OrdinalIgnoreCase)));
            }
        }
Esempio n. 2
0
        protected bool IsVersionInstalled(string lookupVersion, string builtInDir, string dynamicInstallDir)
        {
            var versionsFromDisk = VersionProviderHelper.GetVersionsFromDirectory(builtInDir);

            if (HasVersion(versionsFromDisk))
            {
                Logger.LogDebug(
                    "Version {version} is already installed at directory {installationDir}",
                    lookupVersion,
                    builtInDir);

                return(true);
            }

            versionsFromDisk = VersionProviderHelper.GetVersionsFromDirectory(dynamicInstallDir);
            if (HasVersion(versionsFromDisk))
            {
                // Only if there is a sentinel file we want to indicate that a version exists.
                // This is because a user could kill a build midway which might leave the download of an SDK
                // in a corrupt state.
                var sentinelFile = Path.Combine(
                    dynamicInstallDir,
                    lookupVersion,
                    SdkStorageConstants.SdkDownloadSentinelFileName);

                if (File.Exists(sentinelFile))
                {
                    Logger.LogDebug(
                        "Version {version} is already installed at directory {installationDir}",
                        lookupVersion,
                        dynamicInstallDir);

                    return(true);
                }

                Logger.LogDebug(
                    "Directory for version {version} was already found at directory {installationDir}, " +
                    "but sentinel file {sentinelFile} was not found.",
                    lookupVersion,
                    dynamicInstallDir,
                    SdkStorageConstants.SdkDownloadSentinelFileName);
            }

            Logger.LogDebug(
                "Version {version} was not found to be installed at {builtInDir} or {dynamicInstallDir}",
                lookupVersion,
                builtInDir,
                dynamicInstallDir);

            return(false);

            bool HasVersion(IEnumerable <string> versionsOnDisk)
            {
                return(versionsOnDisk.Any(onDiskVersion
                                          => string.Equals(lookupVersion, onDiskVersion, StringComparison.OrdinalIgnoreCase)));
            }
        }
Esempio n. 3
0
        protected bool IsVersionInstalled(string lookupVersion, string[] installationDirs)
        {
            foreach (var installationDir in installationDirs)
            {
                var versionsFromDisk = VersionProviderHelper.GetVersionsFromDirectory(installationDir);
                if (versionsFromDisk.Any(onDiskVersion
                                         => string.Equals(lookupVersion, onDiskVersion, StringComparison.OrdinalIgnoreCase)))
                {
                    return(true);
                }
            }

            return(false);
        }