/// <summary>
        /// Gets the paradox SDK dir.
        /// </summary>
        /// <returns></returns>
        private static string FindParadoxSdkDir()
        {
            // 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");

            // 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)
                {
                    DefaultPackageId = "Paradox"
                };

                var paradoxPackage = store.GetLatestPackageInstalled(store.DefaultPackageId);
                if (paradoxPackage == null)
                {
                    return(null);
                }

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

            return(null);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the xenko SDK dir.
        /// </summary>
        /// <returns></returns>
        private static PackageInfo FindXenkoSdkDir()
        {
            // 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 xenkoSdkDir = Environment.GetEnvironmentVariable("SiliconStudioXenkoDir");

            // Failed to locate xenko
            if (xenkoSdkDir == null)
            {
                return(packageInfo);
            }

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

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

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

                // If the expected version is not found, get the latest package
                if (xenkoPackage == null)
                {
                    xenkoPackage = store.GetLatestPackageInstalled(store.MainPackageIds);
                }

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

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

            return(packageInfo);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the xenko SDK dir.
        /// </summary>
        /// <param name="xenkoVersion">The xenko version. If null, it will get latest version.</param>
        /// <returns></returns>
        public static string FindXenkoSdkDir(string xenkoVersion = null)
        {
            // TODO: Almost duplicate of XenkoCommandsProxy.FindXenkoSdkDir!!
            // TODO: Maybe move it in some common class somewhere? (in this case it would be included with "Add as link" in VSPackage)
            var xenkoSdkDir = DirectoryHelper.GetInstallationDirectory("Xenko");

            if (xenkoSdkDir == null)
            {
                xenkoSdkDir = Environment.GetEnvironmentVariable("SiliconStudioXenkoDir");
            }

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

            // Check if it is a dev directory
            if (File.Exists(Path.Combine(xenkoSdkDir, "build\\Xenko.sln")))
            {
                return(xenkoSdkDir);
            }

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

                var xenkoPackages = store.GetPackagesInstalled(store.MainPackageIds);
                // Convert the provided xenko version into a valid package version
                PackageVersion packageVersion;
                PackageVersion.TryParse(xenkoVersion, out packageVersion);
                // Retrieve the corresponding package, if it exists
                var xenkoPackage = packageVersion != null
                    ? (xenkoPackages.FirstOrDefault(p => p.Version == packageVersion)
                       ?? xenkoPackages.FirstOrDefault(p => p.Version.Version == packageVersion.Version)) // If no exact match, try a second time without the special version tag (beta, alpha, etc...)
                    : xenkoPackages.FirstOrDefault();
                if (xenkoPackage == null)
                {
                    return(null);
                }

                var packageDirectory = store.GetPackageDirectory(xenkoPackage);
                return(Path.Combine(xenkoSdkDir, store.RepositoryPath, packageDirectory));
            }

            return(null);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the paradox SDK dir.
        /// </summary>
        /// <param name="paradoxVersion">The paradox version. If null, it will get latest version.</param>
        /// <returns></returns>
        public static string FindParadoxSdkDir(string paradoxVersion = null)
        {
            // TODO: Almost duplicate of ParadoxCommandsProxy.FindParadoxSdkDir!!
            // TODO: Maybe move it in some common class somewhere? (in this case it would be included with "Add as link" in VSPackage)
            var paradoxSdkDir = DirectoryHelper.GetInstallationDirectory("Paradox");

            if (paradoxSdkDir == null)
            {
                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 paradoxPackages = store.GetPackagesInstalled(store.MainPackageId);
                var paradoxPackage  = paradoxVersion != null
                    ? (paradoxPackages.FirstOrDefault(p => p.Version.ToString() == paradoxVersion)
                       ?? paradoxPackages.FirstOrDefault(p => VersionWithoutSpecialPart(p.Version.ToString()) == VersionWithoutSpecialPart(paradoxVersion)))  // If no exact match, try a second time without the special version tag (beta, alpha, etc...)
                    : paradoxPackages.FirstOrDefault();
                if (paradoxPackage == null)
                {
                    return(null);
                }

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

            return(null);
        }