JosefNemec/Playnite · error · Exception

Cannot update theme that was not generated via Toolbox utili

Error message

Cannot update theme that was not generated via Toolbox utility.

What it means

Thrown by Themes.UpdateTheme when the target theme directory lacks Theme.csproj (PlaynitePaths.ThemeProjFileName). Toolbox only knows how to update themes it generated (which ship a Theme.csproj); a hand-made theme without that project file cannot be diffed/patched against changelog zips, so the operation aborts before computing versions or backing up.

Source

Thrown at source/Tools/Playnite.Toolbox/Themes.cs:280

            foreach (var subdir in dirs)
            {
                if (!subdir.Name.StartsWith("backup_"))
                {
                    string targetPath = Path.Combine(destination, subdir.Name);
                    BackupTheme(subdir.FullName, targetPath);
                }
            }
        }

        public static void UpdateTheme(string themeDirectory, ApplicationMode mode)
        {
            var themeManifestPath = Path.Combine(themeDirectory, "theme.yaml");
            var currentThemeMan = new ThemeManifest(themeManifestPath);
            var origThemeApiVersion = new Version(currentThemeMan.ThemeApiVersion);

            if (!File.Exists(Path.Combine(themeDirectory, PlaynitePaths.ThemeProjFileName)))
            {
                throw new Exception("Cannot update theme that was not generated via Toolbox utility.");
            }

            if (ThemeManager.GetApiVersion(mode) == origThemeApiVersion)
            {
                logger.Warn("Theme is already updated to current API version.");
                return;
            }

            var folder = Paths.GetNextBackupFolder(themeDirectory);
            BackupTheme(themeDirectory, Paths.GetNextBackupFolder(themeDirectory));
            logger.Info($"Current theme backed up into \"{Path.GetFileName(folder)}\" folder.");

            var defaultThemeDir = Path.Combine(Paths.GetThemesPath(mode), "Default");
            var origFilesZip = Path.Combine(Paths.ChangeLogsDir, currentThemeMan.ThemeApiVersion + ".zip");
            var themeChanges = Themes.GetThemeChangelog(origThemeApiVersion, mode);
            if (!themeChanges.HasItems())
            {
                logger.Info("No files to update.");

View on GitHub (pinned to 5911f4e964)

Solutions

  1. Only call UpdateTheme on themes created by Toolbox (`Toolbox new DesktopTheme`/`FullscreenTheme`), which produce Theme.csproj.
  2. If you have a hand-made theme, regenerate it via `new`, port your XAML overrides in, then use UpdateTheme.
  3. Restore Theme.csproj into the theme directory if it was accidentally removed (regenerate via `new` and copy the project file).
  4. Verify with File.Exists(Path.Combine(themeDirectory, "Theme.csproj")) before calling UpdateTheme.

Example fix

// before
Themes.UpdateTheme(themeDir, mode); // no Theme.csproj present

// after
if (!File.Exists(Path.Combine(themeDir, PlaynitePaths.ThemeProjFileName)))
    throw new InvalidOperationException("Theme not Toolbox-generated; cannot update.");
Themes.UpdateTheme(themeDir, mode);
Defensive patterns

Strategy: validation

Validate before calling

if (!File.Exists(Path.Combine(themeDirectory, PlaynitePaths.ThemeProjFileName)))
    throw new InvalidOperationException($"{themeDirectory} is not a Toolbox-generated theme (no Theme.csproj).");

Prevention

When it happens

Trigger: Calling UpdateTheme on a theme folder that was authored manually or imported from elsewhere and never had a Theme.csproj. The method first loads theme.yaml, then checks for Theme.csproj and throws if absent.

Common situations: Updating a downloaded/custom theme that was not created via `Toolbox new <ThemeType>`; theme folder where Theme.csproj was deleted or excluded; treating a .pthm-extracted theme as Toolbox-generated.

Related errors


AI-assisted analysis of JosefNemec/Playnite@5911f4e964 (2026-08-13). Data as JSON: /api/errors/d8c1c73a65f0c96f. Report an issue: GitHub.