/// <summary>
        /// Gets the paradox SDK dir.
        /// </summary>
        /// <returns></returns>
        private static string FindParadoxSdkDir()
        {
            // TODO: Get the Paradox SDK from the current selected package

            // TODO: Maybe move it in some common class somewhere? (in this case it would be included with "Add as link" in VSPackage)
            var paradoxSdkDir = Environment.GetEnvironmentVariable("SiliconStudioParadoxDir");

            if (paradoxSdkDir == null)
            {
                return null;
            }

            // Check if it is a dev directory
            if (File.Exists(Path.Combine(paradoxSdkDir, "build\\Paradox.sln")))
                return paradoxSdkDir;

            // Check if we are in a root directory with store/packages facilities
            if (NugetStore.IsStoreDirectory(paradoxSdkDir))
            {
                var store = new NugetStore(paradoxSdkDir);

                var paradoxPackage = store.GetLatestPackageInstalled(store.MainPackageId);
                if (paradoxPackage == null)
                    return null;

                var packageDirectory = store.PathResolver.GetPackageDirectory(paradoxPackage);
                return Path.Combine(paradoxSdkDir, store.RepositoryPath, packageDirectory);
            }

            return null;
        }
示例#2
0
        /// <summary>
        /// Gets the paradox SDK dir.
        /// </summary>
        /// <returns></returns>
        private static PackageInfo FindParadoxSdkDir()
        {
            // Resolve the sdk version to load from the solution's package
            var packageInfo = new PackageInfo { ExpectedVersion = PackageSessionHelper.GetPackageVersion(solution) };

            // TODO: Maybe move it in some common class somewhere? (in this case it would be included with "Add as link" in VSPackage)
            var paradoxSdkDir = Environment.GetEnvironmentVariable("SiliconStudioParadoxDir");

            // Failed to locate paradox
            if (paradoxSdkDir == null)
                return packageInfo;

            // If we are in a dev directory, assume we have the right version
            if (File.Exists(Path.Combine(paradoxSdkDir, "build\\Paradox.sln")))
            {
                packageInfo.SdkPath = paradoxSdkDir;
                packageInfo.LoadedVersion = packageInfo.ExpectedVersion;
                return packageInfo;
            }

            // Check if we are in a root directory with store/packages facilities
            if (NugetStore.IsStoreDirectory(paradoxSdkDir))
            {
                var store = new NugetStore(paradoxSdkDir);
                IPackage paradoxPackage = null;

                // Try to find the package with the expected version
                if (packageInfo.ExpectedVersion != null && packageInfo.ExpectedVersion >= MinimumVersion)
                    paradoxPackage = store.GetPackagesInstalled(store.MainPackageId).FirstOrDefault(package => GetVersion(package) == packageInfo.ExpectedVersion);

                // If the expected version is not found, get the latest package
                if (paradoxPackage == null)
                    paradoxPackage = store.GetLatestPackageInstalled(store.MainPackageId);

                // If no package was found, return no sdk path
                if (paradoxPackage == null)
                    return packageInfo;

                // Return the loaded version and the sdk path
                var packageDirectory = store.PathResolver.GetPackageDirectory(paradoxPackage);
                packageInfo.LoadedVersion = GetVersion(paradoxPackage);
                packageInfo.SdkPath = Path.Combine(paradoxSdkDir, store.RepositoryPath, packageDirectory);
            }

            return packageInfo;
        }