using System; namespace MsBuildTest { class Program { static void Main(string[] args) { // Singleton to be used in the build task (visible in .NET Framework, but not on .NET 5) Context.Instance.Id = Guid.NewGuid(); // Create project Microsoft.Build.Evaluation.ProjectCollection projectCollection = new Microsoft.Build.Evaluation.ProjectCollection(); projectCollection.DefaultToolsVersion = "Current"; Microsoft.Build.Evaluation.Project project = projectCollection.LoadProject(@".\TestProject.proj"); // Return true if there is a value in the singleton Id, false if null. bool success = project.Build("Target"); System.Diagnostics.Debug.WriteLine($"Context contains a value: {success}"); } } }