Reputation: 2245
I have a file: AppSetting.config in the root folder of my solution. In my projects App.Config I want to do the following:
<AppSettings file="<PathToSolutionRoot>\AppSetting.config />
Is there a way to get the <PathToSolutionRoot>
somehow and stick it in the AppSettings so it points to the solution root folder?
Upvotes: 2
Views: 2210
Reputation: 7783
From the documentation:
The path that is specified is relative to the local configuration file. The runtime ignores the attribute, if the specified file cannot be found.
So, this should work:
<AppSettings file="AppSetting.config" />
Now, if you run this in debug mode, it won't work. The reason is you need to add a post-build event so the appsettings.config file is copied to the bin\debug folder:
copy "$(ProjectDir)AppSettings.config" "$(TargetDir)AppSettings.config"
The double quotes are intentional as you may have spaces in the path.
So when you deploy your app, make sure you have this file copied to the root where the executable lives and it should work.
Upvotes: 4