title: Cant Build project using MSBuild The "Microsoft.Build.Tasks.Message" task could not be loaded from the assembly Microsoft.Build.Tasks.Core
body: <p>Am having the next error when trying to build a project using the MSBuild API.</p>
  
  <blockquote>
    <p>D:\Visual Studio\2017\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets(753,5) (MSBuild):The "Microsoft.Build.Tasks.Message" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Could not load file or assembly 'Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.</p>
  </blockquote>
  
  <p>I have installed the last versions of MSBuild using Nuget </p>
  
  <p>Microsoft.Build v15.6.85 </p>
  
  <p>Am running .NET Framework 4.6, i have tried installing build tools even when i already have visual studio installed. I have tried the solutions suggested in this thread <a href="https://github.com/Microsoft/msbuild/issues/2369" rel="nofollow noreferrer">https://github.com/Microsoft/msbuild/issues/2369</a> ,unfortunately i havent been able to build my projects.</p>
  
  <p>Following am embedding the code of my builder.</p>
  
  <pre><code>public class DotNetApplicationBuilder : IApplicationBuilderService
  {
      public IBuildLogger BuildLog { get; set; }
      public string BuildPath { get; set; }
      public bool BuildSuccessful { get; set; }
  
  
      public DotNetApplicationBuilder(IBuildLogger buildLogger)
      {
          BuildLog = buildLogger;
  
      }
  
  
  
      public void BuildApplication()
      {
  
          BuildLog.LogInformation("Application Builder: Starting to build App");
          //Environment.SetEnvironmentVariable("VSINSTALLDIR", @"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community");
          //Environment.SetEnvironmentVariable("VSINSTALLDIR", @"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools");
          //Environment.SetEnvironmentVariable("VisualStudioVersion", @"15.0");
          Environment.SetEnvironmentVariable("MSBUILD_EXE_PATH", @"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe");
  
          ProjectCollection pc = new ProjectCollection();
          Dictionary&lt;string, string&gt; GlobalProperty = new Dictionary&lt;string, string&gt;();
          GlobalProperty.Add("Configuration", "Release");
          GlobalProperty.Add("Platform", "AnyCPU");
          //GlobalProperty.Add("OutputPath", Pu);//@"D:\Proyectos\Middleware\Publish"+ @"\" + dirName); //
          //GlobalProperty.Add("VSINSTALLDIR", @"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community");
          GlobalProperty.Add("VisualStudioVersion", @"15.0");
          ////GlobalProperty.Add("DeployOnBuild", "true");
          //GlobalProperty.Add("DeleteExistingFiles", "true");
          //GlobalProperty.Add("WebPublishMethod", "FileSystem");
          //GlobalProperty.Add("publishUrl", publishPath);
  
          //temporaryPath = temporaryPath + $"\\_PublishedWebsites\\{dirName}";
  
  
          BuildParameters bp = new BuildParameters(pc);
          var logger = new ProjectBuilderLogger(BuildLog);
          bp.Loggers = new List&lt;Microsoft.Build.Framework.ILogger&gt; { logger }.AsEnumerable();
  
          BuildManager.DefaultBuildManager.BeginBuild(bp);
  
          BuildRequestData BuildRequest = new BuildRequestData(BuildPath, GlobalProperty, null, new string[] { "Clean", "Build" }, null);
  
          BuildSubmission BuildSubmission = BuildManager.DefaultBuildManager.PendBuildRequest(BuildRequest);
          BuildSubmission.Execute();
          BuildManager.DefaultBuildManager.EndBuild();
  
          BuildSuccessful = BuildSubmission.BuildResult.OverallResult == BuildResultCode.Success;
          BuildLog.LogInformation($"Application Builder: Finished building app. Build Successful {BuildSuccessful}");
      }
  
      public bool WasBuildSuccessful()
      {
          return BuildSuccessful;
      }
  
      public void SetBuildPath(string path)
      {
          BuildPath = path;
      }
  
      public void SetBuildLogger(IBuildLogger logger)
      {
          BuildLog = logger;
      }
  }
  </code></pre>
  
  <p>Thanks for any clue or solution you may provide.</p>