Unhandled Exception: System.Exception: Steam game with id 892970 is not installed
geocine opened this issue · comments
I am getting this error when trying to build
ModTemplateValheim.csproj(65,9): error :
ModTemplateValheim.csproj(65,9): error : Unhandled Exception: System.Exception: Steam game with id 892970 is not installed.
ModTemplateValheim.csproj(65,9): error : at BuildTool.Steam.FindGame(UInt32 steamAppId) in D:\PL\valheim-tools\ModTemplateValheim\BuildTool\Steam.cs:line 34
ModTemplateValheim.csproj(65,9): error : at BuildTool.Program.EnsureSteamGame(UInt32 steamAppId) in D:\PL\valheim-tools\ModTemplateValheim\BuildTool\Program.cs:line 161
ModTemplateValheim.csproj(65,9): error : at BuildTool.Program.<>c.<Main>b__9_2() in D:\PL\valheim-tools\ModTemplateValheim\BuildTool\Program.cs:line 34
ModTemplateValheim.csproj(65,9): error : at System.Threading.Tasks.Task`1.InnerInvoke()
ModTemplateValheim.csproj(65,9): error : at System.Threading.Tasks.Task.Execute()
ModTemplateValheim.csproj(65,9): error : --- End of stack trace from previous location where exception was thrown ---
ModTemplateValheim.csproj(65,9): error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
ModTemplateValheim.csproj(65,9): error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ModTemplateValheim.csproj(65,9): error : at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
ModTemplateValheim.csproj(65,9): error : at BuildTool.Program.<Main>d__9.MoveNext() in D:\PL\valheim-tools\ModTemplateValheim\BuildTool\Program.cs:line 34
ModTemplateValheim.csproj(65,9): error : --- End of stack trace from previous location where exception was thrown ---
ModTemplateValheim.csproj(65,9): error : at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
ModTemplateValheim.csproj(65,9): error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ModTemplateValheim.csproj(65,9): error : at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
ModTemplateValheim.csproj(65,9): error : at BuildTool.Program.<Main>(String[] args)
You can see I have Valheim installed below
My development enviroment
.NET SDK
Version: 5.0.103
Commit: 72dec52dbd
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19041
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.103\
.NET SDKs installed:
5.0.103 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.25 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
I tried to debug this, its looking for the steam library path on the libraryfolders.vdf
file which contains only this
"LibraryFolders"
{
"TimeNextStatsReport" "1614145055"
"ContentStatsID" "-5085998252142069757"
}
I will try to just shortcircuit it to the steamapps
directory , as there is where the appmanifest_*.acf
files are located
I am not exactly sure why we need to do the step I described above @Measurity , so i will just leave this here as a patch if you have a need for it, or if someone has trouble making this work.
diff --git a/BuildTool/Steam.cs b/BuildTool/Steam.cs
index 0720fd4..1ae6e16 100644
--- a/BuildTool/Steam.cs
+++ b/BuildTool/Steam.cs
@@ -20,13 +20,13 @@ namespace BuildTool
/// <exception cref="Exception">If steam is not installed or game could not be found.</exception>
public static SteamGameData FindGame(uint steamAppId)
{
- var steamPath = (string) ReadRegistrySafe("Software\\Valve\\Steam", "SteamPath");
+ var steamPath = (string)ReadRegistrySafe("Software\\Valve\\Steam", "SteamPath");
if (string.IsNullOrEmpty(steamPath))
{
throw new Exception("Steam could not be found. Check if it is installed.");
}
var appsPath = Path.Combine(steamPath, "steamapps");
- var result = SearchAllInstallations(Path.Combine(appsPath, "libraryfolders.vdf"), steamAppId);
+ var result = SearchAllInstallations(appsPath, steamAppId);
if (result == null)
{
throw new Exception($"Steam game with id {steamAppId} is not installed.");
@@ -35,36 +35,27 @@ namespace BuildTool
}
private static SteamGameData SearchAllInstallations(
- string libraryfoldersFile, uint appid)
+ string steamLibraryPath, uint appid)
{
- if (!File.Exists(libraryfoldersFile)) return null;
- // Turn contents of file into dictionary lookup.
- var steamLibraryData = JsonAsDictionary(File.ReadAllText(libraryfoldersFile));
- var steamLibraryIndex = 0;
- while (true)
- {
- steamLibraryIndex++;
- if (!steamLibraryData.TryGetValue(steamLibraryIndex.ToString(), out var steamLibraryPath)) return null;
- var steamAppDataFile = Path.Combine(steamLibraryPath, $"steamapps/appmanifest_{appid}.acf");
- if (!File.Exists(steamAppDataFile)) continue;
+ var steamAppDataFile = Path.Combine(steamLibraryPath, $"appmanifest_{appid}.acf");
+ if (!File.Exists(steamAppDataFile)) return null;
- var gameData = JsonAsDictionary(File.ReadAllText(steamAppDataFile));
+ var gameData = JsonAsDictionary(File.ReadAllText(steamAppDataFile));
- // Validate steam game data exists.
- if (!gameData.TryGetValue("name", out var gameName)) continue;
- if (!gameData.TryGetValue("appid", out var appidStr)) continue;
- if (!gameData.TryGetValue("installdir", out var gameInstallFolderName)) continue;
- // Validate Steam ID matches.
- if (!uint.TryParse(appidStr, out var appIdFromData)) continue;
- if (appIdFromData != appid) continue;
- // Validate game Path exists.
- var gameDir =
- Path.GetFullPath(Path.Combine(steamLibraryPath, "steamapps/common", gameInstallFolderName));
- if (!Directory.Exists(gameDir)) continue;
+ // Validate steam game data exists.
+ if (!gameData.TryGetValue("name", out var gameName)) return null;
+ if (!gameData.TryGetValue("appid", out var appidStr)) return null;
+ if (!gameData.TryGetValue("installdir", out var gameInstallFolderName)) return null;
+ // Validate Steam ID matches.
+ if (!uint.TryParse(appidStr, out var appIdFromData)) return null;
+ if (appIdFromData != appid) return null;
+ // Validate game Path exists.
+ var gameDir =
+ Path.GetFullPath(Path.Combine(steamLibraryPath, "common", gameInstallFolderName));
+ if (!Directory.Exists(gameDir)) return null;
- return new SteamGameData(appid, gameName, gameInstallFolderName, gameDir);
- }
+ return new SteamGameData(appid, gameName, gameInstallFolderName, gameDir);
}
private static Dictionary<string, string> JsonAsDictionary(string json)
I did the libraryfolders.vdf check because you can have steam games on different drives (aka: not where steam is installed) like I have it. Probably should fallback to not reading libraryfolders file if it doesn't contain anything useful.
i also have this issue
This has been fixed should properly work now on latest updates