Friday, February 22, 2008

Replacing mailSettings with Web Deployment Projects

Up until this morning, I've been able to avoid deciding how to handle environment specific settings for a new application I am working on. By using the hosts file, I was able to create a logical name for my SQL server for example which I could replicate accross my environments. This worked fine until this morning when I added email sending capabilities into the web application.

I decided to go and implement web deployment projects which provide a way to replace portions of the configuration files. I set everything up and then following along with this article from Microsoft.

I click build and I get the following error: Error 106 web.config(1): error WDP00002: missing section system.net/mailSettings.

It turns out WDP's configuration replacement tool cannot replace SectionGroups. It can only replace sections. Both System.Net and mailSettings are SectionGroups and thus cannot be replaced out.

If you want to replace the mailSettings you will need to target the smtp node so you'll want to use the following settings:
system.net/mailSettings/smtp=<your config file>

1 comment:

Todd Fennell said...

Thanks! I was just dealing with the exact same issue.