Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -661,9 +661,6 @@ internal bool CreateNode(TaskHostNodeKey nodeKey, INodePacketFactory factory, IN

HandshakeOptions hostContext = nodeKey.HandshakeOptions;

// If runtime host path is null it means we don't have MSBuild.dll path resolved and there is no need to include it in the command line arguments.
string commandLineArgsPlaceholder = "\"{0}\" /nologo /nodemode:2 /nodereuse:{1} /low:{2} /parentpacketversion:{3} ";

// Generate a unique node ID for communication purposes using atomic increment.
int communicationNodeId = Interlocked.Increment(ref _nextNodeId);

Expand All @@ -682,10 +679,14 @@ internal bool CreateNode(TaskHostNodeKey nodeKey, INodePacketFactory factory, IN

var handshake = new Handshake(hostContext, predefinedToolsDirectory: msbuildAssemblyPath);

bool nodeReuse = NodeReuseIsEnabled(hostContext);
// nodemode:2 = Regular TaskHost (short-lived), nodemode:4 = Sidecar TaskHost (long-lived, with callback support)
int nodeMode = nodeReuse ? 4 : 2;

// There is always one task host per host context so we always create just 1 one task host node here.
nodeContexts = GetNodes(
runtimeHostPath,
string.Format(commandLineArgsPlaceholder, Path.Combine(msbuildAssemblyPath, Constants.MSBuildAssemblyName), NodeReuseIsEnabled(hostContext), ComponentHost.BuildParameters.LowPriority, NodePacketTypeExtensions.PacketVersion),
$"\"{Path.Combine(msbuildAssemblyPath, Constants.MSBuildAssemblyName)}\" /nologo /nodemode:{nodeMode} /nodereuse:{nodeReuse} /low:{ComponentHost.BuildParameters.LowPriority} /parentpacketversion:{NodePacketTypeExtensions.PacketVersion} ",
communicationNodeId,
this,
handshake,
Expand All @@ -707,9 +708,13 @@ internal bool CreateNode(TaskHostNodeKey nodeKey, INodePacketFactory factory, IN

CommunicationsUtilities.Trace("For a host context of {0}, spawning executable from {1}.", hostContext.ToString(), msbuildLocation ?? Constants.MSBuildExecutableName);

bool nodeReuseNonNet = NodeReuseIsEnabled(hostContext);
// nodemode:2 = Regular TaskHost (short-lived), nodemode:4 = Sidecar TaskHost (long-lived, with callback support)
int nodeModeNonNet = nodeReuseNonNet ? 4 : 2;

nodeContexts = GetNodes(
msbuildLocation,
string.Format(commandLineArgsPlaceholder, string.Empty, NodeReuseIsEnabled(hostContext), ComponentHost.BuildParameters.LowPriority, NodePacketTypeExtensions.PacketVersion),
$"/nologo /nodemode:{nodeModeNonNet} /nodereuse:{nodeReuseNonNet} /low:{ComponentHost.BuildParameters.LowPriority} /parentpacketversion:{NodePacketTypeExtensions.PacketVersion} ",
communicationNodeId,
this,
new Handshake(hostContext),
Expand Down
2 changes: 2 additions & 0 deletions src/MSBuild/MSBuild.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@
<Compile Include="MSBuildClientApp.cs" />
<Compile Include="NodeEndpointOutOfProcTaskHost.cs" />
<Compile Include="ProjectSchemaValidationHandler.cs" />
<Compile Include="OutOfProcTaskHostNodeBase.cs" />
<Compile Include="OutOfProcTaskHostNode.cs" />
<Compile Include="SidecarTaskHostNode.cs" />
<Compile Include="OutOfProcTaskAppDomainWrapperBase.cs" />
<Compile Include="OutOfProcTaskAppDomainWrapper.cs" />
<Compile Include="PerformanceLogEventListener.cs" />
Expand Down
Loading
Loading