Building a .Net project from a Console Application


I’m trying to set up a CI/CD enviroment, and decided to rely in c# as much as possible.

In order to do that, I created a console application that is going to be responsible from building several .Net projects.

One of those projects is a plain simple console application targeting .Net 6, but when building it, yields a couple of errors. The code from the builder project is this simple:

var projectFileName = @"........ConsoleApp2ConsoleApp2.csproj";
var pc = new ProjectCollection();
var GlobalProperty = new Dictionary<string, string>();

GlobalProperty.Add("Configuration", "Debug");
GlobalProperty.Add("Platform", "x86");
var BuidlRequest = new BuildRequestData(projectFileName, GlobalProperty, null, new string[] { "Build" }, null);
var buildResult = BuildManager.DefaultBuildManager.Build(new BuildParameters(pc), BuidlRequest);

I’m receiving the error:

Could not load SDK Resolver. A manifest file exists, but the path to
the SDK Resolver DLL file could not be found. Manifest file path
SDK resolver path:

Any clues in how to get rid of the error, on how to build a project from a .Net project? I have been flicking through many links but didn’t find much information.


Source: Visual Studio Questions