Building a .Net project from a Console Application

  Uncategorised

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
‘C:UsersmyUsersourceBuilderProjectbinDebugnet6.0SdkResolversMicrosoft.Build.NuGetSdkResolverMicrosoft.Build.NuGetSdkResolver.xml’.
SDK resolver path:
C:UsersmyUsersourceBuilderProjectbinDebugnet6.0Microsoft.Build.NuGetSdkResolver.dll
C:UsersmyUsersourcereposWpfApp1ZConsoleApp2ZConsoleApp2.csproj

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.

Thanks!

Source: Visual Studio Questions

LEAVE A COMMENT