Wayne Molina
Wayne Molina

Reputation: 19586

App.config: appSettings "file" attribute is not reading from the Local.config

I have a test project, with an App.config that sets up default values for some settings. I want to override these settings at the local level so each developer can, for instance, use their own credentials.

In my App.config I have the following:

<appSettings file="Local.config">
    <add key="Username" value="USERNAME"/>
    <add key="Password" value="PASSWORD"/>
</appSettings>

in the Local.config (in the same directory) I have the following:

<appSettings>
    <add key="Username" value="wayne"/>
    <add key="Password" value="secret"/>
</appSettings>

When I run my test I expect that getting the value of Username would return "wayne" from the Local.config; instead, it's "USERNAME" from the App.config - it seems as though it's not actually detecting that I want to override settings in another file.

What am I doing wrong?

Upvotes: 6

Views: 3131

Answers (1)

xelco52
xelco52

Reputation: 5347

I hate to ask, but are you sure the Local.config is being copied to the output directory?

Upvotes: 9

Related Questions