/// <summary> /// Shuts down the component. /// </summary> public void ShutdownComponent() { _host = null; _testDataProvider = null; _result = null; this.Dispose(); }
/// <summary> /// The component is being initialized /// </summary> public void InitializeComponent(IBuildComponentHost host) { this.host = host; this.resultsCache = (IResultsCache)(this.host.GetComponent(BuildComponentType.ResultsCache)); this.configCache = (IConfigCache)(this.host.GetComponent(BuildComponentType.ConfigCache)); this.testDataProvider = (ITestDataProvider)(this.host.GetComponent(BuildComponentType.TestDataProvider)); }
internal QAMockTaskBuilder() { _host = null; _testDataProvider = null; _result = null; _taskDone = new AutoResetEvent(false); }
/// <summary> /// Instantiates an endpoint to act as a client /// </summary> /// <param name="pipeName">The name of the pipe to which we should connect.</param> /// <param name="host">The component host.</param> internal NodeEndpointOutOfProc(string pipeName, IBuildComponentHost host) { ErrorUtilities.VerifyThrowArgumentNull(host, "host"); _componentHost = host; InternalConstruct(pipeName); }
/// <summary> /// The component is being initialized /// </summary> public void InitializeComponent(IBuildComponentHost host) { _host = host; _resultsCache = (IResultsCache)(_host.GetComponent(BuildComponentType.ResultsCache)); _configCache = (IConfigCache)(_host.GetComponent(BuildComponentType.ConfigCache)); _testDataProvider = (ITestDataProvider)(_host.GetComponent(BuildComponentType.TestDataProvider)); }
/// <summary> /// Indicates to the TaskHost that it is no longer needed. /// Called by TaskBuilder when the task using the EngineProxy is done. /// </summary> internal void MarkAsInactive() { lock (_callbackMonitor) { VerifyActiveProxy(); _activeProxy = false; // Since the task has a pointer to this class it may store it in a static field. Null out // internal data so the leak of this object doesn't lead to a major memory leak. _host = null; _requestEntry = null; // Don't bother clearing the tiny task location _taskLoggingContext = null; _targetBuilderCallback = null; // Clear out the sponsor (who is responsible for keeping the EngineProxy remoting lease alive until the task is done) // this will be null if the engine proxy was never sent across an AppDomain boundary. if (_sponsor != null) { ILease lease = (ILease)RemotingServices.GetLifetimeService(this); if (lease != null) { lease.Unregister(_sponsor); } _sponsor.Close(); _sponsor = null; } } }
public TaskHostTask(IElementLocation taskLocation, TaskLoggingContext taskLoggingContext, IBuildComponentHost buildComponentHost, IDictionary <string, string> taskHostParameters, LoadedType taskType #if FEATURE_APPDOMAIN , AppDomainSetup appDomainSetup #endif ) { ErrorUtilities.VerifyThrowInternalNull(taskType, nameof(taskType)); _taskLocation = taskLocation; _taskLoggingContext = taskLoggingContext; _buildComponentHost = buildComponentHost; _taskType = taskType; #if FEATURE_APPDOMAIN _appDomainSetup = appDomainSetup; #endif _taskHostParameters = taskHostParameters; _packetFactory = new NodePacketFactory(); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.LogMessage, LogMessagePacket.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.TaskHostTaskComplete, TaskHostTaskComplete.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeShutdown, NodeShutdown.FactoryForDeserialization, this); _packetReceivedEvent = new AutoResetEvent(false); _receivedPackets = new ConcurrentQueue <INodePacket>(); _taskHostLock = new Object(); _setParameters = new Dictionary <string, object>(); }
/// <summary> /// Shuts down the component. /// </summary> public void ShutdownComponent() { _outOfProcTaskHostNodeProvider = null; _componentHost = null; _componentShutdown = true; ClearPerBuildState(); }
/// <summary> /// Initializes the component /// </summary> /// <param name="host">The component host</param> public void InitializeComponent(IBuildComponentHost host) { ErrorUtilities.VerifyThrow(_componentHost == null, "TaskHostNodeManager already initialized."); ErrorUtilities.VerifyThrow(host != null, "We can't create a TaskHostNodeManager with a null componentHost"); _componentHost = host; _outOfProcTaskHostNodeProvider = _componentHost.GetComponent(BuildComponentType.OutOfProcTaskHostNodeProvider) as INodeProvider; _componentShutdown = false; }
/// <summary> /// Shuts down the component. /// </summary> public void ShutdownComponent() { this.host = null; this.testDataProvider = null; this.testDefinition = null; this.requestCallBack = null; this.requestEntry = null; this.projectLoggingContext = null; }
public QAMockTargetBuilder() { _host = null; _testDataProvider = null; _testDefinition = null; _requestCallBack = null; _requestEntry = null; _projectLoggingContext = null; _buildDone = new AutoResetEvent(false); }
public QAMockTargetBuilder() { this.host = null; this.testDataProvider = null; this.testDefinition = null; this.requestCallBack = null; this.requestEntry = null; this.projectLoggingContext = null; this.buildDone = new AutoResetEvent(false); }
/// <summary> /// Constructor that takes in nothing. /// </summary> public QARequestBuilder() { _host = null; _configCache = null; _resultsCache = null; _builderThread = null; _requestedEntry = null; _cancelEvent = new AutoResetEvent(false); _continueEvent = new AutoResetEvent(false); _threadStarted = new ManualResetEvent(false); _currentProjectDefinition = null; }
/// <summary> /// Constructor that takes in nothing. /// </summary> public QARequestBuilder() { this.host = null; this.configCache = null; this.resultsCache = null; this.builderThread = null; this.requestedEntry = null; this.cancelEvent = new AutoResetEvent(false); this.continueEvent = new AutoResetEvent(false); this.threadStarted = new ManualResetEvent(false); this.currentProjectDefinition = null; }
/// <summary> /// This method is used to create a matched pair of endpoints used by the Node Provider and /// the Node. The inputs and outputs for each node are automatically configured. /// </summary> /// <param name="mode">The communications mode for the endpoints.</param> /// <param name="host">The component host.</param> /// <returns>A matched pair of endpoints.</returns> internal static EndpointPair CreateInProcEndpoints(EndpointMode mode, IBuildComponentHost host) { NodeEndpointInProc node = new NodeEndpointInProc(mode, host); NodeEndpointInProc manager = new NodeEndpointInProc(mode, host); // NOTE: This creates a circular reference which must be explicitly broken before these // objects can be reclaimed by the garbage collector. node._peerEndpoint = manager; manager._peerEndpoint = node; return(new EndpointPair(node, manager)); }
/// <summary> /// Instantiates an endpoint to act as a client /// </summary> /// <param name="host">The component host.</param> /// <param name="enableReuse">Whether this node may be reused for a later build.</param> /// <param name="lowPriority">Whether this node is low priority.</param> internal NodeEndpointOutOfProc( IBuildComponentHost host, bool enableReuse, bool lowPriority) { ErrorUtilities.VerifyThrowArgumentNull(host, nameof(host)); _componentHost = host; _enableReuse = enableReuse; _lowPriority = lowPriority; InternalConstruct(); }
public void InitializeComponent(IBuildComponentHost host) { ErrorUtilities.VerifyThrow(_componentHost == null, "NodeManager already initialized."); ErrorUtilities.VerifyThrow(host != null, "We can't create a NodeManager with a null componentHost"); _componentHost = host; _inProcNodeProvider = _componentHost.GetComponent(BuildComponentType.InProcNodeProvider) as INodeProvider; _outOfProcNodeProvider = _componentHost.GetComponent(BuildComponentType.OutOfProcNodeProvider) as INodeProvider; _componentShutdown = false; // DISTRIBUTED: Get the remote node provider. }
/// <summary> /// Instantiates an endpoint to act as a client /// </summary> /// <param name="pipeName">The name of the pipe to which we should connect.</param> /// <param name="host">The component host.</param> /// <param name="enableReuse">Whether this node may be reused for a later build.</param> internal NodeEndpointOutOfProc( string pipeName, IBuildComponentHost host, bool enableReuse, bool lowPriority) { ErrorUtilities.VerifyThrowArgumentNull(host, "host"); _componentHost = host; _enableReuse = enableReuse; _lowPriority = lowPriority; InternalConstruct(pipeName); }
/// <summary> /// Instantiates a Node and initializes it to unconnected. /// </summary> /// <param name="commMode">The communications mode for this endpoint.</param> /// <param name="host">The component host.</param> private NodeEndpointInProc(EndpointMode commMode, IBuildComponentHost host) { ErrorUtilities.VerifyThrowArgumentNull(host, "host"); _status = LinkStatus.Inactive; _mode = commMode; _componentHost = host; if (commMode == EndpointMode.Asynchronous) { _asyncDataMonitor = new object(); } }
/// <summary> /// Constructor /// </summary> /// <param name="host">The component host</param> /// <param name="requestEntry">The build request entry</param> /// <param name="taskLocation">The <see cref="ElementLocation"/> of the task.</param> /// <param name="targetBuilderCallback">An <see cref="ITargetBuilderCallback"/> to use to invoke targets and build projects.</param> public TaskHost(IBuildComponentHost host, BuildRequestEntry requestEntry, ElementLocation taskLocation, ITargetBuilderCallback targetBuilderCallback) { ErrorUtilities.VerifyThrowArgumentNull(host, "host"); ErrorUtilities.VerifyThrowArgumentNull(requestEntry, "requestEntry"); ErrorUtilities.VerifyThrowInternalNull(taskLocation, "taskLocation"); _host = host; _requestEntry = requestEntry; _taskLocation = taskLocation; _targetBuilderCallback = targetBuilderCallback; _continueOnError = false; _activeProxy = true; _callbackMonitor = new Object(); }
/// <summary> /// Initializes the component. /// </summary> /// <param name="host">The component host.</param> public void InitializeComponent(IBuildComponentHost host) { this.ComponentHost = host; _nodeContexts = new Dictionary <TaskHostContext, NodeContext>(); _nodeIdToPacketFactory = new Dictionary <int, INodePacketFactory>(); _nodeIdToPacketHandler = new Dictionary <int, INodePacketHandler>(); _activeNodes = new HashSet <int>(); _noNodesActiveEvent = new ManualResetEvent(true); _localPacketFactory = new NodePacketFactory(); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.LogMessage, LogMessagePacket.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.TaskHostTaskComplete, TaskHostTaskComplete.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeShutdown, NodeShutdown.FactoryForDeserialization, this); }
/// <summary> /// Constructor. /// </summary> public InProcNode(IBuildComponentHost componentHost, INodeEndpoint inProcNodeEndpoint) { _componentHost = componentHost; _nodeEndpoint = inProcNodeEndpoint; _receivedPackets = new ConcurrentQueue <INodePacket>(); _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new AutoResetEvent(false); _buildRequestEngine = componentHost.GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine; _engineExceptionEventHandler = OnEngineException; _newConfigurationRequestEventHandler = OnNewConfigurationRequest; _requestBlockedEventHandler = OnNewRequest; _requestCompleteEventHandler = OnRequestComplete; }
/// <summary> /// Constructor. /// </summary> public InProcNode(IBuildComponentHost componentHost, INodeEndpoint inProcNodeEndpoint) { _componentHost = componentHost; _nodeEndpoint = inProcNodeEndpoint; _receivedPackets = new Queue <INodePacket>(); _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new AutoResetEvent(false); _configurationProjectsLoaded = new HashSet <NGen <int> >(); _buildRequestEngine = componentHost.GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine; _engineExceptionEventHandler = new EngineExceptionDelegate(OnEngineException); _newConfigurationRequestEventHandler = new NewConfigurationRequestDelegate(OnNewConfigurationRequest); _requestBlockedEventHandler = new RequestBlockedDelegate(OnNewRequest); _requestCompleteEventHandler = new RequestCompleteDelegate(OnRequestComplete); }
/// <summary> /// Instantiates an endpoint to act as a client /// </summary> internal NodeEndpointOutOfProc( string clientToServerPipeHandle, string serverToClientPipeHandle, IBuildComponentHost host, bool enableReuse) #endif { ErrorUtilities.VerifyThrowArgumentNull(host, "host"); _componentHost = host; _enableReuse = enableReuse; #if FEATURE_NAMED_PIPES_FULL_DUPLEX InternalConstruct(pipeName); #else InternalConstruct(clientToServerPipeHandle, serverToClientPipeHandle); #endif }
/// <summary> /// The constructor. /// </summary> /// <param name="requestEntry">The build request entry for the target.</param> /// <param name="targetBuilderCallback">The target builder callback.</param> /// <param name="targetSpecification">The specification for the target to build.</param> /// <param name="baseLookup">The lookup to use.</param> /// <param name="parentTarget">The parent of this entry, if any.</param> /// <param name="host">The Build Component Host to use.</param> /// <param name="stopProcessingOnCompletion">True if the target builder should stop processing the current target stack when this target is complete.</param> internal TargetEntry(BuildRequestEntry requestEntry, ITargetBuilderCallback targetBuilderCallback, TargetSpecification targetSpecification, Lookup baseLookup, TargetEntry parentTarget, IBuildComponentHost host, bool stopProcessingOnCompletion) { ErrorUtilities.VerifyThrowArgumentNull(requestEntry, "requestEntry"); ErrorUtilities.VerifyThrowArgumentNull(targetBuilderCallback, "targetBuilderCallback"); ErrorUtilities.VerifyThrowArgumentNull(targetSpecification, "targetName"); ErrorUtilities.VerifyThrowArgumentNull(baseLookup, "lookup"); ErrorUtilities.VerifyThrowArgumentNull(host, "host"); _requestEntry = requestEntry; _targetBuilderCallback = targetBuilderCallback; _targetSpecification = targetSpecification; _parentTarget = parentTarget; _expander = new Expander <ProjectPropertyInstance, ProjectItemInstance>(baseLookup.ReadOnlyLookup, baseLookup.ReadOnlyLookup); _state = TargetEntryState.Dependencies; _baseLookup = baseLookup; _host = host; this.StopProcessingOnCompletion = stopProcessingOnCompletion; }
/// <summary> /// Gets an instance of the component. /// </summary> public IBuildComponent GetInstance(IBuildComponentHost host) { if (Pattern == CreationPattern.Singleton) { if (_singleton == null) { _singleton = _factory(ComponentType); _singleton.InitializeComponent(host); } return(_singleton); } IBuildComponent component = _factory(ComponentType); component.InitializeComponent(host); return(component); }
public void ShutdownComponent() { if (_inProcNodeProvider != null && _inProcNodeProvider is IDisposable) { ((IDisposable)_inProcNodeProvider).Dispose(); } if (_outOfProcNodeProvider != null && _outOfProcNodeProvider is IDisposable) { ((IDisposable)_outOfProcNodeProvider).Dispose(); } _inProcNodeProvider = null; _outOfProcNodeProvider = null; _componentHost = null; _componentShutdown = true; ClearPerBuildState(); }
public void ShutdownComponent() { _host = null; _cache = null; }
/// <summary> /// Sets the component host /// </summary> /// <param name="host">The component host</param> public void InitializeComponent(IBuildComponentHost host) { throw new NotImplementedException(); }
/// <summary> /// Create an instance of the wrapped ITask for a batch run of the task. /// </summary> internal ITask CreateTaskInstance(ElementLocation taskLocation, TaskLoggingContext taskLoggingContext, IBuildComponentHost buildComponentHost, IDictionary <string, string> taskIdentityParameters, #if FEATURE_APPDOMAIN AppDomainSetup appDomainSetup, #endif bool isOutOfProc) { bool useTaskFactory = false; IDictionary <string, string> mergedParameters = null; _taskLoggingContext = taskLoggingContext; // Optimization for the common (vanilla AssemblyTaskFactory) case -- only calculate // the task factory parameters if we have any to calculate; otherwise even if we // still launch the task factory, it will be with parameters corresponding to the // current process. if ((_factoryIdentityParameters != null && _factoryIdentityParameters.Count > 0) || (taskIdentityParameters != null && taskIdentityParameters.Count > 0)) { VerifyThrowIdentityParametersValid(taskIdentityParameters, taskLocation, _taskName, "MSBuildRuntime", "MSBuildArchitecture"); mergedParameters = MergeTaskFactoryParameterSets(_factoryIdentityParameters, taskIdentityParameters); useTaskFactory = !NativeMethodsShared.IsMono && (_taskHostFactoryExplicitlyRequested || !TaskHostParametersMatchCurrentProcess(mergedParameters)); } else { // if we don't have any task host parameters specified on either the using task or the // task invocation, then we will run in-proc UNLESS "TaskHostFactory" is explicitly specified // as the task factory. useTaskFactory = _taskHostFactoryExplicitlyRequested; } if (useTaskFactory) { ErrorUtilities.VerifyThrowInternalNull(buildComponentHost, "buildComponentHost"); mergedParameters = mergedParameters ?? new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); string runtime = null; string architecture = null; if (!mergedParameters.TryGetValue(XMakeAttributes.runtime, out runtime)) { mergedParameters[XMakeAttributes.runtime] = XMakeAttributes.MSBuildRuntimeValues.clr4; } if (!mergedParameters.TryGetValue(XMakeAttributes.architecture, out architecture)) { mergedParameters[XMakeAttributes.architecture] = XMakeAttributes.GetCurrentMSBuildArchitecture(); } TaskHostTask task = new TaskHostTask(taskLocation, taskLoggingContext, buildComponentHost, mergedParameters, _loadedType #if FEATURE_APPDOMAIN , appDomainSetup #endif ); return(task); } else { #if FEATURE_APPDOMAIN AppDomain taskAppDomain = null; #endif ITask taskInstance = TaskLoader.CreateTask(_loadedType, _taskName, taskLocation.File, taskLocation.Line, taskLocation.Column, new TaskLoader.LogError(ErrorLoggingDelegate) #if FEATURE_APPDOMAIN , appDomainSetup #endif , isOutOfProc #if FEATURE_APPDOMAIN , out taskAppDomain #endif ); #if FEATURE_APPDOMAIN if (taskAppDomain != null) { _tasksAndAppDomains[taskInstance] = taskAppDomain; } #endif return(taskInstance); } }
/// <summary> /// Sets the build component host. /// </summary> /// <param name="host">The component host.</param> public void InitializeComponent(IBuildComponentHost host) { _componentHost = host; _taskExecutionHost = new TaskExecutionHost(host); }
/// <summary> /// Sets the component host. /// </summary> /// <param name="host">The component host.</param> public void InitializeComponent(IBuildComponentHost host) { ErrorUtilities.VerifyThrowArgumentNull(host, "host"); _componentHost = host; }
/// <summary> /// Constructor /// </summary> internal TaskExecutionHost(IBuildComponentHost host) { _buildComponentHost = host; if (host != null && host.BuildParameters != null) { _logTaskInputs = host.BuildParameters.LogTaskInputs; } // If this is false, check the environment variable to see if it's there: if (!_logTaskInputs) { _logTaskInputs = (Environment.GetEnvironmentVariable("MSBUILDLOGTASKINPUTS") == "1"); } }
/// <summary> /// Sets the build component host. /// </summary> /// <param name="host">The component host.</param> public void InitializeComponent(IBuildComponentHost host) { _componentHost = host; }
/// <summary> /// Constructor takes in the filename and the noTargetToBuild parameters. /// </summary> public RequestDefinition(string fileName, IBuildComponentHost host, bool noTargetsToBuild) : this(fileName, null, null, null, 0, null, host, noTargetsToBuild) { }
/// <summary> /// Constructor takes in the filename and an array of child definitions. /// </summary> public RequestDefinition(string fileName, RequestDefinition[] childDefinitions, IBuildComponentHost host) : this(fileName, null, null, null, 0, childDefinitions, host) { }
public void InitializeComponent(IBuildComponentHost host) { _host = host; _cache = new ResultsCache(); }
/// <summary> /// Constructor takes the filename and the build execution time /// </summary> public RequestDefinition(string fileName, int executionTime, IBuildComponentHost host) : this(fileName, null, null, null, executionTime, null, host) { }
/// <summary> /// Save the configuration cache information from the host /// </summary> public void InitializeComponent(IBuildComponentHost host) { this.configurationCache = (IConfigCache)host.GetComponent(BuildComponentType.ConfigCache); this.resultsCache = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache); }
/// <inheritdoc cref="IBuildComponent.InitializeComponent"/> public virtual void InitializeComponent(IBuildComponentHost host) { Host = host; }
/// <summary> /// Constructor allows you to set the filname, toolsversion, targets to build, build properties and execution time. /// Following are the defaults: /// ToolsVersion = "ToolsVersion" /// GlobalProperties = new BuildPropertyGroup() /// ExecutionTime = 0; /// Targets to build = "target1" /// </summary> public RequestDefinition(string fileName, string toolsVersion, string[] targets, PropertyDictionary<ProjectPropertyInstance> properties, int executionTime, RequestDefinition[] childDefinitions, IBuildComponentHost host, bool noTargetsToBuild) { if (noTargetsToBuild || targets == null) { _targetsToBuild = new string[] { }; } else { _targetsToBuild = targets; } _globalProperties = ((properties == null) ? new PropertyDictionary<ProjectPropertyInstance>() : properties); _toolsVersion = ((toolsVersion == null) ? RequestDefinition.defaultToolsVersion : toolsVersion); _fileName = fileName; if (childDefinitions != null) { _childDefinitions = new List<RequestDefinition>(childDefinitions); foreach (RequestDefinition bd in childDefinitions) { _childDefinitions.Add(bd); } } else { _childDefinitions = new List<RequestDefinition>(); } _testProjectCompletedEvent = new AutoResetEvent(false); _executionTime = executionTime; _requestEngine = (IBuildRequestEngine)host.GetComponent(BuildComponentType.RequestEngine); _testDataProvider = (ITestDataProvider)host.GetComponent(BuildComponentType.TestDataProvider); _resultsCache = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache); _testDataProvider.AddDefinition(this); _projectDefinition = new ProjectDefinition(_fileName); _waitForCancel = false; }
/// <summary> /// Shuts down this component. /// </summary> public void ShutdownComponent() { _componentHost = null; _inProcNode = null; }
/// <summary> /// Gets an instance of the component. /// </summary> public IBuildComponent GetInstance(IBuildComponentHost host) { if (Pattern == CreationPattern.Singleton) { if (_singleton == null) { _singleton = _factory(ComponentType); _singleton.InitializeComponent(host); } return _singleton; } else { IBuildComponent component = _factory(ComponentType); component.InitializeComponent(host); return component; } }
/// <summary> /// Shuts down the component. /// </summary> public void ShutdownComponent() { _componentHost = null; }
/// <summary> /// Constructor. /// </summary> public BuildComponentFactoryCollection(IBuildComponentHost host) { _host = host; _componentEntriesByType = new Dictionary<BuildComponentType, BuildComponentEntry>(); }
/// <summary> /// Shuts down the component. /// </summary> public void ShutdownComponent() { lock (_taskExecutionHostSync) { ErrorUtilities.VerifyThrow(_taskExecutionHost != null, "taskExecutionHost not initialized."); _componentHost = null; IDisposable disposable = _taskExecutionHost as IDisposable; if (disposable != null) { disposable.Dispose(); } _taskExecutionHost = null; } }
/// <summary> /// Shuts down this component /// </summary> public void ShutdownComponent() { _host = null; ((IBuildComponent)_resultCache).ShutdownComponent(); }
/// <summary> /// NotThreadSafe, this method should only be called from the component host thread /// Called by the build component host when a component is first initialized. /// </summary> /// <param name="buildComponentHost">The component host for this object</param> /// <exception cref="InternalErrorException">When buildComponentHost is null</exception> /// <exception cref="InternalErrorException">Service has already shutdown</exception> public void InitializeComponent(IBuildComponentHost buildComponentHost) { lock (_lockObject) { ErrorUtilities.VerifyThrow(_serviceState != LoggingServiceState.Shutdown, " The object is shutdown, should not do any operations on a shutdown component"); ErrorUtilities.VerifyThrow(buildComponentHost != null, "BuildComponentHost was null"); _componentHost = buildComponentHost; // Get the number of initial nodes the host is running with, if the component host does not have // this information default to 1 _maxCPUCount = buildComponentHost.BuildParameters.MaxNodeCount; // Ask the component host if onlyLogCriticalEvents is true or false. If the host does // not have this information default to false. _onlyLogCriticalEvents = buildComponentHost.BuildParameters.OnlyLogCriticalEvents; _serviceState = LoggingServiceState.Initialized; } }
/// <summary> /// Initializes the component. /// </summary> /// <param name="host">The component host.</param> public void InitializeComponent(IBuildComponentHost host) { this.ComponentHost = host; _nodeContexts = new Dictionary<TaskHostContext, NodeContext>(); _nodeIdToPacketFactory = new Dictionary<int, INodePacketFactory>(); _nodeIdToPacketHandler = new Dictionary<int, INodePacketHandler>(); _activeNodes = new HashSet<int>(); _noNodesActiveEvent = new ManualResetEvent(true); _localPacketFactory = new NodePacketFactory(); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.LogMessage, LogMessagePacket.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.TaskHostTaskComplete, TaskHostTaskComplete.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeShutdown, NodeShutdown.FactoryForDeserialization, this); }
/// <summary> /// Initializes the component. /// </summary> /// <param name="host">The component host.</param> public void InitializeComponent(IBuildComponentHost host) { this.ComponentHost = host; _nodeContexts = new Dictionary <int, NodeContext>(); }
/// <summary> /// Create an instance of the wrapped ITask for a batch run of the task. /// </summary> internal ITask CreateTaskInstance(ElementLocation taskLocation, TaskLoggingContext taskLoggingContext, IBuildComponentHost buildComponentHost, IDictionary<string, string> taskIdentityParameters, AppDomainSetup appDomainSetup, bool isOutOfProc) { bool useTaskFactory = false; IDictionary<string, string> mergedParameters = null; _taskLoggingContext = taskLoggingContext; // Optimization for the common (vanilla AssemblyTaskFactory) case -- only calculate // the task factory parameters if we have any to calculate; otherwise even if we // still launch the task factory, it will be with parameters corresponding to the // current process. if ((_factoryIdentityParameters != null && _factoryIdentityParameters.Count > 0) || (taskIdentityParameters != null && taskIdentityParameters.Count > 0)) { VerifyThrowIdentityParametersValid(taskIdentityParameters, taskLocation, _taskName, "MSBuildRuntime", "MSBuildArchitecture"); mergedParameters = MergeTaskFactoryParameterSets(_factoryIdentityParameters, taskIdentityParameters); useTaskFactory = _taskHostFactoryExplicitlyRequested || !TaskHostParametersMatchCurrentProcess(mergedParameters); } else { // if we don't have any task host parameters specified on either the using task or the // task invocation, then we will run in-proc UNLESS "TaskHostFactory" is explicitly specified // as the task factory. useTaskFactory = _taskHostFactoryExplicitlyRequested; } if (useTaskFactory) { ErrorUtilities.VerifyThrowInternalNull(buildComponentHost, "buildComponentHost"); mergedParameters = mergedParameters ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); string runtime = null; string architecture = null; if (!mergedParameters.TryGetValue(XMakeAttributes.runtime, out runtime)) { mergedParameters[XMakeAttributes.runtime] = XMakeAttributes.MSBuildRuntimeValues.clr4; } if (!mergedParameters.TryGetValue(XMakeAttributes.architecture, out architecture)) { mergedParameters[XMakeAttributes.architecture] = XMakeAttributes.GetCurrentMSBuildArchitecture(); } TaskHostTask task = new TaskHostTask(taskLocation, taskLoggingContext, buildComponentHost, mergedParameters, _loadedType, appDomainSetup); return task; } else { AppDomain taskAppDomain = null; ITask taskInstance = TaskLoader.CreateTask(_loadedType, _taskName, taskLocation.File, taskLocation.Line, taskLocation.Column, new TaskLoader.LogError(ErrorLoggingDelegate), appDomainSetup, isOutOfProc, out taskAppDomain); if (taskAppDomain != null) { _tasksAndAppDomains[taskInstance] = taskAppDomain; } return taskInstance; } }
/// <summary> /// Initializes the component with the specified component host. /// </summary> /// <param name="host">The component host.</param> public void InitializeComponent(IBuildComponentHost host) { _componentHost = host; _resultsCache = (IResultsCache)_componentHost.GetComponent(BuildComponentType.ResultsCache); _configCache = (IConfigCache)_componentHost.GetComponent(BuildComponentType.ConfigCache); }
/// <summary> /// Constructor which sets most of the data members except for the noTargetsToBuild bool parameter /// </summary> public RequestDefinition(string fileName, string toolsVersion, string[] targets, PropertyDictionary<ProjectPropertyInstance> properties, int executionTime, RequestDefinition[] childDefinitions, IBuildComponentHost host) : this(fileName, toolsVersion, targets, properties, executionTime, childDefinitions, host, false) { }