简体   繁体   中英

Relocating config files of depending assemblies

My application uses NLog as a logging framework hidden behind a facade in MyLogging project. The project is referenced by a number of web sites to not make them directly dependent on NLog. After compilation NLog.config from the logging project ends up in bin folders of each site and NLog manages to find it automatically during startup. That is understandable and pretty much OK. However, editing any file within bin folder forces ASP.NET to restart the working process so I'd like to have NLog.config one folder up beside regular web.config .

Things I'm trying to achieve\\avoid:

  1. Keep NLog configuration in a single file `cause it's the same for all of my web sites
  2. Not to embed it into sites web.config (to not trigger ASP.NET auto-restart)
  3. Just moving the file after building projects with msbuild command is not an option because the sites are deployed to Azure (moved files won't be packaged during publishing process)
  4. I'd like to avoid messing with post-deployment scripts and hard coding things like E:\\siteroot\\0

The issue is not actually NLog specific as I'd have same trouble with standard app.config files. What are my options here?

For ASP.NET applications, it's recommend to set:

  • "Build Action" to "content". Otherwise it won't be copied to the root folder (folder with web.config)
  • "copy to Output Directory" to "none". Otherwise it will be copied to your bin folder.

See:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM