Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
4 changes: 2 additions & 2 deletions .vsts-dotnet-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ jobs:
arguments: --repoRoot $(Build.SourcesDirectory)
- task: PublishPipelineArtifact@1
displayName: Publish Code Coverage Results
continueOnError: false
continueOnError: true
condition: eq(variables.onlyDocChanged, 0)
inputs:
targetPath: '$(Build.SourcesDirectory)/artifacts/CoverageResults/merged.coverage'
Expand Down Expand Up @@ -468,7 +468,7 @@ jobs:
arguments: --repoRoot $(Build.SourcesDirectory)
- task: PublishPipelineArtifact@1
displayName: Publish Code Coverage Results
continueOnError: false
continueOnError: true
condition: eq(variables.onlyDocChanged, 0)
inputs:
targetPath: '$(Build.SourcesDirectory)/artifacts/CoverageResults/merged.coverage'
Expand Down
116 changes: 42 additions & 74 deletions src/Build.UnitTests/BackEnd/AssemblyTaskFactory_Tests.cs

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/Build.UnitTests/BackEnd/TaskExecutionHost_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -997,8 +997,8 @@ public void TestTaskResolutionFailureWithUsingTask()
#endif
false,
CancellationToken.None);
_host.FindTask(null);
_host.InitializeForBatch(new TaskLoggingContext(_loggingService, tlc.BuildEventContext), _bucket, null, scheduledNodeId: 1);
_host.FindTask(TaskHostParameters.Empty);
_host.InitializeForBatch(new TaskLoggingContext(_loggingService, tlc.BuildEventContext), _bucket, TaskHostParameters.Empty, scheduledNodeId: 1);
});
}
/// <summary>
Expand Down Expand Up @@ -1026,8 +1026,8 @@ public void TestTaskResolutionFailureWithNoUsingTask()
false,
CancellationToken.None);

_host.FindTask(null);
_host.InitializeForBatch(new TaskLoggingContext(_loggingService, tlc.BuildEventContext), _bucket, null, scheduledNodeId: 1);
_host.FindTask(TaskHostParameters.Empty);
_host.InitializeForBatch(new TaskLoggingContext(_loggingService, tlc.BuildEventContext), _bucket, TaskHostParameters.Empty, scheduledNodeId: 1);
_logger.AssertLogContains("MSB4036");
}

Expand Down Expand Up @@ -1254,7 +1254,7 @@ private void InitializeHost(bool throwOnExecute)
TaskBuilderTestTask.TaskBuilderTestTaskFactory taskFactory = new TaskBuilderTestTask.TaskBuilderTestTaskFactory();
taskFactory.ThrowOnExecute = throwOnExecute;
string taskName = "TaskBuilderTestTask";
(_host as TaskExecutionHost)._UNITTESTONLY_TaskFactoryWrapper = new TaskFactoryWrapper(taskFactory, loadedType, taskName, null);
(_host as TaskExecutionHost)._UNITTESTONLY_TaskFactoryWrapper = new TaskFactoryWrapper(taskFactory, loadedType, taskName, TaskHostParameters.Empty);
_host.InitializeForTask(
this,
tlc,
Expand Down Expand Up @@ -1289,8 +1289,8 @@ private void InitializeHost(bool throwOnExecute)

_bucket = new ItemBucket(FrozenSet<string>.Empty, new Dictionary<string, string>(), new Lookup(itemsByName, new PropertyDictionary<ProjectPropertyInstance>()), 0);
_bucket.Initialize(null);
_host.FindTask(null);
_host.InitializeForBatch(talc, _bucket, null, scheduledNodeId: 1);
_host.FindTask(TaskHostParameters.Empty);
_host.InitializeForBatch(talc, _bucket, TaskHostParameters.Empty, scheduledNodeId: 1);
_parametersSetOnTask = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
_outputsReadFromTask = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
}
Expand Down
215 changes: 40 additions & 175 deletions src/Build.UnitTests/BackEnd/TaskRegistry_Tests.cs

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/Build.UnitTests/Definition/ToolsVersion_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,25 @@ public void OverrideTasksAreFoundInOverridePath()

foreach (string expectedRegisteredTask in expectedRegisteredTasks)
{
Assert.True(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(expectedRegisteredTask, null)),
Assert.True(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(expectedRegisteredTask, TaskHostParameters.Empty)),
String.Format("Expected task '{0}' registered!", expectedRegisteredTask));
}

foreach (string expectedRegisteredTask in expectedOverrideTasks)
{
Assert.True(taskoverrideRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(expectedRegisteredTask, null)),
Assert.True(taskoverrideRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(expectedRegisteredTask, TaskHostParameters.Empty)),
String.Format("Expected task '{0}' registered!", expectedRegisteredTask));
}

foreach (string unexpectedRegisteredTask in unexpectedRegisteredTasks)
{
Assert.False(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(unexpectedRegisteredTask, null)),
Assert.False(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(unexpectedRegisteredTask, TaskHostParameters.Empty)),
String.Format("Unexpected task '{0}' registered!", unexpectedRegisteredTask));
}

foreach (string unexpectedRegisteredTask in unexpectedOverrideRegisteredTasks)
{
Assert.False(taskoverrideRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(unexpectedRegisteredTask, null)),
Assert.False(taskoverrideRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(unexpectedRegisteredTask, TaskHostParameters.Empty)),
String.Format("Unexpected task '{0}' registered!", unexpectedRegisteredTask));
}
}
Expand Down Expand Up @@ -172,12 +172,12 @@ public void DefaultTasksAreFoundInToolsPath()

foreach (string expectedRegisteredTask in expectedRegisteredTasks)
{
Assert.True(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(expectedRegisteredTask, null)),
Assert.True(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(expectedRegisteredTask, TaskHostParameters.Empty)),
String.Format("Expected task '{0}' registered!", expectedRegisteredTask));
}
foreach (string unexpectedRegisteredTask in unexpectedRegisteredTasks)
{
Assert.False(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(unexpectedRegisteredTask, null)),
Assert.False(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(unexpectedRegisteredTask, TaskHostParameters.Empty)),
String.Format("Unexpected task '{0}' registered!", unexpectedRegisteredTask));
}
}
Expand All @@ -202,7 +202,7 @@ public void WarningLoggedIfNoDefaultTasksFound()
Assert.Equal(1, mockLogger.WarningCount); // "Expected 1 warning logged!"
foreach (string unexpectedRegisteredTask in unexpectedRegisteredTasks)
{
Assert.False(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(unexpectedRegisteredTask, null)),
Assert.False(taskRegistry.TaskRegistrations.ContainsKey(new TaskRegistry.RegisteredTaskIdentity(unexpectedRegisteredTask, TaskHostParameters.Empty)),
String.Format("Unexpected task '{0}' registered!", unexpectedRegisteredTask));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ public void GetTaskRegistrations()
ProjectInstance project = new Project(projectRootElementFromString.Project).CreateProjectInstance();

project.TaskRegistry.TaskRegistrations.Count.ShouldBe(3);
project.TaskRegistry.TaskRegistrations[new TaskRegistry.RegisteredTaskIdentity("t0", null)][0].TaskFactoryAssemblyLoadInfo.AssemblyFile.ShouldBe(Path.Combine(Directory.GetCurrentDirectory(), "af0"));
project.TaskRegistry.TaskRegistrations[new TaskRegistry.RegisteredTaskIdentity("t1", null)][0].TaskFactoryAssemblyLoadInfo.AssemblyFile.ShouldBe(Path.Combine(Directory.GetCurrentDirectory(), "af1a"));
project.TaskRegistry.TaskRegistrations[new TaskRegistry.RegisteredTaskIdentity("t1", null)][1].TaskFactoryAssemblyLoadInfo.AssemblyName.ShouldBe("an1");
project.TaskRegistry.TaskRegistrations[new TaskRegistry.RegisteredTaskIdentity("t2", null)][0].TaskFactoryAssemblyLoadInfo.AssemblyName.ShouldBe("an2");
project.TaskRegistry.TaskRegistrations[new TaskRegistry.RegisteredTaskIdentity("t0", TaskHostParameters.Empty)][0].TaskFactoryAssemblyLoadInfo.AssemblyFile.ShouldBe(Path.Combine(Directory.GetCurrentDirectory(), "af0"));
project.TaskRegistry.TaskRegistrations[new TaskRegistry.RegisteredTaskIdentity("t1", TaskHostParameters.Empty)][0].TaskFactoryAssemblyLoadInfo.AssemblyFile.ShouldBe(Path.Combine(Directory.GetCurrentDirectory(), "af1a"));
project.TaskRegistry.TaskRegistrations[new TaskRegistry.RegisteredTaskIdentity("t1", TaskHostParameters.Empty)][1].TaskFactoryAssemblyLoadInfo.AssemblyName.ShouldBe("an1");
project.TaskRegistry.TaskRegistrations[new TaskRegistry.RegisteredTaskIdentity("t2", TaskHostParameters.Empty)][0].TaskFactoryAssemblyLoadInfo.AssemblyName.ShouldBe("an2");
}
finally
{
Expand Down
16 changes: 8 additions & 8 deletions src/Build.UnitTests/TestComparers/TaskRegistryComparers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ public bool Equals(TaskRegistry.RegisteredTaskRecord x, TaskRegistry.RegisteredT
Assert.Equal(x.TaskFactoryAttributeName, y.TaskFactoryAttributeName);
Assert.Equal(x.ParameterGroupAndTaskBody, y.ParameterGroupAndTaskBody, new ParamterGroupAndTaskBodyComparer());

Helpers.AssertDictionariesEqual(
x.TaskFactoryParameters,
y.TaskFactoryParameters,
(xp, yp) =>
{
Assert.Equal(xp.Key, yp.Key);
Assert.Equal(xp.Value, yp.Value);
});
// Assert TaskFactoryParameters equality
var xParams = x.TaskFactoryParameters;
var yParams = y.TaskFactoryParameters;
Assert.Equal(xParams.Runtime, yParams.Runtime);
Assert.Equal(xParams.Architecture, yParams.Architecture);
Assert.Equal(xParams.DotnetHostPath, yParams.DotnetHostPath);
Assert.Equal(xParams.MSBuildAssemblyPath, yParams.MSBuildAssemblyPath);
Assert.Equal(xParams.IsTaskHostFactory, yParams.IsTaskHostFactory);

return true;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Build/BackEnd/Client/MSBuildClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -534,10 +534,10 @@ private ServerNodeBuildCommand GetServerNodeBuildCommand()
partialBuildTelemetry);
}

private ServerNodeHandshake GetHandshake()
{
return new ServerNodeHandshake(CommunicationsUtilities.GetHandshakeOptions(taskHost: false, architectureFlagToSet: XMakeAttributes.GetCurrentMSBuildArchitecture()));
}
private ServerNodeHandshake GetHandshake() => new(CommunicationsUtilities.GetHandshakeOptions(
taskHost: false,
taskHostParameters: TaskHostParameters.Empty,
architectureFlagToSet: XMakeAttributes.GetCurrentMSBuildArchitecture()));

/// <summary>
/// Handle cancellation.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Microsoft.Build.Framework;
using Microsoft.Build.Internal;
using Microsoft.Build.Shared;

Expand Down Expand Up @@ -35,6 +36,7 @@ protected override Handshake GetHandshake()
{
HandshakeOptions handshakeOptions = CommunicationsUtilities.GetHandshakeOptions(
taskHost: false,
taskHostParameters: TaskHostParameters.Empty,
architectureFlagToSet: XMakeAttributes.GetCurrentMSBuildArchitecture(),
nodeReuse: _enableReuse,
lowPriority: LowPriority);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public int AvailableNodes
internal static Handshake GetHandshake(bool enableNodeReuse, bool enableLowPriority)
{
CommunicationsUtilities.Trace("MSBUILDNODEHANDSHAKESALT=\"{0}\", msbuildDirectory=\"{1}\", enableNodeReuse={2}, enableLowPriority={3}", Traits.MSBuildNodeHandshakeSalt, BuildEnvironmentHelper.Instance.MSBuildToolsDirectory32, enableNodeReuse, enableLowPriority);
return new Handshake(CommunicationsUtilities.GetHandshakeOptions(taskHost: false, architectureFlagToSet: XMakeAttributes.GetCurrentMSBuildArchitecture(), nodeReuse: enableNodeReuse, lowPriority: enableLowPriority));
return new Handshake(CommunicationsUtilities.GetHandshakeOptions(taskHost: false, taskHostParameters: TaskHostParameters.Empty, architectureFlagToSet: XMakeAttributes.GetCurrentMSBuildArchitecture(), nodeReuse: enableNodeReuse, lowPriority: enableLowPriority));
}

/// <summary>
Expand Down Expand Up @@ -98,7 +98,7 @@ public IList<NodeInfo> CreateNodes(int nextNodeId, INodePacketFactory factory, F

CommunicationsUtilities.Trace("Starting to acquire {1} new or existing node(s) to establish nodes from ID {0} to {2}...", nextNodeId, numberOfNodesToCreate, nextNodeId + numberOfNodesToCreate - 1);

Handshake hostHandshake = new(CommunicationsUtilities.GetHandshakeOptions(taskHost: false, architectureFlagToSet: XMakeAttributes.GetCurrentMSBuildArchitecture(), nodeReuse: ComponentHost.BuildParameters.EnableNodeReuse, lowPriority: ComponentHost.BuildParameters.LowPriority));
Handshake hostHandshake = new(CommunicationsUtilities.GetHandshakeOptions(taskHost: false, taskHostParameters: TaskHostParameters.Empty, architectureFlagToSet: XMakeAttributes.GetCurrentMSBuildArchitecture(), nodeReuse: ComponentHost.BuildParameters.EnableNodeReuse, lowPriority: ComponentHost.BuildParameters.LowPriority));
IList<NodeContext> nodeContexts = GetNodes(null, commandLineArgs, nextNodeId, factory, hostHandshake, NodeContextCreated, NodeContextTerminated, numberOfNodesToCreate);

if (nodeContexts.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using System.Linq;
using System.Threading;
using Microsoft.Build.Exceptions;
using Microsoft.Build.Framework;
using Microsoft.Build.Internal;
using Microsoft.Build.Shared;
using Microsoft.Build.Shared.FileSystem;
Expand Down Expand Up @@ -450,23 +451,20 @@ internal static string GetMSBuildExecutablePathForNonNETRuntimes(HandshakeOption
/// - RuntimeHostPath: The path to the dotnet executable that will host the .NET runtime
/// - MSBuildAssemblyPath: The full path to MSBuild.dll that will be loaded by the dotnet host.
/// </returns>
internal static (string RuntimeHostPath, string MSBuildAssemblyPath) GetMSBuildLocationForNETRuntime(HandshakeOptions hostContext, Dictionary<string, string> taskHostParameters)
internal static (string RuntimeHostPath, string MSBuildAssemblyPath) GetMSBuildLocationForNETRuntime(HandshakeOptions hostContext, TaskHostParameters taskHostParameters)
{
ErrorUtilities.VerifyThrowInternalErrorUnreachable(Handshake.IsHandshakeOptionEnabled(hostContext, HandshakeOptions.TaskHost));

taskHostParameters.TryGetValue(Constants.DotnetHostPath, out string runtimeHostPath);
var msbuildAssemblyPath = GetMSBuildAssemblyPath(taskHostParameters);

return (runtimeHostPath, msbuildAssemblyPath);
return (taskHostParameters.DotnetHostPath, GetMSBuildAssemblyPath(taskHostParameters));
}

private static string GetMSBuildAssemblyPath(Dictionary<string, string> taskHostParameters)
private static string GetMSBuildAssemblyPath(TaskHostParameters taskHostParameters)
{
if (taskHostParameters.TryGetValue(Constants.MSBuildAssemblyPath, out string msbuildAssemblyPath))
if (taskHostParameters.MSBuildAssemblyPath != null)
{
ValidateNetHostSdkVersion(msbuildAssemblyPath);
ValidateNetHostSdkVersion(taskHostParameters.MSBuildAssemblyPath);

return msbuildAssemblyPath;
return taskHostParameters.MSBuildAssemblyPath;
}

throw new InvalidProjectFileException(ResourceUtilities.GetResourceString("NETHostTaskLoad_Failed"));
Expand Down Expand Up @@ -572,7 +570,7 @@ internal bool AcquireAndSetUpHost(
INodePacketFactory factory,
INodePacketHandler handler,
TaskHostConfiguration configuration,
Dictionary<string, string> taskHostParameters)
TaskHostParameters taskHostParameters)
{
bool nodeCreationSucceeded;
if (!_nodeContexts.ContainsKey(taskHostNodeId))
Expand Down Expand Up @@ -613,7 +611,7 @@ internal void DisconnectFromHost(int nodeId)
/// <summary>
/// Instantiates a new MSBuild or MSBuildTaskHost process acting as a child node.
/// </summary>
internal bool CreateNode(HandshakeOptions hostContext, int taskHostNodeId, INodePacketFactory factory, INodePacketHandler handler, TaskHostConfiguration configuration, Dictionary<string, string> taskHostParameters)
internal bool CreateNode(HandshakeOptions hostContext, int taskHostNodeId, INodePacketFactory factory, INodePacketHandler handler, TaskHostConfiguration configuration, TaskHostParameters taskHostParameters)
{
ErrorUtilities.VerifyThrowArgumentNull(factory);
ErrorUtilities.VerifyThrow(!_nodeIdToPacketFactory.ContainsKey(taskHostNodeId), "We should not already have a factory for this context! Did we forget to call DisconnectFromHost somewhere?");
Expand Down
Loading