I've written a custom MSBuild task to generate model code from MSSQL stored procedures. I want to use the same configuration for my task to connect to the database as the application does. I've created a config section that looks like this
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="CoreDataConnections" type="CoreData.ConfigHandler, CoreData"></section>
</configSections>
<CoreDataConnections>
<Connection Name="BillingDB" ConnectionString="Data Source=SERVER0;Initial Catalog=DB0;persist security info=False;user id=user;password=password;packet size=4096"/>
<Connection Name="ValidationDB" ConnectionString="data source=SERVER1;initial catalog=DB1;persist security info=False;user id=user;password=password;packet size=4096"/>
</CoreDataConnections>
</configuration>
and access it all day from my app like so:
Dictionary<string,string> Connections = (Dictionary<string,string>)ConfigurationSettings.GetConfig("CoreDataConnections");
My custom task can't see it, though, and GetConfig
returns null
.
What should I do here? I'd prefer not to have to rewrite my custom config section handler, and am more interested in, say, specifying the app.config file in an MSBuild property, but I'll do what it takes.