diff --git a/Core/GameInstanceManager.cs b/Core/GameInstanceManager.cs index e807021545..6488582636 100644 --- a/Core/GameInstanceManager.cs +++ b/Core/GameInstanceManager.cs @@ -281,7 +281,8 @@ public void FakeInstance(IGame game, string newName, string newPath, GameVersion foreach (var anchor in game.InstanceAnchorFiles) { - fileMgr.WriteAllText(Path.Combine(newPath, anchor), ""); + fileMgr.WriteAllText(Path.Combine(newPath, anchor), + version.WithoutBuild.ToString()); } // Don't write the buildID.txts if we have no build, otherwise it would be -1. @@ -289,9 +290,8 @@ public void FakeInstance(IGame game, string newName, string newPath, GameVersion { foreach (var b in KspBuildIdVersionProvider.buildIDfilenames) { - fileMgr.WriteAllText( - Path.Combine(newPath, b), - string.Format("build id = {0}", version.Build)); + fileMgr.WriteAllText(Path.Combine(newPath, b), + string.Format("build id = {0}", version.Build)); } } diff --git a/Core/Games/KerbalSpaceProgram2.cs b/Core/Games/KerbalSpaceProgram2.cs index fff8f6b090..d70a798eac 100644 --- a/Core/Games/KerbalSpaceProgram2.cs +++ b/Core/Games/KerbalSpaceProgram2.cs @@ -203,10 +203,13 @@ public GameVersion DetectVersion(DirectoryInfo where) private GameVersion VersionFromFile(string path) => File.Exists(path) - ? GameVersion.Parse( - FileVersionInfo.GetVersionInfo(path).ProductVersion - ?? versions.Last().ToString()) - : null; + && GameVersion.TryParse(FileVersionInfo.GetVersionInfo(path).ProductVersion + // Fake instances have an EXE containing just the version string + ?? File.ReadAllText(path), + out GameVersion v) + ? v + // Fall back to the most recent version + : KnownVersions.Last(); public string CompatibleVersionsFile => "compatible_game_versions.json"; diff --git a/Core/Registry/Registry.cs b/Core/Registry/Registry.cs index 0ba2d6c0d4..9411bf10cb 100644 --- a/Core/Registry/Registry.cs +++ b/Core/Registry/Registry.cs @@ -632,6 +632,7 @@ public IEnumerable AvailableByIdentifier(string identifier) { log.DebugFormat("Finding all available versions for {0}", identifier); return getAvail(identifier).SelectMany(am => am.AllAvailable()) + .Distinct() .OrderByDescending(m => m.version); }