I want to build asp.net core project using another C# project. Here is the sample code. ( I am using Visual Studio 2015)
var projectCollection = new Microsoft.Build.Evaluation.ProjectCollection(Microsoft.Build.Evaluation.ToolsetDefinitionLocations.Registry);
projectCollection.DefaultToolsVersion = "14.0";
projectCollection.RegisterLogger(new Microsoft.Build.Logging.ConsoleLogger(Microsoft.Build.Framework.LoggerVerbosity.Detailed));
var project = projectCollection.LoadProject(@"H:\Development\WebApplication22\src\WebApplication22\WebApplication22.xproj");
bool b = project.Build();
It gives me many errors. Following is one of them.
The "GetTransitiveNonDotNetProjectDependencies" task could not be loaded from the assembly C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Tasks.dll. Method 'get_BuildEngine' in type 'Microsoft.DotNet.Tasks.KProcess' from assembly 'Microsoft.DotNet.Tasks, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' does not have an implementation. 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. Done building target "_GetDependencyFragmentFiles" in project "WebApplication22. xproj" -- FAILED.
Note : If I am using Visual Studio Command Prompt and use MSbuild then it works fine.