1 // Copyright (c) Microsoft. All rights reserved.
2 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3 //-----------------------------------------------------------------------
4 // </copyright>
5 // <summary>Interface for node packets.</summary>
6 //-----------------------------------------------------------------------
7 
8 using System;
9 using System.Collections.Generic;
10 using System.Text;
11 using System.IO;
12 using Microsoft.Build.Framework;
13 
14 namespace Microsoft.Build.BackEnd
15 {
16     #region Enums
17     /// <summary>
18     /// Enumeration of all of the packet types used for communication.
19     /// </summary>
20     internal enum NodePacketType : byte
21     {
22         /// <summary>
23         /// Notifies the Node to set a configuration for a particular build.  This is sent before
24         /// any BuildRequests are made and will not be sent again for a particular build.  This instructs
25         /// the node to prepare to receive build requests.
26         ///
27         /// Contains:
28         /// Build ID
29         /// Environment variables
30         /// Logging Services Configuration
31         /// Node ID
32         /// Default Global Properties
33         /// Toolset Definition Locations
34         /// Startup Directory
35         /// UI Culture Information
36         /// App Domain Configuration XML
37         /// </summary>
38         NodeConfiguration,
39 
40         /// <summary>
41         /// A BuildRequestConfiguration object.
42         /// When sent TO a node, this informs the node of a build configuration.
43         /// When sent FROM a node, this requests a BuildRequestConfigurationResponse to map the configuration to the
44         /// appropriate global configuration ID.
45         ///
46         /// Contents:
47         /// Configuration ID
48         /// Project Filename
49         /// Project Properties
50         /// Project Tools Version
51         /// </summary>
52         BuildRequestConfiguration,
53 
54         /// <summary>
55         /// A response to a request to map a build configuration
56         ///
57         /// Contents:
58         /// Node Configuration ID
59         /// Global Configuration ID
60         /// </summary>
61         BuildRequestConfigurationResponse,
62 
63         /// <summary>
64         /// Information about a project that has been loaded by a node.
65         ///
66         /// Contents:
67         /// Global Configuration ID
68         /// Initial Targets
69         /// Default Targets
70         /// </summary>
71         ProjectLoadInfo,
72 
73         /// <summary>
74         /// Packet used to inform the scheduler that a node's active build request is blocked.
75         ///
76         /// Contents:
77         /// Build Request ID
78         /// Active Targets
79         /// Blocked Target, if any
80         /// Child Requests, if any
81         /// </summary>
82         BuildRequestBlocker,
83 
84         /// <summary>
85         /// Packet used to unblocked a blocked request on a node.
86         ///
87         /// Contents:
88         /// Build Request ID
89         /// Build Results for child requests, if any.
90         /// </summary>
91         BuildRequestUnblocker,
92 
93         /// <summary>
94         /// A BuildRequest object
95         ///
96         /// Contents:
97         /// Build Request ID
98         /// Configuration ID
99         /// Project Instance ID
100         /// Targets
101         /// </summary>
102         BuildRequest,
103 
104         /// <summary>
105         /// A BuildResult object
106         ///
107         /// Contents:
108         /// Build ID
109         /// Project Instance ID
110         /// Targets
111         /// Outputs (per Target)
112         /// Results (per Target)
113         /// </summary>
114         BuildResult,
115 
116         /// <summary>
117         /// A logging message.
118         ///
119         /// Contents:
120         /// Build Event Type
121         /// Build Event Args
122         /// </summary>
123         LogMessage,
124 
125         /// <summary>
126         /// Informs the node that the build is complete.
127         ///
128         /// Contents:
129         /// Prepare For Reuse
130         /// </summary>
131         NodeBuildComplete,
132 
133         /// <summary>
134         /// Reported by the node (or node provider) when a node has terminated.  This is the final packet that will be received
135         /// from a node.
136         ///
137         /// Contents:
138         /// Reason
139         /// </summary>
140         NodeShutdown,
141 
142         /// <summary>
143         /// Notifies the task host to set the task-specific configuration for a particular task execution.
144         /// This is sent in place of NodeConfiguration and gives the task host all the information it needs
145         /// to set itself up and execute the task that matches this particular configuration.
146         ///
147         /// Contains:
148         /// Node ID (of parent MSBuild node, to make the logging work out)
149         /// Startup directory
150         /// Environment variables
151         /// UI Culture information
152         /// App Domain Configuration XML
153         /// Task name
154         /// Task assembly location
155         /// Parameter names and values to set to the task prior to execution
156         /// </summary>
157         TaskHostConfiguration,
158 
159         /// <summary>
160         /// Informs the parent node that the task host has finished executing a
161         /// particular task.  Does not need to contain identifying information
162         /// about the task, because the task host will only ever be connected to
163         /// one parent node at a a time, and will only ever be executing one task
164         /// for that node at any one time.
165         ///
166         /// Contents:
167         /// Task result (success / failure)
168         /// Resultant parameter values (for output gathering)
169         /// </summary>
170         TaskHostTaskComplete,
171 
172         /// <summary>
173         /// Message sent from the node to its paired task host when a task that
174         /// supports ICancellableTask is cancelled.
175         ///
176         /// Contents:
177         /// (nothing)
178         /// </summary>
179         TaskHostTaskCancelled,
180 
181         /// <summary>
182         /// Message sent from a node when it needs to have an SDK resolved.
183         /// </summary>
184         ResolveSdkRequest,
185 
186         /// <summary>
187         /// Message sent from back to a node when an SDK has been resolved.
188         /// </summary>
189         ResolveSdkResponse,
190     }
191     #endregion
192 
193     /// <summary>
194     /// This interface represents a packet which may be transmitted using an INodeEndpoint.
195     /// Implementations define the serialized form of the data.
196     /// </summary>
197     internal interface INodePacket : INodePacketTranslatable
198     {
199         #region Properties
200         /// <summary>
201         /// The type of the packet.  Used to reconstitute the packet using the correct factory.
202         /// </summary>
203         NodePacketType Type
204         {
205             get;
206         }
207         #endregion
208     }
209 }
210