.NET Config Files configSource outside the application directory folder

前端 未结 10 1495
灰色年华
灰色年华 2020-11-28 05:06

I have two applications one a console application and the other an ASP.NET app. They both need to know the same appSettings and connectionStrings. So ideally I would like to

相关标签:
10条回答
  • 2020-11-28 05:42

    The solution I found worked best was to put the "shared" config files in a central files and then use a pre-build event in Visual Studio to copy them to a relative folder of each project which needed it.

    0 讨论(0)
  • 2020-11-28 05:46

    You can place both settings in the machine.config and then they are available for all you applications on the server.

    0 讨论(0)
  • 2020-11-28 05:47

    Another solution is simply to add the configuration file in all your projects as a link instead of actually copying the file to your projects. Then set the "Build Action" of the file to "Content" and "Copy to Output Directory" to "Copy if newer" and when you compile the project you will have the file in the output directory.

    To add the file as a link in the "Add Existing Item" dialog box, there is an Add button with a dropdown. Choose "Add as link" from the dropdown on the Add button to complete the process.

    0 讨论(0)
  • 2020-11-28 05:48

    Under appSettings you can use file= instead of configSource=

    0 讨论(0)
提交回复
热议问题