/// <summary> /// Constructor. /// </summary> public OutOfProcTaskHostNode() { // We don't know what the current build thinks this variable should be until RunTask(), but as a fallback in case there are // communications before we get the configuration set up, just go with what was already in the environment from when this node // was initially launched. _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1"); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler); _receivedPackets = new Queue <INodePacket>(); // These WaitHandles are disposed in HandleShutDown() _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new ManualResetEvent(false); _taskCompleteEvent = new AutoResetEvent(false); _taskCancelledEvent = new ManualResetEvent(false); _packetFactory = new NodePacketFactory(); INodePacketFactory thisINodePacketFactory = (INodePacketFactory)this; thisINodePacketFactory.RegisterPacketHandler(NodePacketType.TaskHostConfiguration, TaskHostConfiguration.FactoryForDeserialization, this); thisINodePacketFactory.RegisterPacketHandler(NodePacketType.TaskHostTaskCancelled, TaskHostTaskCancelled.FactoryForDeserialization, this); thisINodePacketFactory.RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this); }
/// <summary> /// Constructor. /// </summary> public OutOfProcNode( #if !FEATURE_NAMED_PIPES_FULL_DUPLEX string clientToServerPipeHandle, string serverToClientPipeHandle #endif ) { s_isOutOfProcNode = true; #if FEATURE_APPDOMAIN_UNHANDLED_EXCEPTION AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler); #endif #if !FEATURE_NAMED_PIPES_FULL_DUPLEX _clientToServerPipeHandle = clientToServerPipeHandle; _serverToClientPipeHandle = serverToClientPipeHandle; #endif _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1"); _receivedPackets = new ConcurrentQueue <INodePacket>(); _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new ManualResetEvent(false); _legacyThreadingData = new LegacyThreadingData(); _componentFactories = new BuildComponentFactoryCollection(this); _componentFactories.RegisterDefaultFactories(); _packetFactory = new NodePacketFactory(); _buildRequestEngine = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine; _globalConfigCache = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache; _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager; // Create a factory for the out-of-proc SDK resolver service which can pass our SendPacket delegate to be used for sending packets to the main node OutOfProcNodeSdkResolverServiceFactory sdkResolverServiceFactory = new OutOfProcNodeSdkResolverServiceFactory(SendPacket); ((IBuildComponentHost)this).RegisterFactory(BuildComponentType.SdkResolverService, sdkResolverServiceFactory.CreateInstance); _sdkResolverService = (this as IBuildComponentHost).GetComponent(BuildComponentType.SdkResolverService) as ISdkResolverService; if (s_projectRootElementCache == null) { s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */); } _buildRequestEngine.OnEngineException += new EngineExceptionDelegate(OnEngineException); _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest); _buildRequestEngine.OnRequestBlocked += new RequestBlockedDelegate(OnNewRequest); _buildRequestEngine.OnRequestComplete += new RequestCompleteDelegate(OnRequestComplete); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResolveSdkResponse, SdkResolverResponse.FactoryForDeserialization, _sdkResolverService as INodePacketHandler); }
/// <summary> /// Constructor. /// </summary> public OutOfProcNode() { s_isOutOfProcNode = true; _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1"); _receivedPackets = new ConcurrentQueue <INodePacket>(); _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new ManualResetEvent(false); _legacyThreadingData = new LegacyThreadingData(); _componentFactories = new BuildComponentFactoryCollection(this); _componentFactories.RegisterDefaultFactories(); _packetFactory = new NodePacketFactory(); _buildRequestEngine = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine; _globalConfigCache = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache; _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager; // Create a factory for the out-of-proc SDK resolver service which can pass our SendPacket delegate to be used for sending packets to the main node OutOfProcNodeSdkResolverServiceFactory sdkResolverServiceFactory = new OutOfProcNodeSdkResolverServiceFactory(SendPacket); ((IBuildComponentHost)this).RegisterFactory(BuildComponentType.SdkResolverService, sdkResolverServiceFactory.CreateInstance); _sdkResolverService = (this as IBuildComponentHost).GetComponent(BuildComponentType.SdkResolverService) as ISdkResolverService; if (s_projectRootElementCacheBase == null) { s_projectRootElementCacheBase = new ProjectRootElementCache(true /* automatically reload any changes from disk */); } _buildRequestEngine.OnEngineException += OnEngineException; _buildRequestEngine.OnNewConfigurationRequest += OnNewConfigurationRequest; _buildRequestEngine.OnRequestBlocked += OnNewRequest; _buildRequestEngine.OnRequestComplete += OnRequestComplete; _buildRequestEngine.OnResourceRequest += OnResourceRequest; (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResourceResponse, ResourceResponse.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.ResolveSdkResponse, SdkResult.FactoryForDeserialization, _sdkResolverService as INodePacketHandler); }
/// <summary> /// Constructor. /// </summary> public OutOfProcNode() { s_isOutOfProcNode = true; AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler); _debugCommunications = (Environment.GetEnvironmentVariable("MSBUILDDEBUGCOMM") == "1"); _receivedPackets = new Queue <INodePacket>(); _packetReceivedEvent = new AutoResetEvent(false); _shutdownEvent = new ManualResetEvent(false); _legacyThreadingData = new LegacyThreadingData(); _componentFactories = new BuildComponentFactoryCollection(this); _componentFactories.RegisterDefaultFactories(); _packetFactory = new NodePacketFactory(); _buildRequestEngine = (this as IBuildComponentHost).GetComponent(BuildComponentType.RequestEngine) as IBuildRequestEngine; _globalConfigCache = (this as IBuildComponentHost).GetComponent(BuildComponentType.ConfigCache) as IConfigCache; _taskHostNodeManager = (this as IBuildComponentHost).GetComponent(BuildComponentType.TaskHostNodeManager) as INodeManager; if (s_projectRootElementCache == null) { s_projectRootElementCache = new ProjectRootElementCache(true /* automatically reload any changes from disk */); } _buildRequestEngine.OnEngineException += new EngineExceptionDelegate(OnEngineException); _buildRequestEngine.OnNewConfigurationRequest += new NewConfigurationRequestDelegate(OnNewConfigurationRequest); _buildRequestEngine.OnRequestBlocked += new RequestBlockedDelegate(OnNewRequest); _buildRequestEngine.OnRequestComplete += new RequestCompleteDelegate(OnRequestComplete); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequest, BuildRequest.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfiguration, BuildRequestConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestConfigurationResponse, BuildRequestConfigurationResponse.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.BuildRequestUnblocker, BuildRequestUnblocker.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeConfiguration, NodeConfiguration.FactoryForDeserialization, this); (this as INodePacketFactory).RegisterPacketHandler(NodePacketType.NodeBuildComplete, NodeBuildComplete.FactoryForDeserialization, this); }