dotnet / dotnet/msbuild

BuildSubmission.Execute() starts one MsBuild child process per project to compile (without re-usage)

Open
#3,420 4 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

_From @ocox1 on June 18, 2018 15:23_

My tool gives our developers the chance to compile all our projects (~1000 projects) on their local machines. So we have a build.proj with these nodes:








In my application I try to compile these projects (contained in the ProjectList) by calling buildSubmission.Execute(). This worked fine with VisualStudio 2015 / MsBuild 14, but after migration to VisualStudio 2017 / MsBuild 15 (15.7.179) for every project from the ProjectList a new MsBuild instance is created in the background (1000 child processes in my case).
After a short time I have to kill my application before my computer collapses because more and more resources are used (some processes crashes with OutOfMemory, Explorer.exe freezes...).
If I kill my application early enough, the MsBuild processes keep in memory for ~15 minutes.

Here is a code snippet:

ProjectCollection projectCol = new ProjectCollection();

BuildParameters buildParams = new BuildParameters(projectCol)
{
BuildThreadPriority = ThreadPriority.Highest,
EnableNodeReuse = true,
MaxNodeCount = Convert.ToInt32(Environment.GetEnvironmentVariable("NUMBER_OF_PROCESSORS"))
};

BuildManager bm = new BuildManager();
bm.BeginBuild(buildParams);

BuildRequestData buildReq = new BuildRequestData(
projectPath, // path to build.proj
new Dictionary
{ { "Configuration", "Debug" } }, // buildProperties
"15.0", // toolsVersion
new string[] { "_Make" }, // targetsToBuild
null);
BuildSubmission buildSubmission = bm.PendBuildRequest(buildReq);
buildSubmission.Execute();
//buildSubmission.ExecuteAsync(null, null); // same result with ExecuteAsync

// clean up resources...

![msbuildprocesses](https://user-images.githubusercontent.com/40359019/41545991-f71b369e-730b-11e8-9f75-ada970774946.png)

_Copied from original issue: dotnet/project-system#3665_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.