title: Unable to Invoke Custom task referring WCF Service function through MSBuild
body: <p>I am facing problem while invoking task from MSBuild -
  Below are the details what I have done -</p>
  
  <p>1)I have C# WCF project having few services running. I hosted these services on Local Host.Service "<a href="http://localhost:59605/HotfixDatabaseAccess.svc" rel="nofollow noreferrer">http://localhost:59605/HotfixDatabaseAccess.svc</a>" running on local machine.
    and it have function "IHotfixDatabaseAccess.GetComponentDetailsForHF()" which can be called by client which consume this service. </p>
  
  <p>2)I have created another C# library project and I have added "HotfixDatabaseAccess.svc" service reference within It.
    After adding service it creates App.config file which has all endpoints mentioned for service.
    <strong>App.config -</strong> Content</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8" ?&gt;
    &lt;configuration&gt;
      &lt;system.serviceModel&gt;
          &lt;bindings&gt;
              &lt;basicHttpBinding&gt;
                  &lt;binding name="BasicHttpBinding_IHotfixDatabaseAccess" /&gt;
              &lt;/basicHttpBinding&gt;
              &lt;wsHttpBinding&gt;
                  &lt;binding name="WSHttpBinding_IHotfixDatabaseAccess" /&gt;
              &lt;/wsHttpBinding&gt;
          &lt;/bindings&gt;
          &lt;client&gt;
              &lt;endpoint address="http://localhost:59605/HotfixDatabaseAccess.svc/secure"
                  binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IHotfixDatabaseAccess"
                  contract="HotfixDatabaseAccess.IHotfixDatabaseAccess" name="WSHttpBinding_IHotfixDatabaseAccess"&gt;
                  &lt;identity&gt;
                      &lt;dns value="localhost" /&gt;
                  &lt;/identity&gt;
              &lt;/endpoint&gt;
              &lt;endpoint address="http://localhost:59605/HotfixDatabaseAccess.svc"
                  binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IHotfixDatabaseAccess"
                  contract="HotfixDatabaseAccess.IHotfixDatabaseAccess" name="BasicHttpBinding_IHotfixDatabaseAccess" /&gt;
          &lt;/client&gt;
      &lt;/system.serviceModel&gt;
    &lt;/configuration&gt;
  </code></pre>
  
  <p>This C# project contains classes designed as Task, which can be callable from MSBuild project file.</p>
  
  <pre><code>namespace BuildDeliverablesTask
     {
      using System;
      using System.Collections.Generic;
      using System.IO;
      using System.Linq;
      using System.Reflection;
      using System.Text;
      using System.Text.RegularExpressions;
      using CustomTasks.HotfixDatabaseAccess;
      using Microsoft.Build.Framework;
      using Microsoft.Build.Tasks;
      using Microsoft.Build.Utilities;
  
      public class BuildDeliverables : Task
      {
           public override bool Execute()
           {
                 using (HotfixDatabaseAccessClient hfdbClient = new HotfixDatabaseAccessClient())
                 {
                     hfdbClient.GetComponentDetailsForHF(); //Called Service Function.
                 }
           }
       }
     }
  </code></pre>
  
  <p>After building this project it gives "BuildDeliverablesTask.dll" &amp; "BuildDeliverablesTask.dll.config" file.
     content of "BuildDeliverables.dll.config" is same as that of  App.config.</p>
  
  <p>3) My intention is to call this  BuildDeliverables Task from MSBuild Proj File.
      This is MSBuild "BuildDeliverables.proj" file which I have written -</p>
  
  <pre><code> &lt;Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" &gt;
      &lt;UsingTask AssemblyFile="BuildDeliverablesTask.dll" TaskName="BuildDeliverables" /&gt;
  
      &lt;Target Name="BuildDeliverableSoultions"&gt;
      &lt;BuildDeliverables/&gt;  &lt;!-- Task is Called here --&gt;    
      &lt;/Target&gt;
     &lt;/Project&gt;
  </code></pre>
  
  <p>4) Now Using MSBuild when I try to invoke "BuildDeliverables.proj" it gives me error <strong>InvalidOperationException: Could not find default endpoint element that references contra
      ct 'HotfixDatabaseAccess.IHotfixDatabaseAccess' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.\r</strong> below are error details -</p>
  
  <pre><code>"BuildDeliverables.proj" (default target) (1) -&gt;
  (BuildDeliverableSoultions target) -&gt;
    BuildDeliverables.proj(13,5): error : InvalidOperationException: Could not find default endpoint element that references contra
  ct 'HotfixDatabaseAccess.IHotfixDatabaseAccess' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element.\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.Description.ConfigLoader.LoadChannelBehaviors(ServiceEndpoint ser
  viceEndpoint, String configurationName)\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName, Confi
  guration configuration)\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.ChannelFactory.ApplyConfiguration(String configurationName)\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, Endpo
  intAddress address)\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, Endpoint
  Address remoteAddress)\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.ConfigurationEndpointTrait`1.CreateSimplexFactory()\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.ConfigurationEndpointTrait`1.CreateChannelFactory()\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrai
  t)\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()\r
  BuildDeliverables.proj(13,5): error :    at System.ServiceModel.ClientBase`1..ctor()\r
  </code></pre>
  
  <p>Could Some one help me to Resolve this error ?</p>