.Net core single file build is generating multiple setting folders with different hashes for each assemblyversion

258 Views Asked by At

im using .Net Core 3.1 and WPF for my project and today i was playing a little bit with the settings.All worked fine. I can save values and i can access this values after restart.

After that im increased my assembly value from 1.0.0.0 to 1.0.0.1 and the settings are gone... I searched many hours to fix this issue but i did not found any solution.

Keep user's settings after altering assembly/file version

This was a pretty nice solution but this is not working for me. WHY?

Easy to say after every single file build and access to any Setting.Default values my appilcation generates a new setting folder with an new hash.

So i have multiple folders with each one user.config. Without the single file build it works fine. The new assembly version gets generated in the latest folder and i can update ist like the solution above.

enter image description here

Currently i need so setup my app again on eveery new assembly version :/ Someone had the same issue and can help me? Why is my application creating multiple settings folder for each assemblyversion?

  1. .Net Core 3.1
  2. Visual Studio 2022 (17.2.2)

enter image description here

1

There are 1 best solutions below

2
Nanmu Honery On

You can use the Upgrade method for migrating settings from previous versions.

https://learn.microsoft.com/en-us/dotnet/api/system.configuration.applicationsettingsbase.upgrade?redirectedfrom=MSDN&view=dotnet-plat-ext-6.0#System_Configuration_ApplicationSettingsBase_Upgrade

It notifies all of the corresponding settings providers of the existence of the upgraded application through a call to their IApplicationSettingsProvider.Upgrade method.

You can override the default behavior of Upgrade to implement custom upgrading or merging behavior. Use the GetPreviousVersion method to retrieve individual values for a setting for the previous version of the application.