title: How can I access app.config on the BeforeBuild event from a custom MSBuild task?
body: <p>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</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt;
  &lt;configuration&gt;
    &lt;configSections&gt;
      &lt;section name="CoreDataConnections" type="CoreData.ConfigHandler, CoreData"&gt;&lt;/section&gt;
    &lt;/configSections&gt;
    &lt;CoreDataConnections&gt;
    &lt;Connection Name="BillingDB" ConnectionString="Data Source=SERVER0;Initial Catalog=DB0;persist security info=False;user id=user;password=password;packet size=4096"/&gt;
    &lt;Connection Name="ValidationDB" ConnectionString="data source=SERVER1;initial catalog=DB1;persist security info=False;user id=user;password=password;packet size=4096"/&gt;
    &lt;/CoreDataConnections&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>and access it all day from my app like so:</p>
  
  <pre><code>Dictionary&lt;string,string&gt; Connections = (Dictionary&lt;string,string&gt;)ConfigurationSettings.GetConfig("CoreDataConnections");
  </code></pre>
  
  <p>My custom task can't see it, though, and <code>GetConfig</code> returns <code>null</code>.</p>
  
  <p>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.</p>