/// <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; }
/// <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; }