Search code examples
msix

MSIX Packaging Tool: Installed app is looking for icon in system32 and isn't found


So I finished my app, made an installer with Inno Setup, and that installer works fine.

When I made the MSIX package using MSIX Packaging Tool, installed it, and ran the app, I get this error saying it couldn't find the icon in system32. I tried adding some lines in my app's code to help find the path, but it doesn't work.

    #original code
    current_path = os.path.dirname(os.path.abspath(__file__))
    icon_path = os.path.join(current_path, "icon.ico")
    
    #new code
    if(not os.path.exists(icon_path)):
        tpath = "c:\Program Files (x86)\App Name\icon.ico"
        if(os.path.exists(tpath)):
            icon_path = tpath
        else:
            tpath = "d:\Program Files (x86)\App Name\icon.ico"
            if(os.path.exists(tpath)):
                icon_path = tpath
            else:
                tpath = "e:\Program Files (x86)\App Name\icon.ico"
                if(os.path.exists(tpath)):
                    icon_path = tpath
                else:
                    tpath = "f:\Program Files (x86)\App Name\icon.ico"
                    if(os.path.exists(tpath)):
                        icon_path = tpath
                    else:
                        tpath = "c:\Program Files\WindowsApps\AppName_1.0.0.0_x64__s235487e6trvr\VFS\ProgramFilesX86\App Name\icon.ico"
                        if(os.path.exists(tpath)):
                            icon_path = tpath
                        else:
                            glo = glob.glob("c:\Program Files\WindowsApps\AppNa*")
                            for filename in glo:
                                tpath = os.path.join(filename, "VFS\ProgrameFilesX86\App Name\icon.ico")
                                if(os.path.exists(tpath)):
                                    icon_path = tpath
                                    break

I realize some or most of that code is unnecessary, but I was just trying to fix this annoying issue.

The MSIX installs the app in c:\Program Files\WindowsApps\[some more folders], and I checked the app folder and both the app and the icon are installed there.


Solution

  • So I'm fairly certain that the MSIX Packaging Tool makes the working directory system32, and there are approximately 2 ways to fix this:

    1. (Easier) Use Advanced Installer Express to make an MSIX package or to change the working directory.
    2. (Harder) Use the MSIX Package Support Framework to do a working directory fixup.