I've run into some issues with the Visual Studio Properties.Settings.Default
method of saving config values persistently in a user.config
file in AppData
. The main problem is the way the file is stored - it's location (and the file contents) when running unit tests compared to the main executable. It also changes along with the assembly version.
Update:
To clarify (per comments), when running the app different ways (and from different projects in a solution), the Properties.Settings.Default
auto-generated functionality uses a different folder to store the user.config file in each case:
- When running the application directly (with the company name in the assembly information empty):
[Documents]\AppData\[MyApp]\[MyApp.Exe]_Url_[hash]\1.0.0.0\user.config
- When running the Resharper test runner:
[Documents]\AppData\JetBrains\[MyUnitTestProjectName]_StrongName_[hash]\109.0.0.0\user.config
- When running the xunit test runner within Visual Studio:
[Documents]\AppData\Microsoft_Corporation\[MyUnitTestProjectName]_StrongName_[hash]\15.0.26720.2\user.config
Since the user.config file is stored and looked for in different places, depending on whether I'm running the app directly or running unit tests, when I save info out of my normal running exe, I cannot access that same info while running unit tests.
Similarly, if I switch from a GUI frontend to a Console frontend, I have the same issue, because the file is specific to the run-time executable parent (I think). I just want a single config that is saved and used for any part of a given solution that wants to access it.
So, is there another built-in way to do configuration management in .NET, or another way to solve this issue?
I see lots of applications that have custom named config files and other data in their AppData folders - are they using a standard .NET library for that?