WPF/MSIX application settings not getting updated when new version of the app is installed

Chuck Bohling 346 Reputation points
2021-01-15T02:24:47.223+00:00

I have a WPF app that I'm packaging and publishing with MSIX. Application settings are saved in a class that's derived from ApplicationSettingsBase. Those settings are saved to disk in user.config in a directory something like:

C:\Users...\AppData\Local\Packages\ABC.App_bw79f7s70jab0\LocalCache\Local\ABC\App_Url_sfq33ivn4e0a1gnv0fnvxm5k421iqybb\2.0.0.0

2.0.0.0 is the app's version number. If I create a new version of the app, 2.0.1.0 for example, a new user.config is created but the settings from version 2.0.0.0 are not copied to the new user.config. The new user.config is in a new directory like:

.../LocalCache\Local\ABC\App_Url_jmygyyawvvmdg51cvztao3w12rgeuu0u\2.0.1.0

It sounds like ApplicationSettingsBase.Upgrade is supposed to update the new config with settings from the old version but it's not working.

Any idea what could be wrong?

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,678 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Chuck Bohling 346 Reputation points
    2021-01-15T18:40:58.527+00:00

    I have a Visual Studio 2019 solution with my app project and an MSIX project. To "publish", I just use MSIX -> Publish -> Create App Packages -> Sideloading. The cert I use for signing is a temp self-signed cert that VS created.

    Apparently, the source of the problem is how the resulting msixbundle get installed.

    In my example above, user.config for version 2.0.0.0 gets written to

    .../LocalCache/Local/.../App_Url_sfq33ivn4e0a1gnv0fnvxm5k421iqybb\2.0.0.0

    But when I create version 2.0.1.0, build a new msixbundle and update to the new version, user.config for version 2.0.1.0 is in

    .../LocalCache/Local/.../App_Url_jmygyyawvvmdg51cvztao3w12rgeuu0u\2.0.1.0

    The parent directories are different. If I copy user.config 2.0.0.0 into the same directory as 2.0.1.0 (App_Url_jmygyyawvvmdg51cvztao3w12rgeuu0u) then the upgrade works.

    So the question now is, why does the MSIX installer use different directories? That means each version of the app has its own directory. Why? Is this because I'm sideloading? Is there something in the MSIX project I need to set to prevent this from happening?

    Thanks

    1 person found this answer helpful.

  2. TAH 1 Reputation point
    2021-05-13T16:39:38.98+00:00

    @Chuck Bohling
    Could you solve the problem? Because I am struggeling with the same issue.
    Appreciate your response!