Microsoft.Build
Factory for
Implementation of file system operations directly over the dot net managed layer
Implementation of file system operations on windows. Combination of native and managed implementations.
TODO Remove this class and replace with WindowsFileSystem. Test perf to ensure no regressions.
A possibly-recoverable exception wrapping a failed native call. The captures the
associated recent error code (). The
accounts for the native code as well as a human readable portion.
This is much like , but the message field contains the caller-provided part in addition
to the system-provided message (rather than replacing the system provided message).
Creates an exception representing a native failure (with a corresponding Win32 error code).
The exception's includes the error code, a system-provided message describing it,
and the provided application-specific message prefix (e.g. "Unable to open log file").
Creates an exception representing a native failure (with a corresponding Win32 error code).
The exception's includes the error code and a system-provided message describing it.
Returns a human readable error string for a native error code, like Native: Can't access the log file (0x5: Access is denied).
The message prefix (e.g. "Can't access the log file") is optional.
Converts a Win32 error code to HResult
Handle for a volume iteration as returned by WindowsNative.FindFirstVolumeW />
Private constructor for the PInvoke marshaller.
The type of file artifact to search for
Windows-specific implementation of file system operations using Windows native invocations.
TODO For potential extra perf gains, provide native implementations for all IFileSystem methods and stop inheriting from ManagedFileSystem
Native implementation of file system operations
Maximum path length.
ERROR_SUCCESS
ERROR_FILE_NOT_FOUND
ERROR_PATH_NOT_FOUND
ERROR_DIRECTORY
ERROR_ACCESS_DENIED
ERROR_NO_MORE_FILES
Modifies the search condition of PathMatchSpecEx
The pszSpec parameter points to a single file name pattern to be matched.
The pszSpec parameter points to a semicolon-delimited list of file name patterns to be matched.
If PMSF_NORMAL is used, ignore leading spaces in the string pointed to by pszSpec. If PMSF_MULTIPLE is used,
ignore leading spaces in each file type contained in the string pointed to by pszSpec. This flag can be combined with PMSF_NORMAL and PMSF_MULTIPLE.
Status of attempting to enumerate a directory.
Enumeration of an existent directory succeeded.
One or more path components did not exist, so the search directory could not be opened.
A path component in the search path refers to a file. Only directories can be enumerated.
Directory enumeration could not complete due to denied access to the search directory or a file inside.
Directory enumeration failed without a well-known status (see ).
Represents the result of attempting to enumerate a directory.
Enumerated directory.
Overall status indication.
Native error code. Note that an error code other than ERROR_SUCCESS may be present even on success.
Indicates if enumeration succeeded.
Throws an exception if the native error code could not be canonicalized (a fairly exceptional circumstance).
This is allowed when is .
This is a good default: case when switching on every possible
Throws an exception if the native error code was corresponds to a known
(and enumeration was not successful).
Creates (but does not throw) an exception for this result. The result must not be successful.
Win32FindData
The file attributes of a file
Specified when a file or directory was created
Specifies when the file was last read from, written to, or for executable files, run.
For a file, the structure specifies when the file was last written to, truncated, or overwritten.
For a directory, the structure specifies when the directory is created.
The high-order DWORD value of the file size, in bytes.
The low-order DWORD value of the file size, in bytes.
If the dwFileAttributes member includes the FILE_ATTRIBUTE_REPARSE_POINT attribute, this member specifies the reparse point tag.
Reserved for future use.
The name of the file.
An alternative name for the file.
A class to help with printline debugging in difficult environments like CI, or when debugging msbuild through other
tools like VS or CLI.
See example usages in PrintLineDebugger_Tests
A collection of useful writers
This class contains utility methods for dealing with encoding.
Get the current system locale code page, OEM version. OEM code pages are used for console-based input/output
for historical reasons.
Checks two encoding types to determine if they are similar to each other (equal or if
the Encoding Name is the same).
True if the two Encoding objects are equal or similar.
Check if an encoding type is UTF8 (with or without BOM).
True if the encoding is UTF8.
Check the first 3 bytes of a stream to determine if it matches the UTF8 preamble.
Steam to check.
True when the first 3 bytes of the Stream are equal to the UTF8 preamble (BOM).
Check the first 3 bytes of a stream to determine if it matches the given preamble.
Steam to check.
Preamble to look for.
True when the first 3 bytes of the Stream are equal to the preamble.
Check the first 3 bytes of a file to determine if it matches the 3-byte UTF8 preamble (BOM).
Path to file to check.
True when the first 3 bytes of the file are equal to the UTF8 BOM.
Checks to see if a string can be encoded in a specified code page.
Internal for testing purposes.
Code page for encoding.
String to encode.
True if the string can be encoded in the specified code page.
Find the encoding for the batch file.
The "best" encoding is the current OEM encoding, unless it's not capable of representing
the characters we plan to put in the file. If it isn't, we can fall back to UTF-8.
Why not always UTF-8? Because tools don't always handle it well. See
https://github.com/Microsoft/msbuild/issues/397
Name of the Visual Studio (and Blend) process.
VS ASP intellisense server fails without Microsoft.VisualStudio.Web.Host. Remove when issue fixed: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/574986
Name of the MSBuild process(es)
Name of MSBuild executable files.
Gets the cached Build Environment instance.
Find the location of MSBuild.exe based on the current environment.
This defines the order and precedence for various methods of discovering MSBuild and associated toolsets.
At a high level, an install under Visual Studio is preferred as the user may have SDKs installed to a
specific instance of Visual Studio and build will only succeed if we can discover those. See
https://github.com/Microsoft/msbuild/issues/1461 for details.
Build environment.
Returns true if processName appears in the processList
Name of the process
List of processes to check
Resets the current singleton instance (for testing).
Resets the current singleton instance (for testing).
Enum which defines which environment / mode MSBuild is currently running.
Running from Visual Studio directly or from MSBuild installed under an instance of Visual Studio.
Toolsets and extensions will be loaded from the Visual Studio instance.
Running in a standalone toolset mode. All toolsets and extensions paths are relative to the app
running and not dependent on Visual Studio. (e.g. dotnet CLI, open source clone of our repo)
Running without any defined toolsets. Most functionality limited. Likely will not be able to
build or evaluate a project. (e.g. reference to Microsoft.*.dll without a toolset definition
or Visual Studio instance installed).
Defines the current environment for build tools.
Gets the flag that indicates if we are running in a test harness.
Returns true when the entry point application is Visual Studio.
Path to the MSBuild 32-bit tools directory.
Path to the MSBuild 64-bit (AMD64) tools directory.
Path to the Sdks folder for this MSBuild instance.
Full path to the current MSBuild configuration file.
Full path to current MSBuild.exe.
This path is likely not the current running process. We may be inside
Visual Studio or a test harness. In that case this will point to the
version of MSBuild found to be associated with the current environment.
Full path to the current MSBuild tools directory. This will be 32-bit unless
we're executing from the 'AMD64' folder.
Path to the root Visual Studio install directory
(e.g. 'C:\Program Files (x86)\Microsoft Visual Studio\Preview\Enterprise')
MSBuild extensions path. On Standalone this defaults to the MSBuild folder. In
VisualStudio mode this folder will be %VSINSTALLDIR%\MSBuild.
StringWriter class that allows Encoding to be specified. In the standard StringWriter
class only UTF16 is allowed.
Default ctor (Encoding = UTF8)
Overload to specify encoding.
IKeyComparer implementation that compares AssemblyNames for using in Hashtables.
Comparer for two assembly name extensions
Comparer for two assembly name extensions
Comparer for two assembly name extensions
Comparer for two assembly name extensions
Should the comparer consider the retargetable flag when doing comparisons
Private construct so there's only one instance.
Compare o1 and o2 as AssemblyNames.
Treat o1 and o2 as AssemblyNames. Are they equal?
Get a hashcode for AssemblyName.
Determine if the assembly name extensions are equal
Get a hashcode for AssemblyName.
Class defining extension methods for awaitable objects.
Synchronizes access to the staScheduler field.
The singleton STA scheduler object.
Gets the STA scheduler.
Provides await functionality for ordinary s.
The handle to wait on.
The awaiter.
Provides await functionality for an array of ordinary s.
The handles to wait on.
The awaiter.
Creates a TPL Task that is marked as completed when a is signaled.
The handle whose signal triggers the task to be completed. Do not use a here.
The timeout (in milliseconds) after which the task will fault with a if the handle is not signaled by that time.
A Task that is completed after the handle is signaled.
There is a (brief) time delay between when the handle is signaled and when the task is marked as completed.
Creates a TPL Task that is marked as completed when any in the array is signaled.
The handles whose signals triggers the task to be completed. Do not use a here.
The timeout (in milliseconds) after which the task will return a value of WaitTimeout.
A Task that is completed after any handle is signaled.
There is a (brief) time delay between when the handles are signaled and when the task is marked as completed.
A class which acts as a task scheduler and ensures each scheduled task gets its
own STA thread.
The current queue of tasks.
Returns the list of queued tasks.
Queues a task to the scheduler.
Tries to execute the task immediately. This method will always return false for the STA scheduler.
Compare the version numbers only for an AssemblyNameExtension and make sure they are in reverse order. This assumes the names are the same.
A static instance of the comparer for use in a sort method
Compare x and y by version only.
Change the return value to sort the values in reverse order.
If x is greater than y return -1 indicating x is less than y.
If x is less than y return 1 indicating x is greater than y.
If x and y are equal return 0.
Functions for dealing with the specially formatted errors returned by
build tools.
Various tools produce and consume CanonicalErrors in various formats.
DEVENV Format When Clicking on Items in the Output Window
(taken from env\msenv\core\findutil.cpp ParseLocation function)
v:\dir\file.ext (loc) : msg
\\server\share\dir\file.ext(loc):msg
url
loc:
(line)
(line-line)
(line,col)
(line,col-col)
(line,col,len)
(line,col,line,col)
DevDiv Build Process
(taken from tools\devdiv2.def)
To echo warnings and errors to the build console, the
"description block" must be recognized by build. To do this,
add a $(ECHO_COMPILING_COMMAND) or $(ECHO_PROCESSING_COMMAND)
to the first line of the description block, e.g.
$(ECHO_COMPILING_CMD) Resgen_$<
Errors must have the format:
<text> : error [num]: <msg>
Warnings must have the format:
<text> : warning [num]: <msg>
Represents the parts of a decomposed canonical message.
Defines the error category\severity level.
Value used for unspecified line and column numbers, which are 1-relative.
Initializes a new instance of the class.
Name of the file or tool (not localized)
The line number.
The column number.
The ending line number.
The ending column number.
The category/severity level
The sub category (localized)
The error code (not localized)
The error message text (localized)
A small custom int conversion method that treats invalid entries as missing (0). This is done to work around tools
that don't fully conform to the canonical message format - we still want to salvage what we can from the message.
'value' converted to int or 0 if it can't be parsed or is negative
Decompose an error or warning message into constituent parts. If the message isn't in the canonical form, return null.
This method is thread-safe, because the Regex class is thread-safe (per MSDN).
Decomposed canonical message, or null.
To avoid CA908 warnings (types that in ngen images that will JIT)
wrap each problematic value type in the collection in
one of these objects.
This trick is based on advice from
http://sharepoint/sites/codeanalysis/Wiki%20Pages/Rule%20-%20Avoid%20Types%20That%20Require%20JIT%20Compilation%20In%20Precompiled%20Assemblies.aspx.
It works because although this is a value type, it is not defined in mscorlib.
Wrapped type
Wrapped value
Constructor
Exposes the value
Consumes the value
This struct is functionally identical to KeyValuePair, but avoids
CA908 warnings (types that in ngen images that will JIT).
Instead of generic collections of KeyValuePair, use Pair.
This trick is based on advice from
http://sharepoint/sites/codeanalysis/Wiki%20Pages/Rule%20-%20Avoid%20Types%20That%20Require%20JIT%20Compilation%20In%20Precompiled%20Assemblies.aspx.
It works because although this is a value type, it is not defined in mscorlib.
Key
Value
Key
Value
Constructor
Key
Value
A result of executing a target or task.
Constructor
Constructor
Constructor
Constructor
Constructor
The overall result of the task execution.
Dictionary of the final values of the task parameters
The exception thrown by the task during initialization or execution,
if any.
The name of the resource representing the message to be logged along with the
above exception.
The arguments to be used when formatting ExceptionMessage
Class for loading tasks
For saving the assembly that was loaded by the TypeLoader
We only use this when the assembly failed to load properly into the appdomain
Delegate for logging task loading errors.
Checks if the given type is a task factory.
This method is used as a type filter delegate.
true, if specified type is a task
Creates an ITask instance and returns it.
This is a resolver to help created AppDomains when they are unable to load an assembly into their domain we will help
them succeed by providing the already loaded one in the currentdomain so that they can derive AssemblyName info from it
Check if we added a resolver and remove it
An enumeration of all the types of BuildEventArgs that can be
packaged by this logMessagePacket
An invalid eventId, used during initialization of a LoggingEventType
Event is a CustomEventArgs
Event is a BuildErrorEventArgs
Event is a BuildFinishedEventArgs
Event is a BuildMessageEventArgs
Event is a BuildStartedEventArgs
Event is a BuildWarningEventArgs
Event is a ProjectFinishedEventArgs
Event is a ProjectStartedEventArgs
Event is a TargetStartedEventArgs
Event is a TargetFinishedEventArgs
Event is a TaskStartedEventArgs
Event is a TaskFinishedEventArgs
Event is a TaskCommandLineEventArgs
Event is a TaskParameterEventArgs
Event is a ProjectEvaluationStartedEventArgs
Event is a ProjectEvaluationFinishedEventArgs
Event is a ProjectImportedEventArgs
Event is a TargetSkippedEventArgs
Event is a TelemetryEventArgs
A packet to encapsulate a BuildEventArg logging message.
Contents:
Build Event Type
Build Event Args
The packet version, which is based on the CLR version. Cached because querying Environment.Version each time becomes an allocation bottleneck.
Dictionary of methods used to read BuildEventArgs.
Dictionary of methods used to write BuildEventArgs.
Dictionary of assemblies we've added to the resolver.
The resolver used to load custom event types.
The object used to synchronize access to shared data.
Delegate for translating targetfinished events.
The event type of the buildEventArg based on the
LoggingEventType enumeration
The buildEventArg which is encapsulated by the packet
The sink id
Encapsulates the buildEventArg in this packet.
Constructor for deserialization
Delegate for translating TargetFinishedEventArgs
Delegate representing a method on the BuildEventArgs classes used to write to a stream.
Delegate representing a method on the BuildEventArgs classes used to read from a stream.
The nodePacket Type, in this case the packet is a Logging Message
The buildEventArg wrapped by this packet
The event type of the wrapped buildEventArg
based on the LoggingEventType enumeration
Reads/writes this packet
Writes the logging packet to the translator.
Reads the logging packet from the translator.
Wrapper for Delegate.CreateDelegate with retries.
TODO: Investigate if it would be possible to use one of the overrides of CreateDelegate
that doesn't force the delegate to be closed over its first argument, so that we can
only create the delegate once per event type and cache it.
Takes in a id (LoggingEventType as an int) and creates the correct specific logging class
Based on the type of the BuildEventArg to be wrapped
generate an Id which identifies which concrete type the
BuildEventArg is.
Argument to get the type Id for
An enumeration entry which represents the type
Given a build event that is presumed to be 2.0 (due to its lack of a "WriteToStream" method) and its
LoggingEventType, serialize that event to the stream.
Serialize ExternalProjectFinished Event Argument to the stream
ExternalProjectStartedEvent
Write Build Warning Log message into the translator
Write a Build Error message into the translator
Write Task Command Line log message into the translator
Write a "standard" Message Log the translator
Given a build event that is presumed to be 2.0 (due to its lack of a "ReadFromStream" method) and its
LoggingEventType, read that event from the stream.
Read and reconstruct a ProjectFinishedEventArgs from the stream
Read and reconstruct a ProjectStartedEventArgs from the stream
Read and reconstruct a BuildWarningEventArgs from the stream
Read and reconstruct a BuildErrorEventArgs from the stream
Read and reconstruct a TaskCommandLineEventArgs from the stream
Read and reconstruct a BuildMessageEventArgs from the stream
A StringBuilder lookalike that reuses its internal storage.
This class is being deprecated in favor of SpanBasedStringBuilder in StringTools. Avoid adding more uses.
Captured string builder.
Capacity to initialize the builder with.
Create a new builder, under the covers wrapping a reused one.
The length of the target.
Convert to a string.
Dispose, indicating you are done with this builder.
Append a character.
Append a string.
Append a substring.
Remove a substring.
Grab a backing builder if necessary.
A utility class that mediates access to a shared string builder.
If this shared builder is highly contended, this class could add
a second one and try both in turn.
Made up limit beyond which we won't share the builder
because we could otherwise hold a huge builder indefinitely.
This size seems reasonable for MSBuild uses (mostly expression expansion)
The shared builder.
Obtains a string builder which may or may not already
have been used.
Never returns null.
Returns the shared builder for the next caller to use.
** CALLERS, DO NOT USE THE BUILDER AFTER RELEASING IT HERE! **
Class to wrap the saving and restoring of the culture of a threadpool thread
Queue a threadpool thread and set it to a certain culture.
Helper class to wrap the Microsoft.VisualStudio.Setup.Configuration.Interop API to query
Visual Studio setup for instances installed on the machine.
Code derived from sample: https://code.msdn.microsoft.com/Visual-Studio-Setup-0cedd331
Query the Visual Studio setup API to get instances of Visual Studio installed
on the machine. Will not include anything before Visual Studio "15".
Enumerable list of Visual Studio instances
Wrapper class to represent an installed instance of Visual Studio.
Version of the Visual Studio Instance
Path to the Visual Studio installation
Full name of the Visual Studio instance with SKU name
Utilities for collections
Returns a new list containing the input list
contents, except for nulls
Type of list elements
Extension method -- combines a TryGet with a check to see that the value is equal.
This class provides access to the assembly's resources.
A slot for msbuild.exe to add a resource manager over its own resources, that can also be consulted.
The internals of the Engine are exposed to MSBuild.exe, so they must share the same AssemblyResources class and
ResourceUtilities class that uses it. To make this possible, MSBuild.exe registers its resources here and they are
normally consulted last. This assumes that there are no duplicated resource ID's between the Engine and MSBuild.exe.
(Actually there are currently two: LoggerCreationError and LoggerNotFoundError.
We can't change the resource ID's this late in the cycle and we sometimes want to load the MSBuild.exe ones,
because they're a little different. So for that purpose we call GetStringLookingInMSBuildExeResourcesFirst() )
Loads the specified resource string, either from the assembly's primary resources, or its shared resources.
This method is thread-safe.
The resource string, or null if not found.
Loads the specified resource string.
The resource string, or null if not found.
Loads the specified resource string, from the Engine or else Shared resources.
The resource string, or null if not found.
Loads the specified resource string, from the MSBuild.exe resources.
The resource string, or null if not found.
This class packages information about how to load a given assembly -- an assembly can be loaded by either its assembly
name (strong or weak), or its filename/path.
Uses factory to instantiate correct private class to save space: only one field is ever used of the two.
This constructor initializes the assembly information.
Gets the assembly's identity denoted by its strong/weak name.
Gets the path to the assembly file.
Get the assembly location
Computes a hashcode for this assembly info, so this object can be used as a key into
a hash table.
Determines if two AssemblyLoadInfos are effectively the same.
Assembly represented by name
Assembly name
Constructor
Gets the assembly's identity denoted by its strong/weak name.
Gets the path to the assembly file.
Get the assembly location
Assembly info that uses a file path
Path to assembly
Constructor
Gets the assembly's identity denoted by its strong/weak name.
Gets the path to the assembly file.
Get the assembly location
Specifies the parts of the assembly name to partially match
Compare SimpleName A.PartialCompare(B,SimpleName) match the simple name on A and B if the simple name on A is not null.
Compare Version A.PartialCompare(B, Version) match the Version on A and B if the Version on A is not null.
Compare Culture A.PartialCompare(B, Culture) match the Culture on A and B if the Culture on A is not null.
Compare PublicKeyToken A.PartialCompare(B, PublicKeyToken) match the PublicKeyToken on A and B if the PublicKeyToken on A is not null.
When doing a comparison A.PartialCompare(B, Default) compare all fields of A which are not null with B.
A replacement for AssemblyName that optimizes calls to FullName which is expensive.
The assembly name is represented internally by an AssemblyName and a string, conversion
between the two is done lazily on demand.
Set of assemblyNameExtensions that THIS assemblyname was remapped from.
Construct an unnamed assembly.
Private because we want only one of these.
Construct with AssemblyName.
Construct with string.
Construct from a string, but immediately construct a real AssemblyName.
This will cause an exception to be thrown up front if the assembly name
isn't well formed.
The string version of the assembly name.
Used when the assembly name comes from a user-controlled source like a project file or config file.
Does extra checking on the assembly name and will throw exceptions if something is invalid.
Ctor for deserializing from state file (binary serialization).
This is required because AssemblyName is not Serializable on .NET Core.
Ctor for deserializing from state file (custom binary serialization) using translator.
To be used as a delegate. Gets the AssemblyName of the given file.
Run after the object has been deserialized
Initialize the remapped from structure.
Create remappedFrom HashSet. Used by deserialization as well.
Assume there is a string version, create the AssemblyName version.
Assume there is a string version, create the AssemblyName version.
The base name of the assembly.
Gets the backing AssemblyName, this can be None.
The assembly's version number.
Is the assembly a complex name or a simple name. A simple name is where only the name is set
a complex name is where the version, culture or publickeytoken is also set
Does the fullName have the processor architecture defined
Replace the current version with a new version.
The assembly's Culture
The assembly's retargetable bit
The full name of the original extension we were before being remapped.
Add an assemblyNameExtension which represents an assembly name which was mapped to THIS assemblyName.
As an AssemblyName
The assembly's full name.
Get the assembly's public key token.
A special "unnamed" instance of AssemblyNameExtension.
Compare one assembly name to another.
Compare one assembly name to another.
Get a hash code for this assembly name.
Compare two base names as quickly as possible.
An implementation of compare that compares two base
names as quickly as possible.
Compare two basenames.
Clone this assemblyNameExtension
Clone the object but mark and mark the cloned object as immutable
Is this object immutable
Mark this object as immutable
Compare two assembly names for equality.
Interface method for IEquatable<AssemblyNameExtension>
Compare two assembly names for equality ignoring version.
Compare two assembly names and consider the retargetable flag during the comparison
Compare two assembly names for equality.
Allows the comparison of the culture.
Allows the comparison of just the PublicKeyToken
Compare two public key tokens.
Only the unnamed assembly has both null assemblyname and null string.
Given a display name, construct an assembly name.
The display name.
The assembly name.
Return a string that has AssemblyName special characters escaped.
Those characters are Equals(=), Comma(,), Quote("), Apostrophe('), Backslash(\).
WARNING! This method is not meant as a general purpose escaping method for assembly names.
Use only if you really know that this does what you need.
Convert to a string for display.
Compare the fields of this with that if they are not null.
Compare the fields of this with that if they are not null.
Do a partial comparison between two assembly name extensions.
Compare the fields of A and B on the following conditions:
1) A.Field has a non null value
2) The field has been selected in the comparison flags or the default comparison flags are passed in.
If A.Field is null then we will not compare A.Field and B.Field even when the comparison flag is set for that field unless skipNullFields is false.
Do a partial comparison between two assembly name extensions.
Compare the fields of A and B on the following conditions:
1) A.Field has a non null value
2) The field has been selected in the comparison flags or the default comparison flags are passed in.
If A.Field is null then we will not compare A.Field and B.Field even when the comparison flag is set for that field unless skipNullFields is false.
Reads/writes this class
This class encapsulates information about a file that is associated with a build event.
Creates an instance of this class using the given filename/path.
Filename may be an empty string, if there is truly no file associated.
This overload may also be used if there is a file but truly no line/column,
for example when failing to load a project file.
IF AN IELEMENTLOCATION IS AVAILABLE, USE THE OVERLOAD ACCEPTING THAT INSTEAD.
Creates an instance of this class using the given location.
This does not provide end-line or end-column information.
This is the preferred overload.
Creates an instance of this class using the given filename/path and a line/column of interest in the file.
IF AN IELEMENTLOCATION IS AVAILABLE, USE THE OVERLOAD ACCEPTING THAT INSTEAD.
Set to zero if not available.
Set to zero if not available.
Creates an instance of this class using the given filename/path and a range of lines/columns of interest in the file.
IF AN IELEMENTLOCATION IS AVAILABLE, USE THE OVERLOAD ACCEPTING THAT INSTEAD.
Set to zero if not available.
Set to zero if not available.
Set to zero if not available.
Set to zero if not available.
Creates an instance of this class using the information in the given XmlException.
Creates an instance of this class using the information in the given XmlException and file location.
Gets the filename/path to be associated with some build event.
The filename/path string.
Gets the line number of interest in the file.
Line number, or zero if not available.
Gets the column number of interest in the file.
Column number, or zero if not available.
Gets the last line number of a range of interesting lines in the file.
Last line number, or zero if not available.
Gets the last column number of a range of interesting columns in the file.
Last column number, or zero if not available.
This class contains only static methods, which are useful throughout many
of the MSBuild classes and don't really belong in any specific class.
Converts a string to a bool. We consider "true/false", "on/off", and
"yes/no" to be valid boolean representations in the XML.
The string to convert.
Boolean true or false, corresponding to the string.
Returns a hex representation of a byte array.
The bytes to convert
A string byte types formated as X2.
Returns true if the string can be successfully converted to a bool,
such as "on" or "yes"
Returns true if the string represents a valid MSBuild boolean true value,
such as "on", "!false", "yes"
Returns true if the string represents a valid MSBuild boolean false value,
such as "!on" "off" "no" "!true"
Converts a string like "123.456" into a double. Leading sign is allowed.
Converts a hex string like "0xABC" into a double.
Converts a string like "123.456" or "0xABC" into a double.
Tries decimal conversion first.
Returns true if the string is a valid hex number, like "0xABC"
Returns true if the string is a valid decimal number, like "-123.456"
Returns true if the string is a valid decimal or hex number
delegate for System.IO.Directory.GetFiles, used for testing
Directory path to start search for files in
pattern of files to match
string array of files which match search pattern
delegate for Directory.GetDirectories.
The path to get directories for.
The pattern to search for.
An array of directories.
Delegate for System.IO.Directory.Exists
Directory path to check if it exists
true if directory exists
File exists delegate
The path to check for existence.
'true' if the file exists.
File.Copy delegate
File.Delete delegate
File create delegate
The path to create.
This class contains methods that are useful for error checking and validation.
Emergency escape hatch. If a customer hits a bug in the shipped product causing an internal exception,
and fortuitously it happens that ignoring the VerifyThrow allows execution to continue in a reasonable way,
then we can give them this undocumented environment variable as an immediate workaround.
Throws InternalErrorException.
This is only for situations that would mean that there is a bug in MSBuild itself.
Throws InternalErrorException.
This is only for situations that would mean that there is a bug in MSBuild itself.
Throws InternalErrorException.
Indicates the code path followed should not have been possible.
This is only for situations that would mean that there is a bug in MSBuild itself.
Throws InternalErrorException.
Indicates the code path followed should not have been possible.
This is only for situations that would mean that there is a bug in MSBuild itself.
Throws InternalErrorException.
Indicates the code path followed should not have been possible.
This is only for situations that would mean that there is a bug in MSBuild itself.
Helper to throw an InternalErrorException when the specified parameter is null.
This should be used ONLY if this would indicate a bug in MSBuild rather than
anything caused by user action.
The value of the argument.
Parameter that should not be null
Helper to throw an InternalErrorException when a lock on the specified object is not already held.
This should be used ONLY if this would indicate a bug in MSBuild rather than
anything caused by user action.
The object that should already have been used as a lock.
Helper to throw an InternalErrorException when the specified parameter is null or zero length.
This should be used ONLY if this would indicate a bug in MSBuild rather than
anything caused by user action.
The value of the argument.
Parameter that should not be null or zero length
Helper to throw an InternalErrorException when the specified parameter is not a rooted path.
This should be used ONLY if this would indicate a bug in MSBuild rather than
anything caused by user action.
Parameter that should be a rooted path
This method should be used in places where one would normally put
an "assert". It should be used to validate that our assumptions are
true, where false would indicate that there must be a bug in our
code somewhere. This should not be used to throw errors based on bad
user input or anything that the user did wrong.
Overload for one string format argument.
Overload for two string format arguments.
Overload for three string format arguments.
Overload for four string format arguments.
Throws an InvalidOperationException with the specified resource string
Resource to use in the exception
Formatting args.
Throws an InvalidOperationException if the given condition is false.
Overload for one string format argument.
Overload for two string format arguments.
Overload for three string format arguments.
Overload for four string format arguments.
Throws an ArgumentException that can include an inner exception.
PERF WARNING: calling a method that takes a variable number of arguments
is expensive, because memory is allocated for the array of arguments -- do
not call this method repeatedly in performance-critical scenarios
Throws an ArgumentException that can include an inner exception.
PERF WARNING: calling a method that takes a variable number of arguments
is expensive, because memory is allocated for the array of arguments -- do
not call this method repeatedly in performance-critical scenarios
This method is thread-safe.
Can be null.
Throws an ArgumentException if the given condition is false.
This method is thread-safe.
Overload for one string format argument.
This method is thread-safe.
Overload for two string format arguments.
This method is thread-safe.
Overload for three string format arguments.
This method is thread-safe.
Overload for four string format arguments.
This method is thread-safe.
Throws an ArgumentException that includes an inner exception, if
the given condition is false.
This method is thread-safe.
Can be null.
Overload for one string format argument.
This method is thread-safe.
Overload for two string format arguments.
This method is thread-safe.
Overload for three string format arguments.
This method is thread-safe.
Overload for four string format arguments.
This method is thread-safe.
Throws an argument out of range exception.
Throws an ArgumentOutOfRangeException using the given parameter name
if the condition is false.
Throws an ArgumentNullException if the given string parameter is null
and ArgumentException if it has zero length.
Throws an ArgumentNullException if the given collection is null
and ArgumentException if it has zero length.
Throws an ArgumentException if the given collection is not null but of zero length.
Throws an ArgumentNullException if the given string parameter is null
and ArgumentException if it has zero length.
Throws an ArgumentException if the string has zero length, unless it is
null, in which case no exception is thrown.
Throws an ArgumentNullException if the given parameter is null.
This method is thread-safe.
Throws an ArgumentNullException if the given parameter is null.
This method is thread-safe.
Verifies the given arrays are not null and have the same length
This class implements static methods to assist with unescaping of %XX codes
in the MSBuild file format.
PERF: since we escape and unescape relatively frequently, it may be worth caching
the last N strings that were (un)escaped
Optional cache of escaped strings for use when needing to escape in performance-critical scenarios with significant
expected string reuse.
Replaces all instances of %XX in the input string with the character represented
by the hexadecimal number XX.
The string to unescape.
If the string should be trimmed before being unescaped.
unescaped string
Adds instances of %XX in the input string where the char to be escaped appears
XX is the hex value of the ASCII code for the char. Interns and caches the result.
NOTE: Only recommended for use in scenarios where there's expected to be significant
repetition of the escaped string. Cache currently grows unbounded.
Adds instances of %XX in the input string where the char to be escaped appears
XX is the hex value of the ASCII code for the char.
The string to escape.
escaped string
Adds instances of %XX in the input string where the char to be escaped appears
XX is the hex value of the ASCII code for the char. Caches if requested.
The string to escape.
True if the cache should be checked, and if the resultant string
should be cached.
Before trying to actually escape the string, it can be useful to call this method to determine
if escaping is necessary at all. This can save lots of calls to copy around item metadata
that is really the same whether escaped or not.
Determines whether the string contains the escaped form of '*' or '?'.
Convert the given integer into its hexadecimal representation.
The number to convert, which must be non-negative and less than 16
The character which is the hexadecimal representation of .
Append the escaped version of the given character to a .
The to which to append.
The character to escape.
Append the escaped version of the given string to a .
The to which to append.
The unescaped string.
Special characters that need escaping.
It's VERY important that the percent character is the FIRST on the list - since it's both a character
we escape and use in escape sequences, we can unintentionally escape other escape sequences if we
don't process it first. Of course we'll have a similar problem if we ever decide to escape hex digits
(that would require rewriting the algorithm) but since it seems unlikely that we ever do, this should
be good enough to avoid complicating the algorithm at this point.
Set of methods to deal with versions in the tasks
Convert a version number like 0.0.0.0 to a Version instance.
The method will return null if the string is not a valid value
Version string to convert to a version object
Go though an enumeration and create a sorted list of strings which can be parsed as versions. Keep around the original
string because it may contain a v and this would be required to create the correct path on disk if the string was part of a path.
Convert a version number like 0.0.0.0 to a Version instance.
Should we use Parse to TryParse (parse means we throw an exception, tryparse means we will not).
Static accessor for a ReverseVersionGenericComparer
The Compare implements a reverse comparison
Static accessor for a ReverseVersionGenericComparer
The Compare implements a reverse comparison
Offers a default string format for Error and Warning events
Format the error event message and all the other event data into
a single string.
Error to format
true to show the project file which issued the event, otherwise false.
Properties to Print along with message
The formatted message string.
Format the warning message and all the other event data into a
single string.
Warning to format
true to show the project file which issued the event, otherwise false.
Properties to Print along with message
The formatted message string.
Format the message and all the other event data into a
single string.
Message to format
true to show the project file which issued the event, otherwise false.
Properties to Print along with message
The formatted message string.
Format the error event message and all the other event data into
a single string.
Error to format
The formatted message string.
Format the error event message and all the other event data into
a single string.
Error to format
true to show the project file which issued the event, otherwise false.
The formatted message string.
Format the warning message and all the other event data into a
single string.
Warning to format
The formatted message string.
Format the warning message and all the other event data into a
single string.
Warning to format
true to show the project file which issued the event, otherwise false.
The formatted message string.
Format the message and all the other event data into a
single string.
Message to format
The formatted message string.
Format the message and all the other event data into a
single string.
Message to format
Show project file or not
The formatted message string.
Format the event message and all the other event data into a
single string.
category ("error" or "warning")
subcategory
event message
error or warning code number
file name
line number (0 if n/a)
end line number (0 if n/a)
column number (0 if n/a)
end column number (0 if n/a)
thread id
The formatted message string.
Format the event message and all the other event data into a
single string.
category ("error" or "warning")
subcategory
event message
error or warning code number
file name
the project file name
line number (0 if n/a)
end line number (0 if n/a)
column number (0 if n/a)
end column number (0 if n/a)
thread id
log output properties
The formatted message string.
Splits strings on 'newLines' with tolerance for Everett and Dogfood builds.
String to split.
The kinds of newline breaks we expect.
Currently we're not supporting "\r".
Utility methods for classifying and handling exceptions.
Gets the location of the directory used for diagnostic log files.
The directory used for diagnostic log files.
The filename that exceptions will be dumped to
If the given exception is "ignorable under some circumstances" return false.
Otherwise it's "really bad", and return true.
This makes it possible to catch(Exception ex) without catching disasters.
The exception to check.
True if exception is critical.
If the given exception is file IO related or expected return false.
Otherwise, return true.
The exception to check.
True if exception is not IO related or expected otherwise false.
Determine whether the exception is file-IO related.
The exception to check.
True if exception is IO related.
Checks if the exception is an XML one.
Exception to check.
True if exception is related to XML parsing.
Extracts line and column numbers from the exception if it is XML-related one.
XML-related exception.
Line and column numbers if available, (0,0) if not.
This function works around the fact that XmlException and XmlSchemaException are not directly related.
If the given exception is file IO related or Xml related return false.
Otherwise, return true.
The exception to check.
If the given exception is reflection-related return false.
Otherwise, return true.
The exception to check.
Serialization has been observed to throw TypeLoadException as
well as SerializationException and IO exceptions. (Obviously
it has to do reflection but it ought to be wrapping the exceptions.)
Returns false if this is a known exception thrown by the registry API.
Returns false if this is a known exception thrown by function evaluation
Dump any unhandled exceptions to a file so they can be diagnosed
Dump the exception information to a file
Returns the content of any exception dump files modified
since the provided time, otherwise returns an empty string.
Line and column pair.
Gets or sets line number.
Gets or sets column position.
Functions for matching file names with patterns.
Cache of the list of invalid path characters, because this method returns a clone (for security reasons)
which can cause significant transient allocations
The Default FileMatcher does not cache directory enumeration.
The type of entity that GetFileSystemEntries should return.
Delegate defines the GetFileSystemEntries signature that GetLongPathName uses
to enumerate directories on the file system.
Files, Directories, or Files and Directories
The path to search.
The file pattern.
An enumerable of filesystem entries.
Determines whether the given path has any wild card characters.
Determines whether the given path has any wild card characters, any semicolons or any property references.
Determines whether the given path has any property references.
Get the files and\or folders specified by the given path and pattern.
Whether Files, Directories or both.
The path to search.
The pattern to search.
The directory for the project within which the call is made
If true the project directory should be stripped
The file system abstraction to use that implements file system operations
Returns an enumerable of file system entries matching the specified search criteria. Inaccessible or non-existent file
system entries are skipped.
The file system abstraction to use that implements file system operations
An enumerable of matching file system entries (can be empty).
Determine if the given search pattern will match loosely on Windows
The search pattern to check
Same as Directory.EnumerateFiles(...) except that files that
aren't accessible are skipped instead of throwing an exception.
Other exceptions are passed through.
The path.
The pattern.
The project directory
The file system abstraction to use that implements file system operations
Files that can be accessed.
Same as Directory.EnumerateDirectories(...) except that files that
aren't accessible are skipped instead of throwing an exception.
Other exceptions are passed through.
The path.
Pattern to match
The file system abstraction to use that implements file system operations
Accessible directories.
Given a path name, get its long version.
The short path.
The long path.
Given a path name, get its long version.
The short path.
Delegate.
The long path.
Given a filespec, split it into left-most 'fixed' dir part, middle 'wildcard' dir part, and filename part.
The filename part may have wildcard characters in it.
The filespec to be decomposed.
Receives the fixed directory part.
The wildcard directory part.
The filename part.
Do most of the grunt work of splitting the filespec into parts.
Does not handle post-processing common to the different matching
paths.
The filespec to be decomposed.
Receives the fixed directory part.
The wildcard directory part.
The filename part.
Removes the leading ".\" from all of the paths in the array.
Paths to remove .\ from.
Checks if the char is a DirectorySeparatorChar or a AltDirectorySeparatorChar
Removes the current directory converting the file back to relative path
Paths to remove current directory from.
The filespec.
Holds the directory pattern for globs like **/{pattern}/**, i.e. when we're looking for a matching directory name
regardless of where on the path it is. This field is used only if the wildcard directory part has this shape. In
other cases such as **/{pattern1}/**/{pattern2}/**, we don't use this optimization and instead rely on
to test if a file path matches the glob or not.
Wild-card matching.
If true, then recursion is required.
The directory to search in
The remaining, wildcard part of the directory.
True if SearchData.DirectoryPattern is non-null and we have descended into a directory that matches the pattern.
Data about a search that does not change as the search recursively traverses directories
True if a SearchData.DirectoryPattern is specified but we have not descended into a matching directory.
Get all files that match either the file-spec or the regular expression.
List of files that gets populated.
Information about the search
Patterns to exclude from the results
exclude patterns that might activate farther down the directory tree. Keys assume paths are normalized with forward slashes and no trailing slashes
Options for tuning the parallelization of subdirectories
Given a split file spec consisting of a directory without wildcard characters,
a sub-directory containing wildcard characters,
and a filename which may contain wildcard characters,
create a regular expression that will match that file spec.
PERF WARNING: this method is called in performance-critical
scenarios, so keep it fast and cheap
The fixed directory part.
The wildcard directory part.
The filename part.
The regular expression string.
Determine if the filespec is legal according to the following conditions:
(1) It is not legal for there to be a ".." after a wildcard.
(2) By definition, "**" must appear alone between directory slashes.If there is any remaining "**" then this is not
a valid filespec.
True if both parts meet all conditions for a legal filespec.
Append the regex equivalents for character sequences in the fixed directory part of a filespec:
(1) The leading \\ in UNC paths, so that the doubled slash isn't reduced in the last step
(2) Common filespec characters
Append the regex equivalents for character sequences in the wildcard directory part of a filespec:
(1) The leading **\ if existing
(2) Each occurrence of recursive wildcard \**\
(3) Common filespec characters
Append the regex equivalents for character sequences in the filename part of a filespec:
(1) Trailing dots in file names have to be treated specially.
We want:
*. to match foo
but 'foo' doesn't have a trailing '.' so we need to handle this while still being careful
not to match 'foo.txt' by modifying the generated regex for wildcard characters * and ?
(2) Common filespec characters
(3) Ignore the .* portion of any *.* sequence when no trailing dot exists
Append the regex equivalents for characters common to all filespec parts.
Given an index at a directory separator,
iteratively skip to the end of two sequences:
(1) \.\ -> \
This is an identity, so for example, these two are equivalent,
dir1\.\dir2 == dir1\dir2
(2) \\ -> \
Double directory separators are treated as a single directory separator,
so, for example, this is an identity:
f:\dir1\\dir2 == f:\dir1\dir2
The single exemption is for UNC path names, like this:
\\server\share != \server\share
This case is handled by isUncPath in
a prior step.
The last index of a directory sequence.
Given an index at a directory separator or start of a recursive operator,
iteratively skip to the end of three sequences:
(1), (2) Both sequences handled by IndexOfNextNonCollapsibleChar
(3) \**\**\ -> \**\
This is an identity, so for example, these two are equivalent,
dir1\**\**\ == dir1\**\
]
If starting at a recursive operator, the last index of a recursive sequence.
Otherwise, the last index of a directory sequence.
Given a filespec, get the information needed for file matching.
The filespec.
Receives the regular expression.
Receives the flag that is true if recursion is required.
Receives the flag that is true if the filespec is legal.
Given a filespec, parse it and construct the regular expression string.
The filespec.
Receives the fixed directory part.
Receives the wildcard directory part.
Receives the filename part.
Receives the flag that is true if recursion is required.
Receives the flag that is true if the filespec is legal.
hook method to further change the parts
The results of a match between a filespec and a file name.
Default constructor.
A wildcard (* and ?) matching algorithm that tests whether the input string matches against the pattern.
String which is matched against the pattern.
Pattern against which string is matched.
Given a pattern (filespec) and a candidate filename (fileToMatch)
return matching information.
The filespec.
The candidate to match against.
The result class.
The maximum number of tasks that are allowed to run concurrently
The number of currently available tasks
The maximum number of tasks that Parallel.ForEach may use
Given a filespec, find the files that match.
Will never throw IO exceptions: if there is no match, returns the input verbatim.
The project directory.
Get files that match the given file spec.
Exclude files that match this file spec.
The array of files.
Replace all slashes to the OS slash, collapse multiple slashes into one, trim trailing slashes
A string
The normalized string
Skips slash characters in a string.
The working string
Offset in string to start the search in
First index that is not a slash. Returns the string's length if end of string is reached
Returns true if the given character is a valid drive letter
Given a filespec, find the files that match.
Will never throw IO exceptions: if there is no match, returns the input verbatim.
The project directory.
Get files that match the given file spec.
Exclude files that match this file spec.
The array of files.
Returns true if the last component of the given directory path (assumed to not have any trailing slashes)
matches the given pattern.
The path to test.
The pattern to test against.
True in case of a match (e.g. directoryPath = "dir/subdir" and pattern = "s*"), false otherwise.
This class contains utility methods for file IO.
PERF\COVERAGE NOTE: Try to keep classes in 'shared' as granular as possible. All the methods in
each class get pulled into the resulting assembly.
This class contains utility methods for file IO.
It is in a separate file so that it can be selectively included into an assembly.
This class contains utility methods for file IO.
Partial class in order to reduce the amount of sharing into different assemblies
The directory where MSBuild stores cache information used during the build.
FOR UNIT TESTS ONLY
Clear out the static variable used for the cache directory so that tests that
modify it can validate their modifications.
Determines whether the file system is case sensitive.
Copied from https://github.com/dotnet/runtime/blob/73ba11f3015216b39cb866d9fb7d3d25e93489f2/src/libraries/Common/src/System/IO/PathInternal.CaseSensitivity.cs#L41-L59
Copied from https://github.com/dotnet/corefx/blob/056715ff70e14712419d82d51c8c50c54b9ea795/src/Common/src/System/IO/PathInternal.Windows.cs#L61
MSBuild should support the union of invalid path chars across the supported OSes, so builds can have the same behaviour crossplatform: https://github.com/Microsoft/msbuild/issues/781#issuecomment-243942514
Copied from https://github.com/dotnet/corefx/blob/387cf98c410bdca8fd195b28cbe53af578698f94/src/System.Runtime.Extensions/src/System/IO/Path.Windows.cs#L18
MSBuild should support the union of invalid path chars across the supported OSes, so builds can have the same behaviour crossplatform: https://github.com/Microsoft/msbuild/issues/781#issuecomment-243942514
Retrieves the MSBuild runtime cache directory
Get the hex hash string for the string
Get the hash for the assemblyPaths
Clears the MSBuild runtime cache
If the given path doesn't have a trailing slash then add one.
If the path is an empty string, does not modify it.
The path to check.
A path with a slash.
Ensures the path does not have a leading or trailing slash after removing the first 'start' characters.
Ensures the path does not have a leading slash after removing the first 'start' characters but does end in a slash.
Ensures the path does not have a trailing slash.
Indicates if the given file-spec ends with a slash.
The file spec.
true, if file-spec has trailing slash
Indicates if the given character is a slash.
true, if slash
Trims the string and removes any double quotes around it.
Get the directory name of a rooted full path
Gets the canonicalized full path of the provided path.
Guidance for use: call this on all paths accepted through public entry
points that need normalization. After that point, only verify the path
is rooted, using ErrorUtilities.VerifyThrowPathRooted.
ASSUMES INPUT IS ALREADY UNESCAPED.
If on Unix, convert backslashes to slashes for strings that resemble paths.
The heuristic is if something resembles paths (contains slashes) check if the
first segment exists and is a directory.
Use a native shared method to massage file path. If the file is adjusted,
that qualifies is as a path.
@baseDirectory is just passed to LooksLikeUnixFilePath, to help with the check
If on Unix, convert backslashes to slashes for strings that resemble paths.
This overload takes and returns ReadOnlyMemory of characters.
If on Unix, check if the string looks like a file path.
The heuristic is if something resembles paths (contains slashes) check if the
first segment exists and is a directory.
If @baseDirectory is not null, then look for the first segment exists under
that
Extracts the directory from the given file-spec.
The filespec.
directory path
Determines whether the given assembly file name has one of the listed extensions.
The name of the file
Array of extensions to consider.
Get the currently executing assembly path
Determines the full path for the given file-spec.
ASSUMES INPUT IS STILL ESCAPED
The file spec to get the full path of.
full path
A variation of Path.GetFullPath that will return the input value
instead of throwing any IO exception.
Useful to get a better path for an error message, without the risk of throwing
if the error message was itself caused by the path being invalid!
Compare if two paths, relative to the given currentDirectory are equal.
Does not throw IO exceptions. See
Normalizes a path for path comparison
Does not throw IO exceptions. See
A variation on File.Delete that will throw ExceptionHandling.NotExpectedException exceptions
A variation on Directory.Delete that will throw ExceptionHandling.NotExpectedException exceptions
Deletes a directory, ensuring that Directory.Delete does not get a path ending in a slash.
This is a workaround for https://github.com/dotnet/corefx/issues/3780, which clashed with a common
pattern in our tests.
Gets a file info object for the specified file path. If the file path
is invalid, or is a directory, or cannot be accessed, or does not exist,
it returns null rather than throwing or returning a FileInfo around a non-existent file.
This allows it to be called where File.Exists() (which never throws, and returns false
for directories) was called - but with the advantage that a FileInfo object is returned
that can be queried (e.g., for LastWriteTime) without hitting the disk again.
FileInfo around path if it is an existing /file/, else null
Returns if the directory exists
Full path to the directory in the filesystem
The file system
Returns if the directory exists
Full path to the file in the filesystem
The file system
If there is a directory or file at the specified path, returns true.
Otherwise, returns false.
Does not throw IO exceptions, to match Directory.Exists and File.Exists.
Unlike calling each of those in turn it only accesses the disk once, which is faster.
This method returns true if the specified filename is a solution file (.sln) or
solution filter file (.slnf); otherwise, it returns false.
Solution filters are included because they are a thin veneer over solutions, just
with a more limited set of projects to build, and should be treated the same way.
Returns true if the specified filename is a VC++ project file, otherwise returns false
Returns true if the specified filename is a metaproject file (.metaproj), otherwise false.
Given the absolute location of a file, and a disc location, returns relative file path to that disk location.
Throws UriFormatException.
The base path we want to be relative to. Must be absolute.
Should not include a filename as the last segment will be interpreted as a directory.
The path we need to make relative to basePath. The path can be either absolute path or a relative path in which case it is relative to the base path.
If the path cannot be made relative to the base path (for example, it is on another drive), it is returned verbatim.
If the basePath is an empty string, returns the path.
relative path (can be the full path)
Helper function to create an Uri object from path.
path string
uri object
Normalizes the path if and only if it is longer than max path,
or would be if rooted by the current directory.
This may make it shorter by removing ".."'s.
A variation of Path.IsRooted that not throw any IO exception.
Get the folder N levels above the given. Will stop and return current path when rooted.
Path to get the folder above.
Number of levels up to walk.
Full path to the folder N levels above the path.
Combine multiple paths. Should only be used when compiling against .NET 2.0.
Only use in .NET 2.0. Otherwise, use System.IO.Path.Combine(...)
Root path.
Paths to concatenate.
Combined path.
Replace all backward slashes to forward slashes
Ensure all slashes are the current platform's slash
Locate a file in either the directory specified or a location in the
directory structure above that directory.
Searches for a file based on the specified starting directory.
The file to search for.
An optional directory to start the search in. The default location is the directory
of the file containing the property function.
The filesystem
The full path of the file if it is found, otherwise an empty string.
Clears the file existence cache.
Generates a unique directory name in the temporary folder.
Caller must delete when finished.
Generates a unique temporary file name with a given extension in the temporary folder.
File is guaranteed to be unique.
Extension may have an initial period.
File will NOT be created.
May throw IOException.
Generates a unique temporary file name with a given extension in the temporary folder.
If no extension is provided, uses ".tmp".
File is guaranteed to be unique.
Caller must delete it when finished.
Generates a unique temporary file name with a given extension in the temporary folder.
File is guaranteed to be unique.
Extension may have an initial period.
Caller must delete it when finished.
May throw IOException.
Creates a file with unique temporary file name with a given extension in the specified folder.
File is guaranteed to be unique.
Extension may have an initial period.
If folder is null, the temporary folder will be used.
Caller must delete it when finished.
May throw IOException.
Encapsulates the definitions of the item-spec modifiers a.k.a. reserved item metadata.
Indicates if the given name is reserved for an item-spec modifier.
Indicates if the given name is reserved for one of the specific subset of itemspec
modifiers to do with the defining project of the item.
Indicates if the given name is reserved for a derivable item-spec modifier.
Derivable means it can be computed given a file name.
Name to check.
true, if name of a derivable modifier
Performs path manipulations on the given item-spec as directed.
Does not cache the result.
Performs path manipulations on the given item-spec as directed.
Supported modifiers:
%(FullPath) = full path of item
%(RootDir) = root directory of item
%(Filename) = item filename without extension
%(Extension) = item filename extension
%(RelativeDir) = item directory as given in item-spec
%(Directory) = full path of item directory relative to root
%(RecursiveDir) = portion of item path that matched a recursive wildcard
%(Identity) = item-spec as given
%(ModifiedTime) = last write time of item
%(CreatedTime) = creation time of item
%(AccessedTime) = last access time of item
NOTES:
1) This method always returns an empty string for the %(RecursiveDir) modifier because it does not have enough
information to compute it -- only the BuildItem class can compute this modifier.
2) All but the file time modifiers could be cached, but it's not worth the space. Only full path is cached, as the others are just string manipulations.
Methods of the Path class "normalize" slashes and periods. For example:
1) successive slashes are combined into 1 slash
2) trailing periods are discarded
3) forward slashes are changed to back-slashes
As a result, we cannot rely on any file-spec that has passed through a Path method to remain the same. We will
therefore not bother preserving slashes and periods when file-specs are transformed.
Never returns null.
The root directory for relative item-specs. When called on the Engine thread, this is the project directory. When called as part of building a task, it is null, indicating that the current directory should be used.
The item-spec to modify.
The path to the project that defined this item (may be null).
The modifier to apply to the item-spec.
Full path if any was previously computed, to cache.
The modified item-spec (can be empty string, but will never be null).
Thrown when the item-spec is not a path.
Indicates whether the given path is a UNC or drive pattern root directory.
Note: This function mimics the behavior of checking if Path.GetDirectoryName(path) == null.
Temporary check for something like http://foo which will end up like c:\foo\bar\http://foo
We should either have no colon, or exactly one colon.
UNDONE: This is a minimal safe change for Dev10. The correct fix should be to make GetFullPath/NormalizePath throw for this.
This class contains utility methods for file IO.
Separate from FileUtilities because some assemblies may only need the patterns.
PERF\COVERAGE NOTE: Try to keep classes in 'shared' as granular as possible. All the methods in
each class get pulled into the resulting assembly.
Indicates whether the specified string follows the pattern drive pattern (for example "C:", "D:").
Input to check for drive pattern.
true if follows the drive pattern, false otherwise.
Indicates whether the specified string follows the pattern drive pattern (for example "C:/" or "C:\").
Input to check for drive pattern with slash.
true if follows the drive pattern with slash, false otherwise.
Indicates whether the specified string starts with the drive pattern (for example "C:").
Input to check for drive pattern.
true if starts with drive pattern, false otherwise.
Indicates whether the specified string starts with the drive pattern (for example "C:/" or "C:\").
Input to check for drive pattern.
true if starts with drive pattern with slash, false otherwise.
Indicates whether the specified file-spec comprises exactly "\\server\share" (with no trailing characters).
Input to check for UNC pattern.
true if comprises UNC pattern.
Indicates whether the specified file-spec begins with "\\server\share".
Input to check for UNC pattern.
true if starts with UNC pattern.
Indicates whether the file-spec begins with a UNC pattern and how long the match is.
Input to check for UNC pattern.
length of the match, -1 if no match.
Indicates whether or not the file-spec meets the minimum requirements of a UNC pattern.
Input to check for UNC pattern minimum requirements.
true if the UNC pattern is a minimum length of 5 and the first two characters are be a slash, false otherwise.
Used to specify the targeted bitness of the .NET Framework for some methods of FrameworkLocationHelper
Indicates the .NET Framework that is currently being run under.
Indicates the 32-bit .NET Framework
Indicates the 64-bit .NET Framework
FrameworkLocationHelper provides utility methods for locating .NET Framework and .NET Framework SDK directories and files
Path to the ToolsVersion definitions in the registry
By default when a root path is not specified we would like to use the program files directory \ reference assemblies\framework as the root location
to generate the reference assembly paths from.
List the supported .net versions.
List the supported visual studio versions.
The items must be ordered by the version, because some methods depend on that fact to find the previous visual studio version.
Define explicit fallback rules for the request to get path of .net framework sdk tools folder.
The default rule is fallback to previous VS. However, there are some special cases that need
explicit rules, i.e. v4.5.1 on VS12 fallbacks to v4.5 on VS12.
The rules are maintained in a 2-dimensions array. Each row defines a rule. The first column
defines the trigger condition. The second column defines the fallback .net and VS versions.
Because there is no longer a strong 1:1 mapping between FX versions and SDK
versions, if we're unable to locate the desired SDK version, we will try to
use whichever SDK version is installed by looking at the key pointing to the
"latest" version.
This isn't ideal, but it will allow our tasks to function on any of several
related SDKs even if they don't have exactly the same versions.
NOTE: This returns the path to the root of the fallback SDK
Because there is no longer a strong 1:1 mapping between FX versions and SDK
versions, if we're unable to locate the desired SDK version, we will try to
use whichever SDK version is installed by looking at the key pointing to the
"latest" version.
This isn't ideal, but it will allow our tasks to function on any of several
related SDKs even if they don't have exactly the same versions.
NOTE: This explicitly returns the path to the 3.5 tools (bin) under the fallback
SDK, to match the data we're pulling from the registry now.
Because there is no longer a strong 1:1 mapping between FX versions and SDK
versions, if we're unable to locate the desired SDK version, we will try to
use whichever SDK version is installed by looking at the key pointing to the
"latest" version.
This isn't ideal, but it will allow our tasks to function on any of several
related SDKs even if they don't have exactly the same versions.
NOTE: This explicitly returns the path to the 4.X tools (bin\NetFX 4.0 Tools)
under the fallback SDK, to match the data we're pulling from the registry now.
Check the registry key and value to see if the .net Framework is installed on the machine.
Registry path to look for the value
Key to retrieve the value from
True if the registry key is 1 false if it is not there. This method also return true if the complus enviornment variables are set.
Heuristic that first considers the current runtime path and then searches the base of that path for the given
frameworks version.
The path to the runtime that is currently executing.
Should be something like 'v1.2' that indicates the runtime version we want.
Function that checks if directory exists.
Delegate to method that can return filesystem entries.
.NET framework architecture
Will return 'null' if there is no target frameworks on this machine.
Determine the 32 bit program files directory, this is used for finding where the reference assemblies live.
Determine the 64-bit program files directory, used as the basis for MSBuildExtensionsPath64.
Returns null if we're not on a 64-bit machine
Generate the path to the program files reference assembly location by taking in the program files special folder and then
using that path to generate the path to the reference assemblies location.
Given a ToolsVersion, find the path to the build tools folder for that ToolsVersion.
The ToolsVersion to look up
Target build tools architecture.
The path to the build tools folder for that ToolsVersion, if it exists, or
null otherwise
Take the parts of the Target framework moniker and formulate the reference assembly path based on the following pattern:
For a framework and version:
$(TargetFrameworkRootPath)\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)
For a subtype:
$(TargetFrameworkRootPath)\$(TargetFrameworkIdentifier)\$(TargetFrameworkVersion)\SubType\$(TargetFrameworkSubType)
e.g.NET Framework v4.0 would locate its reference assemblies in:
\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
e.g.Silverlight v2.0 would locate its reference assemblies in:
\Program Files\Reference Assemblies\Microsoft\Framework\Silverlight\v2.0
e.g.NET Compact Framework v3.5, subtype PocketPC would locate its reference assemblies in:
\Program Files\Reference Assemblies\Microsoft\Framework\.NETCompactFramework\v3.5\SubType\PocketPC
The path to the reference assembly location
Given a path, subtracts the requested number of directories and returns the result.
Internal only so that I can have the unit tests use it too, instead of duplicating the same code
Look up the path to the build tools directory for the requested ToolsVersion in the .exe.config file of this executable
Look up the path to the build tools directory in the registry for the requested ToolsVersion and requested architecture
Will return the path to the dot net framework reference assemblies if they exist under the program files\reference assembies\microsoft\framework directory
or null if the directory does not exist.
Look for the given registry value under the given key.
Helper method to create an instance of for .net v4.x,
because most of attributes are the same for v4.x versions.
.net framework version.
Version of Visual Studio
The key in registry to indicate the corresponding .net framework in this visual studio.
i.e. 'v8.0A' for VS11.
The version of this visual studio.
The list of supported .net framework versions in this visual studio.
The key in registry to indicate the corresponding windows sdk, i.e. "v8.0" for VS11.
The name in registry to indicate the sdk installation folder path, i.e. "InstallationFolder" for windows v8.0.
The key in the registry to indicate the corresponding .net framework in this visual studio.
i.e. 'v8.0A' for VS11.
The registry key of this .net framework, i.e. "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" for .net v4.5.
The name in registry to indicate that this .net framework is installed, i.e. "Install" for .net v4.5.
The key in registry to indicate the sdk tools folder, i.e. "WinSDK-NetFx40Tools-x86" for .net v4.5.
The version of visual studio that shipped with this .net framework.
Does this .net framework include MSBuild?
Cached paths of .net framework on different architecture.
Cached paths of .net framework sdk tools folder path on different visual studio version.
Cached path of the corresponding windows sdk.
Cached path of .net framework reference assemblies.
The version of this .net framework.
The name in registry to indicate the sdk installation folder path, i.e. "InstallationFolder" for .net v4.5.
Folder prefix, i.e. v4.0 for .net v4.5.
Get the FrameworkName for this version of the .NET Framework.
Gets the full registry key of this .net framework Sdk for the given visual studio version.
i.e. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v8.0A\WinSDK-NetFx40Tools-x86" for .net v4.5 on VS11.
Gets the full path of .net framework for the given architecture.
Gets the full path of .net framework sdk tools for the given visual studio version.
i.e. "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\" for .net v4.5 on VS11.
Gets the full path of .net framework sdk.
i.e. "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\" for .net v4.5 on VS11.
Gets the full path of reference assemblies folder.
i.e. "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\" for .net v4.5.
Gets the full path of the corresponding windows sdk shipped with this .net framework.
i.e. "C:\Program Files (x86)\Windows Kits\8.0\" for v8.0 (shipped with .net v4.5 and VS11).
Specialized implementation for legacy .net framework v1.1 and v2.0.
Gets the full registry key of this .net framework Sdk for the given visual studio version.
i.e. "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework" for v1.1 and v2.0.
Gets the full path of .net framework sdk tools for the given visual studio version.
Gets the full path of .net framework sdk, which is the full path of .net framework sdk tools for v1.1 and v2.0.
Gets the full path of reference assemblies folder, which is the full path of .net framework for v1.1 and v2.0.
Specialized implementation for legacy .net framework v3.0 and v3.5.
Gets the full path of .net framework sdk.
i.e. "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\" for .net v3.5 on VS11.
Gets the full path of reference assemblies folder.
i.e. "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\" for v3.5.
Represents the location information for error reporting purposes. This is normally used to
associate a run-time error with the original XML.
This is not used for arbitrary errors from tasks, which store location in a BuildXXXXEventArgs.
All implementations should be IMMUTABLE.
This is not public because the current implementation only provides correct data for unedited projects.
DO NOT make it public without considering a solution to this problem.
The file from which this particular element originated. It may
differ from the ProjectFile if, for instance, it was part of
an import or originated in a targets file.
Should always have a value.
If not known, returns empty string.
The line number where this element exists in its file.
The first line is numbered 1.
Zero indicates "unknown location".
The column number where this element exists in its file.
The first column is numbered 1.
Zero indicates "unknown location".
The location in a form suitable for replacement
into a message.
This exception is to be thrown whenever an assumption we have made in the code turns out to be false. Thus, if this
exception ever gets thrown, it is because of a bug in our own code, not because of something the user or project author
did wrong.
!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~
WARNING: When this file is shared into multiple assemblies each assembly will view this as a different type.
Don't throw this exception from one assembly and catch it in another.
!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~!~
Default constructor.
SHOULD ONLY BE CALLED BY DESERIALIZER.
SUPPLY A MESSAGE INSTEAD.
Creates an instance of this exception using the given message.
Creates an instance of this exception using the given message and inner exception.
Adds the inner exception's details to the exception message because most bug reporters don't bother
to provide the inner exception details which is typically what we care about.
Private constructor used for (de)serialization. The constructor is private as this class is sealed
If we ever add new members to this class, we'll need to update this.
A fatal internal error due to a bug has occurred. Give the dev a chance to debug it, if possible.
Will in all cases launch the debugger, if the environment variable "MSBUILDLAUNCHDEBUGGER" is set.
In DEBUG build, will always launch the debugger, unless we are in razzle (_NTROOT is set) or in NUnit,
or MSBUILDDONOTLAUNCHDEBUGGER is set (that could be useful in suite runs).
We don't launch in retail or LKG so builds don't jam; they get a callstack, and continue or send a mail, etc.
We don't launch in NUnit as tests often intentionally cause InternalErrorExceptions.
Because we only call this method from this class, just before throwing an InternalErrorException, there is
no danger that this suppression will cause a bug to only manifest itself outside NUnit
(which would be most unfortunate!). Do not make this non-private.
Unfortunately NUnit can't handle unhandled exceptions like InternalErrorException on anything other than
the main test thread. However, there's still a callstack displayed before it quits.
If it is going to launch the debugger, it first does a Debug.Fail to give information about what needs to
be debugged -- the exception hasn't been thrown yet. This automatically displays the current callstack.
This class packages information about a type loaded from an assembly: for example,
the GenerateResource task class type or the ConsoleLogger logger class type.
Creates an instance of this class for the given type.
Creates an instance of this class for the given type.
The Type to be loaded
Information used to load the assembly
The assembly which has been loaded, if any
Gets whether there's a LoadInSeparateAppDomain attribute on this type.
Caches the result - since it can't change during the build.
Gets whether there's a STAThread attribute on the Execute method of this type.
Caches the result - since it can't change during the build.
Determines if the task has a hardcoded requirement for STA thread usage.
Gets the type that was loaded from an assembly.
The loaded type.
If we loaded an assembly for this type.
We use this information to help created AppDomains to resolve types that it could not load successfully
Gets the assembly the type was loaded from.
The assembly info for the loaded type.
Assembly, if any, that we loaded for this type.
We use this information to help created AppDomains to resolve types that it could not load successfully
Interop methods.
Default buffer size to use when dealing with the Windows API.
Flags for CoWaitForMultipleHandles
Exit when a handle is signaled.
Exit when all handles are signaled AND a message is received.
Exit when an RPC call is serviced.
Processor architecture values
Structure that contain information about the system on which we are running
Wrap the intptr returned by OpenProcess in a safe handle.
Contains information about the current state of both physical and virtual memory, including extended memory
Initializes a new instance of the class.
Size of the structure, in bytes. You must set this member before calling GlobalMemoryStatusEx.
Number between 0 and 100 that specifies the approximate percentage of physical
memory that is in use (0 indicates no memory use and 100 indicates full memory use).
Total size of physical memory, in bytes.
Size of physical memory available, in bytes.
Size of the committed memory limit, in bytes. This is physical memory plus the
size of the page file, minus a small overhead.
Size of available memory to commit, in bytes. The limit is ullTotalPageFile.
Total size of the user mode portion of the virtual address space of the calling process, in bytes.
Size of unreserved and uncommitted memory in the user mode portion of the virtual
address space of the calling process, in bytes.
Size of unreserved and uncommitted memory in the extended portion of the virtual
address space of the calling process, in bytes.
Contains information about a file or directory; used by GetFileAttributesEx.
Contains the security descriptor for an object and specifies whether
the handle retrieved by specifying this structure is inheritable.
Architecture as far as the current process is concerned.
It's x86 in wow64 (native architecture is x64 in that case).
Otherwise it's the same as the native architecture.
Actual architecture of the system.
Convert SYSTEM_INFO architecture values to the internal enum
Read system info values
Get the exact physical core count on Windows
Useful for getting the exact core count in 32 bits processes,
as Environment.ProcessorCount has a 32-core limit in that case.
https://github.com/dotnet/runtime/blob/221ad5b728f93489655df290c1ea52956ad8f51c/src/libraries/System.Runtime.Extensions/src/System/Environment.Windows.cs#L171-L210
Gets the max path limit of the current OS.
Cached value for MaxPath.
Cached value for IsUnixLike (this method is called frequently during evaluation).
Gets a flag indicating if we are running under a Unix-like system (Mac, Linux, etc.)
Gets a flag indicating if we are running under Linux
Gets a flag indicating if we are running under flavor of BSD (NetBSD, OpenBSD, FreeBSD)
Gets a flag indicating if we are running under MONO
Gets a flag indicating if we are running under some version of Windows
Gets a flag indicating if we are running under Mac OSX
Gets a string for the current OS. This matches the OS env variable
for Windows (Windows_NT).
OS name that can be used for the msbuildExtensionsPathSearchPaths element
for a toolset
The base directory for all framework paths in Mono
The directory of the current framework
Gets the currently running framework path
Gets the base directory of all Mono frameworks
System information, initialized when required.
Initially implemented as , but
that's .NET 4+, and this is used in MSBuildTaskHost.
Architecture getter
Native architecture getter
Really truly non pumping wait.
Raw IntPtrs have to be used, because the marshaller does not support arrays of SafeHandle, only
single SafeHandles.
Get the last write time of the fullpath to a directory. If the pointed path is not a directory, or
if the directory does not exist, then false is returned and fileModifiedTimeUtc is set DateTime.MinValue.
Full path to the file in the filesystem
The UTC last write time for the directory
Takes the path and returns the short path
Takes the path and returns a full path
Retrieves the current global memory status.
Get the last write time of the fullpath to the file.
Full path to the file in the filesystem
The last write time of the file, or DateTime.MinValue if the file does not exist.
This method should be accurate for regular files and symlinks, but can report incorrect data
if the file's content was modified by writing to it through a different link, unless
MSBUILDALWAYSCHECKCONTENTTIMESTAMP=1.
Get the last write time of the content pointed to by a file path.
Full path to the file in the filesystem
The last write time of the file, or DateTime.MinValue if the file does not exist.
This is the most accurate timestamp-extraction mechanism, but it is too slow to use all the time.
See https://github.com/Microsoft/msbuild/issues/2052.
Did the HRESULT succeed
Did the HRESULT Fail
Given an error code, converts it to an HRESULT and throws the appropriate exception.
Kills the specified process by id and all of its children recursively.
Returns the parent process id for the specified process.
Returns zero if it cannot be gotten for some reason.
Returns an array of all the immediate child processes by id.
NOTE: The IntPtr in the tuple is the handle of the child process. CloseHandle MUST be called on this.
Internal, optimized GetCurrentDirectory implementation that simply delegates to the native method
Compare an unsafe char buffer with a to see if their contents are identical.
The beginning of the char buffer.
The length of the buffer.
The string.
True only if the contents of and the first characters in are identical.
Gets the current OEM code page which is used by console apps
(as opposed to the Windows/ANSI code page)
Basically for each ANSI code page (set in Regional settings) there's a corresponding OEM code page
that needs to be used for instance when writing to batch files
Gets the fully qualified filename of the currently executing .exe
CoWaitForMultipleHandles allows us to wait in an STA apartment and still service RPC requests from other threads.
VS needs this in order to allow the in-proc compilers to properly initialize, since they will make calls from the
build thread which the main thread (blocked on BuildSubmission.Execute) must service.
Waits while pumping APC messages. This is important if the waiting thread is an STA thread which is potentially
servicing COM calls from other threads.
Waits while pumping APC messages. This is important if the waiting thread is an STA thread which is potentially
servicing COM calls from other threads.
Waits while pumping APC messages. This is important if the waiting thread is an STA thread which is potentially
servicing COM calls from other threads.
This class contains common reflection tasks
This class contains methods that are useful for error checking and
validation of project files.
FUTURE: This class could except an optional inner exception to put in the
InvalidProjectFileException, which could make debugging a host easier in some circumstances.
This method is used to flag errors in the project file being processed.
Do NOT use this method in place of ErrorUtilities.VerifyThrow(), because
ErrorUtilities.VerifyThrow() is used to flag internal/programming errors.
The condition to check.
The of the element.
The resource string for the error message.
Overload for one string format argument.
The of the element.
The resource string for the error message.
Overload for one string format argument.
The condition to check.
The of the element.
The resource string for the error message.
Overload for two string format arguments.
The of the element.
The resource string for the error message.
Overload for three string format arguments.
The of the element.
The resource string for the error message.
Overload for four string format arguments.
The of the element.
The resource string for the error message.
Overload for if there are more than four string format arguments.
The of the element.
The resource string for the error message.
Overload for two string format arguments.
The condition to check.
The of the element.
The resource string for the error message.
Overload for three string format arguments.
The condition to check.
The of the element.
The resource string for the error message.
Overload for four string format arguments.
The condition to check.
The of the element.
The resource string for the error message.
This method is used to flag errors in the project file being processed.
Do NOT use this method in place of ErrorUtilities.VerifyThrow(), because
ErrorUtilities.VerifyThrow() is used to flag internal/programming errors.
The condition to check.
The resource string for the
error sub-category (can be null).
The of the element.
The resource string for the error message.
Overload for one string format argument.
The condition to check.
The resource string for the
error sub-category (can be null).
The of the element.
The resource string for the error message.
Overload for two string format arguments.
The condition to check.
The resource string for the
error sub-category (can be null).
The of the element.
The resource string for the error message.
Overload for three string format arguments.
The condition to check.
The resource string for the
error sub-category (can be null).
The of the element.
The resource string for the error message.
Overload for four string format arguments.
The condition to check.
The resource string for the
error sub-category (can be null).
The of the element.
The resource string for the error message.
Throws an InvalidProjectFileException using the given data.
PERF WARNING: calling a method that takes a variable number of arguments
is expensive, because memory is allocated for the array of arguments -- do
not call this method repeatedly in performance-critical scenarios
The resource string for the
error sub-category (can be null).
The of the element.
The resource string for the error message.
Extra arguments for formatting the error message.
This class contains methods that are useful for error checking and validation of project files.
This method is used to flag errors in the project file being processed. Do NOT use this method in place of
ErrorUtilities.VerifyThrow(), because ErrorUtilities.VerifyThrow() is used to flag internal/programming errors.
PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
the array of arguments -- do not call this method repeatedly in performance-critical scenarios
The invalid project file.
The resource string for the error message.
Extra arguments for formatting the error message.
This method is used to flag errors in the project file being processed. Do NOT use this method in place of
ErrorUtilities.VerifyThrow(), because ErrorUtilities.VerifyThrow() is used to flag internal/programming errors.
PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
the array of arguments -- do not call this method repeatedly in performance-critical scenarios
The invalid project file.
Any inner exception. May be null.
The resource string for the error message.
Extra arguments for formatting the error message.
This method is used to flag errors in the project file being processed. Do NOT use this method in place of
ErrorUtilities.VerifyThrow(), because ErrorUtilities.VerifyThrow() is used to flag internal/programming errors.
PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
the array of arguments -- do not call this method repeatedly in performance-critical scenarios
The condition to check.
The invalid project file.
The resource string for the error message.
Extra arguments for formatting the error message.
This method is used to flag errors in the project file being processed. Do NOT use this method in place of
ErrorUtilities.VerifyThrow(), because ErrorUtilities.VerifyThrow() is used to flag internal/programming errors.
PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
the array of arguments -- do not call this method repeatedly in performance-critical scenarios
The resource string for the error sub-category (can be null).
The invalid project file.
The resource string for the error message.
Extra arguments for formatting the error message.
This method is used to flag errors in the project file being processed. Do NOT use this method in place of
ErrorUtilities.VerifyThrow(), because ErrorUtilities.VerifyThrow() is used to flag internal/programming errors.
PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
the array of arguments -- do not call this method repeatedly in performance-critical scenarios
The condition to check.
The resource string for the error sub-category (can be null).
The invalid project file.
The resource string for the error message.
Extra arguments for formatting the error message.
This method is used to flag errors in the project file being processed. Do NOT use this method in place of
ErrorUtilities.VerifyThrow(), because ErrorUtilities.VerifyThrow() is used to flag internal/programming errors.
PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
the array of arguments -- do not call this method repeatedly in performance-critical scenarios
The condition to check.
The resource string for the error sub-category (can be null).
The invalid project file.
The inner .
The resource string for the error message.
Extra arguments for formatting the error message.
This class is used to save MSBuild project files. It contains special handling for MSBuild notations that are not saved
correctly by the XML DOM's default save mechanism.
Creates an instance of this class using the specified TextWriter.
Creates an instance of this class using the specified file.
If null, defaults to UTF-8 and omits encoding attribute from processing instruction.
Initializes settings for the project to be saved.
Initializes settings for the project to be saved.
If null, XML declaration is not written.
Writes item vector transforms embedded in the given string without escaping '->' into "->".
Override method in order to omit the xml declaration tag in certain cases. The tag will be written if:
- The tag was present in the file/stream loaded.
- The Encoding is specified and not default (UTF8)
This class contains utility methods for dealing with resources.
Extracts the message code (if any) prefixed to the given string.
MSB\d\d\d\d):\s*(?.*)$"
Arbitrary codes match "^\s*(?[A-Za-z]+\d+):\s*(?.*)$"
]]>
Thread safe.
Whether to match only MSBuild error codes, or any error code.
The string to parse.
[out] The message code, or null if there was no code.
The string without its message code prefix, if any.
Retrieves the MSBuild F1-help keyword for the given resource string. Help keywords are used to index help topics in
host IDEs.
Resource string to get the MSBuild F1-keyword for.
The MSBuild F1-help keyword string.
Retrieves the contents of the named resource string.
Resource string name.
Resource string contents.
Loads the specified string resource and formats it with the arguments passed in. If the string resource has an MSBuild
message code and help keyword associated with it, they too are returned.
PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
the array of arguments -- do not call this method repeatedly in performance-critical scenarios
This method is thread-safe.
[out] The MSBuild message code, or null.
[out] The MSBuild F1-help keyword for the host IDE, or null.
Resource string to load.
Optional arguments for formatting the resource string.
The formatted resource string.
Looks up a string in the resources, and formats it with the arguments passed in. If the string resource has an MSBuild
message code and help keyword associated with it, they are discarded.
PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
the array of arguments -- do not call this method repeatedly in performance-critical scenarios
This method is thread-safe.
Resource string to load.
Optional arguments for formatting the resource string.
The formatted resource string.
Formats the resource string with the given arguments.
Ignores error codes and keywords
Formats the given string using the variable arguments passed in.
PERF WARNING: calling a method that takes a variable number of arguments is expensive, because memory is allocated for
the array of arguments -- do not call this method repeatedly in performance-critical scenarios
Thread safe.
The string to format.
Optional arguments for formatting the given string.
The formatted string.
Verifies that a particular resource string actually exists in the string table. This will only be called in debug
builds. It helps catch situations where a dev calls VerifyThrowXXX with a new resource string, but forgets to add the
resource string to the string table, or misspells it!
This method is thread-safe.
Resource string to check.
This class is used to load types from their assemblies.
Cache to keep track of the assemblyLoadInfos based on a given type filter.
Cache to keep track of the assemblyLoadInfos based on a given type filter for assemblies which are to be loaded for reflectionOnlyLoads.
Type filter for this typeloader
Constructor.
Given two type names, looks for a partial match between them. A partial match is considered valid only if it occurs on
the right side (tail end) of the name strings, and at the start of a class or namespace name.
1) Matches are case-insensitive.
2) .NET conventions regarding namespaces and nested classes are respected, including escaping of reserved characters.
"Csc" and "csc" ==> exact match
"Microsoft.Build.Tasks.Csc" and "Microsoft.Build.Tasks.Csc" ==> exact match
"Microsoft.Build.Tasks.Csc" and "Csc" ==> partial match
"Microsoft.Build.Tasks.Csc" and "Tasks.Csc" ==> partial match
"MyTasks.ATask+NestedTask" and "NestedTask" ==> partial match
"MyTasks.ATask\\+NestedTask" and "NestedTask" ==> partial match
"MyTasks.CscTask" and "Csc" ==> no match
"MyTasks.MyCsc" and "Csc" ==> no match
"MyTasks.ATask\.Csc" and "Csc" ==> no match
"MyTasks.ATask\\\.Csc" and "Csc" ==> no match
true, if the type names match exactly or partially; false, if there is no match at all
Load an assembly given its AssemblyLoadInfo
Loads the specified type if it exists in the given assembly. If the type name is fully qualified, then a match (if
any) is unambiguous; otherwise, if there are multiple types with the same name in different namespaces, the first type
found will be returned.
Loads the specified type if it exists in the given assembly. If the type name is fully qualified, then a match (if
any) is unambiguous; otherwise, if there are multiple types with the same name in different namespaces, the first type
found will be returned.
The loaded type, or null if the type was not found.
Loads the specified type if it exists in the given assembly. If the type name is fully qualified, then a match (if
any) is unambiguous; otherwise, if there are multiple types with the same name in different namespaces, the first type
found will be returned.
Given a type filter and an asssemblyInfo object keep track of what types in a given assembly which match the type filter.
Also, use this information to determine if a given TypeName is in the assembly which is pointed to by the AssemblyLoadInfo object.
This type represents a combination of a type filter and an assemblyInfo object.
Lock to prevent two threads from using this object at the same time.
Since we fill up internal structures with what is in the assembly
Type filter to pick the correct types out of an assembly
Assembly load information so we can load an assembly
What is the type for the given type name, this may be null if the typeName does not map to a type.
List of public types in the assembly which match the type filter and their corresponding types
Have we scanned the public types for this assembly yet.
Assembly, if any, that we loaded for this type.
We use this information to set the LoadedType.LoadedAssembly so that this object can be used
to help created AppDomains to resolve those that it could not load successfully
Given a type filter, and an assembly to load the type information from determine if a given type name is in the assembly or not.
Determine if a given type name is in the assembly or not. Return null if the type is not in the assembly
Scan the assembly pointed to by the assemblyLoadInfo for public types. We will use these public types to do partial name matching on
to find tasks, loggers, and task factories.
Shared Visual Studio related constants
This is the version number of the most recent solution file format
we will read. It will be the version number used in solution files
by the latest version of Visual Studio.
This is the version number of the latest version of Visual Studio.
We use it for the version of the VC PIA we try to load and to find
Visual Studio registry hive that we use to find where vcbuild.exe might be.
Contains the names of the known attributes in the XML project file.
Returns true if and only if the specified attribute is one of the attributes that the engine specifically recognizes
on a task and treats in a special way.
true, if given attribute is a reserved task attribute
Checks if the specified attribute is a reserved task attribute with incorrect casing.
true, if the given attribute is reserved and badly cased
Indicates if the specified attribute cannot be used for batching targets.
true, if a target cannot batch on the given attribute
Returns true if the given string is a valid member of the MSBuildRuntimeValues set
Returns true if the given string is a valid member of the MSBuildArchitectureValues set
Compares two members of MSBuildRuntimeValues, returning true if they count as a match, and false otherwise.
Given two MSBuildRuntime values, returns the concrete result of merging the two. If the merge fails, the merged runtime
string is returned null, and the return value of the method is false. Otherwise, if the merge succeeds, the method returns
true with the merged runtime value. E.g.:
"CLR4" + "CLR2" = null (false)
"CLR2" + "don't care" = "CLR2" (true)
"current runtime" + "CLR4" = "CLR4" (true)
"current runtime" + "don't care" = "CLR4" (true)
If both specify "don't care", then defaults to the current runtime -- CLR4.
A null or empty string is interpreted as "don't care".
Compares two members of MSBuildArchitectureValues, returning true if they count as a match, and false otherwise.
Given an MSBuildRuntime value that may be non-explicit -- e.g. "CurrentRuntime" or "Any" --
return the specific MSBuildRuntime value that it would map to in this case. If it does not map
to any known runtime, just return it as is -- maybe someone else knows what to do with it; if
not, they'll certainly have more context on logging or throwing the error.
Given two MSBuildArchitecture values, returns the concrete result of merging the two. If the merge fails, the merged architecture
string is returned null, and the return value of the method is false. Otherwise, if the merge succeeds, the method returns
true with the merged architecture value. E.g.:
"x86" + "x64" = null (false)
"x86" + "don't care" = "x86" (true)
"current architecture" + "x86" = "x86" (true) on a 32-bit process, and null (false) on a 64-bit process
"current architecture" + "don't care" = "x86" (true) on a 32-bit process, and "x64" (true) on a 64-bit process
A null or empty string is interpreted as "don't care".
If both specify "don't care", then defaults to whatever the current process architecture is.
Returns the MSBuildArchitecture value corresponding to the current process' architecture.
Revisit if we ever run on something other than Intel.
Given an MSBuildArchitecture value that may be non-explicit -- e.g. "CurrentArchitecture" or "Any" --
return the specific MSBuildArchitecture value that it would map to in this case. If it does not map
to any known architecture, just return it as is -- maybe someone else knows what to do with it; if
not, they'll certainly have more context on logging or throwing the error.
Contains the names of the known elements in the XML project file.
This class contains utility methods for XML manipulation.
This method renames an XML element. Well, actually you can't directly
rename an XML element using the DOM, so what you have to do is create
a brand new XML element with the new name, and copy over all the attributes
and children. This method returns the new XML element object.
If the name is the same, does nothing and returns the element passed in.
Can be null if global namespace.
new/renamed element
Verifies that a name is valid for the name of an item, property, or piece of metadata.
If it isn't, throws an ArgumentException indicating the invalid character.
Note that our restrictions are more stringent than the XML Standard's restrictions.
ArgumentException
name to validate
Verifies that a name is valid for the name of an item, property, or piece of metadata.
If it isn't, throws an InvalidProjectException indicating the invalid character.
Note that our restrictions are more stringent than the XML Standard's restrictions.
Verifies that a name is valid for the name of an item, property, or piece of metadata.
If it isn't, throws an InvalidProjectException indicating the invalid character.
Note that our restrictions are more stringent than the XML Standard's restrictions.
Indicates if the given name is valid as the name of an item, property or metadatum.
Note that our restrictions are more stringent than those of the XML Standard.
true, if name is valid
Finds the location of the first invalid character, if any, in the name of an
item, property, or piece of metadata. Returns the location of the first invalid character, or -1 if there are none.
Valid names must match this pattern: [A-Za-z_][A-Za-z_0-9\-.]*
Note, this is a subset of all possible valid XmlElement names: we use a subset because we also
have to match this same set in our regular expressions, and allowing all valid XmlElement name
characters in a regular expression would be impractical.
Note that our restrictions are more stringent than the XML Standard's restrictions.
PERF: This method has to be as fast as possible, as it's called when any item, property, or piece
of metadata is constructed.
Defines methods to support the comparison of objects for
equality over constrained inputs.
Determines whether the specified objects are equal, factoring in the specified bounds when comparing .
Returns a hash code for the specified object factoring in the specified bounds.
A read-only wrapper over an empty collection.
Thus this is an omission from the BCL.
Type of element in the collection
Backing live collection
Private default constructor as this is a singleton
Get the instance
Pass through for underlying collection
Returns true.
Whether collection is synchronized
Sync root
Prohibited on read only collection: throws
Prohibited on read only collection: throws
Pass through for underlying collection
Pass through for underlying collection
Prohibited on read only collection: throws
Get an enumerator over an empty collection
Get an enumerator over an empty collection
ICollection version of CopyTo
Interface allowing items and metadata and properties to go into keyed collections
This can be internal as it is a constraint only on internal collections.
Returns some value useful for a key in a dictionary
The extensions class for ConcurrentQueue<T>
The dequeue method.
The type contained within the queue
The extensions class for ConcurrentStack<T>
The peek method.
The type contained within the stack.
The pop method.
The type contained within the stack.
A simple string interner designed for IPC.
This interner works by providing a way to convert strings to integer IDs. When used as a form of compression,
clients will intern their strings and record the set of IDs returned, then transmit those IDs instead of the
original strings. The interner itself is also transmitted ahead of time, with the IDs, allowing
reconstruction of the original strings. This ensures each string is transmitted exactly once.
Index used for null strings.
Index used for empty strings.
The map used to intern strings for serialization. This map doesn't exist when the strings
are deserialized (it is not needed.)
The list of strings by ID.
Constructor to be used during serialization.
Constructor to be used during deserialization.
Intern cannot be used on this interner if it came from serialization, since we do
not reconstruct the interning dictionary.
Interns the specified string.
The string to intern.
The index representing the string.
Retrieves a string corresponding to the provided index.
The index.
The corresponding string.
The translator, for serialization.
Implementation notes:
This uses an array-based implementation similar to , using a buckets array
to map hash values to the Slots array. Items in the Slots array that hash to the same value
are chained together through the "next" indices.
The capacity is always prime; so during resizing, the capacity is chosen as the next prime
greater than double the last capacity.
The underlying data structures are lazily initialized. Because of the observation that,
in practice, hashtables tend to contain only a few elements, the initial capacity is
set very small (3 elements) unless the ctor with a collection is used.
The +/- 1 modifications in methods that add, check for containment, etc allow us to
distinguish a hash code of 0 from an uninitialized bucket. This saves us from having to
reset each bucket to -1 when resizing. See Contains, for example.
Set methods such as UnionWith, IntersectWith, ExceptWith, and SymmetricExceptWith modify
this set.
Some operations can perform faster if we can assume "other" contains unique elements
according to this equality comparer. The only times this is efficient to check is if
other is a hashset. Note that checking that it's a hashset alone doesn't suffice; we
also have to check that the hashset is using the same equality comparer. If other
has a different equality comparer, it will have unique elements according to its own
equality comparer, but not necessarily according to ours. Therefore, to go these
optimized routes we check that other is a hashset using the same equality comparer.
A HashSet with no elements has the properties of the empty set. (See IsSubset, etc. for
special empty set checks.)
A couple of methods have a special case if other is this (e.g. SymmetricExceptWith).
If we didn't have these checks, we could be iterating over the set and modifying at
the same time.
Implementation Notes:
Since resizes are relatively expensive (require rehashing), this attempts to minimize
the need to resize by setting the initial capacity based on size of collection.
Implementation Notes:
Since resizes are relatively expensive (require rehashing), this attempts to minimize
the need to resize by setting the initial capacity based on size of collection.
Add item to this hashset. This is the explicit implementation of the
interface. The other Add method returns bool indicating whether item was added.
item to add
Remove all items from this set. This clears the elements but not the underlying
buckets and slots array. Follow this call by TrimExcess to release these.
Checks if this hashset contains the item
item to check for containment
true if item contained; false if not
Gets the item if any with the given name
key to check for containment
true if item contained; false if not
Gets the item if any with the given name
key to check for containment
The position of the substring within .
The maximum number of characters in the to lookup.
true if item contained; false if not
Gets the item if any with the given name
item to check for containment
The position of the substring within .
The maximum number of characters in the to lookup.
true if item contained; false if not
Copy items in this hashset to array, starting at arrayIndex
array to add items to
index to start at
Remove entry that compares equal to T
Remove item from this hashset
item to remove
true if removed; false if not (i.e. if the item wasn't in the HashSet)
Number of elements in this hashset
Whether this is readonly
Permanently prevent changes to the set.
Add item to this HashSet.
*** MSBUILD NOTE: Always added - overwrite semantics
Take the union of this HashSet with other. Modifies this set.
Implementation note: GetSuggestedCapacity (to increase capacity in advance avoiding
multiple resizes ended up not being useful in practice; quickly gets to the
point where it's a wasteful check.
enumerable with items to add
Sets the capacity of this list to the size of the list (rounded up to nearest prime),
unless count is 0, in which case we release references.
This method can be used to minimize a list's memory overhead once it is known that no
new elements will be added to the list. To completely clear a list and release all
memory referenced by the list, execute the following statements:
list.Clear();
list.TrimExcess();
Initializes buckets and slots arrays. Uses suggested capacity by finding next prime
greater than or equal to capacity.
Expand to new capacity. New capacity is next prime greater than or equal to suggested
size. This is called when the underlying array is filled. This performs no
defragmentation, allowing faster execution; note that this is reasonable since
AddEvenIfPresent attempts to insert new elements in re-opened spots.
Adds value to HashSet if not contained already
Returns true if added and false if already present
** MSBUILD: Modified so that it DOES add even if present. It will return false in that case, though.**
value to find
Equality comparer against another of this type.
Compares entries by reference - not merely by using the comparer on the key
Copies this to an array. Used for DebugView
Workaround Comparers that throw ArgumentNullException for GetHashCode(null).
hash code
ABOUT:
Helps with operations that rely on bit marking to indicate whether an item in the
collection should be added, removed, visited already, etc.
BitHelper doesn't allocate the array; you must pass in an array or ints allocated on the
stack or heap. ToIntArrayLength() tells you the int array size you must allocate.
USAGE:
Suppose you need to represent a bit array of length (i.e. logical bit array length)
BIT_ARRAY_LENGTH. Then this is the suggested way to instantiate BitHelper:
***************************************************************************
int intArrayLength = BitHelper.ToIntArrayLength(BIT_ARRAY_LENGTH);
BitHelper bitHelper;
if (intArrayLength less than stack alloc threshold)
int* m_arrayPtr = stackalloc int[intArrayLength];
bitHelper = new BitHelper(m_arrayPtr, intArrayLength);
else
int[] m_arrayPtr = new int[intArrayLength];
bitHelper = new BitHelper(m_arrayPtr, intArrayLength);
***************************************************************************
IMPORTANT:
The second ctor args, length, should be specified as the length of the int array, not
the logical bit array. Because length is used for bounds checking into the int array,
it's especially important to get this correct for the stackalloc version. See the code
samples above; this is the value gotten from ToIntArrayLength().
The length ctor argument is the only exception; for other methods -- MarkBit and
IsMarked -- pass in values as indices into the logical bit array, and it will be mapped
to the position within the array of ints.
FUTURE OPTIMIZATIONS:
A method such as FindFirstMarked/Unmarked Bit would be useful for callers that operate
on a bit array and then need to loop over it. In particular, if it avoided visiting
every bit, it would allow good perf improvements when the bit array is sparse.
Instantiates a BitHelper with a heap alloc'd array of ints
int array to hold bits
length of int array
Instantiates a BitHelper with a heap alloc'd array of ints
int array to hold bits
length of int array
Mark bit at specified position
Is bit at specified position marked?
How many ints must be allocated to represent n bits. Returns (n+31)/32, but
avoids overflow
Debug view for HashSet
Duplicated because internal to mscorlib
Enumerable that uses a provided Converter delegate to
convert each item from a backing enumerator as it is returned.
Type of underlying enumerator
Type returned
Enumerable behind this one
Converter delegate used on each item in the backing enumerable as it is returned
Constructor
Gets the converting enumerator
IEnumerable version of GetEnumerator
Enumerable that uses a provided Converter delegate to
convert each item from a backing enumerator as it is returned.
Type of underlying enumerator
Type returned
Enumerator behind this one
Converter delegate used on each item in the backing enumerator as it is returned
Constructor
Get the current element, converted
Get the current element, converted
Move to the next element
Reset the enumerator
Dispose of the enumerator
A class which implements IEnumerable by creating an optionally-deep copy of the backing collection.
If the type contained in the collection implements IDeepCloneable then the copies will be deep clones instead
of mere reference copies.
is thread safe for concurrent access.
The type contained in the backing collection.
The backing collection.
The object used to synchronize access for copying.
Constructor.
The collection which serves as a source for enumeration.
The object used to synchronize access for copying.
Returns an enumerator over the collection.
The enumerator.
Returns an numerator over the collection.
The enumerator.
A dictionary that has copy-on-write semantics.
KEYS AND VALUES MUST BE IMMUTABLE OR COPY-ON-WRITE FOR THIS TO WORK.
The value type.
Thread safety: for all users, this class is as thread safe as the underlying Dictionary implementation, that is,
safe for concurrent readers or one writer from EACH user. It achieves this by locking itself and cloning before
any write, if it is being shared - i.e., stopping sharing before any writes occur.
This class must be serializable as it is used for metadata passed to tasks, which may
be run in a separate appdomain.
Empty dictionary with a ,
used as the basis of new dictionaries with that comparer to avoid
allocating new comparers objects.
Empty dictionary with ,
used as the basis of new dictionaries with that comparer to avoid
allocating new comparers objects.
The backing dictionary.
Lazily created.
Constructor. Consider supplying a comparer instead.
Constructor taking an initial capacity
Constructor taking a specified comparer for the keys
Constructor taking a specified comparer for the keys and an initial capacity
Serialization constructor, for crossing appdomain boundaries
Cloning constructor. Defers the actual clone.
Returns the collection of keys in the dictionary.
Returns the collection of values in the dictionary.
Returns the number of items in the collection.
Returns true if the collection is read-only.
IDictionary implementation
IDictionary implementation
IDictionary implementation
IDictionary implementation
IDictionary implementation
IDictionary implementation
IDictionary implementation
Comparer used for keys
Accesses the value for the specified key.
IDictionary implementation
Adds a value to the dictionary.
Adds several value to the dictionary.
Returns true if the dictionary contains the specified key.
Removes the entry for the specified key from the dictionary.
Attempts to find the value for the specified key in the dictionary.
Adds an item to the collection.
Clears the collection.
Returns true ff the collection contains the specified item.
Copies all of the elements of the collection to the specified array.
Remove an item from the dictionary.
Implementation of generic IEnumerable.GetEnumerator()
Implementation of IEnumerable.GetEnumerator()
IDictionary implementation.
IDictionary implementation.
IDictionary implementation.
IDictionary implementation.
IDictionary implementation.
IDictionary implementation.
Clone, with the actual clone deferred
Returns true if these dictionaries have the same backing.
A dictionary of unordered property or metadata name/value pairs, with copy-on-write semantics.
The copy-on-write semantics are only possible if the contained type is immutable, which currently
means it can only be used for ProjectMetadataInstance's.
USE THIS DICTIONARY ONLY FOR IMMUTABLE TYPES. OTHERWISE USE PROPERTYDICTIONARY.
The value that this adds over IDictionary<string, T> is:
- enforces that key = T.Name
- default enumerator is over values
- (marginal) enforces the correct key comparer
- potentially makes copy on write possible
Really a Dictionary<string, T> where the key (the name) is obtained from IKeyed.Key.
Is not observable, so if clients wish to observe modifications they must mediate them themselves and
either not expose this collection or expose it through a readonly wrapper.
At various places in this class locks are taken on the backing collection. The reason for this is to allow
this class to be asynchronously enumerated. This is accomplished by the CopyOnReadEnumerable which will
lock the backing collection when it does its deep cloning. This prevents asynchronous access from corrupting
the state of the enumeration until the collection has been fully copied.
The use of a CopyOnWriteDictionary does not reduce the concurrency of this collection, because CopyOnWriteDictionary
offers the same concurrency guarantees (concurrent readers OR single writer) for EACH user of the dictionary.
Since we use the mutable ignore case comparer we need to make sure that we lock our self before we call the comparer since the comparer can call back
into this dictionary which could cause a deadlock if another thread is also accessing another method in the dictionary.
Property or Metadata class type to store
Backing dictionary
Creates empty dictionary
Creates empty dictionary with specified initial capacity
Cloning constructor, with deferred cloning semantics
Accessor for the list of property names
Accessor for the list of properties
Returns the number of properties in the collection
Whether the collection is read-only.
Returns the number of property in the collection.
Retrieves a collection containing the names of all the properties present in the dictionary.
Get the property with the specified name, or null if none exists.
Sets the property with the specified name, overwriting it if already exists.
Unlike Dictionary<K,V>[K], the getter returns null instead of throwing if the key does not exist.
This better matches the semantics of property, which are considered to have a blank value if they
are not defined.
Get the property with the specified name, or null if none exists.
Sets the property with the specified name, overwriting it if already exists.
Unlike Dictionary<K,V>[K], the getter returns null instead of throwing if the key does not exist.
This better matches the semantics of property, which are considered to have a blank value if they
are not defined.
Returns an enumerable which clones the properties
Returns a cloning enumerable.
Returns true if a property with the specified name is present in the collection,
otherwise false.
Empties the collection
Gets an enumerator over all the properties in the collection
Enumeration is in undefined order
Get an enumerator over entries
Compares two property dictionaries for equivalence. They are equal if each contains the same properties with the
same values as the other, unequal otherwise.
The dictionary to which this should be compared
True if they are equivalent, false otherwise.
Adds a property
Returns true if the dictionary contains the key
Removes a property
Attempts to retrieve the a property.
Adds a property
Clears the property collection
Checks for a property in the collection
Not implemented
Removes a property from the collection
Get an enumerator over the entries.
Removes any property with the specified name.
Returns true if the property was in the collection, otherwise false.
Removes any property with the specified name.
Returns true if the property was in the collection, otherwise false.
Add the specified property to the collection.
Overwrites any property with the same name already in the collection.
To remove a property, use Remove(...) instead.
Adds the specified properties to this dictionary.
An enumerator over the properties to add.
Removes the specified properties from this dictionary
An enumerator over the properties to remove.
Helper to convert into a read-only dictionary of string, string.
Clone. As we're copy on write, this
should be cheap.
An interface representing an item which can clone itself.
The type returned by the clone operation.
Creates a clone of the item where no data references are shared. Changes made to the clone
do not affect the original item.
The cloned item.
This is a custom string comparer that has three advantages over the regular
string comparer:
1) It can generate hash codes and perform equivalence operations on parts of a string rather than a whole
2) It uses "unsafe" pointers to maximize performance of those operations
3) It takes advantage of limitations on MSBuild Property/Item names to cheaply do case insensitive comparison.
The processor architecture on which we are running, but default it will be x86
We need a static constructor to retrieve the running ProcessorArchitecture that way we can
avoid using optimized code that will not run correctly on IA64 due to alignment issues
The default immutable comparer instance.
Performs the "Equals" operation on two MSBuild property, item or metadata names
Getting a case insensitive hash code for the msbuild property, item or metadata name
Tools for working with Hashtables.
Compares the given hashtables.
May be null
May be null
-1, if first hashtable is "less than" the second one
0, if hashtables have identical keys and equivalent (case-insensitive) values
+1, if first hashtable is "greater than" the second one
Collection of items that allows a list of all items of a specified type to be
retrieved in O(1), and specific items to be added, removed, or checked for in O(1).
All items of a particular type can also be removed in O(1).
Items are ordered with respect to all other items of their type.
Really a Dictionary<string, ICollection<T>> where the key (the item type) is obtained from IKeyed.Key
Is not observable, so if clients wish to observe modifications they must mediate them themselves and
either not expose this collection or expose it through a readonly wrapper.
At various places in this class locks are taken on the backing collection. The reason for this is to allow
this class to be asynchronously enumerated. This is accomplished by the CopyOnReadEnumerable which will
lock the backing collection when it does its deep cloning. This prevents asynchronous access from corrupting
the state of the enumeration until the collection has been fully copied.
Item class type to store
Dictionary of item lists used as a backing store.
An empty list should never be stored in here unless it is an empty marker.
See AddEmptyMarker.
This collection provides quick access to the ordered set of items of a particular type.
Dictionary of items in the collection, to speed up Contains,
Remove, and Replace. For those operations, we look up here,
then modify the other dictionary to match.
Constructor for an empty collection.
Constructor for an empty collection taking an initial capacity
for the number of distinct item types
Constructor for an collection holding items from a specified enumerable.
Number of items in total, for debugging purposes.
Get the item types that have at least one item in this collection
KeyCollection<K> is already a read only collection, so no protection
is necessary.
Returns the item list for a particular item type,
creating and adding a new item list if necessary.
Does not throw if there are no items of this type.
This is a read-only list.
If the result is not empty it is a live list.
Use AddItem or RemoveItem to modify items in this project.
Using the return value from this in a multithreaded situation is unsafe.
Empty the collection
Returns an enumerable which copies the underlying data on read.
Gets an enumerator over the items in the collection
Get an enumerator over entries
Enumerates item lists per each item type under the lock.
A delegate that accepts the item type string and a list of items of that type.
Will be called for each item type in the list.
Returns all of the items for the specified type.
If there are no items of this type, returns an empty list.
Using the return from this method in a multithreaded scenario is unsafe.
The item type to return
The list of matching items.
Whether the provided item is in this table or not.
Add a new item to the collection, at the
end of the list of other items with its key.
Removes an item, if it is in the collection.
Returns true if it was found, otherwise false.
If a list is emptied, removes the list from the enclosing collection
so it can be garbage collected.
Replaces an exsting item with a new item. This is necessary to preserve the original ordering semantics of Lookup.GetItems
when items with metadata modifications are being returned. See Dev10 bug 480737.
If the item is not found, does nothing.
The item to be replaced.
The replacement item.
Add the set of items specified to this dictionary
An enumerator over the items to remove.
Add the set of items specified, all sharing an item type, to this dictionary.
This is a little faster than ImportItems where all the items have the same item type.
Remove the set of items specified from this dictionary
An enumerator over the items to remove.
Special method used for batching buckets.
Adds an explicit marker indicating there are no items for the specified item type.
In the general case, this is redundant, but batching buckets use this to indicate that they are
batching over the item type, but their bucket does not contain items of that type.
See HasEmptyMarker.
Special method used for batching buckets.
Lookup can call this to see whether there was an explicit marker placed indicating that
there are no items of this type. See comment on AddEmptyMarker.
Custom enumerator that allows enumeration over all the items in the collection
as though they were in a single list.
All items of a type are returned consecutively in their correct order.
However the order in which item types are returned is not defined.
Enumerator over lists
Enumerator over items in the current list
Constructs an item enumerator over a list enumerator
Finalizer
Get the current item
Undefined if enumerator is before or after collection: we return null.
Implementation of IEnumerator.Current, which unlike IEnumerator>T<.Current throws
if there is no current object
Move to the next object if any,
otherwise returns false
Reset the enumerator
IDisposable implementation.
The real disposer.
Get an item enumerator over the next list with items in it
Interface indicating a type is immutable, to constrain generic types.
This can be internal as it is a constraint only on internal collections.
A dictionary that can hold more than one distinct value with the same key.
All keys must have at least one value: null values are currently rejected.
Order of values for a key is not defined but is currently the order of add.
A variation could store the values in a HashSet, for different tradeoffs.
Type of key
Type of value
Backing dictionary
Number of values over all keys
Constructor taking a specified comparer for the keys
Number of keys
Number of values over all keys
return keys in the dictionary
Enumerator over values that have the specified key.
Add a single value under the specified key.
Value may not be null.
Removes an entry with the specified key and value.
Returns true if found, false otherwise.
Empty the collection
List capable of holding 0-n items.
Uses less memory than List for less than 2 items.
Type of the value
Entry - either a TT or a list of TT.
Constructor taking the initial object
Number of entries in this multivalue.
Enumerable over the values.
Enumerable over the values.
Add a value.
Does not verify the value is not already present.
Remove a value.
Returns true if the value existed, otherwise false.
Interface allowing values of things to be gotten.
This can be internal as it is a constraint only on internal collections.
Returns some value of a thing
A dictionary of unordered property or metadata name/value pairs.
The value that this adds over IDictionary<string, T> is:
- enforces that key = T.Name
- default enumerator is over values
- (marginal) enforces the correct key comparer
- potentially makes copy on write possible
Really a Dictionary<string, T> where the key (the name) is obtained from IKeyed.Key.
Is not observable, so if clients wish to observe modifications they must mediate them themselves and
either not expose this collection or expose it through a readonly wrapper.
At various places in this class locks are taken on the backing collection. The reason for this is to allow
this class to be asynchronously enumerated. This is accomplished by the CopyOnReadEnumerable which will
lock the backing collection when it does its deep cloning. This prevents asynchronous access from corrupting
the state of the enumeration until the collection has been fully copied.
Since we use the mutable ignore case comparer we need to make sure that we lock our self before we call the comparer since the comparer can call back
into this dictionary which could cause a deadlock if another thread is also accessing another method in the dictionary.
Property or Metadata class type to store
Backing dictionary
Creates empty dictionary
Creates empty dictionary, optionally specifying initial capacity
Create a new dictionary from an enumerator
Creates empty dictionary, specifying a comparer
Create a new dictionary from an enumerator
Accessor for the list of property names
Accessor for the list of properties
Returns the number of properties in the collection
Whether the collection is read-only.
Returns the number of property in the collection.
Get the property with the specified name, or null if none exists.
Sets the property with the specified name, overwriting it if already exists.
Unlike Dictionary<K,V>[K], the getter returns null instead of throwing if the key does not exist.
This better matches the semantics of property, which are considered to have a blank value if they
are not defined.
Get the property with the specified name, or null if none exists.
Sets the property with the specified name, overwriting it if already exists.
Unlike Dictionary<K,V>[K], the getter returns null instead of throwing if the key does not exist.
This better matches the semantics of property, which are considered to have a blank value if they
are not defined.
Returns an enumerable which clones the properties
Returns a cloning enumerable.
Returns true if a property with the specified name is present in the collection,
otherwise false.
Empties the collection
Gets an enumerator over all the properties in the collection
Enumeration is in undefined order
Get an enumerator over entries
Compares two property dictionaries for equivalence. They are equal if each contains the same properties with the
same values as the other, unequal otherwise.
The dictionary to which this should be compared
True if they are equivalent, false otherwise.
Get the property with the specified name or null if it is not present
Get the property with the specified name or null if it is not present.
Name is the segment of the provided string with the provided start and end indexes.
Adds a property
Returns true if the dictionary contains the key
Removes a property
Attempts to retrieve the a property.
Adds a property
Clears the property collection
Checks for a property in the collection
Not implemented
Removes a property from the collection
Get an enumerator over the entries.
Removes any property with the specified name.
Returns true if the property was in the collection, otherwise false.
Add the specified property to the collection.
Overwrites any property with the same name already in the collection.
To remove a property, use Remove(...) instead.
Adds the specified properties to this dictionary.
An enumerator over the properties to add.
Removes the specified properties from this dictionary
An enumerator over the properties to remove.
Helper to convert into a read-only dictionary of string, string.
TODO: for performance, consider switching to returning IDictionary
and returning ArrayDictionary if lookup of results is not needed.
A read-only live wrapper over a collection.
It does not prevent modification of the values themselves.
There is a type with the same name in the BCL, but it is actually a ReadOnlyList and does not accept an ICollection>T<.
Thus this is an omission from the BCL.
Type of element in the collection
Backing live enumerable.
May be a collection.
Construct a read only wrapper around the current contents
of the IEnumerable, or around the backing collection if the
IEnumerable is in fact a collection.
Return the number of items in the backing collection
Returns true.
Whether collection is synchronized
Sync root
Get a backing ICollection.
Prohibited on read only collection: throws
Prohibited on read only collection: throws
Pass through for underlying collection
Pass through for underlying collection
Prohibited on read only collection: throws
Pass through for underlying collection
NOTE: This does NOT cause a copy into a List, since the
backing enumerable suffices.
Pass through for underlying collection
NOTE: This does NOT cause a copy into a List, since the
backing enumerable suffices.
ICollection version of CopyTo
Implementation of a dictionary which acts as a read-only wrapper on another dictionary, but
converts values as they are accessed to another type.
The backing dictionary's key type.
The backing dictionary's value type.
The desired value type.
The backing dictionary.
The delegate used to convert values.
Constructor.
Returns the collection of keys in the dictionary.
Returns the collection of values in the dictionary.
Returns the number of items in the collection.
Returns true if the collection is read-only.
Accesses the value for the specified key.
Adds a value to the dictionary.
Returns true if the dictionary contains the specified key.
Removes the entry for the specified key from the dictionary.
Attempts to find the value for the specified key in the dictionary.
Adds an item to the collection.
Clears the collection.
Returns true ff the collection contains the specified item.
Copies all of the elements of the collection to the specified array.
Remove an item from the dictionary.
Implementation of generic IEnumerable.GetEnumerator()
Implementation of IEnumerable.GetEnumerator()
Delegate used by ConvertingEnumerable
Dictionary that does not prevent values from being garbage collected.
Type of key
Type of value, without the WeakReference wrapper.
The dictionary used internally to store the keys and values.
Improvised capacity. See comment in item setter.
Constructor for a collection using the default key comparer
Constructor taking a specified comparer for the keys
Count of entries.
Some entries may represent keys or values that have already been garbage collected.
To clean these out call .
Return keys
Obtains the value for a given key.
If we find the entry but its value's target is null, we take the opportunity
to remove the entry, as if the GC had done it.
Whether there is a key present with the specified key
As usual, don't just call Contained as the wrapped value may be null.
Attempts to get the value for the provided key.
Returns true if the key is found, otherwise false.
If we find the entry but its value's target is null, we take the opportunity
to remove the entry, as if the GC had done it.
Removes an entry with the specified key.
Returns true if found, false otherwise.
Remove any entries from the dictionary that represent keys
that have been garbage collected.
The number of entries removed.
Empty the collection
Lightweight, read-only IDictionary implementation using two arrays
and O(n) lookup.
Requires specifying capacity at construction and does not
support reallocation to increase capacity.
Type of keys
Type of values
A special singleton enumerable that enumerates a read-only empty dictionary
Key
Value
The single instance
The single instance
Private default constructor as this is a singleton
Get the instance
Empty returns zero
Returns true
Gets empty collection
Gets empty collection
Is it fixed size
Not synchronized
No sync root
Keys
Values
Indexer
Get returns null as read-only
Set is prohibited and throws.
Pass through for underlying collection
Empty returns false
Prohibited on read only collection: throws
Empty returns false
Prohibited on read only collection: throws
Prohibited on read only collection: throws
Empty returns false
Empty does nothing
Prohibited on read only collection: throws
Get empty enumerator
Get empty enumerator
Add
Contains
Enumerator
Remove
CopyTo
Given a string of semi-colon delimited name=value pairs, this method parses it and creates
a hash table containing the property names as keys and the property values as values.
true on success, false on failure.
Given a string of semi-colon delimited name=value pairs, this method parses it and creates
a hash table containing the property names as keys and the property values as values.
This method escapes any special characters found in the property values, in case they
are going to be passed to a method (such as that expects the appropriate escaping to have happened
already.
true on success, false on failure.
A very simple class that holds two strings, a property name and property value.
Property name
Property value fragments. Join with semicolon to get the final value.
TaskHostConfiguration contains information needed for the task host to
configure itself for to execute a particular task.
The node id (of the parent node, to make the logging work out)
The startup directory
The process environment.
The culture
The UI culture.
The AppDomainSetup that we may want to use on AppDomainIsolated tasks.
Line number where the instance of this task is defined.
Column number where the instance of this task is defined.
Project file where the instance of this task is defined.
ContinueOnError flag for this particular task.
Name of the task to be executed on the task host.
Location of the assembly containing the task to be executed.
The set of parameters to apply to the task prior to execution.
Constructor
The ID of the node being configured.
The startup directory for the task being executed.
The set of environment variables to apply to the task execution process.
The culture of the thread that will execute the task.
The UI culture of the thread that will execute the task.
The AppDomainSetup that may be used to pass information to an AppDomainIsolated task.
The line number of the location from which this task was invoked.
The column number of the location from which this task was invoked.
The project file from which this task was invoked.
Flag to continue with the build after a the task failed
Name of the task.
Location of the assembly the task is to be loaded from.
Parameters to apply to the task.
global properties for the current project.
Warning codes to be treated as errors for the current project.
Warning codes to be treated as messages for the current project.
Constructor for deserialization.
The node id
The startup directory
The process environment.
The culture
The UI culture.
The AppDomain configuration bytes that we may want to use to initialize
AppDomainIsolated tasks.
Line number where the instance of this task is defined.
Column number where the instance of this task is defined.
ContinueOnError flag for this particular task
Project file where the instance of this task is defined.
Name of the task to execute.
Path to the assembly to load the task from.
Parameters to set on the instantiated task prior to execution.
Gets the global properties for the current project.
The NodePacketType of this NodePacket
Translates the packet to/from binary form.
The translator to use.
Factory for deserialization.
TaskHostTaskCancelled informs the task host that the task it is
currently executing has been canceled.
Constructor
The type of this NodePacket
Translates the packet to/from binary form.
The translator to use.
Factory for deserialization.
How the task completed -- successful, failed, or crashed
Task execution succeeded
Task execution failed
Task crashed during initialization steps -- loading the task,
validating or setting the parameters, etc.
Task crashed while being executed
Task crashed after being executed
-- Getting outputs, etc
TaskHostTaskComplete contains all the information the parent node
needs from the task host on completion of task execution.
Result of the task's execution.
If the task threw an exception during its initialization or execution,
save it here.
If there's an additional message that should be attached to the error
logged beyond "task X failed unexpectedly", save it here. May be null.
If the message saved in taskExceptionMessage requires arguments, save
them here. May be null.
The set of parameters / values from the task after it finishes execution.
The process environment at the end of task execution.
Constructor
Result of the task's execution.
The build process environment as it was at the end of the task's execution.
For deserialization.
Result of the task's execution.
If the task threw an exception during its initialization or execution,
save it here.
If there's an additional message that should be attached to the error
logged beyond "task X failed unexpectedly", put it here. May be null.
If there are arguments that need to be formatted into the message being
sent, set them here. May be null.
Task parameters and their values after the task has finished.
The process environment.
The type of this packet.
Translates the packet to/from binary form.
The translator to use.
Factory for deserialization.
Used to receive link status updates from an endpoint.
The endpoint invoking the delegate.
The current status of the link.
Used to receive data from a node
The endpoint invoking the delegate.
The packet received.
The connection status of a link between the NodeEndpoint on the host and the NodeEndpoint
on the peer.
The connection has never been started.
The connection is active, the most recent data has been successfully sent, and the
node is responding to pings.
The connection has failed and been terminated.
The connection could not be made/timed out.
This interface represents one end of a connection between the INodeProvider and a Node.
Implementations of this interface define the actual mechanism by which data is communicated.
Raised when the status of the node's link has changed.
The current link status for this endpoint.
Waits for the remote node to establish a connection.
The factory used to deserialize packets.
Only one of Listen() or Connect() may be called on an endpoint.
Instructs the node to connect to its peer endpoint.
The factory used to deserialize packets.
Instructs the node to disconnect from its peer endpoint.
Sends a data packet to the node.
The packet to be sent.
This is an implementation of INodeEndpoint for the out-of-proc nodes. It acts only as a client.
The amount of time to wait for the client to connect to the host.
The size of the buffers to use for named pipes
Flag indicating if we should debug communications or not.
The current communication status of the node.
The pipe client used by the nodes.
Object used as a lock source for the async data
Set when a packet is available in the packet queue
Set when the asynchronous packet pump should terminate
The thread which runs the asynchronous packet pump
The factory used to create and route packets.
The asynchronous packet queue.
Operations on this queue must be synchronized since it is accessible by multiple threads.
Use a lock on the packetQueue itself.
Per-node shared read buffer.
A way to cache a byte array when writing out packets
A binary writer to help write into
Raised when the link status has changed.
Returns the link status of this node.
Causes this endpoint to wait for the remote endpoint to connect
The factory used to create packets.
Causes this node to connect to the matched endpoint.
The factory used to create packets.
Shuts down the link
Sends data to the peer endpoint.
The packet to send.
Instantiates an endpoint to act as a client
The name of the pipe to which we should connect.
Returns the host handshake for this node endpoint
Updates the current link status if it has changed and notifies any registered delegates.
The status the node should now be in.
Invokes the OnLinkStatusChanged event in a thread-safe manner.
The new status of the endpoint link.
This does the actual work of changing the status and shutting down any threads we may have for
disconnection.
Adds a packet to the packet queue when asynchronous mode is enabled.
The packet to be transmitted.
Initializes the packet pump thread and the supporting events as well as the packet queue.
This method handles the asynchronous message pump. It waits for messages to show up on the queue
and calls FireDataAvailable for each such packet. It will terminate when the terminate event is
set.
Enumeration of all of the packet types used for communication.
Notifies the Node to set a configuration for a particular build. This is sent before
any BuildRequests are made and will not be sent again for a particular build. This instructs
the node to prepare to receive build requests.
Contains:
Build ID
Environment variables
Logging Services Configuration
Node ID
Default Global Properties
Toolset Definition Locations
Startup Directory
UI Culture Information
App Domain Configuration XML
A BuildRequestConfiguration object.
When sent TO a node, this informs the node of a build configuration.
When sent FROM a node, this requests a BuildRequestConfigurationResponse to map the configuration to the
appropriate global configuration ID.
Contents:
Configuration ID
Project Filename
Project Properties
Project Tools Version
A response to a request to map a build configuration
Contents:
Node Configuration ID
Global Configuration ID
Information about a project that has been loaded by a node.
Contents:
Global Configuration ID
Initial Targets
Default Targets
Packet used to inform the scheduler that a node's active build request is blocked.
Contents:
Build Request ID
Active Targets
Blocked Target, if any
Child Requests, if any
Packet used to unblocked a blocked request on a node.
Contents:
Build Request ID
Build Results for child requests, if any.
A BuildRequest object
Contents:
Build Request ID
Configuration ID
Project Instance ID
Targets
A BuildResult object
Contents:
Build ID
Project Instance ID
Targets
Outputs (per Target)
Results (per Target)
A logging message.
Contents:
Build Event Type
Build Event Args
Informs the node that the build is complete.
Contents:
Prepare For Reuse
Reported by the node (or node provider) when a node has terminated. This is the final packet that will be received
from a node.
Contents:
Reason
Notifies the task host to set the task-specific configuration for a particular task execution.
This is sent in place of NodeConfiguration and gives the task host all the information it needs
to set itself up and execute the task that matches this particular configuration.
Contains:
Node ID (of parent MSBuild node, to make the logging work out)
Startup directory
Environment variables
UI Culture information
App Domain Configuration XML
Task name
Task assembly location
Parameter names and values to set to the task prior to execution
Informs the parent node that the task host has finished executing a
particular task. Does not need to contain identifying information
about the task, because the task host will only ever be connected to
one parent node at a a time, and will only ever be executing one task
for that node at any one time.
Contents:
Task result (success / failure)
Resultant parameter values (for output gathering)
Message sent from the node to its paired task host when a task that
supports ICancellableTask is cancelled.
Contents:
(nothing)
Message sent from a node when it needs to have an SDK resolved.
Message sent back to a node when an SDK has been resolved.
Message sent from a node when a task is requesting or returning resources from the scheduler.
Message sent back to a node informing it about the resource that were granted by the scheduler.
This interface represents a packet which may be transmitted using an INodeEndpoint.
Implementations define the serialized form of the data.
The type of the packet. Used to reconstitute the packet using the correct factory.
A delegate representing factory methods used to re-create packets deserialized from a stream.
The translator containing the packet data.
The packet reconstructed from the stream.
This interface represents an object which is used to reconstruct packet objects from
binary data.
Registers the specified handler for a particular packet type.
The packet type.
The factory for packets of the specified type.
The handler to be called when packets of the specified type are received.
Unregisters a packet handler.
The packet type.
Takes a serializer, deserializes the packet and routes it to the appropriate handler.
The node from which the packet was received.
The packet type.
The translator containing the data from which the packet should be reconstructed.
Routes the specified packet
The node from which the packet was received.
The packet to route.
Objects which wish to receive packets from the NodePacketRouter must implement this interface.
This method is invoked by the NodePacketRouter when a packet is received and is intended for
this recipient.
The node from which the packet was received.
The packet.
An interface representing an object which may be serialized by the node packet serializer.
Reads or writes the packet to the serializer.
This delegate is used for objects which do not have public parameterless constructors and must be constructed using
another method. When invoked, this delegate should return a new object which has been translated appropriately.
The type to be translated.
Delegate for users that want to translate an arbitrary structure that doesn't implement (e.g. translating a complex collection)
the translator
the object to translate
This delegate is used to create arbitrary collection types for serialization.
The type of dictionary to be created.
The serialization mode.
Indicates the serializer is operating in write mode.
Indicates the serializer is operating in read mode.
This interface represents an object which aids objects in serializing and
deserializing INodePackets.
The reason we bother with a custom serialization mechanism at all is two fold:
1. The .Net serialization mechanism is inefficient, even if you implement ISerializable
with your own custom mechanism. This is because the serializer uses a bag called
SerializationInfo into which you are expected to drop all your data. This adds
an unnecessary level of indirection to the serialization routines and prevents direct,
efficient access to the byte-stream.
2. You have to implement both a reader and writer part, which introduces the potential for
error should the classes be later modified. If the reader and writer methods are not
kept in perfect sync, serialization errors will occur. Our custom serializer eliminates
that by ensuring a single Translate method on a given object can handle both reads and
writes without referencing any field more than once.
Returns the current serialization mode.
Returns the binary reader.
This should ONLY be used when absolutely necessary for translation. It is generally unnecessary for the
translating object to know the direction of translation. Use one of the Translate methods instead.
Returns the binary writer.
This should ONLY be used when absolutely necessary for translation. It is generally unnecessary for the
translating object to know the direction of translation. Use one of the Translate methods instead.
Translates a boolean.
The value to be translated.
Translates a byte.
The value to be translated.
Translates a short.
The value to be translated.
Translates a unsigned short.
The value to be translated.
Translates an integer.
The value to be translated.
Translates a long.
The value to be translated.
Translates a string.
The value to be translated.
Translates a double.
The value to be translated.
Translates a string array.
The array to be translated.
Translates a list of strings
The list to be translated.
Translates a set of strings
The set to be translated.
Translates a list of T using an
The list to be translated.
The translator to use for the items in the list
A TaskItemType
Translates a list of T using an anda collection factory
The list to be translated.
The translator to use for the items in the list
An ITranslatable subtype
An IList subtype
factory to create a collection
Translates a collection of T into the specified type using an and
The collection to be translated.
The translator to use for the values in the collection.
The factory to create the ICollection.
The type contained in the collection.
The type of collection to be created.
Translates a DateTime.
The value to be translated.
Translates a TimeSpan.
The value to be translated.
Translates a BuildEventContext
This method exists only because there is no serialization method built into the BuildEventContext
class, and it lives in Framework and we don't want to add a public method to it.
The context to be translated.
Translates an enumeration.
The enumeration type.
The enumeration instance to be translated.
The enumeration value as an integer.
This is a bit ugly, but it doesn't seem like a nice method signature is possible because
you can't pass the enum type as a reference and constrain the generic parameter to Enum. Nor
can you simply pass as ref Enum, because an enum instance doesn't match that function signature.
Finally, converting the enum to an int assumes that we always want to transport enums as ints. This
works in all of our current cases, but certainly isn't perfectly generic.
Translates a value using the .Net binary formatter.
The reference type.
The value to be translated.
The primary purpose of this method is to support serialization of Exceptions and
custom build logging events, since these do not support our custom serialization
methods.
Translates an object implementing INodePacketTranslatable.
The reference type.
The value to be translated.
Translates a culture
The culture
Translates a byte array
The array to be translated.
Translates a byte array
The array to be translated.
The length of array which will be used in translation
Translates an array of objects implementing INodePacketTranslatable.
The reference type.
The array to be translated.
Translates an array of objects using an .
The reference type.
The array to be translated.
The translator to use for the elements in the array.
Translates a dictionary of { string, string }.
The dictionary to be translated.
The comparer used to instantiate the dictionary.
Translates a dictionary of { string, T }.
The reference type for the values, which implements INodePacketTranslatable.
The dictionary to be translated.
The comparer used to instantiate the dictionary.
The translator to use for the values in the dictionary
Translates a dictionary of { string, T } for dictionaries with public parameterless constructors.
The reference type for the dictionary.
The reference type for values in the dictionary.
The dictionary to be translated.
The translator to use for the values in the dictionary.
Translates a dictionary of { string, T } for dictionaries with public parameterless constructors.
The reference type for the dictionary.
The reference type for values in the dictionary.
The dictionary to be translated.
The translator to use for the values in the dictionary
A factory used to create the dictionary.
Translates the boolean that says whether this value is null or not
The object to test.
The type of object to test.
True if the object should be written, false otherwise.
This class is responsible for serializing and deserializing simple types to and
from the byte streams used to communicate INodePacket-implementing classes.
Each class implements a Translate method on INodePacket which takes this class
as a parameter, and uses it to store and retrieve fields to the stream.
Returns a read-only serializer.
The serializer.
Returns a write-only serializer.
The stream containing data to serialize.
The serializer.
Implementation of ITranslator for reading from a stream.
The stream used as a source or destination for data.
The binary reader used in read mode.
Constructs a serializer from the specified stream, operating in the designated mode.
Gets the reader, if any.
Gets the writer, if any.
Returns the current serialization mode.
Translates a boolean.
The value to be translated.
Translates a byte.
The value to be translated.
Translates a short.
The value to be translated.
Translates an unsigned short.
The value to be translated.
Translates an integer.
The value to be translated.
Translates a long.
The value to be translated.
Translates a double.
The value to be translated.
Translates a string.
The value to be translated.
Translates a byte array
The array to be translated
Translates a byte array
The array to be translated.
The length of array which will be used in translation. This parameter is not used when reading
Translates a string array.
The array to be translated.
Translates a list of strings
The list to be translated.
Translates a list of T using an
The list to be translated.
The translator to use for the items in the list
TaskItem type
Translates a collection of T into the specified type using an and
The collection to be translated.
The translator to use for the values in the collection.
The factory to create the ICollection.
The type contained in the collection.
The type of collection to be created.
Translates a DateTime.
The value to be translated.
Translates a TimeSpan.
The value to be translated.
Translates a BuildEventContext
This method exists only because there is no serialization method built into the BuildEventContext
class, and it lives in Framework and we don't want to add a public method to it.
The context to be translated.
Translates a CultureInfo
The CultureInfo to translate
Translates an enumeration.
The enumeration type.
The enumeration instance to be translated.
The enumeration value as an integer.
This is a bit ugly, but it doesn't seem like a nice method signature is possible because
you can't pass the enum type as a reference and constrain the generic parameter to Enum. Nor
can you simply pass as ref Enum, because an enum instance doesn't match that function signature.
Finally, converting the enum to an int assumes that we always want to transport enums as ints. This
works in all of our current cases, but certainly isn't perfectly generic.
Translates a value using the .Net binary formatter.
The reference type.
The value to be translated.
Translates an object implementing INodePacketTranslatable.
The reference type.
The value to be translated.
Translates an array of objects implementing INodePacketTranslatable.
The reference type.
The array to be translated.
Translates an array of objects using an
The reference type.
The array to be translated.
The translator to use for the elements in the array
Translates a dictionary of { string, string }.
The dictionary to be translated.
The comparer used to instantiate the dictionary.
Translates a dictionary of { string, T }.
The reference type for the values
The dictionary to be translated.
The comparer used to instantiate the dictionary.
The translator to use for the values in the dictionary
Translates a dictionary of { string, T } for dictionaries with public parameterless constructors.
The reference type for the dictionary.
The reference type for values in the dictionary.
The dictionary to be translated.
The translator to use for the values in the dictionary
Translates a dictionary of { string, T } for dictionaries with public parameterless constructors.
The reference type for the dictionary.
The reference type for values in the dictionary.
The dictionary to be translated.
The translator to use for the values in the dictionary
The delegate used to instantiate the dictionary.
Reads in the boolean which says if this object is null or not.
The type of object to test.
True if the object should be read, false otherwise.
Implementation of ITranslator for writing to a stream.
The stream used as a source or destination for data.
The binary writer used in write mode.
Constructs a serializer from the specified stream, operating in the designated mode.
The stream serving as the source or destination of data.
Gets the reader, if any.
Gets the writer, if any.
Returns the current serialization mode.
Translates a boolean.
The value to be translated.
Translates a byte.
The value to be translated.
Translates a short.
The value to be translated.
Translates an unsigned short.
The value to be translated.
Translates an integer.
The value to be translated.
Translates a long.
The value to be translated.
Translates a double.
The value to be translated.
Translates a string.
The value to be translated.
Translates a string array.
The array to be translated.
Translates a list of strings
The list to be translated.
Translates a list of T using an
The list to be translated.
The translator to use for the items in the list
A TaskItemType
Translates a list of T using an
The list to be translated.
The translator to use for the items in the list
factory to create the IList
A TaskItemType
IList subtype
Translates a collection of T into the specified type using an and
The collection to be translated.
The translator to use for the values in the collection.
The factory to create the ICollection.
The type contained in the collection.
The type of collection to be created.
Translates a DateTime.
The value to be translated.
Translates a TimeSpan.
The value to be translated.
Translates a BuildEventContext
This method exists only because there is no serialization method built into the BuildEventContext
class, and it lives in Framework and we don't want to add a public method to it.
The context to be translated.
Translates a CultureInfo
The CultureInfo
Translates an enumeration.
The enumeration type.
The enumeration instance to be translated.
The enumeration value as an integer.
This is a bit ugly, but it doesn't seem like a nice method signature is possible because
you can't pass the enum type as a reference and constrain the generic parameter to Enum. Nor
can you simply pass as ref Enum, because an enum instance doesn't match that function signature.
Finally, converting the enum to an int assumes that we always want to transport enums as ints. This
works in all of our current cases, but certainly isn't perfectly generic.
Translates a value using the .Net binary formatter.
The reference type.
The value to be translated.
Translates an object implementing INodePacketTranslatable.
The reference type.
The value to be translated.
Translates a byte array
The byte array to be translated
Translates a byte array
The array to be translated.
The length of array which will be used in translation
Translates an array of objects implementing INodePacketTranslatable.
The reference type.
The array to be translated.
Translates an array of objects using an
The reference type.
The array to be translated.
The translator to use for the elements in the array
Translates a dictionary of { string, string }.
The dictionary to be translated.
The comparer used to instantiate the dictionary.
Translates a dictionary of { string, T }.
The reference type for the values, which implements INodePacketTranslatable.
The dictionary to be translated.
The comparer used to instantiate the dictionary.
The translator to use for the values in the dictionary
Translates a dictionary of { string, T } for dictionaries with public parameterless constructors.
The reference type for the dictionary.
The reference type for values in the dictionary.
The dictionary to be translated.
The translator to use for the values in the dictionary
Translates a dictionary of { string, T } for dictionaries with public parameterless constructors.
The reference type for the dictionary.
The reference type for values in the dictionary.
The dictionary to be translated.
The translator to use for the values in the dictionary
The delegate used to instantiate the dictionary.
Writes out the boolean which says if this object is null or not.
The object to test.
The type of object to test.
True if the object should be written, false otherwise.
Implementation of INodePacketFactory as a helper class for classes which expose this interface publicly.
Mapping of packet types to factory information.
Constructor
Registers a packet handler
Unregisters a packet handler.
Creates and routes a packet with data from a binary stream.
Routes the specified packet.
A record for a packet factory
The handler to invoke when the packet is deserialized.
The method used to construct a packet from a translator stream.
Constructor.
Creates a packet from a binary stream and sends it to the registered handler.
Routes the packet to the correct destination.
The NodeBuildComplete packet is used to indicate to a node that it should clean up its current build and
possibly prepare for node reuse.
Flag indicating if the node should prepare for reuse after cleanup.
Constructor.
Private constructor for translation
Flag indicating if the node should prepare for reuse.
The packet type
Translates the packet to/from binary form.
The translator to use.
Factory for deserialization.
Reasons why the node shut down.
The node shut down because it was requested to shut down.
The node shut down because of an error.
The node shut down because the connection failed.
Implementation of INodePacket for the packet informing the build manager than a node has shut down.
This is the last packet the BuildManager will receive from a Node, and as such can be used to trigger
any appropriate cleanup behavior.
The reason the node shut down.
The exception - if any.
Constructor
Constructor
Constructor for deserialization
Returns the packet type.
The reason for shutting down.
The exception, if any.
Serializes or deserializes a packet.
Factory method for deserialization
Helper logging class - contains all the logging methods used by tasks.
A TaskLoggingHelper object is passed to every task by MSBuild. For tasks that derive
from the Task class, it is provided in the Log property.
This class is thread safe: tasks can log from any threads.
public constructor
task containing an instance of this class
Public constructor which can be used by task factories to assist them in logging messages.
A client sponsor is a class
which will respond to a lease renewal request and will
increase the lease time allowing the object to stay in memory
Object to make this class thread-safe.
Gets the name of the parent task.
Task name string.
Gets the upper-case version of the parent task's name.
Upper-case task name string.
The build engine we are going to log against
Shortcut property for getting our build engine - we retrieve it from the task instance
Used to load culture-specific resources. Derived classes should register their resources either during construction, or
via this property, if they have localized strings.
Gets or sets the prefix used to compose help keywords from string resource names.
The help keyword prefix string.
Has the task logged any errors through this logging helper object?
Extracts the message code (if any) prefixed to the given message string. Message code prefixes must match the
following .NET regular expression in order to be recognized: ^\s*[A-Za-z]+\d+:\s*
Thread safe.
If this method is given the string "MYTASK1001: This is an error message.", it will return "MYTASK1001" for the
message code, and "This is an error message." for the message.
The message to parse.
The message with the code prefix removed (if any).
The message code extracted from the prefix, or null if there was no code.
Thrown when message is null.
Loads the specified resource string and optionally formats it using the given arguments. The current thread's culture
is used for formatting.
Requires the owner task to have registered its resources either via the Task (or TaskMarshalByRef) base
class constructor, or the Task.TaskResources (or AppDomainIsolatedTask.TaskResources) property.
Thread safe.
The name of the string resource to load.
Optional arguments for formatting the loaded string.
The formatted string.
Thrown when resourceName is null.
Thrown when the string resource indicated by resourceName does not exist.
Thrown when the TaskResources property of the owner task is not set.
Formats the given string using the variable arguments passed in. The current thread's culture is used for formatting.
Thread safe.
The string to format.
Arguments for formatting.
The formatted string.
Thrown when unformatted is null.
Get the message from resource in task library.
Thread safe.
The resource name.
The message from resource.
Logs a message using the specified string.
Thread safe.
The message string.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs a message of the given importance using the specified string.
Thread safe.
Take care to order the parameters correctly or the other overload will be called inadvertently.
The importance level of the message.
The message string.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs a message using the specified string and other message details.
Thread safe.
Description of the warning type (can be null).
Message code (can be null)
The help keyword for the host IDE (can be null).
The path to the file causing the message (can be null).
The line in the file causing the message (set to zero if not available).
The column in the file causing the message (set to zero if not available).
The last line of a range of lines in the file causing the message (set to zero if not available).
The last column of a range of columns in the file causing the message (set to zero if not available).
Importance of the message.
The message string.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs a critical message using the specified string and other message details.
Thread safe.
Description of the warning type (can be null).
Message code (can be null).
The help keyword for the host IDE (can be null).
The path to the file causing the message (can be null).
The line in the file causing the message (set to zero if not available).
The column in the file causing the message (set to zero if not available).
The last line of a range of lines in the file causing the message (set to zero if not available).
The last column of a range of columns in the file causing the message (set to zero if not available).
The message string.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs a message using the specified resource string.
Thread safe.
The name of the string resource to load.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Logs a message of the given importance using the specified resource string.
Thread safe.
Take care to order the parameters correctly or the other overload will be called inadvertently.
The importance level of the message.
The name of the string resource to load.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Small helper for logging the custom ExternalProjectStarted build event
Thread safe.
text message
help keyword
project name
targets we are going to build (empty indicates default targets)
Small helper for logging the custom ExternalProjectFinished build event.
Thread safe.
text message
help keyword
project name
true indicates project built successfully
Logs the command line for a task's underlying tool/executable/shell command.
Thread safe.
The command line string.
Logs the command line for a task's underlying tool/executable/shell
command, using the given importance level.
Thread safe.
The importance level of the command line.
The command line string.
Logs an error using the specified string.
Thread safe.
The message string.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs an error using the specified string and other error details.
Thread safe.
Description of the error type (can be null).
The error code (can be null).
The help keyword for the host IDE (can be null).
The path to the file containing the error (can be null).
The line in the file where the error occurs (set to zero if not available).
The column in the file where the error occurs (set to zero if not available).
The last line of a range of lines in the file where the error occurs (set to zero if not available).
The last column of a range of columns in the file where the error occurs (set to zero if not available).
The message string.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs an error using the specified string and other error details.
Thread safe.
Description of the error type (can be null).
The error code (can be null).
The help keyword for the host IDE (can be null).
The path to the file containing the error (can be null).
The line in the file where the error occurs (set to zero if not available).
The column in the file where the error occurs (set to zero if not available).
The last line of a range of lines in the file where the error occurs (set to zero if not available).
The last column of a range of columns in the file where the error occurs (set to zero if not available).
The message string.
A link pointing to more information about the error.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs an error using the specified resource string.
Thread safe.
The name of the string resource to load.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Logs an error using the specified resource string and other error details.
Thread safe.
The name of the string resource that describes the error type (can be null).
The error code (can be null).
The help keyword for the host IDE (can be null).
The path to the file containing the error (can be null).
The line in the file where the error occurs (set to zero if not available).
The column in the file where the error occurs (set to zero if not available).
The last line of a range of lines in the file where the error occurs (set to zero if not available).
The last column of a range of columns in the file where the error occurs (set to zero if not available).
The name of the string resource containing the error message.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Logs an error using the specified resource string.
If the message has an error code prefixed to it, the code is extracted and logged with the message. If a help keyword
prefix has been provided, a help keyword for the host IDE is also logged with the message. The help keyword is
composed by appending the string resource name to the prefix.
A task can provide a help keyword prefix either via the Task (or TaskMarshalByRef) base class constructor, or the
Task.HelpKeywordPrefix (or AppDomainIsolatedTask.HelpKeywordPrefix) property.
Thread safe.
The name of the string resource to load.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Logs an error using the specified resource string and other error details.
If the message has an error code prefixed, the code is extracted and logged with the message. If a
help keyword prefix has been provided, a help keyword for the host IDE is also logged with the message. The help
keyword is composed by appending the error message resource string name to the prefix.
A task can provide a help keyword prefix either via the Task (or TaskMarshalByRef) base class constructor, or the
Task.HelpKeywordPrefix (or AppDomainIsolatedTask.HelpKeywordPrefix) property.
Thread safe.
The name of the string resource that describes the error type (can be null).
The path to the file containing the error (can be null).
The line in the file where the error occurs (set to zero if not available).
The column in the file where the error occurs (set to zero if not available).
The last line of a range of lines in the file where the error occurs (set to zero if not available).
The last column of a range of columns in the file where the error occurs (set to zero if not available).
The name of the string resource containing the error message.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Logs an error using the message from the given exception context.
No callstack will be shown.
Thread safe.
Exception to log.
Thrown when e is null.
Logs an error using the message (and optionally the stack-trace) from the given exception context.
Thread safe.
Exception to log.
If true, callstack will be appended to message.
Thrown when exception is null.
Logs an error using the message, and optionally the stack-trace from the given exception, and
optionally inner exceptions too.
Thread safe.
Exception to log.
If true, callstack will be appended to message.
Whether to log exception types and any inner exceptions.
File related to the exception, or null if the project file should be logged
Thrown when exception is null.
Logs a warning using the specified string.
Thread safe.
The message string.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs a warning using the specified string and other warning details.
Thread safe.
Description of the warning type (can be null).
The warning code (can be null).
The help keyword for the host IDE (can be null).
The path to the file causing the warning (can be null).
The line in the file causing the warning (set to zero if not available).
The column in the file causing the warning (set to zero if not available).
The last line of a range of lines in the file causing the warning (set to zero if not available).
The last column of a range of columns in the file causing the warning (set to zero if not available).
The message string.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs a warning using the specified string and other warning details.
Thread safe.
Description of the warning type (can be null).
The warning code (can be null).
The help keyword for the host IDE (can be null).
A link pointing to more information about the warning (can be null).
The path to the file causing the warning (can be null).
The line in the file causing the warning (set to zero if not available).
The column in the file causing the warning (set to zero if not available).
The last line of a range of lines in the file causing the warning (set to zero if not available).
The last column of a range of columns in the file causing the warning (set to zero if not available).
The message string.
Optional arguments for formatting the message string.
Thrown when message is null.
Logs a warning using the specified resource string.
Thread safe.
The name of the string resource to load.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Logs a warning using the specified resource string and other warning details.
Thread safe.
The name of the string resource that describes the warning type (can be null).
The warning code (can be null).
The help keyword for the host IDE (can be null).
The path to the file causing the warning (can be null).
The line in the file causing the warning (set to zero if not available).
The column in the file causing the warning (set to zero if not available).
The last line of a range of lines in the file causing the warning (set to zero if not available).
The last column of a range of columns in the file causing the warning (set to zero if not available).
The name of the string resource containing the warning message.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Logs a warning using the specified resource string.
If the message has a warning code prefixed to it, the code is extracted and logged with the message. If a help keyword
prefix has been provided, a help keyword for the host IDE is also logged with the message. The help keyword is
composed by appending the string resource name to the prefix.
A task can provide a help keyword prefix either via the Task (or TaskMarshalByRef) base class constructor, or the
Task.HelpKeywordPrefix (or AppDomainIsolatedTask.HelpKeywordPrefix) property.
Thread safe.
The name of the string resource to load.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Logs a warning using the specified resource string and other warning details.
If the message has a warning code, the code is extracted and logged with the message.
If a help keyword prefix has been provided, a help keyword for the host IDE is also logged with the message. The help
keyword is composed by appending the warning message resource string name to the prefix.
A task can provide a help keyword prefix either via the Task (or TaskMarshalByRef) base class constructor, or the
Task.HelpKeywordPrefix (or AppDomainIsolatedTask.HelpKeywordPrefix) property.
Thread safe.
The name of the string resource that describes the warning type (can be null).
The path to the file causing the warning (can be null).
The line in the file causing the warning (set to zero if not available).
The column in the file causing the warning (set to zero if not available).
The last line of a range of lines in the file causing the warning (set to zero if not available).
The last column of a range of columns in the file causing the warning (set to zero if not available).
The name of the string resource containing the warning message.
Optional arguments for formatting the loaded string.
Thrown when messageResourceName is null.
Logs a warning using the message from the given exception context.
Thread safe.
Exception to log.
Thrown when exception is null.
Logs a warning using the message (and optionally the stack-trace) from the given exception context.
Thread safe.
Exception to log.
If true, the exception callstack is appended to the message.
Thrown when exception is null.
Logs errors/warnings/messages for each line of text in the given file. Errors/warnings are only logged for lines that
fit a particular (canonical) format -- the remaining lines are treated as messages.
Thread safe.
The file to log from.
true, if any errors were logged
Thrown when filename is null.
Logs errors/warnings/messages for each line of text in the given file. Errors/warnings are only logged for lines that
fit a particular (canonical) format -- the remaining lines are treated as messages.
Thread safe.
The file to log from.
The importance level for messages that are neither errors nor warnings.
true, if any errors were logged
Thrown when filename is null.
Logs errors/warnings/messages for each line of text in the given stream. Errors/warnings are only logged for lines
that fit a particular (canonical) format -- the remaining lines are treated as messages.
Thread safe.
The stream to log from.
The importance level for messages that are neither errors nor warnings.
true, if any errors were logged
Thrown when stream is null.
Logs an error/warning/message from the given line of text. Errors/warnings are only logged for lines that fit a
particular (canonical) format -- all other lines are treated as messages.
Thread safe.
The line of text to log from.
The importance level for messages that are neither errors nor warnings.
true, if an error was logged
Thrown when lineOfText is null.
Logs telemetry with the specified event name and properties.
The event name.
The list of properties associated with the event.
InitializeLifetimeService is called when the remote object is activated.
This method will determine how long the lifetime for the object will be.
Thread safe. However, InitializeLifetimeService and MarkAsInactive should
only be called in that order, together or not at all, and no more than once.
The lease object to control this object's lifetime.
Notifies this object that its work is done.
Thread safe. However, InitializeLifetimeService and MarkAsInactive should
only be called in that order, together or not at all, and no more than once.
Indicates to the TaskLoggingHelper that it is no longer needed.
Helper logging class for tasks, used for dealing with two resource streams.
public constructor
Used to load culture-specific resources. Derived classes should register their resources either during construction, or
via this property, if they have localized strings.
Loads the specified resource string and optionally formats it using the given arguments. The current thread's culture
is used for formatting.
1) This method requires the owner task to have registered its resources either via the Task (or TaskMarshalByRef) base
class constructor, or the "Task.TaskResources" (or "AppDomainIsolatedTask.TaskResources") property.
2) This method is thread-safe.
The name of the string resource to load.
Optional arguments for formatting the loaded string.
The formatted string.
Thrown when resourceName is null.
Thrown when the string resource indicated by resourceName does not exist.
Thrown when the TaskResources property of the owner task is not set.
Type of parameter, used to figure out how to serialize it.
Parameter is null
Parameter is a string
Parameter is an array of strings
Parameter is a value type. Note: Must be serializable
Parameter is an array of value types. Note: Must be serializable.
Parameter is an ITaskItem
Parameter is an array of ITaskItems
An invalid parameter -- the value of this parameter contains the exception
that is thrown when trying to access it.
Wrapper for task parameters, to allow proper serialization even
in cases where the parameter is not .NET serializable.
The TaskParameterType of the wrapped parameter
The actual task parameter that we're wrapping
Create a new TaskParameter
Constructor for deserialization
The TaskParameterType of the wrapped parameter
The actual task parameter that we're wrapping
TaskParameter's ToString should just pass through to whatever it's wrapping.
Serialize / deserialize this item.
Overridden to give this class infinite lease time. Otherwise we end up with a limited
lease (5 minutes I think) and instances can expire if they take long time processing.
Factory for deserialization.
Creates a new ITaskItem with the contents of the old one.
Serialize / deserialize this item.
Serialize / deserialize this item.
Write the given ITaskItem, using the given write translator
Read an ITaskItem into the given parameter, using the given read translator
Writes out the boolean which says if this object is null or not.
The nullable type to translate.
Super simple ITaskItem derivative that we can use as a container for read items.
The item spec
The full path to the project that originally defined this item.
The custom metadata
Cache for fullpath metadata
Constructor for serialization
Gets or sets the item "specification" e.g. for disk-based items this would be the file path.
This should be named "EvaluatedInclude" but that would be a breaking change to this interface.
The item-spec string.
Gets the names of all the metadata on the item.
Includes the built-in metadata like "FullPath".
The list of metadata names.
Gets the number of pieces of metadata on the item. Includes
both custom and built-in metadata. Used only for unit testing.
Count of pieces of metadata.
Returns the escaped version of this item's ItemSpec
Allows the values of metadata on the item to be queried.
The name of the metadata to retrieve.
The value of the specified metadata.
Allows a piece of custom metadata to be set on the item.
The name of the metadata to set.
The metadata value.
Allows the removal of custom metadata set on the item.
The name of the metadata to remove.
Allows custom metadata on the item to be copied to another item.
RECOMMENDED GUIDELINES FOR METHOD IMPLEMENTATIONS:
1) this method should NOT copy over the item-spec
2) if a particular piece of metadata already exists on the destination item, it should NOT be overwritten
3) if there are pieces of metadata on the item that make no semantic sense on the destination item, they should NOT be copied
The item to copy metadata to.
Get the collection of custom metadata. This does not include built-in metadata.
RECOMMENDED GUIDELINES FOR METHOD IMPLEMENTATIONS:
1) this method should return a clone of the metadata
2) writing to this dictionary should not be reflected in the underlying item.
Dictionary of cloned metadata
Overridden to give this class infinite lease time. Otherwise we end up with a limited
lease (5 minutes I think) and instances can expire if they take long time processing.
Returns the escaped value of the requested metadata name.
Sets the exact metadata value given to the metadata name requested.
Returns a dictionary containing all metadata and their escaped forms.
Provide a class which can verify the correct type for both input and output parameters.
Is the parameter type a valid scalar input value
Is the passed in parameterType a valid vector input parameter
Is the passed in value type assignable to an ITask or Itask[] object
Is the passed parameter a valid value type output parameter
Is the parameter type a valid scalar or value type input parameter
Is the parameter type a valid scalar or value type output parameter
This class provides helper methods to adapt from to
.
Translates an object implementing which does not expose a
public parameterless constructor.
The reference type.
The translator
The value to be translated.
The factory method used to instantiate values of type T.
This is a helper class to install an AssemblyResolver event handler in whatever AppDomain this class is created in.
This public default constructor is needed so that instances of this class can be created by NDP.
Initializes the instance.
Installs an AssemblyResolve handler in the current AppDomain. This class can be created in any AppDomain,
so it's possible to create an AppDomain, create an instance of this class in it and use this method to install
an event handler in that AppDomain. Since the event handler instance is stored internally, this method
should only be called once before a corresponding call to RemoveHandler (not that it would make sense to do
anything else).
Removes the event handler.
This is an assembly resolution handler necessary for fixing up types instantiated in different
AppDomains and loaded with a Assembly.LoadFrom equivalent call. See comments in TaskEngine.ExecuteTask
for more details.
Overridden to give this class infinite lease time. Otherwise we end up with a limited
lease (5 minutes I think) and instances can expire if they take long time processing.
Intended to be used in the nodes, during a build, where a base LoggingContext is created when the node
initializes for a build (this is the public constructor.) When a new project, target batch
or task batch is started, the appropriate method on the current LoggingContext is invoked
and a new LoggingContext is returned. This new LoggingContext should be used for all
subsequent logging within the subcontext.
True if this context comes from the in-proc node.
Constructs the logging context from a logging service and an event context.
The logging service to use
The event context
Flag indicating if this context belongs to an in-proc node.
Flag indicating if the context is being used for the in-proc node.
Log an error based on an exception during the execution of a task
The exception wich is to be logged
The file in which the error occurred
The task in which the error occurred
This object encapsulates the logging service plus the current BuildEventContext and
hides the requirement to pass BuildEventContexts to the logging service or query the
host for the logging service all of the time.
The logging service to which this context is attached
The build event context understood by the logging service.
True if this context is still valid (i.e. hasn't been "finished")
Constructs the logging context from a logging service and an event context.
The logging service to use
The event context
Constructs a logging context from another logging context. This is used primarily in
the constructors for other logging contexts to populate the logging service parameter,
while the event context will come from a call into the logging service itself.
The context from which this context is being created.
Retrieves the logging service
Retrieves the build event context
UNDONE: (Refactor) We eventually want to remove this because all logging should go
through a context object. This exists only so we can make certain
logging calls in code which has not yet been fully refactored.
Returns true if the context is still valid, false if the
appropriate 'Finished' call has been invoked.
Helper method to create a message build event from a string resource and some parameters
Importance level of the message
string within the resource which indicates the format string to use
string resource arguments
Helper method to create a message build event from a string
Importance level of the message
message to log
Helper method to create a message build event from a string
Importance level of the message
Message to log
Format string arguments
Log an error
The file in which the error occurred
The resource name for the error
Parameters for the resource string
Log an error
The resource name which indicates the subCategory
The file in which the error occurred
The resource name for the error
Parameters for the resource string
Log an error
The resource name which indicates the subCategory
Error code
Help keyword
The file in which the error occurred
Error message
Log an invalid project file exception
The invalid Project File Exception which is to be logged
Log an error based on an exception
The exception wich is to be logged
The file in which the error occurred
The string resource which has the formatting string for the error
The arguments for the error message
Log a warning
The subcategory resource name
The file in which the warning occurred
The string resource which contains the formatted warning string
parameters for the string resource
Log a warning based on a text message
The subcategory resource name
Warning code
Help keyword
The file in which the warning occurred
The message to be logged as a warning
Will Log a build Event. Will also take into account OnlyLogCriticalEvents when determining if to drop the event or to log it.
The event to log
Log an error based on an exception
The exception to be logged
The file in which the error occurred
Delegate to a method which will transport the packet accross the wire.
A node packet to send accross the wire
This class will consume the BuildEventArgs forwarded by the EventRedirectorToSink class.
The sink will then create a packet and then pass this along to the transport layer to be
sent back to the build manager.
Delegate to a method which accepts a INodePacket and send the packet to where it needs to go
Create the sink which will consume a buildEventArg
Create a INodePacket and send it to the transport component
A delegate which takes an INodePacket and sends the packet to where it needs to go
Send data delegate is null
Provide a friendly name for the sink to make it easier to differentiate during
debugging and display
Has the sink logged the BuildStartedEvent. This is important to know because we only want to log the build started event once
Has the sink logged the BuildFinishedEvent. This is important to know because we only want to log the build finished event once
This property is ignored by this event sink and relies on the receiver to treat warnings as errors.
This property is ignored by this event sink and relies on the receiver to treat warnings as errors.
This property is ignored by this event sink and relies on the receiver to treat warnings as low importance messages.
This property is ignored by this event sink and relies on the receiver to treat warnings as low importance messages.
This property is ignored by this event sink and relies on the receiver to keep track of whether or not any errors have been logged.
This method should not be used since we need the sinkID
Consumes the buildEventArg and creates a logMessagePacket
Build event to package into a INodePacket
The sink identifier.
buildEvent is null
Dispose of any resources the sink is holding onto.
Logger that forwards events to loggers registered with the LoggingServices
An IEventRedirector which will redirect any events forwarded from the logger. The eventRedirector determines where the events will
be redirected.
The nodeId of the node on which the logger is currently running.
Verbosity of the logger, in the central forwarding logger this is currently ignored
Logging Parameters
Initialize the logger with an eventSource and a node count.
The logger will register and listen to anyEvents on the eventSource.
The node count is for informational purposes. The logger may want to take different
actions depending on how many nodes there are in the system.
Event source which the logger will register with to receive events
Number of nodes the system was started with
Initialize the logger. The logger will register with AnyEventRaised on the eventSource
eventSource which the logger will register on to listen for events
EventSource is null
Shuts down the logger. This will null out the buildEventRedirector
Forwards any event raised to the BuildEventRedirector, this redirector will send the event on a path which will
take it to a logger.
Who sent the message, this is not used
BuildEvent to forward
Will redirect events from forwarding loggers to the a IBuildEventSink, many redirectors may redirect to one sink.
The Id of the central logger to which this event should be forwarded
The sink which will consume the messages
Initalize this class with a central logger id identifying the central logger to which
these events should consumed by. The redirector will send the messages to the registered sink to
be consumed
Id which will be attached to the build event arguments to indicate which logger the events came from
sink which will initially consume the events
Eventsink is null
LoggerId is less than 0
This method is called by the node loggers to forward the events to cenral logger
Build event to forward
BuildEvent is null
This class raises events on behalf of the build engine to all registered loggers.
This event is raised to log a message.
This event is raised to log an error.
This event is raised to log a warning.
this event is raised to log the start of a build
this event is raised to log the end of a build
this event is raised to log the start of a project build
this event is raised to log the end of a project build
this event is raised to log the start of a target build
this event is raised to log the end of a target build
this event is raised to log the start of task execution
this event is raised to log the end of task execution
this event is raised to log a custom event
this event is raised to log build status events, such as
build/project/target/task started/stopped
This event is raised to log that some event has
occurred. It is raised on every event.
This event is raised to log telemetry.
Provide a friendly name for the sink to make it easier to differentiate during
debugging and display
Has the sink logged the BuildStartedEvent. This is important to know because we only want to log the build started event once
Has the sink logged the BuildFinishedEvent. This is important to know because we only want to log the build finished event once
Should evaluation events include generated metaprojects?
Should evaluation events include profiling information?
Should task events include task inputs?
Determines whether properties and items should be logged on
instead of
Raises the given event to all registered loggers. This method up-cast the events
extracted from the queue.
BuildEventArgs
Note this is not used in the eventsource sink
Raises the given event to all registered loggers. This method up-cast the events
extracted from the queue.
Shutdown and displose of any resource this object is holding onto.
Clears out all events.
Raises a message event to all registered loggers.
sender of the event
BuildMessageEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises an error event to all registered loggers.
sender of the event
BuildErrorEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a warning event to all registered loggers.
sender of the event
BuildWarningEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a "build started" event to all registered loggers.
sender of the event
BuildStartedEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a "build finished" event to all registered loggers.
sender of the event
BuildFinishedEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a "project build started" event to all registered loggers.
sender of the event
ProjectStartedEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a "project build finished" event to all registered loggers.
sender of the event
ProjectFinishedEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a "target build started" event to all registered loggers.
sender of the event
TargetStartedEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a "target build finished" event to all registered loggers.
sender of the event
TargetFinishedEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a "task execution started" event to all registered loggers.
sender of the event
TaskStartedEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a "task finished executing" event to all registered loggers.
sender of the event
TaskFinishedEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a custom event to all registered loggers.
sender of the event
CustomBuildEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a catch-all build status event to all registered loggers.
sender of the event
BuildStatusEventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises a catch-all build event to all registered loggers.
sender of the event
Build EventArgs
When EventHandler raises an logger exception the LoggerException is rethrown
Any exceptions which are not LoggerExceptions are wrapped in an InternalLoggerException
ExceptionHandling.IsCriticalException exceptions will not be wrapped
Raises the a telemetry event to all registered loggers.
Delegate for an event which will take an exception and raise it on the registered event handlers.
Exception to be raised with registered event handlers
Interface representing logging services in the build system.
Implementations should be thread-safe.
When there is an exception on the logging thread, we do not want to throw the exception from there
instead we would like the exception to be thrown on the engine thread as this is where hosts expect
to see the exception. This event will transport the exception from the loggingService to the engine
which will register on this event.
Raised when a ProjectStarted event is about to be sent to the loggers.
Raised when a ProjectFinished event has just been sent to the loggers.
Provide the current state of the loggingService.
Is it Inistantiated
Has it been Initialized
Is it starting to shutdown
Has it shutdown
Returns the synchronous/asynchronous mode for the logging service.
When true, only log critical events such as warnings and errors. Has to be in here for API compat
Number of nodes in the system when it was initially started
Enumerator over all registered loggers.
The list of descriptions which describe how to create forwarding loggers on a node.
This is used by the node provider to get a list of registered descriptions so that
they can be transmitted to child nodes.
Return an array which contains the logger type names
this can be used to display which loggers are registered on the node
Return an array which contains the sink names
this can be used to display which sinks are on the node
List of properties to serialize from the child node
Should all properties be serialized from the child to the parent process
Is the logging running on a remote node
Set of warnings to treat as errors. An empty non-null set will treat all warnings as errors.
A list of warnings to treat as low importance messages.
Should evaluation events include generated metaprojects?
Should evaluation events include profiling information?
Should properties and items be logged on
instead of ?
Should task events include task inputs?
Adds a set of warning codes to treat as low importance messages for the specified project instance ID.
A to associate with the list of warning codes.
The list of warning codes to treat as low importance messsages.
Adds a set of warning codes to treat as errors for the specified project instance ID.
A to associate with the list of warning codes.
The list of warning codes to treat as errors.
Determines if the specified submission has logged an errors.
The ID of the build submission. A value of "0" means that an error was logged outside of any build submission.
true if the build submission logged an errors, otherwise false.
Returns a hashset of warnings to be logged as errors for the specified project instance ID.
The build context through which warnings will be logged as errors.
A Hashset containing warning codes that should be treated as errors.
Returns a hashset of warnings to be logged as messages for the specified project instance ID.
The build context through which warnings will be logged as errors.
A Hashset containing warning codes that should be treated as messages.
Allows the registering of an ICentralLogger and a forwarding logger pair
Central logger which is to receive the events created by the forwarding logger
A description of the forwarding logger
True if the central and forwarding loggers were registered. False if the central logger or the forwarding logger were already registered
Register an logger which expects all logging events from the system
The logger to register.
True if the central was registered. False if the central logger was already registered
Clear out all registered loggers so that none are registered.
In order to setup the forwarding loggers on a node, we need to take in the logger descriptions and initialize them.
The method will create a forwarding logger, an eventRedirector which will redirect all forwarded messages to the forwardingLoggerSink.
All forwarding loggers will use the same forwardingLoggerSink.
Collection of logger descriptions which we would like to use to create a set of forwarding loggers on a node
The buildEventSink which the fowarding loggers will forward their events to
The id of the node the logging services is on
When forwardingLoggerSink is null
When loggerDescriptions is null
Helper method to create a message build event from a string resource and some parameters
Event context which describes where in the build the message came from
Importance level of the message
string within the resource which indicates the format string to use
string resource arguments
Helper method to create a message build event from a string
Event context which describes where in the build the message came from
Importance level of the message
message to log
Log a comment from a format string and arguments
Event context information which describes who is logging the event
How important is the message, this will determine which verbosities the message will show up on.
The higher the importance the lower the verbosity needs to be for the message to be seen
Message to log
Message formatting arguments
BuildEventContext is null
Message is null
Will Log a build Event. Will also take into account OnlyLogCriticalEvents when determining if to drop the event or to log it.
Log an error
The event context information as to where the error occurred
The file in which the error occurred
The resource name for the error
Parameters for the resource string
Log an error
The event context for where the error occurred
The resource name which indicates the subCategory
The file in which the error occurred
The resource name for the error
Parameters for the resource string
Log an error
The event context for where the error occurred
The resource name which indicates the subCategory
Error code
Help keyword
The file in which the error occurred
Error message
Log an invalid project file exception
The event context for where the error occurred
The invalid Project File Exception which is to be logged
Log an error based on an exception
The event context for where the error occurred
The exception wich is to be logged
The file in which the error occurred
Log an error based on an exception during the execution of a task
The event context for where the error occurred
The exception wich is to be logged
The file in which the error occurred
The task in which the error occurred
Log an error based on an exception
The event context for where the error occurred
The exception wich is to be logged
The file in which the error occurred
The string resource which has the formatting string for the error
The arguments for the error message
Log a warning based on an exception
The event context for where the warning occurred
The exception to be logged as a warning
The file in which the warning occurred
The task in which the warning occurred
Log a warning
The event context for where the warning occurred
The subcategory resource name
The file in which the warning occurred
The string resource which contains the formatted warning string
parameters for the string resource
Log a warning based on a text message
The event context for where the warning occurred
The subcategory resource name
Warning code
Help keyword
The file in which the warning occurred
The message to be logged as a warning
Log the start of the build
Log the completion of a build
Did the build succeed or not
Create an evaluation context, by generating a new evaluation id.
The node id
The submission id
Logs that a project evaluation has started
The event context to use for logging
Project file being built
The evaluation event context for the project.
Logs that a project evaluation has finished
Event context for the project.
Project file being built
Global properties used for the evaluation.
Properties produced by the evaluation.
Items produced by the evaluation.
Profiler results if evaluation profiling was enabled.
BuildEventContext is null
Log that a project has started
The logging context of the node which is building this project.
The id of the build submission.
The id of the project instance which is about to start
The build context of the parent project which asked this project to build
The project file path of the project about to be built
The entrypoint target names for this project
The initial properties of the project
The initial items of the project
EvaluationId of the project instance
The BuildEventContext to use for this project.
Log that the project has finished
The build context of the project which has just finished
The path to the projec file which was just built
Did the build succeede or not
Log that a target has started
The build event context of the project spawning this target.
The name of the target which is about to start
The project file which is being built
The file in which the target is defined - typically a .targets file
The name of the parent target.
The reason the parent target built the target.
The target build event context
Log that a target has finished
The event context of the target which has just completed
The name of the target which has just completed
The project file which the target was being run in
The file in which the target is defined - typically a .targets file
Did the target finish successfully or not
List of target outputs for the target, right now this is for all batches and only is on the last target finished event
Log that a task is about to start
The event context of the task.
The name of the task
The project file which is being built
The file in which the task is defined - typically a .targets file
Log that a task is about to start
The event context of the target which is spawning this task.
The name of the task
The project file which is being built
The file in which the task is defined - typically a .targets file
The task build event context
Log that a task has just completed
The event context of the task which has just finished
The name of the task
The project file which is being built
The file in which the task is defined - typically a .targets file
True of the task finished successfully, false otherwise.
Logs telemetry.
The event context of the task which sent the telemetry.
The event name.
The list of properties associated with the event.
Acts as an endpoint for a buildEventArg. The objects which implement this interface are intended to consume the BuildEventArg.
Provide a the sink a friendly name which can be used to distinguish sinks in memory
and for display
Has the sink logged the BuildStartedEvent. This is important to know because we only want to log the build started event once
Has the sink logged the BuildFinishedEvent. This is important to know because we only want to log the build finished event once
Entry point for a sink to consume an event.
The event to be consumed by the sink.
Sink where the message should go to, this is really only used for the transport sink
Entry point for a sink to consume an event.
Shuts down the sink and any resources it may be holding
What is the mode of the logger, should there be a thread
processing the buildEvents and raising them on the filters and sinks
or should they be done synchronously
Events are processed synchronously
A thread is started which will process build events by raising them on a filter event source
or on the correct sink.
What is the current state of the logging service
When the logging service has been instantiated but not yet initialized through a call
to initializecomponent
The logging service has been initialized through a call to initialize component
The logging service is in the process of starting to shutdown.
The logging service completly shutdown
Logging services is used as a helper class to assist logging messages in getting to the correct loggers.
Partial class half of LoggingService which contains the Logging methods.
The default maximum size for the logging event queue.
Lock for the nextProjectId
A cached reflection accessor for an internal member.
We use a BindingFlags.Public flag here because the getter is public, so although the setter is internal,
it is only discoverable with Reflection using the Public flag (go figure!)
A cached reflection accessor for an internal member.
We use a BindingFlags.Public flag here because the getter is public, so although the setter is internal,
it is only discoverable with Reflection using the Public flag (go figure!)
The mapping of build request configuration ids to project file names.
The current state of the logging service
Use to optimize away status messages. When this is set to true, only "critical"
events like errors are logged. Default is false
Contains a dictionary of loggerId's and the sink which the logger (of the given Id) is expecting to consume its messages
A list of ILoggers registered with the LoggingService
A list of LoggerDescriptions which describe how to create a forwarding logger on a node. These are
passed to each node as they are created so that the forwarding loggers can be registered on them.
The event source to which filters will listen to get the build events which are logged to the logging service through the
logging helper methods. Ie LogMessage and LogMessageEvent
Index into the eventSinkDictionary which indicates which sink is the sink for any logger registered through RegisterLogger
What is the Id for the next logger registered with the logging service.
This Id is unique for this instance of the loggingService.
The number of nodes in the system. Loggers may take different action depending on how many nodes are in the system.
Component host for this component which is used to get system parameters and other initialization information.
The IConfigCache instance obtained from componentHost (stored here to avoid repeated dictionary lookups).
The next project ID to assign when a project evaluation started event is received.
The next project ID to assign when a project started event is received.
The next target ID to assign when a target started event is received.
The next task ID to assign when a task started event is received.
What node is this logging service running on
Whether to include evaluation metaprojects in events.
Whether to include evaluation profiles in events.
Whether properties and items should be logged on
instead of .
Whether to include task inputs in task events.
A list of build submission IDs that have logged errors. If an error is logged outside of a submission, the submission ID is .
A list of warnings to treat as errors for an associated . If an empty set, all warnings are treated as errors.
A list of warnings to treat as messages for an associated .
The data flow buffer for logging events.
The data flow processor for logging events.
The queue size above which the queue will close to messages from remote nodes.
This value should be selected such that during normal builds it is never reached.
It should also be low enough that we do not accumulate enough messages to cause
virtual memory exhaustion in extremely large builds.
By default our logMode is Asynchronous. We do this
because we are hoping it will make the system
more responsive when there are a large number of logging messages
Initialize an instance of a loggingService.
Should the events be processed synchronously or asynchronously
The node identifier.
When there is an exception on the logging thread, we do not want to throw the exception from there
instead we would like the exception to be thrown on the engine thread as this is where hosts expect
to see the exception. This event will transport the exception from the loggingService to the engine
which will register on this event.
Raised when a ProjectStarted event is about to be sent to the loggers.
Raised when a ProjectFinished event has just been sent to the loggers.
Properties we need to serialize from the child node
Should all properties be serialized from the child to the parent node
Is the logging running on a remote node
Gets the next project evaluation id.
This property is thread-safe
Gets the next project id.
This property is thread-safe
Gets the next target id.
This property is thread-safe
Gets the next task id.
This property is thread-safe
Provide the current state of the loggingService.
Is it Inistantiated
Has it been Initialized
Is it starting to shutdown
Has it shutdown
Use to optimize away status messages. When this is set to true, only "critical"
events like errors are logged.
Number of nodes in the system when the system is initially started
The list of descriptions which describe how to create forwarding loggers on a node.
This is used by the node provider to get a list of registered descriptions so that
they can be transmitted to child nodes.
Enumerator over all registered loggers.
What type of logging mode is the logger running under.
Is it Synchronous or Asynchronous
Get of warnings to treat as errors. An empty non-null set will treat all warnings as errors.
A list of warnings to treat as low importance messages.
Should evaluation events include generated metaprojects?
Should evaluation events include profiling information?
Should task events include task inputs?
Should properties and items be logged on
instead of ?
Determines if the specified submission has logged an errors.
The ID of the build submission. A value of "0" means that an error was logged outside of any build submission.
true if the build submission logged an errors, otherwise false.
Returns a hashset of warnings to be logged as errors for the specified build context.
The build context through which warnings will be logged as errors.
Return whether or not the LoggingQueue has any events left in it
Return an array which contains the logger type names
this can be used to display which loggers are registered on the node
Return an array which contains the sink names
this can be used to display which sinks are on the node
Create an instance of a LoggingService using the specified mode.
This method is used by the object factories to create instances of components.
Should the logger component created be synchronous or asynchronous
The identifier of the node.
An instantiated LoggingService as a IBuildComponent
NotThreadSafe, this method should only be called from the component host thread
Called by the build component host when a component is first initialized.
The component host for this object
When buildComponentHost is null
Service has already shutdown
NotThreadSafe, this method should only be called from the component host thread
Called by the build component host when the component host is about to shutdown.
1. Shutdown forwarding loggers so that any events they have left to forward can get into the queue
2. Terminate the logging thread
3. Null out sinks and the filter event source so that no more events can get to the central loggers
4. Shutdown the central loggers
Service has already shutdown
A logger may throw a logger exception when shutting down
A logger will wrap other exceptions (except ExceptionHandling.IsCriticalException exceptions) in a InternalLoggerException if it crashes during shutdown
Will receive a logging packet and send it to the correct
sink which is registered to the LoggingServices.
PacketReceived should be called from a single thread.
The node from which the packet was received.
A LogMessagePacket
Packet is null
Packet is not a NodePacketType.LogMessage
Register an instantiated logger which implements the ILogger interface. This logger will be registered to a specific event
source (the central logger event source) which will receive all logging messages for a given build.
This should not be used on a node, Loggers are not to be registered on a child node.
ILogger
True if the logger has been registered successfully. False if the logger was not registered due to it already being registered before
If logger is null
Clear out all registered loggers so that none are registered.
If no loggers are registered, does nothing.
UNDONE: (Logging) I don't like the semantics of this. Why should unregistering imply shutting down? VS actually calls it before registering any loggers.
Also, why not just have ShutdownComponent? Or call this Shutdown or Dispose?
Register a distributed logger. This involves creating a new eventsource sink
and associating this with the central logger. In addition the sinkId needs
to be put in the loggerDescription so that nodes know what they need to
tag onto the event so that the message goes to the correct logger.
The central logger is initialized before the distributed logger
Central logger to receive messages from the forwarding logger, This logger cannot have been registered before
Logger description which describes how to create the forwarding logger, the logger description cannot have been used before
True if the distributed and central logger were registered, false if they either were already registered
If forwardingLogger is null
If a logger exception is thrown while creating or initializing the distributed or central logger
If any exception (other than a loggerException)is thrown while creating or initializing the distributed or central logger, we will wrap these exceptions in an InternalLoggerException
In order to setup the forwarding loggers on a node, we need to take in the logger descriptions and initialize them.
The method will create a forwarding logger, an eventRedirector which will redirect all forwarded messages to the forwardingLoggerSink.
All forwarding loggers will use the same forwardingLoggerSink.
Collection of logger descriptions which we would like to use to create a set of forwarding loggers on a node
The buildEventSink which the fowarding loggers will forward their events to
The id of the node the logging services is on
When forwardingLoggerSink is null
When loggerDescriptions is null
Will Log a build Event. Will also take into account OnlyLogCriticalEvents when determining
if to drop the event or to log it.
Only the following events will be logged if OnlyLogCriticalEvents is true:
CustomEventArgs
BuildErrorEventArgs
BuildWarningEventArgs
BuildEvent to log
buildEvent is null
This method will becalled from multiple threads in asynchronous mode.
Determine where to send the buildevent either to the filters or to a specific sink.
When in Asynchronous mode the event should to into the logging queue (as long as we are initialized).
In Synchronous mode the event should be routed to the correct sink or logger right away
BuildEventArgs to process
true to allow throttling, otherwise false.
buildEvent is null
Wait for the logging messages in the logging queue to be completly processed.
This is required because for Logging build finished or when the component is to shutdown
we need to make sure we process all of the events before the build finished event is raised
and we need to make sure we process all of the logging events before we shutdown the component.
Adds data to the EventArgs of the log packet that the main node is aware of, but doesn't
get serialized for perf reasons.
Create a logging thread to process the logging queue
Wait for the logginQueue to empty and then terminate the logging thread
Shutdown an ILogger
Rethrow LoggerExceptions
Wrap all other exceptions in an InternalLoggerException
Logger to shutdown
Any exception comming from a logger during shutdown that is not a LoggerException is wrapped in an InternalLoggerException and thrown
Errors during logger shutdown may throw a LoggerException, in this case the exception is re-thrown
Create an event source to which the distributed (filter loggers) can attach to and listen
for logging events. This event source will consume events which are logged against
the logging service and raise them on itself.
The logging services thread loop. This loop will wait until the logging queue has build events.
When this happens the thread will start to process the queue items by raising the build event
on either a filter event source or a sink depending on where the message is supposed to go.
WaitHandle returns something other than 0 or 1
Route the event to the correct location, this is mostly used by the logging thread since it may have a buildevent or a tuple.
Route the build event to the correct filter or sink depending on what the sinId is in the build event.
Route the build event to the filter
Build event that needs to be routed to the correct filter or sink.
Initializes the logger and adds it to the list of loggers maintained by the engine.
This method is not expected to be called from multiple threads
A logger exception thrown by a logger when its initialize call is made
Any exceptions from initializing the logger which are not loggerExceptions are caught and wrapped in a InternalLoggerException
Any exception which is a ExceptionHandling.IsCriticalException will not be wrapped
When an exception is raised in the logging thread, we do not want the application to terminate right away.
Whidbey and orcas msbuild have the logger exceptions occurring on the engine thread so that the host can
catch and deal with these exceptions as they may occur somewhat frequently due to user generated loggers.
This method will raise the exception on a delegate to which the engine is registered to. This delegate will
send the exception to the engine so that it can be raised on the engine thread.
Exception to raise to event handlers
Raise the project started event, if necessary.
Raise the project finished event, if necessary.
Get the project name from a context ID. Throw an exception if it's not found.
Determines if the specified warning should be treated as a low importance message.
A that specifies the warning.
true if the warning should be treated as a low importance message, otherwise false.
Determines if the specified warning should be treated as an error.
A that specifies the warning.
true if the warning should be treated as an error, otherwise false.
Logs a comment (BuildMessageEventArgs) with a certain MessageImportance level
Event context information which describes who is logging the event
How important is the message, this will determine which verbosities the message will show up on.
The higher the importance the lower the verbosity needs to be for the message to be seen
String which identifies the message in the string resx
Arguments for the format string indexed by messageResourceName
MessageResourceName is null
Log a comment
Event context information which describes who is logging the event
How important is the message, this will determine which verbosities the message will show up on.
The higher the importance the lower the verbosity needs to be for the message to be seen
Message to log
BuildEventContext is null
Message is null
Log a comment
Event context information which describes who is logging the event
How important is the message, this will determine which verbosities the message will show up on.
The higher the importance the lower the verbosity needs to be for the message to be seen
Message to log
Message formatting arguments
BuildEventContext is null
Message is null
Logs an error with all registered loggers using the specified resource string.
Event context information which describes who is logging the event
File information where the error happened
String key to find the correct string resource
Arguments for the string resource
Logs an error
Event context information which describes who is logging the event
Can be null.
File information about where the error happened
String index into the string.resx file
Arguments for the format string in the resource file
MessageResourceName is null
Logs an error with a given message
Event context information which describes who is logging the event
Can be null.
Can be null.
Can be null.
File information about where the error happened
Error message which will be displayed
File is null
Message is null
Logs an error regarding an invalid project file . Since this method may be multiple times for the same InvalidProjectException
we do not want to log the error multiple times. Once the exception has been logged we set a flag on the exception to note that
it has already been logged.
Event context information which describes who is logging the event
Exception which is causing the error
InvalidProjectFileException is null
BuildEventContext is null
Logs an error regarding an unexpected build failure
This will include a stack dump.
BuildEventContext of the error
Exception wihch caused the build error
Provides file information about where the build error happened
Logs an error regarding an unexpected task failure.
This will include a stack dump.
BuildEventContext of the error
Exceptionm which caused the error
File information which indicates which file the error is happening in
Task which the error is happening in
TaskName is null
Logs an error regarding an unexpected failure using the specified resource string.
This will include a stack dump.
BuildEventContext of the error
Exception which will be used to generate the error message
File information which describes where the error happened
String name for the resource string to be used
Arguments for messageResourceName
MessageResourceName is null
Logs an warning regarding an unexpected task failure
This will include a stack dump.
Event context information which describes who is logging the event
The exception to be used to create the warning text
The file information which indicates where the warning happened
Name of the task which the warning is being raised from
Logs a warning using the specified resource string.
Event context information which describes who is logging the event
Can be null.
File information which describes where the warning happened
String name for the resource string to be used
Arguments for messageResourceName
Logs a warning
Event context information which describes who is logging the event
Subcategory resource Name. Can be null.
The warning code of the message. Can be null.
Help keyword for the message. Can be null.
The file information which will describe where the warning happened
Warning message to log
Logs that the build has started
Logs that the build has finished
Did the build pass or fail
Logs that a project evaluation has finished
Event context for the project.
Project file being built
Global properties used for the evaluation.
Properties produced by the evaluation.
Items produced by the evaluation.
Profiler results if evaluation profiling was enabled.
BuildEventContext is null
Logs that a project build has started
The event context of the node which is spawning this project.
The id of the submission.
Id of the project instance which is being started
BuildEventContext of the project who is requesting "projectFile" to build
Project file to build
Target names to build
Initial property list
Initial items list
EvaluationId of the project instance
The build event context for the project.
parentBuildEventContext is null
projectBuildEventContext is null
Logs that a project has finished
Event context for the project.
Project file being built
Did the project pass or fail
BuildEventContext is null
Logs that a target started
Event context for the project spawning this target
Name of target
Project file being built
Project file which contains the target
The name of the parent target.
The reason the parent target built the target.
The build event context for the target.
BuildEventContext is null
Logs that a target has finished.
Event context for the target
Target which has just finished
Project file being built
Project file which contains the target
Did the target pass or fail
Target outputs for the target.
BuildEventContext is null
Logs that task execution has started.
Event context for the task
Task Name
Project file being built
Project file which contains the task
BuildEventContext is null
Logs that task execution has started.
Event context for the target spawning this task.
Task Name
Project file being built
Project file which contains the task
The build event context for the task.
BuildEventContext is null
Logs that a task has finished executing.
Event context for the task
Name of the task
Project which is being processed
Project file which contains the task
Did the task pass or fail
BuildEventContext is null
Logs a telemetry event.
Event context information which describes who is logging the event
The event name.
The list of properties assocated with the event.
Factory to create components of the type LoggingService
What kind of LoggerMode are the logging services when created.
They could be Synchronous or Asynchronous
What node is this logging service being created on.
Tell the factory what kind of logging services is should create
Synchronous or Asynchronous
The node identifier.
Create an instance of a LoggingService and returns is as an IBuildComponent
An instance of a LoggingService as a IBuildComponent
The logging context for an entire node.
Used to create the initial, base logging context for the node.
The logging service to use.
The
true if this is an in-process node, otherwise false.
Log the completion of a build
Did the build succeed or not
Log that a project has started if it has no parent (the first project)
The build request entry for this project.
The BuildEventContext to use for this project.
Log that a project has started if it is serviced from the cache
The build request.
The configuration used to build the request.
The BuildEventContext to use for this project.
Logs the project started/finished pair for projects which are skipped entirely because all
of their results are available in the cache.
A logging context for a project.
The project's full path
The parent node logging context this context was derived from.
Constructs a project logging context.
Constructs a project logging context.
Constructs a project logging contexts.
Retrieves the node logging context.
Log that the project has finished
Did the build succeede or not
Log that a target has started
An enumerable wrapper for items that clones items as they are requested,
so that writes have no effect on the items.
This class is designed to be passed to loggers.
The expense of copying items is only incurred if and when
a logger chooses to enumerate over it.
The type of the items enumerated over is imposed by backwards compatibility for ProjectStartedEvent.
Enumerable that this proxies
Constructor
Enumerator this class should proxy
Returns an enumerator that provides copies of the items
in the backing store.
Each dictionary entry has key of the item type and value of an ITaskItem.
Type of the enumerator is imposed by backwards compatibility for ProjectStartedEvent.
Returns an enumerator that provides copies of the items
in the backing store.
An enumerable wrapper for properties that clones properties as they are requested,
so that writes have no effect on the properties.
This class is designed to be passed to loggers.
The expense of copying items is only incurred if and when
a logger chooses to enumerate over it.
The type of the items enumerated over is imposed by backwards compatibility for ProjectStartedEvent.
Enumerable that this proxies
Constructor
Enumerator this class should proxy
Returns an enumerator that provides copies of the properties
in the backing store.
Each DictionaryEntry has key of the property name and value of the property value.
Type of the enumerator is imposed by backwards compatibility for ProjectStartedEvent.
Returns an enumerator that provides copies of the properties
in the backing store.
A logging context for building a specific target within a project.
Should target outputs be logged also.
The project to which this target is attached.
The target being built.
Creates a new target logging context from an existing project context and target.
Constructor used to support out-of-proc task host (proxy for in-proc logging service.)
Should target outputs be logged also.
Retrieves the project logging context.
Retrieves the target.
Log that a target has finished
Log that a task is about to start
An enumerable wrapper for items that clones items as they are requested,
so that writes have no effect on the items.
This class is designed to be passed to loggers.
The expense of copying items is only incurred if and when
a logger chooses to enumerate over it.
Enumerable that this proxies
Constructor
Enumerator this class should proxy
Returns an enumerator that provides copies of the items
in the backing store.
Each dictionary entry has key of the item type and value of an ITaskItem.
Type of the enumerator is imposed by backwards compatibility for ProjectStartedEvent.
Returns an enumerator that provides copies of the items
in the backing store.
A logging context representing a task being built.
The target context in which this task is being built.
The task instance
The name of the task
Constructs a task logging context from a parent target context and a task node.
Constructor used to support out-of-proc task host (proxy for in-proc logging service.)
Retrieves the target logging context.
Retrieves the task node.
Retrieves the task node.
Log that a task has just completed
Log a warning based on an exception
The exception to be logged as a warning
The file in which the warning occurred
The task in which the warning occurred
When set, we'll try reading background color.
Some platforms do not allow getting current background color. There
is not way to check, but not-supported exception is thrown. Assume
black, but don't crash.
Gets or sets the level of detail to show in the event log.
Verbosity level.
Gets or sets the number of MSBuild processes participating in the build. If greater than 1,
include the node ID
The console logger takes a single parameter to suppress the output of the errors
and warnings summary at the end of a build.
null
Suppresses the display of project headers. Project headers are
displayed by default unless this property is set.
This is only needed by the IDE logger.
Suppresses the display of error and warnings summary.
If null, user has made no indication.
Provide access to the write hander delegate so that it can be redirected
if necessary (e.g. to a file)
Parses out the logger parameters from the Parameters string.
An implementation of IComparer useful for comparing the keys
on DictionaryEntry's
Uses CurrentCulture for display purposes
An implementation of IComparer useful for comparing the ItemSpecs
on ITaskItem's
Uses CurrentCulture for display purposes
Indents the given string by the specified number of spaces.
String to indent.
Depth to indent.
Splits strings on 'newLines' with tolerance for Everett and Dogfood builds.
String to split.
Writes a newline to the log.
Writes a line from a resource string to the log, using the default indentation.
Writes a line from a resource string to the log, using the specified indentation.
Writes to the log, using the default indentation. Does not
terminate with a newline.
If requested, display a performance summary at the end of the build. This
shows how much time (and # hits) were spent inside of each project, target,
and task.
Writes to the log, using the specified indentation. Does not
terminate with a newline.
Writes a line to the log, using the default indentation.
Writes a line to the log, using the specified indentation.
Check to see what kind of device we are outputting the log to, is it a character device, a file, or something else
this can be used by loggers to modify their outputs based on the device they are writing to
Determines whether the current verbosity setting is at least the value
passed in.
Sets foreground color to color specified
Resets the color
Sets foreground color to color specified using ANSI escape codes
foreground color
Resets the color using ANSI escape codes
Changes the foreground color to black if the foreground is the
same as the background. Changes the foreground to white if the
background is black.
foreground color for black
current background
Does nothing, meets the ColorSetter delegate type
foreground color (is ignored)
Does nothing, meets the ColorResetter delegate type
Writes out the list of property names and their values.
This could be done at any time during the build to show the latest
property values, using the cached reference to the list from the
appropriate ProjectStarted event.
List of properties
Writes out the environment as seen on build started.
Generate a list which contains the properties referenced by the properties
enumerable object
Write the environment of the build as was captured on the build started event.
Writes out the list of item specs and their metadata.
This could be done at any time during the build to show the latest
items, using the cached reference to the list from the
appropriate ProjectStarted event.
Extract the Items from the enumerable object and return a sorted list containing these items
Dump the initial items provided.
Overridden in ParallelConsoleLogger.
Returns a performance counter for a given scope (either task name or target name)
from the given table.
Task name or target name.
Table that has tasks or targets.
Display the timings for each counter in the dictionary.
Records performance information consumed by a task or target.
Construct.
Name of the scope.
Total number of calls so far.
Total accumulated time so far.
Whether or not this scope was reentered. Timing information is not recorded in these cases.
Whether or not this task or target is executing right now.
Returns an IComparer that will put performance counters
in descending order by elapsed time.
Private IComparer class for sorting performance counters
in descending order by elapsed time.
Compare two PerformanceCounters.
Signs up the console logger for all build events.
Available events.
Apply a logger parameter.
parameterValue may be null, if there is no parameter value.
Apply the verbosity value
Time the build started
Delegate used to change text color.
Delegate used to reset text color
Number of spaces that each level of indentation is worth
Keeps track of the current indentation level.
The kinds of newline breaks we expect.
Currently we're not supporting "\r".
Visual separator for projects. Line length was picked arbitrarily.
Console logger parameters delimiters.
Console logger parameter value split character.
When true, accumulate performance numbers.
When true, show the list of item and property values at the start of each project
Should the target output items be displayed
When true, suppresses all messages except for warnings. (And possibly errors, if showOnlyErrors is true.)
When true, suppresses all messages except for errors. (And possibly warnings, if showOnlyWarnings is true.)
When true the environment block supplied by the build started event should be printed out at the start of the build
When true, indicates that the logger should tack the project file onto the end of errors and warnings.
Number of errors encountered in this build
Number of warnings encountered in this build
A list of the errors that have occurred during this build.
A list of the warnings that have occurred during this build.
Accumulated project performance information.
Accumulated target performance information.
Accumulated task performance information.
This class will throw an exception when it receives any event except for the build started or build finished event
this logger is good to use if a distributed logger is attached but does not want to forward any events
Stores and manages projects and targets events for logging purposes
Adds a new project to the list of project started events which have been fired
Adds a new target to the list of project started events which have been fired
Get a call stack of event contexts for a starting point event context
Set an error flag on all projects in the call stack of a given event context
Retrieve the project call stack based on the starting point of buildEventContext e
Get a deferred project started event based on a given event context
Get a deferred target started event based on a given event context
Will remove a project started event from the list of deferred project started events
Will remove a project started event from the list of deferred project started events
Compares two event contexts on ProjectContextId and NodeId only
Compares two event contexts based on the ProjectContextId, NodeId, and TargetId only
This class stands in for a full project started event because it contains only the
minimum amount of inforomation needed for the logger
This class stands in for a full target started event because it contains only the
minimum amount of inforomation needed for the logger
This class is used as a key to group warnings and errors by the project entry point and the target they
error or warning was in
Structure that holds both project and entrypoint keys
Output the projectKey or the projectKey and the entrypointKey depending on the verbosity level of the logger
The default of he ToString method should be to output the projectKey or the projectKey and the entrypointKey depending if a
entry point key exists or not
This class implements the default logger that outputs event data
to the console (stdout).
This class is not thread safe.
Associate a (nodeID and project_context_id) to a target framework.
Default constructor.
Create a logger instance with a specific verbosity. This logs to
the default console.
Initializes the logger, with alternate output handlers.
Check to see if the console is going to a char output such as a console,printer or com port, or if it going to a file
Allows the logger to take action based on a parameter passed on when initializing the logger
Keep track of the last event displayed so target names can be displayed at the correct time
Reset the states of per-build member variables
VSW#516376
Handler for build started events
sender (should be null)
event arguments
Handler for build finished events
sender (should be null)
event arguments
At the end of the build, repeats the errors and warnings that occurred
during the build, and displays the error count and warning count.
Does this in a "flat" style, without context.
At the end of the build, repeats the errors and warnings that occurred
during the build, and displays the error count and warning count.
Does this in a "nested" style.
Handler for project started events
sender (should be null)
event arguments
Handler for project finished events
sender (should be null)
event arguments
Writes out the list of property names and their values.
This could be done at any time during the build to show the latest
property values, using the cached reference to the list from the
appropriate ProjectStarted event.
A object containing information about the build event.
List of properties
Write the environment strings to the console.
Writes out the list of item specs and their metadata.
This could be done at any time during the build to show the latest
items, using the cached reference to the list from the
appropriate ProjectStarted event.
A object containing information about the build event.
List of items
Handler for target started events
sender (should be null)
event arguments
Handler for target finished events
sender (should be null)
event arguments
Handler for task started events
sender (should be null)
event arguments
Handler for task finished events
sender (should be null)
event arguments
Finds the LogOutProperty string to be printed in messages.
Build event to extract context information from.
Prints an error event
Prints a warning event
Prints a message event
Prints out a message event to the console
Writes a message to the console, aligned and formatted to fit within the console width
Message to be formatted to fit on the console
Has the prefix(timestamp or key been written)
Writes a message to the console, aligned and formatted to fit within the console width
Message to be formatted to fit on the console
Has the prefix(timestamp or key been written)
An amount to adjust the prefix by.
Write message taking into account whether or not the prefix (timestamp and key) have already been written on the line
Will display the target started event which was deferred until the first visible message for the target is ready to be displayed
Will display the project started event which was deferred until the first visible message for the project is ready to be displayed
Prints a custom event
Writes message contextual information for each message displayed on the console
Extract the full project key from the BuildEventContext
Returns a performance counter for a given scope (either task name or target name)
from the given table.
Task name or target name.
Table that has tasks or targets.
Stores and calculates the performance numbers for the different events
Add a started event to the performance counter, by adding the event this sets the start time of the performance counter
Add a finished event to the performance counter, so perf numbers can be calculated
Print out the performance counter message
Utility helper functions for formatting logger output.
Formats the timestamp in the log as Hours:Minutes:Seconds.Milliseconds
Formats a timespan for logger output.
String representation of time-span.
Default constructor.
Create a logger instance with a specific verbosity. This logs to
the default console.
Verbosity level.
Initializes the logger, with alternate output handlers.
Reset the states of per-build member variables
VSW#516376
Handler for build started events
sender (should be null)
event arguments
Handler for build finished events
sender (should be null)
event arguments
At the end of the build, repeats the errors and warnings that occurred
during the build, and displays the error count and warning count.
Handler for project started events
sender (should be null)
event arguments
Handler for project finished events
sender (should be null)
event arguments
Handler for target started events
sender (should be null)
event arguments
Handler for target finished events
sender (should be null)
event arguments
Handler for task started events
sender (should be null)
event arguments
Handler for task finished events
sender (should be null)
event arguments
Prints an error event
Prints a warning event
Prints a message event
Prints a custom event
Writes project started messages.
Displays the text for a project started message.
current project file
previous project file
targets that are being invoked
indentation level
Writes target started messages.
Determines the currently building project file.
name of project file currently being built
Displays project started and target started messages that
are shown only when the associated project or target produces
output.
Marks the current frame to indicate that an error or warning
occurred during it.
Checks the condition passed in. If it's false, it emits an error message to the console
indicating that there's a problem with the console logger. These "problems" should
never occur in the real world after we ship, unless there's a bug in the MSBuild
engine such that events aren't getting paired up properly. So the messages don't
really need to be localized here, since they're only for our own benefit, and have
zero value to a customer.
This enumeration represents the kinds of context that can be
stored in the context stack.
This struct represents context information about a single
target or project.
Creates a new instance of frame with all fields specified.
the type of the this frame
display state. true indicates this frame has been displayed to the user
indentation level for this frame
frame id
targets to execute, in the case of a project frame
the file name where the target is defined
parent project file
Indicates if project or target frame.
Set to true to indicate the user has seen a message about this frame.
The number of tabstops to indent this event when it is eventually displayed.
A string associated with this frame -- should be a target name
or a project file.
For a TargetStarted or a ProjectStarted event, this field tells us
the name of the *parent* project file that was responsible.
Stores the TargetNames from the ProjectStarted event. Null for Target frames.
For TargetStarted events, this stores the filename where the Target is defined
(e.g., Microsoft.Common.targets). This is different than the project that is
being built.
For ProjectStarted events, this is null.
True if there were errors/warnings during the project or target frame.
The FrameStack class represents a (lifo) stack of Frames.
The frames member is contained by FrameStack and does
all the heavy lifting for FrameStack.
Create a new, empty, FrameStack.
Remove and return the top element in the stack.
Thrown when stack is empty.
Returns, but does not remove, the top of the stack.
Push(f) adds f to the top of the stack.
a frame to push
Constant property that indicates the number of elements
in the stack.
s.IsEmpty() is true iff s.Count == 0
contextStack is the only interesting state in the console
logger. The context stack contains a sequence of frames
denoting current and previous containing projects and targets
Default SDK resolver for compatibility with VS2017 RTM.
Default Sdk folder will to:
1) MSBuildSDKsPath environment variable if defined
2) When in Visual Studio, (VSRoot)\MSBuild\Sdks\
3) Outside of Visual Studio (MSBuild Root)\Sdks\
An interface for services which resolve SDKs.
A method to use when sending packets to a remote host.
Clears the cache for the specified build submission ID.
The build submission ID to clear from the cache.
Clear the entire cache
Resolves the full path to the specified SDK.
The build submission ID that the resolution request is for.
The containing information about the referenced SDK.
The to use when logging messages during resolution.
The of the element which referenced the SDK.
The full path to the solution file, if any, that is resolving the SDK.
The full path to the project file that is resolving the SDK.
Indicates whether or not the resolver is allowed to be interactive.
Indicates whether or not the resolver is running in Visual Studio.
An containing information about the resolved SDK. If no resolver was able to resolve it, then == false.
An implementation of that is hosted in an out-of-proc node for multi-proc builds. This instance of the service
sends requests to the main node that SDK resolution is handled in a central location. This instance is registered in
using a factory so that parameters can be passed to the constructor. This service caches responses for a given build so that it can avoid sending
a packet where possible. The cache is always in effect here because the out-of-proc node is only used for builds.
Since this object is a registered , it is a singleton for the main process. To get an instance of it, you
must have access to an and call and pass .
The cache of responses which is cleared between builds.
An event to signal when a response has been received.
An object used to store the last response from a remote node. Since evaluation is single threaded, this object is only set one at a time.
Initializes a new instance of the OutOfProcNodeSdkResolverService class.
A to use when sending packets to the main node.
Handles a response from the main node.
A factory used when creating a which can pass parameters to its constructor. Our
dependency inject cannot pass parameters to constructors so this factory is used as a middle man.
Stores the SendPacket delegate to use.
An internal implementation of .
Stores the cache in a set of concurrent dictionaries. The main dictionary is by build submission ID and the inner dictionary contains a case-insensitive SDK name and the cached .
An internal implementation of .
Find all files that are to be considered SDK Resolvers. Pattern will match
Root\SdkResolver\(ResolverName)\(ResolverName).dll.
Serialization contract for an SDK Resolver manifest
Deserialize the file into an SdkResolverManifest.
Path to the manifest xml file.
New deserialized collection instance.
Represents an SDK resolver request which is serialized and sent between nodes. This is mostly a wrapper around
with an additional implementation.
An implementation of that is hosted in the main node for multi-proc builds. This instance of the service
listens for requests from out-of-proc nodes so that SDK resolution is handled in a central location. This instance is registered in
and can be overridden for different contexts. This service calls the to do any actual SDK resolution
because the is used for stand-alone evaluations where there is no build context available so caching
is not an option.
Since this object is a registered , it is a singleton for the main process. To get an instance of it, you
must have access to an and call and pass .
An object used for locking in this class instance.
A running in the background which handles requests from remote nodes.
An event which is signaled when a request is received from a remote host.
A list of requests from remote hosts which need to be processed.
A factory which is registered to create an instance of this class.
Handles a request from a remote node.
The ID of the remote node.
The containing information about the SDK to resolve.
This method must not directly handle requests because it would block requests from other nodes. Instead, it simply
adds requests to a queue which are processed by a background thread.
Processes all requests that are currently in the queue.
A background thread that waits for requests to be received.
The main implementation of which resolves SDKs. This class is the central location for all SDK resolution and is used
directly by the main node and non-build evaluations and is used indirectly by the out-of-proc node when it sends requests to the main node.
Stores the singleton instance for a particular process.
A lock object used for this class.
Stores resolver state by build submission ID.
Stores the list of SDK resolvers which were loaded.
Stores an which can load registered SDK resolvers.
Gets the current instance of for this process.
Determines if the is the same as the specified version. If the object has null for the version,
this method will always return true since null can match any version.
An object.
The version to compare.
true if the specified SDK reference has the same version as the specified result, otherwise false.
Used for unit tests only. This is currently only called through reflection in Microsoft.Build.Engine.UnitTests.TransientSdkResolution.CallResetForTests
An to use for loading SDK resolvers.
Explicit set of SdkResolvers to use for all SDK resolution.
A base class for "hosted" ISdkResolverService implementations which are registered by an .
An event to signal for waiting threads when the is being shut down.
The current which is hosting this component.
An internal implementation of .
An internal implementation of .
Helper class for maintaining the component collection
The build component factories.
The host used to initialize components.
Constructor.
The creation pattern to use for this component.
The component should be created as a singleton.
A new instance of the component should be created with every request.
Registers the default factories.
Shuts down all factories registered to this component factory collection.
Shuts down a specific singleton component.
Registers a factory to replace one of the defaults. Creation pattern is inherited from the original.
The type which is created by this factory.
The factory to be registered.
Registers a factory to replace one of the defaults. Creation pattern is inherited from the original.
The type which is created by this factory.
The instance to be registered.
Adds a factory.
The type which is created by this factory.
Delegate which is responsible for creating the Component.
Creation pattern.
Gets an instance of the specified component type from the host.
The component type to be retrieved
The component
A helper class wrapping build components.
The factory used to construct instances of the component.
The singleton instance for components which adhere to the singleton pattern.
Constructor.
Constructor for existing singleton.
Retrieves the component type.
Retrieves the creation pattern.
Gets an instance of the component.
Shuts down the single instance for this component type.
Defines a cache for registered task objects.
Disposes of all of the objects with the specified lifetime.
Registers a task object with the specified key and lifetime.
Gets a previously registered task object.
Unregisters a task object.
This is a cache of objects which are registered to be disposed of at a specified time.
The cache for AppDomain lifetime objects.
The cache for Build lifetime objects.
Static constructor which registers a callback to dispose of AppDomain-lifetime cache objects.
Disposes of all of the cached objects registered with the specified lifetime.
Registers a task object with the specified key and lifetime.
Gets a previously registered task object.
Unregisters a previously registered task object.
Returns true if a collection is not yet created or if it has no content.
Returns the collection associated with a particular lifetime.
Gets the lazy cache for the specified lifetime.
Cleans up a cache collection.
This is a cache of objects which are registered to be disposed of at a specified time.
Finalizer
Initialize the build component.
Shuts down the build component.
Implementation of Dispose pattern.
Component factory.
Implementation of Dispose pattern.
Logging context and helpers for evaluation logging
Log that the project has finished
This class implements the "CallTarget" task, which invokes other targets within the same
project file. Marked RunInMTA because we do not want this task to ever be invoked explicitly
on the STA if the RequestBuilder is running on another thread, as this will cause thread
id validation checks to fail.
The task logging helper
A list of targets to build. This is a required parameter. If you want to build the
default targets, use the task and pass in Projects=$(MSBuildProjectFile).
Array of target names.
Outputs of the targets built in each project.
Array of output items.
When this is true, instead of calling the engine once to build all the targets (for each project),
we would call the engine once per target (for each project). The benefit of this is that
if one target fails, you can still continue with the remaining targets.
Deprecated. Does nothing.
The host object, from ITask
Instructs the MSBuild engine to build one or more targets in the current project.
true if all targets built successfully; false if any target fails
The factory
Constructor
Returns the factory name
Returns the task type.
Initialize the factory.
Gets all of the parameters on the task.
Creates an instance of the task.
Cleanup for the task.
Helper class to convert ItemGroup parameters to a string value for logging.
The default character limit for logging parameters. 10k is somewhat arbitrary, see https://github.com/microsoft/msbuild/issues/4907.
The default parameter limit for logging. 200 is somewhat arbitrary, see https://github.com/microsoft/msbuild/pull/5210.
by itself doesn't have the implementation
to materialize the Message as that's a declaration assembly. We inject the logic
here.
Gets a text serialized value of a parameter for logging.
Given an object wrapping a scalar value that will be set on a task,
returns a suitable string to log its value, with a trailing newline.
First line is already indented.
Indent of any subsequent line should be 12 spaces.
This class implements the "MSBuild" task, which hands off child project files to the MSBuild engine to be built.
Enum describing the behavior when a project doesn't exist on disk.
Skip the project if there is no file on disk.
Error if the project does not exist on disk.
Build even if the project does not exist on disk.
The build engine, from ITask
The host object, from ITask
A list of property name/value pairs to apply as global properties to
the child project.
A typical input: "propname1=propvalue1", "propname2=propvalue2", "propname3=propvalue3".
The fact that this is a string[] makes the following illegal:
The engine fails on this because it doesn't like item lists being concatenated with string
constants when the data is being passed into an array parameter. So the workaround is to
write this in the project file:
Gets or sets a semicolon-delimited list of global properties to remove.
The targets to build in each project specified by the property.
Array of target names.
The projects to build.
Array of project items.
Outputs of the targets built in each project.
Array of output items.
Indicates if the paths of target output items should be rebased relative to the calling project.
true, if target output item paths should be rebased
Forces the task to stop building the remaining projects as soon as any of
them fail.
When this is true, instead of calling the engine once to build all the targets (for each project),
we would call the engine once per target (for each project). The benefit of this is that
if one target fails, you can still continue with the remaining targets.
Value of ToolsVersion to use when building projects passed to this task.
When this is true we call the engine with all the projects at once instead of
calling the engine once per project
If true the project will be unloaded once the operation is completed
Deprecated. Does nothing.
When this is true, project files that do not exist on the disk will be skipped. By default,
such projects will cause an error.
Un-escape Targets, Properties (including Properties and AdditionalProperties as Project item metadata)
will be un-escaped before processing. e.g. %3B (an escaped ';') in the string for any of them will
be treated as if it were an un-escaped ';'
If set, MSBuild will skip the targets specified in this build request if they are not defined in the
to build. This only applies to this build request (if another target calls the
"missing target" later this will still result in an error).
This could be useful when implementing a breaking protocol change between projects or stubbing behavior
which may not make sense in all project types (e.g. Restore).
Instructs the MSBuild engine to build one or more project files whose locations are specified by the
property.
true if all projects build successfully; false if any project fails
Build projects which have not been skipped. This will be done in parallel
Expand and re-construct arrays of all targets and properties
The state enumeration for SchedulableRequests.
This request has been submitted but has never been scheduled so it has executed no tasks and does not currently have an
entry residing on any node. There may be multiple requests with the same global request id in this state.
This request may continue executing. It already has an entry on a node. There may only ever be one request with a given
global request id in this state.
This request is currently executing tasks on its node. In this case it will be the only task executing on the node -
all other tasks are either Ready or Blocked. There may only ever be one request with a given global request id in this state.
This request is currently blocked on one or more requests which must complete before it may continue. There may only ever be one
request with a given global request id in this state.
This request has yielded control of the node while it is running a long-running out-of-process program. Any number of tasks on a
node may be in the yielding state.
This request has completed and removed from the system.
A representation of a BuildRequest and associated data used by the Scheduler to track work being done by the build system.
SchedulableRequests implicitly form a directed acyclic graph showing the blocking/blocked relationship between the requests
known to the system at any given time. These associations are updated by the BlockByRequest, UnblockWithResult and ResumeExecution
methods. These methods, along with Complete, cause state changes which the SchedulingData object will record. That data can be
queried to determine the state of any request or node in the system.
The request collection to which this belongs.
The current state.
The node to which this request is assigned.
The BuildRequest this class represents.
The schedulable request which issued this request.
The list of targets which were actively building at the time we were blocked.
The requests which must complete before we can continue executing. Indexed by global request id and node request id.
Each global request id may have multiple requests which map to it, but they will have separate node request ids.
The requests which cannot continue until we have finished executing.
The time this request was created.
The time this request started building.
The time this request was completed.
Records of the amount of time spent in each of the states.
Constructor.
The current state of the request.
The underlying BuildRequest.
The request which issued this request.
Returns the node to which this request is assigned.
The set of active targets.
The target we are blocked on
Gets a count of the requests we are blocked by.
Gets the set of requests for which we require results before we may proceed.
Gets a count of the requests we are blocking.
Gets the set of requests which cannot proceed because they are waiting for results from us.
The time this request was created.
The time this request started building.
The time this request was completed.
Number of cores granted as part of running the build request.
Gets the amount of time we spent in the specified state.
Inticates the request is yielding the node.
Indicates the request is ready to reacquire the node.
Marks this request as being blocked by the specified request. Establishes the correct relationships between the requests.
The request which is blocking this one.
The list of targets this request was currently building at the time it became blocked.
Target that we are blocked on which is being built by
Indicates that there are partial results (project producing the result is still running) which can be used to unblock this request. Updates the relationships between requests.
Indicates that there are results which can be used to unblock this request. Updates the relationships between requests.
Resumes execution of the request on the specified node.
Completes this request.
Removes an unscheduled request.
Verifies that the current state is as expected.
Verifies that the current state is as expected.
Change to the specified state. Update internal counters.
Detects a circular dependency. Throws a CircularDependencyException if one exists. Circular dependencies can occur
under the following conditions:
1. If the blocking request's global request ID appears in the ancestor chain (Direct).
2. If a request appears in the ancestor chain and has a different global request ID but has an active target that
matches one of the targets specified in the blocking request (Direct).
3. If the blocking request exists elsewhere as a blocked request with the same global request ID, and one of its children
(recursively) matches this request's global request ID (Indirect).
4. If the blocking request's configuration is part of another request elsewhere which is also blocked, and that request
is building targets this blocking request is building, and one of that blocked request's children (recursively)
matches this request's global request ID (Indirect).
Detects a circular dependency where the request which is about to block us is already blocked by us, usually as a result
of it having been previously scheduled in a multiproc scenario, but before this request was able to execute.
Let A be 'this' project and B be 'blockingRequest' (the request which is going to block A.)
An indirect circular dependency exists if there is a dependency path from B to A. If there is no
existing blocked request B' with the same global request id as B, then there can be no path from B to A because B is a brand new
request with no other dependencies. If there is an existing blocked request B' with the same global request ID as B, then we
walk the set of dependencies recursively searching for A. If A is found, we have a circular dependency.
Build our ancestor list then throw the circular dependency error.
Detects a circular dependency where the blocking request is in our direct ancestor chain.
Removes associations with all blocking requests and throws an exception.
Removes the association between this request and the one we are blocked by.
A key for blocking requests combining the global request and node request ids.
The global request id.
The request id known to the node.
Constructor over a request.
Constructor over a result.
Equals override.
GetHashCode override.
This class manages the set of schedulable requests. In concert with SchedulableRequest, it tracks all relationships
between requests in the system, verifies state change validity and provides efficient methods for querying request relationships.
Maps global request Id to an executing request.
Maps global request Id to a blocked request.
Maps global request Id to a blocked request.
Maps global request Id to a ready request.
Holds all of the unscheduled requests.
Maps a schedulable request directly to the node holding it in the linked list. This allows us to perform an O(1) operation to
remove the node from the linked list without exposing the list directly.
Maps node id to the requests scheduled on it.
Maps a node id to the currently executing request, if any.
Maps a node id to those requests which are ready to execute, if any.
Maps a node id to the set of configurations assigned to it.
Maps a configuration id to the node to which it is assigned.
Maps a configuration id to the requests which apply to it.
The sum of number of cores explicitly granted to all build requests.
This is the hierarchy of build requests as they were created.
The sequence of events which have taken place during this build.
The current time for events. This is set by the scheduler when it does a scheduling cycle in response to an event.
Constructor.
Retrieves all of the build events.
Retrieves all of the executing requests.
Gets a count of all executing requests.
Retrieves all of the ready requests.
Gets a count of all the ready requests.
Gets the total number of cores granted to executing and yielding build requests.
Retrieves all of the blocked requests.
Gets a count of all of the blocked requests.
Retrieves all of the yielded requests.
Gets a count of all of the yielded requests.
Retrieves all of the unscheduled requests.
Gets a count of all the unscheduled requests.
Enumerates the unscheduled requests which don't have other instances scheduled already.
Gets all of the configurations for this build.
Gets or sets the current event time.
Creates a new request and adds it to the system
New requests always go on the front of the queue, because we prefer to build the projects we just received first (depth first, absent
any particular scheduling algorithm such as in the single-proc case.)
Updates the state of the specified request.
Gets the requests assigned to a particular configuration.
Retrieves the number of requests which exist in the system that are attributed to the specified configuration.
Retrieves a request which is currently executing.
Retrieves a request which is currently blocked.
Retrieves a request which is currently blocked, or null if there is none.
Retrieves a request which is currently yielding.
Retrieves a request which is ready to continue executing.
Retrieves a request which has been assigned to a node and is in the executing, yielding, blocked, or ready states.
Returns true if the specified node has an executing request, false otherwise.
Returns the number of configurations assigned to the specified node.
Gets the request currently executing on the node.
Determines if the specified request is currently scheduled.
Retrieves the count all of the requests scheduled to the specified node.
Retrieves all of the requests scheduled to the specified node.
Retrieves all of the ready requests on the specified node.
Retrieves a set of build requests which have the specified parent. If root is null, this will retrieve all of the
top-level requests.
Returns the node id to which this request should be assigned based on its configuration.
The node if one has been assigned for this configuration, otherwise -1.
Returns true if the request can be scheduled to the specified node.
Explicitly grants CPU cores to a request.
Explicitly removes previously granted CPU cores from a request.
Unassigns the node associated with a particular configuration.
The operation is only valid when there are no scheduled requests for this configuration.
Gets a schedulable request with the specified global request id if it is currently scheduled.
Verifies that the request is scheduled and in the expected state.
A scheduling event.
The time the event took place.
The request involved in the event.
The state of the request before the event.
The state of the request as a result of the event.
Constructor.
The time the event took place.
The request involved in the event.
The state of the request before the event.
The state of the request as a result of the event.
The MSBuild Scheduler
The invalid node id
ID used to indicate that the results for a particular configuration may at one point
have resided on this node, but currently do not and will need to be transferred back
in order to be used.
The in-proc node id
The virtual node, used when a request is initially given to the scheduler.
If MSBUILDCUSTOMSCHEDULER = CustomSchedulerForSQL, the default multiplier for the amount by which
the count of configurations on any one node can exceed the average configuration count is 1.1 --
+ 10%.
Content of the environment variable MSBUILDSCHEDULINGUNLIMITED
If MSBUILDSCHEDULINGUNLIMITED is set, this flag will make AtSchedulingLimit() always return false
If MSBUILDNODELIMITOFFSET is set, this will add an offset to the limit used in AtSchedulingLimit()
The result of calling NativeMethodsShared.GetLogicalCoreCount() unless overriden with MSBUILDCORELIMIT.
The weight of busy nodes in GetAvailableCoresForExplicitRequests().
{ nodeId -> NodeInfo }
A list of nodes we know about. For the non-distributed case, there will be no more nodes than the
maximum specified on the command-line.
The number of inproc nodes that can be created without hitting the
node limit.
The number of out-of-proc nodes that can be created without hitting the
node limit.
The collection of all requests currently known to the system.
A queue of RequestCores requests waiting for at least one core to become available.
The component host.
The configuration cache.
The results cache.
The next ID to assign for a global request id.
Flag indicating that we are supposed to dump the scheduler state to the disk periodically.
Flag used for debugging by forcing all scheduling to go out-of-proc.
The path into which debug files will be written.
If MSBUILDCUSTOMSCHEDULER = CustomSchedulerForSQL, the user may also choose to set
MSBUILDCUSTOMSCHEDULERFORSQLCONFIGURATIONLIMITMULTIPLIER to the value by which they want
the max configuration count for any one node to exceed the average configuration count.
If that env var is not set, or is set to an invalid value (negative, less than 1, non-numeric)
then we use the default value instead.
The plan.
If MSBUILDCUSTOMSCHEDULER is set, contains the requested scheduling algorithm
Constructor.
In the circumstance where we want to specify the scheduling algorithm via the secret environment variable
MSBUILDCUSTOMSCHEDULING, the scheduling algorithm used will be assigned to a delegate of this type.
Retrieves the minimum configuration id which can be assigned that won't conflict with those in the scheduling plan.
Returns true if the specified configuration is currently in the scheduler.
The configuration id
True if the specified configuration is already building.
Gets a configuration id from the plan which matches the specified path.
The path.
The configuration id which has been assigned to this path.
Reports that the specified request has become blocked and cannot proceed.
Informs the scheduler of a specific result.
Signals that a node has been created.
Information about the nodes which were created.
A new set of scheduling actions to take.
Signals that the build has been aborted by the specified node.
The node which reported the failure.
Resets the scheduler.
Writes out the detailed summary of the build.
The id of the submission which is at the root of the build.
Requests CPU resources.
Returns CPU resources.
Initializes the component with the specified component host.
The component host.
Shuts down the component.
Factory for component construction.
Updates the state of a request based on its desire to yield or reacquire control of its node.
Attempts to schedule unassigned requests to free nodes.
The list which should be populated with responses from the scheduling.
Determines which requests to assign to available nodes.
This is where all the real scheduling decisions take place. It should not be necessary to edit functions outside of this
to alter how scheduling occurs.
Reads in the scheduling plan if one exists and has not previously been read; returns true if the scheduling plan
both exists and is valid, or false otherwise.
Assigns requests to nodes based on those which refer to the most other projects.
Assigns requests to nodes based on those which have the most plan time.
Assigns requests preferring those which are traversal projects as determined by filename.
Returns true if the request is for a traversal project. Traversals are used to find more work.
Assigns requests to nodes attempting to ensure each node has the same number of configurations assigned to it.
Assigns requests with the smallest file sizes first.
Assigns requests with the largest file sizes first.
Assigns requests preferring the ones which have the most other requests waiting on them using the transitive closure.
Assigns requests preferring those with the most requests waiting on them, but only counting those requests which are
directly waiting, as opposed to the transitive closure.
Assigns requests on a first-come, first-serve basis.
Custom scheduler for the SQL folks to solve a performance problem with their builds where they end up with a few long-running
requests on all but one node, and then a very large number of short-running requests on that one node -- which is by design for
our current scheduler, but makes it so that later in the build, when these configurations are re-entered with new requests, the
build becomes essentially serial because so many of the configurations are tied to that one node.
Fixes that problem by intentionally choosing to refrain from assigning new configurations to idle nodes if those idle nodes already
have more than their fair share of the existing configurations assigned to them.
Assigns the specified request to the specified node.
Returns the maximum number of cores that can be returned from a RequestCores() call at the moment.
Returns true if we are at the limit of work we can schedule.
Returns true if a request can be scheduled to a node, false otherwise.
Adds CreateNode responses to satisfy all the affinities in the list of requests, with the following constraints:
a) Issue no more than one response to create an inproc node, and aggressively issues as many requests for an out-of-proc node
as there are requests to assign to them.
b) Don't exceed the max node count, *unless* there isn't even one node of the necessary affinity yet. (That means that even if there's a max
node count of e.g., 3, and we have already created 3 out of proc nodes, we will still create an inproc node if affinity requires it; if
we didn't, the build would jam.)
Returns true if there is a pending response to create a new node.
Marks the specified request and all of its ancestors as having aborted.
Marks the request as being blocked by another request which is currently building a target whose results we need to proceed.
Marks the parent as blocked waiting for results from a results transfer.
Marks the request as being blocked by new requests whose results we must get before we can proceed.
Resumes executing a request which was in the Ready state for the specified node, if any.
Attempts to get results from the cache for this request. If results are available, reports them to the
correct node. If that action causes the parent to become ready and its node is idle, the parent is
resumed.
Satisfies pending resource requests. Requests are pulled from the queue in FIFO fashion and granted as many cores
as possible, optimizing for maximum number of cores granted to a single request, not for maximum number of satisfied
requests.
Determines which work is available which must be assigned to the nodes. This includes:
1. Ready requests - those requests which can immediately resume executing.
2. Requests which can continue because results are now available but we haven't distributed them.
Attempts to get a result from the cache to satisfy the request, and returns the appropriate response if possible.
True if caches misses are allowed, false otherwise
Gets the appropriate ScheduleResponse for a result, either to complete a submission or to report to a node.
Logs the project started/finished pair for projects which are skipped entirely because all
of their results are available in the cache.
This method determines how many requests are waiting for this request, taking into account the full tree of all requests
in all dependency chains which are waiting.
Gets the node affinity for the specified request.
Iterates through the set of available nodes and checks whether any of them is
capable of servicing this request or any of the requests that it is blocked
by (regardless of whether they are currently available to do so).
Determines if we have a matching request somewhere, and if so, assigns the same request ID. Otherwise
assigns a new request id.
UNDONE: (Performance) This algorithm should be modified so we don't have to iterate over all of the
requests to find a matching one. A HashSet with proper equality semantics and a good hash code for the BuildRequest
would speed this considerably, especially for large numbers of projects in a build.
The request whose ID should be assigned
Writes the graph representation of how the nodes were utilized.
Writes a single line of node utilization information.
Recursively dumps the build information for the specified hierarchy
Method used for debugging purposes.
Dumps the current state of the scheduler.
Dumps all of the configurations.
Dumps all of the requests.
Dumps the hierarchy of requests.
Dumps the state of a request.
Dumps detailed information about a request.
Write out the scheduling information so the next time we can read the plan back in and use it.
Retrieves the scheduling plan from the previous run.
Exception thrown when a circular dependency is detected in the Scheduler.
The ancestors which led to this circular dependency.
The request which caused the circular dependency.
Constructor.
Gets an enumeration of the ancestors which led to this circular dependency.
Gets the request which caused the circular dependency.
Class used to track time accumulated during scheduling.
The time the current counter started.
The accumulated time for this counter.
Constructor.
Retrieve the accumulated time.
Start the timer.
End the timer and update the accumulated time.
A SchedulingPlan contains timing and relationship information for a build which has already occurred. This data can then be
used by subsequent builds to determine how best to distribute work among several nodes.
The configuration cache.
The active scheduling data.
Mapping of project full paths to plan configuration data.
Mapping of configuration ids to plan configuration data.
Mapping of configuration ids to the set of configurations which were traversed to get to this configuration.
Constructor.
Returns true if a valid plan was read, false otherwise.
Returns the largest configuration id known to the plan.
Writes a plan for the specified submission id.
Reads a plan for the specified submission Id.
Returns the config id for the config specified by the path, if any.
The config id if one exists, otherwise BuildRequestConfiguration.InvalidConfigurationId
Given a list of configuration IDs, returns the id of the config with the greatest number of immediate references.
The set of configurations to consider.
The id of the configuration with the most immediate references.
Given a list of real configuration IDs, returns the id of the config with the largest plan time.
Determines how many references a config with a particular path has.
Advances the state of the plan by removing the specified config from all paths
Advances the state of the plan by zeroing out the time spend on the config.
Gets the name of the plan file for a specified submission.
Returns the config id with the greatest value according to the comparer.
Analyzes the plan data which has been read.
Writes out configuration in order of the greatest total plan time.
Writes out configs in order of most immediate references.
Writes out configs in order of how often they are seen in the hierarchy.
This method finds all of the paths which lead to any given project
Recursively visits all nodes in the hierarchy.
Finds projects in order of expense and displays the paths leading to them.
Reads the hierarchy from a plan file.
Reads the accumulated time and path information for each configuration from the plan file.
Retrieves the root request for the specified submission id.
The request if one exists, otherwise null.
Writes out all of the dependencies for a specified request, recursively.
Recursively accumulates the amount of time spent in each configuration.
The data associated with a config as read from a build plan.
The configuration id.
The full path to the project.
The amount of time spent in the configuration.
The total time of all of the references.
The set of references.
The set of referrers.
Constructor.
Gets the configuration id.
Gets the configuration's full path.
Gets the configuration's accumulated time.
Gets the configuration's accumulated time for all of its references.
Retrieves the total time for this configuration, which includes the time spent on its references.
Retrieves the number of references this configuration has.
Retrieves the references from this configuration.
Retrieves the number of configurations which refer to this one.
Retrieves the configurations which refer to this one.
Adds the specified configuration as a reference.
Applies the specified duration offset to the configurations which refer to this one.
A struct representing the uniquely-identifying portion of a BuildRequestConfiguration. Used for lookups.
Constructor over a BuildRequestConfiguration.
Constructor over a Project.
Constructor taking individual arguments.
The full path to the project to build.
The tools version specified for the configuration.
Always specified.
May have originated from a /tv switch, or an MSBuild task,
or a Project tag, or the default.
The set of global properties which should be used when building this project.
This override is used to provide a hash code for storage in dictionaries and the like.
If two objects are Equal, they must have the same hash code, for dictionaries to work correctly.
Two configurations are Equal if their global properties are equivalent, not necessary reference equals.
So only include filename and tools version in the hashcode.
A hash code
Determines object equality
The object to compare with
True if they contain the same data, false otherwise
Equality of the configuration is the product of the equality of its members.
The other configuration to which we will compare ourselves.
True if equal, false otherwise.
Compares this object with another for equality
The object with which to compare this one.
True if the objects contain the same data, false otherwise.
The type of response.
There were no matching results, or some implicit targets need to be built.
All explicit and implicit targets have results.
Container for results of IResultsCache.SatisfyRequest
The results type.
The actual results, if the request was satisfied.
The subset of explicit targets which must be built because there are no results for them in the cache.
Constructor.
The response type.
This is an implementation of INodeEndpoint for the out-of-proc nodes. It acts only as a client.
The build component host
Instantiates an endpoint to act as a client
The name of the pipe to which we should connect.
The component host.
Whether this node may be reused for a later build.
Whether this node is low priority.
Returns the host handshake for this node endpoint
Used to return a matched pair of endpoints for in-proc nodes to use with the Build Manager.
The endpoint destined for use by a node.
The endpoint destined for use by the Build Manager
Creates an endpoint pair
The node-side endpoint.
The manager-side endpoint.
The NodeManager class is responsible for marshalling data to/from the NodeProviders and organizing the
creation of new nodes on request.
The invalid node id
The node provider for the in-proc node.
The node provider for out-of-proc nodes.
The build component host.
Mapping of manager-produced node IDs to the provider hosting the node.
The packet factory used to translate and route packets
The next node id to assign to a node.
The nodeID for the inproc node.
Flag indicating when the nodes have been shut down.
BUGBUG: This is a fix which corrects an RI blocking BVT failure. The real fix must be determined before RTM.
This must be investigated and resolved before RTM. The apparent issue is that a design-time build has already called EndBuild
through the BuildManagerAccessor, and the nodes are shut down. Shortly thereafter, the solution build manager comes through and calls EndBuild, which throws
another Shutdown packet in the queue, and causes the following build to stop prematurely. This is all timing related - not every sequence of builds seems to
cause the problem, probably due to the order in which the packet queue gets serviced relative to other threads.
It appears that the problem is that the BuildRequestEngine is being invoked in a way that causes a shutdown packet to appear to overlap with a build request packet.
Interactions between the in-proc node communication thread and the shutdown mechanism must be investigated to determine how BuildManager.EndBuild is allowing itself
to return before the node has indicated it is actually finished.
Tracks whether ShutdownComponent has been called.
Constructor.
Creates a node on an available NodeProvider, if any..
The configuration to use for the remote node.
The to use.
A NodeInfo describing the node created, or null if none could be created.
Sends data to the specified node.
The node.
The packet to send.
Shuts down all of the connected managed nodes.
Flag indicating if nodes should prepare for reuse.
Shuts down all of managed nodes permanently.
Initializes the component
The component host
Shuts down the component.
Reset the state of objects in the node manager which need to be reset between builds.
Registers the specified handler for a particular packet type.
The packet type.
The factory for packets of the specified type.
The handler to be called when packets of the specified type are received.
Unregisters a packet handler.
The packet type.
Takes a serializer, deserializes the packet and routes it to the appropriate handler.
The node from which the packet was received.
The packet type.
The translator containing the data from which the packet should be reconstructed.
Routes the specified packet. This is called by the Inproc node directly since it does not have to do any deserialization
The node from which the packet was received.
The packet to route.
Factory for component creation.
We have received the node shutdown packet for this node, we should remove it from our list of providers.
Attempts to create a node on the specified machine using the specified provider.
The provider used to create the node.
The to use.
The id of the node created.
The NodeManager class is responsible for marshalling data to/from the NodeProviders and organizing the
creation of new nodes on request.
The node provider for task hosts.
The build component host.
Tracks whether ShutdownComponent has been called.
Constructor.
Creates a node on an available NodeProvider, if any..
The configuration to use for the remote node.
The to use.
A NodeInfo describing the node created, or null if none could be created.
Sends data to the specified node.
The node.
The packet to send.
Shuts down all of the connected managed nodes.
Flag indicating if nodes should prepare for reuse.
Shuts down all of the managed nodes permanently.
Initializes the component
The component host
Shuts down the component.
Reset the state of objects in the node manager which need to be reset between builds.
Registers the specified handler for a particular packet type.
The packet type.
The factory for packets of the specified type.
The handler to be called when packets of the specified type are received.
Unregisters a packet handler.
The packet type.
Takes a serializer, deserializes the packet and routes it to the appropriate handler.
The node from which the packet was received.
The packet type.
The translator containing the data from which the packet should be reconstructed.
Routes the specified packet. This is called by the Inproc node directly since it does not have to do any deserialization
The node from which the packet was received.
The packet to route.
Factory for component creation.
A packet to encapsulate a BuildEventArg logging message.
Contents:
Build Event Type
Build Event Args
Encapsulates the buildEventArg in this packet.
Constructor for deserialization
Factory for serialization
Translate the TargetOutputs for the target finished event.
An exception representing the case where a TaskHost node failed to launch.
This may happen for example when the TaskHost binary is corrupted.
If you add fields to this class, add a custom serialization constructor and override GetObjectData().
Constructs a standard NodeFailedToLaunchException.
Constructs a standard NodeFailedToLaunchException.
Constructor for deserialization.
Gets the error code (if any) associated with the exception message.
Error code string, or null.
Gets the error code (if any) associated with the exception message.
Error code string, or null.
ISerializable method which we must override since Exception implements this interface
If we ever add new members to this class, we'll need to update this.
This is the packet which is sent in response to a build configuration ID request. When the node generates a new configuration which it has
never seen before, it gives that configuration a temporary, "unresolved" configuration id. The node then asks the Build Request Manager
for the "resolved" configuration id, which is global to all nodes in the system. This packet maps the unresolved to the resolved
configuration id. Once this packet is received, the node engine can then continue processing requests associated with the configuration.
The configuration ID assigned by the node
The configuration ID assigned by the build manager.
The results node assigned to this configuration
Constructor for non-deserialization initialization.
The node-assigned configuration id
The build manager-assigned configuration id
The result node identifier.
Constructor for deserialization
Returns the node-assigned configuration id
Returns the build manager assigned configuration id
Returns the results node for the global configuration.
INodePacket property. Returns the packet type.
Reads/writes this packet
Factory for serialization.
The BuildRequestEngine is responsible for managing the building of projects on a given node. It
receives build requests, reports results and deals with BuildRequestConfiguration transactions.
As it runs on its own thread, all BuildRequestEngine operations are asynchronous.
Internally, the BuildRequestEngine manages the requests in the form of BuildRequestEntry objects.
Each of these maintains the complete state of a build request, accumulating results until completion.
The EngineLoop method is the separate thread proc which handles state changes for BuildRequestEntries
and shutting down. However, each RequestBuilder can call back into the BuildRequestEngine (via events)
to cause new requests to be submitted. See .
The starting unresolved configuration id assigned by the engine.
The starting build request id
The current engine status
Ths component host
The work queue.
The list of current requests the engine is working on.
Mapping of global request ids to the request entries.
The list of requests currently waiting to be submitted from RequestBuilders.
The next available local unresolved configuration Id
The next available build request Id
The global configuration cache
The list of unresolved configurations
The logging context for the node
Flag indicating if we should trace.
The path where we will store debug files
Forces caching of all configurations and results.
Constructor
Raised when a request has completed.
Raised when a request is resumed by the engine itself.
Raised when a new request is generated.
Raised when the engine's status has changed.
Raised when a configuration needs its ID resolved.
Raised when an unexpected exception occurs.
Raised when resources are requested.
Returns the current engine status.
Prepares the build request engine to run a build.
The logging context to use.
Called by the Node. Non-overlapping with other calls from the Node.
Cleans up after a build but leaves the engine thread running. Aborts
any outstanding requests. Blocks until the engine has cleaned up
everything. After this method is called, InitializeForBuild may be
called to start a new build, or the component may be shut down.
Called by the Node. Non-overlapping with other calls from the Node.
Adds a new build request to the request queue.
The request to be added.
Called by the Node. Non-overlapping with other calls from the Node.
Reports a build result to the engine, allowing it to satisfy outstanding requests. This result
is reported to each entry, allowing it the opportunity to determine for itself if the
result applies.
Information needed to unblock the engine.
Called by the Node. Non-overlapping with other calls from the Node.
Notifies the engine of a resource response granting the node resources.
The resource response.
Reports a configuration response to the request, allowing it to satisfy outstanding requests.
The configuration response.
Called by the Node. Non-overlapping with other calls from the Node.
Sets the build component host for this object.
The host.
Called to terminate the functions of this component
Class factory for component creation.
Called when a build request entry has a state change. We should re-evaluate our requests when this happens.
The entry raising the event.
The event's new state.
Raises the OnRequestComplete event.
The request which completed.
The result for the request
Raises the OnRequestResumed event.
The request being resumed.
Raises the OnEngineException event.
The exception being thrown.
Raises the OnNewRequest event.
Information about what is blocking the current request.
Raises the OnStatusChanged event.
The new engine status.
Raises the OnNewConfigurationRequest event.
The configuration which needs resolving.
Changes the engine's status and raises the OnStatsChanged event.
The new engine status.
This method examines the current list of requests to determine if any requests should change
state, possibly reactivating a previously inactive request or removing a now-completed
request from the list.
Check the amount of memory we are using and, if we exceed the threshold, unload cacheable items.
Since this causes synchronous I/O and a stop-the-world GC, it can be very expensive. If
something other than build results is taking up the bulk of the memory space, it may not
free any space. That's caused customer reports of VS hangs resulting from build requests
that are very slow because something in VS is taking all of the memory, but every
project build is slowed down by this codepath. To mitigate this, don't perform these
checks in devenv.exe. On the command line, 32-bit MSBuild may still need to cache build
results on very large builds, but build results are much more likely to be the bulk of
memory usage there.
Makes the specified build request entry the active one, loading the project if necessary.
The entry to activate.
Returns an unused request builder if there are any, or creates a new one.
An IRequestBuilder to use.
Starts to terminate any builder associated with the entry and clean it up in preparation for removal.
The entry to be deactivated
Waits for the builders until they are terminated.
The entry to be deactivated
Raised when the active request needs to build new requests.
The request issuing the requests.
The requests being issued.
Called by the RequestBuilder (implicitly through an event). Non-overlapping with other RequestBuilders.
Called when the request builder needs to block on another request.
Called by the RequestBuilder (implicitly through an event). Non-overlapping with other RequestBuilders.
Called when the request builder needs to request resources.
Dequeue some requests from the unsubmitted request queue and submit them.
This method is responsible for evaluating whether we have enough information to make the request of the Build Manager,
or if we need to obtain additional configuration information. It then issues either configuration
requests or build requests, or both as needed.
The BuildRequestEntry which is making the request
The array of "child" build requests to be issued.
When we receive a build request, we first have to determine if we already have a configuration which matches the
one used by the request. We do this because everywhere we deal with requests and results beyond this function, we
use configuration ids, which are assigned once by the Build Manager and are global to the system. If we do
not have a global configuration id, we can't check to see if we already have build results for the request, so we
cannot send the request out. Thus, first we determine the configuration id.
Assuming we don't have the global configuration id locally, we will send the configuration to the Build Manager.
It will look up or assign the global configuration id and send it back to us.
Once we have the global configuration id, we can then look up results locally. If we have enough results to fulfill
the request, we give them back to the request, otherwise we have to forward the request to the Build Mangager
for scheduling.
Retrieves a new configuration ID
The next unused local configuration ID.
Retrieves a new build request ID
The next build request ID.
This method forms a configuration request from an unresolved configuration and posts it to the
Build Manager.
The configuration to be mapped.
Sends a build request to the Build Manager for scheduling
The information about why the request is blocked.
Queue an action to be run in the engine.
The action to execute.
true if this is the last task for this queue, otherwise false.
This method will return false if an attempt is made to schedule an action after the queue has been shut down.
Method used for debugging purposes.
Struct used to contain information about requests submitted by the RequestBuilder.
The global request id on which we are blocking
The target on which we are blocking
The issuing request
The new requests to issue
Create a new unsubmitted request entry
The build request originating these requests.
The new requests to be issued.
Create a new unsubmitted request entry
The build request originating these requests.
The request on which we are blocked.
The target on which we are blocked.
Delegate is called when the state for a build request entry has changed.
The entry whose state has changed.
The new state value.
The set of states in which a build request entry can be.
There should only ever be one entry in the Active state. This is the request which is
being actively built by the engine - i.e. it has a running task thread. All other requests
must be in one of the other states. When in this state, the outstandingRequest and
receivedResult members must be null.
Transitions:
Waiting: When an msbuild callback is made the active build request needs to wait
for the results in order to continue to process.
Complete: The build request has generated all of the required results.
This state means the node has received all of the results needed to continue processing this
request. When this state is set, the receivedResult member of this entry must be non-null.
The request engine can continue it at some later point when it is no longer busy.
Any number of entries may be in this state.
Transitions:
Active: The build request engine picks this ready request to process.
This state means the node is waiting for results from outstanding build requests. When this
state is set, the outstandingRequest or outstandingConfiguration members of the entry
must be non-null.
Transitions:
Ready: All of the results which caused the build request to wait have been received
This state means the request has completed and results are available. The engine will remove
the request from the list and the results will be returned to the node for processing.
Transitions: None, this is the final state of the build request
BuildRequestEntry holds a build request and associated state data.
Mapping of Build Request Configurations to Build Requests waiting for configuration resolution.
The set of requests to issue. This holds all of the requests as we prepare them. Once their configurations
have all been resolved, we will issue them to the Scheduler in the order received.
The list of unresolved configurations we need to issue.
Mapping of nodeRequestIDs to Build Requests waiting for results.
Mapping of nodeRequestIDs to Build Results.
The ID of the request we are blocked waiting for.
The object used to build this request.
The project's root directory.
Creates a build request entry from a build request.
The originating build request.
The build request configuration.
Raised when the state changes.
Returns the object used to lock for synchronization of long-running operations.
Returns the root directory for the project being built by this request.
Returns the current state of the build request.
Returns the request which originated this entry.
Returns the build request configuration
Returns the overall result for this request.
Returns the request builder.
Informs the entry that it has configurations which need to be resolved.
The configuration to be resolved.
Waits for a result from a request.
The build request
Signals that we are waiting for a specific blocking request to finish.
Waits for a result from a request which previously had an unresolved configuration.
The id of the unresolved configuration.
The id of the resolved configuration.
True if all unresolved configurations have been resolved, false otherwise.
Returns the set of build requests which should be issued to the scheduler.
Returns the list of unresolved configurations to issue.
Returns the list of currently active targets.
This reports a result for a request on which this entry was waiting.
PERF: Once we have fixed up all the result reporting, we can probably
optimize this. See the comment in BuildRequestEngine.ReportBuildResult.
The result for the request.
Unblocks an entry which was waiting for a specific global request id.
Marks the entry as active and returns all of the results needed to continue.
Results are returned as { nodeRequestId -> BuildResult }
The results for all previously pending requests, or null if there were none.
Starts to cancel the current request.
Waits for the current request until it's canceled.
Marks this entry as complete and sets the final results.
The result of the build.
Adds a request to the set of waiting requests.
Updates the state of this entry.
The new state for this entry.
This class represents a build request as it would be received from an MSBuild callback. Such requests have
configurations which have not yet been assigned a global configuration ID, and therefore must be resolved
with the build manager before a formal request can be sent.
This class is called "Fully Qualified" because it completely and directly specifies all of the configuration information.
A standard Build Request only specifies the configuration id, so to get the configuration requires an additional lookup
in a configuration cache.
Initializes a build request.
The configuration to use for the request.
The set of targets to build.
Whether or not to wait for the results of this request.
Whether to skip the constraints of static graph isolation.
Flags specified for the build request.
Returns the configuration for this request.
Returns the set of targets to be satisfied for this request.
Returns true if this request must wait for its results in order to complete.
The set of flags specified in the BuildRequestData for this request.
Implementation of the equality operator.
The left hand argument
The right hand argument
True if the objects are equivalent, false otherwise.
Implementation of the inequality operator.
The left-hand argument
The right-hand argument
True if the objects are not equivalent, false otherwise.
Returns the hash code for this object.
The hash code
Determines equivalence between this object and another.
The object to which this one should be compared.
True if the objects are equivalent, false otherwise.
Determines equivalence with another object of the same type.
The other object with which to compare this one.
True if the objects are equivalent, false otherwise.
Delegate invoked to create a configuration
An interfacing representing a build request configuration cache.
Returns the configuration with the specified id.
The configuration id.
The configuration with the specified id.
Adds the configuration to the cache.
The configuration to add.
Removes the specified configuration from the cache.
The id of the configuration to remove.
Gets the cached configuration which matches the specified configuration
The configuration to match.
The matching configuration if any, null otherwise.
Gets the cached configuration which matches the specified configuration
The configuration metadata to match.
The matching configuration if any, null otherwise.
Gets a matching configuration. If no such configration exists, one is created and optionally loaded.
The configuration metadata to match.
Callback to be invoked if the configuration does not exist.
True if the configuration should also be loaded.
The matching configuration if any, null otherwise.
Returns true if a configuration with the specified id exists in the cache.
The configuration id to check.
True if there is a configuration with the specified id, false otherwise.
Clears out the configurations
Clear non explicltly loaded configurations.
The configuration ids which have been cleared.
Check whether the config cache has more items that the predefined threshold
Unloads any configurations not in use.
True if any configurations were cached, false otherwise.
Implementation of the results cache.
The table of all build results. This table is indexed by configuration id and
contains BuildResult objects which have all of the target information.
Creates an empty results cache.
Returns the internal cache for testing purposes.
Adds the specified build result to the cache
The result to add.
Clears the results for the specified build.
Retrieves the results for the specified build request.
The request for which results should be retrieved.
The build results for the specified request.
Retrieves the results for the specified configuration
The configuration for which results should be returned.
The results, if any
Attempts to satisfy the request from the cache. The request can be satisfied only if:
1. All specified targets in the request have successful results in the cache or if the sequence of target results
includes 0 or more successful targets followed by at least one failed target.
2. All initial targets in the configuration for the request have non-skipped results in the cache.
3. If there are no specified targets, then all default targets in the request must have non-skipped results
in the cache.
The request whose results we should return
The initial targets for the request's configuration.
The default targets for the request's configuration.
If false, a cached skipped target will cause this method to return "NotSatisfied".
If true, then as long as there is a result in the cache (regardless of whether it was skipped or not), this method
will return "Satisfied". In most cases this should be false, but it may be set to true in a situation where there is no
chance of re-execution (which is the usual response to missing / skipped targets), and the caller just needs the data.
A response indicating the results, if any, and the targets needing to be built, if any.
Removes the results for a particular configuration.
The configuration
Cache as many results as we can.
Sets the build component host.
The component host.
Shuts down this component
Factory for component creation.
Looks for results for the specified targets.
The result to examine
The targets to search for
An optional list to be populated with missing targets
If true, a status of "skipped" counts as having valid results
for that target. Otherwise, a skipped target is treated as equivalent to a missing target.
False if there were missing results, true otherwise.
Implements a build request configuration cache.
The configurations
Object used for locking.
Lookup which can be used to find a configuration with the specified metadata.
The maximum cache entries allowed before a sweep can occur.
Creates a new build configuration cache.
Returns the configuration cached under the specified configuration id.
The id of the configuration to return.
The cached configuration.
Returned if a configuration with the specified id is not in the cache.
Adds the specified configuration to the cache.
The configuration to add.
Removes the specified configuration from the cache.
The id of the configuration to remove.
Returns the entry in the cache which matches the specified config.
The configuration to match
A matching configuration if one exists, null otherwise.
Returns the entry in the cache which matches the specified config.
The configuration metadata to match
A matching configuration if one exists, null otherwise.
Gets a matching configuration. If no such configuration exists, one is created and optionally loaded.
Returns true if the cache contains a configuration with the specified id, false otherwise.
The configuration id to check.
True if the cache contains a configuration with this id, false otherwise.
Clear all configurations
Clears configurations from the configuration cache which have not been explicitly loaded.
Set if configurations which have been cleared.
Check whether the config cache has more items that the predefined threshold
Writes out as many configurations to disk as we can, under the assumption that inactive configurations
probably aren't going to be accessed again (the exception is re-entrant builds) and we want to make as much
space as possible now for future projects to load.
True if any configurations were cached, false otherwise.
Gets the enumerator over the configurations in the cache.
Gets the enumerator over the configurations in the cache.
Sets the component host.
The build component host.
Shuts down this component
Factory for component creation.
Override which determines the key for entry into the collection from the specified build request configuration.
The build request configuration.
The configuration id.
Represents a cache for build properties
This interface represents an object which holds build results.
Adds a result to the cache
The result to add.
Deletes all results from the cache for the specified build.
Retrieves a BuildResult for the specified matching BuildRequest.
The request for which the result should be returned.
A BuildResult if there is a matching one in the cache, otherwise null.
Retrieves a BuildResult for the specified configuration.
The configuration for which results should be returned.
A BuildResult if there is a matching one in the cache, otherwise null.
Attempts to satisfy the request from the cache. The request can be satisfied only if:
1. All specified targets in the request have non-skipped results in the cache.
2. All initial targets in the configuration for the request have non-skipped results in the cache.
3. If there are no specified targets, then all default targets in the request must have non-skipped results
in the cache.
The request whose results we should return
The initial targets for the request's configuration.
The default targets for the request's configuration.
If false, a cached skipped target will cause this method to return "NotSatisfied".
If true, then as long as there is a result in the cache (regardless of whether it was skipped or not), this method
will return "Satisfied". In most cases this should be false, but it may be set to true in a situation where there is no
chance of re-execution (which is the usual response to missing / skipped targets), and the caller just needs the data.
A response indicating the results, if any, and the targets needing to be built, if any.
Clears the results for a specific configuration.
The configuration id.
Caches results to disk if possible.
This class is responsible for serializing and deserializing anything that is not
officially supported by ITranslator, but that we still want to do
custom translation of.
Translates a PropertyDictionary of ProjectPropertyInstances.
The tranlator doing the translating
The dictionary to translate.
Deserialize a type or a subtype by its full name. The type must implement ITranslateable
Top level type. Serialized types can be of this type, or subtypes
The provider for out-of-proc nodes. This manages the lifetime of external MSBuild.exe processes
which act as child nodes for the build system.
A mapping of all the nodes managed by this provider.
Constructor.
Returns the node provider type.
Returns the number of available nodes.
Magic number sent by the host to the client during the handshake.
Derived from the binary timestamp to avoid mixing binary versions,
Is64BitProcess to avoid mixing bitness, and enableNodeReuse to
ensure that a /nr:false build doesn't reuse clients left over from
a prior /nr:true build. The enableLowPriority flag is to ensure that
a build with /low:false doesn't reuse clients left over for a prior
/low:true build.
Is reuse of build nodes allowed?
Is the build running at low priority?
Instantiates a new MSBuild process acting as a child node.
Sends data to the specified node.
The node to which data shall be sent.
The packet to send.
Shuts down all of the connected managed nodes.
Flag indicating if nodes should prepare for reuse.
Shuts down all of the managed nodes permanently.
Initializes the component.
The component host.
Shuts down the component
Static factory for component creation.
Method called when a context terminates.
Contains the shared pieces of code from NodeProviderOutOfProc
and NodeProviderOutOfProcTaskHost.
The maximum number of bytes to write
The number of times to retry creating an out-of-proc node.
The amount of time to wait for an out-of-proc node to spool up before we give up.
The amount of time to wait for an out-of-proc node to exit.
The build component host.
Keeps track of the processes we've already checked for nodes so we don't check them again.
Delegate used to tell the node provider that a context has terminated.
The id of the node which terminated.
The build component host.
Sends data to the specified node.
The node to which data shall be sent.
The packet to send.
Shuts down all of the connected managed nodes.
List of the contexts to be shut down
Flag indicating if nodes should prepare for reuse.
Shuts down all of the managed nodes permanently.
Whether to reuse the node
Delegate used to tell the node provider that a context has terminated
Finds or creates a child process which can act as a node.
The pipe stream representing the node.
Finds processes named after either msbuild or msbuildtaskhost.
Item 1 is the name of the process being searched for.
Item 2 is the list of processes themselves.
Generate a string from task host context and the remote process to be used as key to lookup processes we have already
attempted to connect to or are already connected to
Attempts to connect to the specified process.
Creates a new MSBuild process
Identify the .NET host of the current process.
The full path to the executable hosting the current process, or null if running on Full Framework on Windows.
Class which wraps up the communications infrastructure for a given node.
The factory used to create packets from data read off the pipe.
The node id assigned by the node provider.
The node process.
An array used to store the header byte for each packet when read.
A buffer typically big enough to handle a packet body.
We use this as a convenient way to manage and cache a byte[] that's resized
automatically to fit our payload.
A reusable buffer for writing packets.
A queue used for enqueuing packets to write to the stream asynchronously.
A task representing the last packet write, so we can chain packet writes one after another.
We want to queue up writing packets on a separate thread asynchronously, but serially.
Each task drains the
Delegate called when the context terminates.
Tracks the state of the packet sent to terminate the node.
Per node read buffers
Constructor.
Starts a new asynchronous read operation for this node.
Sends the specified packet to this node asynchronously.
The method enqueues a task to write the packet and returns
immediately. This is because SendData() is on a hot path
under the primary lock (BuildManager's _syncLock)
and we want to minimize our time there.
The packet to send.
Schedule a task to drain the packet write queue. We could have had a
dedicated thread that would pump the queue constantly, but
we don't want to allocate a dedicated thread per node (1MB stack)
Usually there'll be a single packet in the queue, but sometimes
a burst of SendData comes in, with 10-20 packets scheduled. In this case
the first scheduled task will drain all of them, and subsequent tasks
will run on an empty queue. I tried to write logic that avoids queueing
a new task if the queue is already being drained, but it didn't show any
improvement and made things more complicated.
Actually writes and sends the packet. This can't be called in parallel
because it reuses the _writeBufferMemoryStream, and this is why we use
the _packetWriteDrainTask to serially chain invocations one after another.
The packet to send.
Avoid having a BinaryWriter just to write a 4-byte int
Closes the node's context, disconnecting it from the node.
Waits for the child node process to exit.
The provider for out-of-proc nodes. This manages the lifetime of external MSBuild.exe processes
which act as child nodes for the build system.
The maximum number of nodes that this provider supports. Should
always be equivalent to the number of different TaskHostContexts
that exist.
Store the path for MSBuild / MSBuildTaskHost so that we don't have to keep recalculating it.
Store the 64-bit path for MSBuild / MSBuildTaskHost so that we don't have to keep recalculating it.
Store the path for the 32-bit MSBuildTaskHost so that we don't have to keep re-calculating it.
Store the path for the 64-bit MSBuildTaskHost so that we don't have to keep re-calculating it.
Store the path for the 32-bit MSBuild so that we don't have to keep re-calculating it.
Store the path for the 64-bit MSBuild so that we don't have to keep re-calculating it.
Name for MSBuild.exe
Name for MSBuildTaskHost.exe
Are there any active nodes?
A mapping of all the nodes managed by this provider.
A mapping of all of the INodePacketFactories wrapped by this provider.
A mapping of all of the INodePacketHandlers wrapped by this provider.
Keeps track of the set of nodes for which we have not yet received shutdown notification.
Packet factory we use if there's not already one associated with a particular context.
Constructor.
Returns the node provider type.
Returns the number of available nodes.
Returns the name of the CLR2 Task Host executable
Instantiates a new MSBuild process acting as a child node.
Sends data to the specified node.
The node to which data shall be sent.
The packet to send.
Sends data to the specified node.
The node to which data shall be sent.
The packet to send.
Shuts down all of the connected managed nodes.
Flag indicating if nodes should prepare for reuse.
Shuts down all of the managed nodes permanently.
Initializes the component.
The component host.
Shuts down the component
Registers the specified handler for a particular packet type.
The packet type.
The factory for packets of the specified type.
The handler to be called when packets of the specified type are received.
Unregisters a packet handler.
The packet type.
Takes a serializer, deserializes the packet and routes it to the appropriate handler.
The node from which the packet was received.
The packet type.
The translator containing the data from which the packet should be reconstructed.
Routes the specified packet
The node from which the packet was received.
The packet to route.
This method is invoked by the NodePacketRouter when a packet is received and is intended for
this recipient.
The node from which the packet was received.
The packet.
Static factory for component creation.
Clears out our cached values for the various task host names and paths.
FOR UNIT TESTING ONLY
Given a TaskHostContext, returns the name of the executable we should be searching for.
Given a TaskHostContext, return the appropriate location of the
executable (MSBuild or MSBuildTaskHost) that we wish to use, or null
if that location cannot be resolved.
Make sure a node in the requested context exists.
Expected to be called when TaskHostTask is done with host of the given context.
Instantiates a new MSBuild or MSBuildTaskHost process acting as a child node.
Method called when a context terminates.
This class is used by objects in the build engine that have the ability to execute themselves in batches, to partition the
items they consume into "buckets", based on the values of select item metadata.
What batching does
Batching partitions the items consumed by the batchable object into buckets, where each bucket
contains a set of items that have the same value set on all item metadata consumed by the object.
Metadata consumed may be unqualified, for example %(m), or qualified by the item list to which it
refers, for example %(a.m).
If metadata is qualified, for example %(a.m), then this is considered distinct to metadata with the
same name on a different item type. For example, %(a.m) is distinct to %(b.m), and items of type ‘b’
are considered to always have a blank value for %(a.m). This means items of type ‘b’ will only be
placed in buckets where %(a.m) is blank. However %(a.m) is equivalent to %(m) on items of type ‘a’.
There is an extra ambiguity rule: every items consumed by the object must have an explicit value for
every piece of unqualified metadata. For example, if @(a), %(m), and %(a.n) are consumed, every item
of type ‘a’ must have a value for the metadata ‘m’ but need not all necessarily have a value for the
metadata ‘n’. This rule eliminates ambiguity about whether items that do not define values for an
unqualified metadata should go in all buckets, or just into buckets with a blank value for
that metadata.
For example
m0
m1
n0
n1
Will produce 5 buckets:
a={a1;a2.m0} b={.}
a={a3.m1} b={.}
a={.} b={b1.n0}
a={.} b={b2;b3.n1}
a={.} b={b4.}
Determines how many times the batchable object needs to be executed (each execution is termed a "batch"), and prepares
buckets of items to pass to the object in each batch.
List containing ItemBucket objects, each one representing an execution batch.
Determines how many times the batchable object needs to be executed (each execution is termed a "batch"), and prepares
buckets of items to pass to the object in each batch.
Any item type that can be considered an implicit input to this batchable object.
This is useful for items inside targets, where the item name is plainly an item type that's an "input" to the object.
List containing ItemBucket objects, each one representing an execution batch.
Of all the item lists that are referenced in this batchable object, which ones should we
batch on, and which ones should we just pass in wholesale to every invocation of the
target/task?
Rule #1. If the user has referenced any *qualified* item metadata such as %(EmbeddedResource.Culture),
then that item list "EmbeddedResource" will definitely get batched.
Rule #2. For all the unqualified item metadata such as %(Culture), we make sure that
every single item in every single item list being passed into the task contains a value
for that metadata. If not, it's an error. If so, we batch all of those item lists.
All other item lists will not be batched, and instead will be passed in wholesale to all buckets.
Dictionary containing the item names that should be batched. If the items match unqualified metadata,
the entire list of items will be returned in the Value. Otherwise, the Value will be empty, indicating only the
qualified item set (in the Key) should be batched.
Partitions the items consumed by the batchable object into buckets, where each bucket contains a set of items that
have the same value set on all item metadata consumed by the object.
PERF NOTE: Given n items and m batching metadata that produce l buckets, it is usually the case that n > l > m,
because a batchable object typically uses one or two item metadata to control batching, and only has a handful of
buckets. The number of buckets is typically only large if a batchable object is using single-item batching
(where l == n). Any algorithm devised for bucketing therefore, should try to minimize n and l in its complexity
equation. The algorithm below has a complexity of O(n*lg(l)*m/2) in its comparisons, and is effectively O(n) when
l is small, and O(n*lg(n)) in the worst case as l -> n. However, note that the comparison complexity is not the
same as the operational complexity for this algorithm. The operational complexity of this algorithm is actually
O(n*m + n*lg(l)*m/2 + n*l/2 + n + l), which is effectively O(n^2) in the worst case. The additional complexity comes
from the array and metadata operations that are performed. However, those operations are extremely cheap compared
to the comparison operations, which dominate the time spent in this method.
List containing ItemBucket objects (can be empty), each one representing an execution batch.
Gets the values of the specified metadata for the given item.
The keys in the dictionary returned may be qualified and/or unqualified, exactly
as they are found in the metadata reference.
For example if %(x) is found, the key is "x", if %(z.x) is found, the key is "z.x".
This dictionary in each bucket is used by Expander to expand exactly the same metadata references, so
%(x) is expanded using the key "x", and %(z.x) is expanded using the key "z.x".
the metadata values
A class that evaluates an ItemGroup or PropertyGroup that is within a target.
Initializes this base class.
The logging context
The project instance
Flag to determine whether or not to log task inputs.
Gets or sets the logging context.
Gets or sets the project instance.
Flag to determine whether or not to log task inputs.
Factory for intrinsic tasks.
The task instance object.
The logging context.
The project instance.
true to log task inputs, otherwise false.
An instantiated intrinsic task.
Called to execute a task within a target. This method instantiates the task, sets its parameters, and executes it.
The lookup used for expansion and to receive created items and properties.
If value is not an empty string, adds it to list.
The list of strings to which this should be added, if it is not empty.
The string to add.
Implementation of the ItemGroup intrinsic task
The task instance data
Instantiates an ItemGroup task
The original task instance data
The logging context
The project instance
Flag to determine whether or not to log task inputs.
Execute an ItemGroup element, including each child item expression
The lookup used for evaluation and as a destination for these items.
Add items to the world. This is the in-target equivalent of an item include expression outside of a target.
The item specification to evaluate and add.
The batching bucket.
An of metadata names to keep.
An of metadata names to remove.
Remove items from the world. Removes to items that are part of the project manifest are backed up, so
they can be reverted when the project is reset after the end of the build.
The item specification to evaluate and remove.
The batching bucket.
Metadata matching.
Options matching.
Modifies items in the world - specifically, changes their metadata. Changes to items that are part of the project manifest are backed up, so
they can be reverted when the project is reset after the end of the build.
The item specification to evaluate and modify.
The batching bucket.
An of metadata names to keep.
An of metadata names to remove.
Adds batchable parameters from an item element into the list. If the item element was a task, these
would be its raw parameter values.
The list of batchable values
The item from which to find batchable values
Takes an item specification, evaluates it and expands it into a list of items
The original item data
The expander to use.
An of metadata names to keep.
An of metadata names to remove.
This code is very close to that which exists in the Evaluator.EvaluateItemXml method. However, because
it invokes type constructors, and those constructors take arguments of fundamentally different types, it has not
been refactored.
A list of items.
Returns a list of all items in the provided item group whose itemspecs match the specification, after it is split and any wildcards are expanded.
If no items match, returns null.
The items to match
The specification to match against the items.
The specification to match against the provided items
The expander to use
A list of matching items
This class is used during ItemGroup intrinsic tasks to resolve metadata references. It consists of three tables:
1. The metadata added during evaluation.
1. The metadata table created for the bucket, may be null.
2. The metadata table derived from the item definition group, may be null.
The table for all metadata added during expansion
The table for metadata which was generated for this batch bucket.
May be null.
The table for metadata from the item definition
May be null.
The item type to which this metadata applies.
Creates a new metadata table aggregating the bucket and item definition tables.
The type of item for which we are doing evaluation.
The metadata table created for this batch bucket. May be null.
The metadata table for the item definition representing this item. May be null.
Retrieves the metadata table used to collect additions.
Gets the specified metadata value. Returns an empty string if none is set.
Gets the specified metadata value for the qualified item type. Returns an empty string if none is set.
Gets the specified metadata value for the qualified item type. Returns null if none is set.
Sets the metadata value.
This class represents a PropertyGroup intrinsic task.
The original task instance data.
Create a new PropertyGroup task.
The task instance data
The logging context
The project instance
Flag to determine whether or not to log task inputs.
Execute a PropertyGroup element, including each child property
The lookup use for evaluation and as a destination for these properties.
Adds batchable parameters from a property element into the list. If the property element was
a task, these would be its raw parameter values.
The list which will contain the batchable values.
The property from which to take the values.
Interface implemented by the Target Builder which allows tasks to invoke targets and build projects.
Invokes the specified targets using Dev9 behavior.
The targets to build.
True to continue building the remaining targets if one fails.
The of the reference.
The results for each target.
The target is run using the data context of the Project, rather than the data context
of the current target. This has the following effects:
1. Data visible to the CALLING target at the time it was first invoked is the only
data which the CALLED target can see. No changes made between the time the CALLING
target starts and the CALLED target starts are visible to the CALLED target.
2. Items and Properties modified by the CALLED target are not visible to the CALLING
target, even after the CALLED target returns. However, any changes made to
items and properties by the CALLING target will override any changes made by the
CALLED target.
Contains information about a target name and reference location.
Construct a target specification.
The name of the target
The location from which it was referred.
Gets or sets the target name
Gets or sets the reference location
This class represents an implementation of INode for in-proc nodes.
The build component host.
The environment at the time the build is started.
The current directory at the time the build is started.
The node logging context.
The build request engine.
The queue of packets we have received but which have not yet been processed.
The event which is set when we receive packets.
The event which is set when we should shut down.
The reason we are shutting down.
The exception, if any, which caused shutdown.
The node endpoint
Handler for engine exceptions.
Handler for new configuration requests.
Handler for blocked request events.
Handler for request completed events.
Handler for resource request events.
Constructor.
Starts up the node and processes messages until the node is requested to shut down.
The exception which caused shutdown, if any.
The reason for shutting down.
Not necessary for in-proc node - we don't serialize.
Not necessary for in-proc node - we don't serialize.
Not necessary for in-proc node - we don't serialize.
Routes the packet to the appropriate handler.
The node id.
The packet.
Event handler for the BuildEngine's OnRequestComplete event.
Event handler for the BuildEngine's OnNewRequest event.
Event handler for the BuildEngine's OnNewConfigurationRequest event.
Event handler for the BuildEngine's OnResourceRequest event.
Event handler for the LoggingService's OnLoggingThreadException event.
Event handler for the BuildEngine's OnEngineException event.
Perform necessary actions to shut down the node.
Dispatches the packet to the correct handler.
Event handler for the node endpoint's LinkStatusChanged event.
Handles the BuildRequest packet.
Handles the BuildRequestConfiguration packet.
Handles the BuildRequestConfigurationResponse packet.
Handles the BuildResult packet.
Handles the NodeConfiguration packet.
Handles the NodeBuildComplete packet.
Handles the ResourceResponse packet.
NodeConfiguration contains all of the information necessary for a node to configure itself for building.
The node id
The system parameters which were defined on the host.
The app domain information needed for setting up AppDomain-isolated tasks.
The forwarding loggers to use.
The logging configuration for the node.
Constructor
The node id.
The build parameters
The forwarding loggers.
The AppDomain setup information.
The logging configuration for the node.
Private constructor for deserialization
Gets or sets the node id
Retrieves the system parameters.
Retrieves the logger descriptions.
Retrieves the app domain setup information.
The logging configuration for the node.
Retrieves the packet type.
Translates the packet to/from binary form.
The translator to use.
Factory for deserialization.
We need to clone this object since it gets modified for each node which is launched.
Native methods used by the backend. This was copied from the oldOM so we can make it stylecop compliant and allow
easier deletion of the native code in the old OM
Null Pointer
Invalid Handle
Start the process with a normal priority class
Do not create a window
Use the standard handles
Create a new console.
Create a new process
Structure that contains the startupinfo
Represents STARTUP_INFO in win32
The size of the structure, in bytes.
Reserved; must be NULL
The name of the desktop, or the name of both the desktop and window station for this process.
A backslash in the string indicates that the string includes both the desktop and window station names
For console processes, this is the title displayed in the title bar if a new console window is created.
If NULL, the name of the executable file is used as the window title instead.
This parameter must be NULL for GUI or console processes that do not create a new console window
If dwFlags specifies STARTF_USEPOSITION, this member is the x offset of the upper left corner of a window if a new window is created, in pixels. Otherwise, this member is ignored
If dwFlags specifies STARTF_USEPOSITION, this member is the y offset of the upper left corner of a window if a new window is created, in pixels. Otherwise, this member is ignored.
If dwFlags specifies STARTF_USESIZE, this member is the width of the window if a new window is created, in pixels. Otherwise, this member is ignored.
If dwFlags specifies STARTF_USESIZE, this member is the height of the window if a new window is created, in pixels. Otherwise, this member is ignored.
If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is created in a console process, this member specifies the screen buffer width, in character columns. Otherwise, this member is ignored.
If dwFlags specifies STARTF_USECOUNTCHARS, if a new console window is created in a console process, this member specifies the screen buffer height, in character rows. Otherwise, this member is ignored.dwFillAttribute
If dwFlags specifies STARTF_USEFILLATTRIBUTE, this member is the initial text and background colors if a new console window is created in a console application. Otherwise, this member is ignored.
A bit field that determines whether certain STARTUPINFO members are used when the process creates a window
If dwFlags specifies STARTF_USESHOWWINDOW, this member can be any of the SW_ constants defined in Winuser.h. Otherwise, this member is ignored.
Reserved for use by the C Run-time; must be zero.
Reserved for use by the C Run-time; must be NULL.
If dwFlags specifies STARTF_USESTDHANDLES, this member is the standard input handle for the process. Otherwise, this member is ignored and the default for standard input is the keyboard buffer.
If dwFlags specifies STARTF_USESTDHANDLES, this member is the standard output handle for the process. Otherwise, this member is ignored and the default for standard output is the console window's buffer.
If dwFlags specifies STARTF_USESTDHANDLES, this member is the standard error handle for the process. Otherwise, this member is ignored and the default for standard error is the console window's buffer.
Structure to contain security attributes from the create process call represents
SECURITY_ATTRIBUTE in win32
The size, in bytes, of this structure. Set this value to the size of the SECURITY_ATTRIBUTES structure
A pointer to a security descriptor for the object that controls the sharing of it.
If NULL is specified for this member, the object is assigned the default security descriptor of the calling process.
This is not the same as granting access to everyone by assigning a NULL discretionary access control list (DACL).
The default security descriptor is based on the default DACL of the access token belonging to the calling process.
By default, the default DACL in the access token of a process allows access only to the user represented by the access token.
If other users must access the object, you can either create a security descriptor with the appropriate access,
or add ACEs to the DACL that grants access to a group of users.
A Boolean value that specifies whether the returned handle is inherited when a new process is created.
If this member is TRUE, the new process inherits the handle.
Process information from the create process call
Represents PROCESS_INFORMATION in win32
A handle to the newly created process. The handle is used to specify the process in all functions that perform operations on the process object.
A handle to the primary thread of the newly created process. The handle is used to specify the thread in all functions that perform operations on the thread object
A value that can be used to identify a process.
The value is valid from the time the process is created until all handles to the process are closed and
the process object is freed; at this point, the identifier may be reused.
A value that can be used to identify a thread. The value is valid from the time the thread is created until all handles to the thread are closed and the thread object is freed; at this point, the identifier may be reused.
Delegate for event raised when a new build request needs to be issued.
The entry issuing the request.
The request to be issued.
Delegate for event raised when a build request has completed.
The entry which completed.
Delegate for event raised when a build request is blocked on another request which is in progress.
The build request entry which is being blocked.
The request on which we are blocked.
The target on which we are blocked.
The partial build result on which we are blocked.
Represents a class which is capable of building BuildRequestEntries.
Raised when a new build request is to be issued.
Raised when the build request is complete.
Raised when a build request is blocked on another one in progress.
Raised when resources are requested.
Builds the request contained in the specified entry.
The logging context for the node.
The entry to be built.
Continues building a request which was previously waiting for results.
Continues building a request which was previously waiting for a resource grant.
Cancels an existing request.
Starts to cancel an existing request.
This method should return immediately after signal the cancel event.
"CancelRequest()" is equal to call "BeginCancel()" and "WaitForCancelCompletion()".
We break "CancelRequest()" to 2 phases, so that we could signal cancel event
to a bunch of requests without waiting, in order to optimize the "cancel build" scenario.
Waits for the cancellation until it's completed, and cleans up the internal states.
This interface is passed to objects which might need to call back into the request builder, such as the Target and Task builders
This method instructs the request builder to build the specified projects using the specified parameters. This is
what is ultimately used by something like an MSBuild task which needs to invoke a project-to-project reference. IBuildEngine
and IBuildEngine2 have BuildProjectFile methods which boil down to an invocation of this method as well.
An array of projects to be built.
The property groups to use for each project. Must be the same number as there are project files.
The tools version to use for each project. Must be the same number as there are project files.
The targets to be built. Each project will be built with the same targets.
True to wait for the results
If set, skip targets that are not defined in the projects to be built.
An Task representing the work which will be done.
This method instructs the request builder that the target builder is blocked on a target which is already in progress on the
configuration due to another request.
The request on which we are blocked.
The target on which we are blocked.
Results so far from the target builder that's blocking
Instructs the RequestBuilder that it may yield its control of the node.
Instructs the RequestBuilder to suspend until the node is reacquired.
Instructs the RequestBuilder that next Build request from a task should post its request
and immediately return so that the thread may be freed up. May not be nested.
Exits the previous MSBuild callback state.
Requests CPU resources from the scheduler.
The object used by the caller for synchronization. The lock on this object must be taken when calling this method.
Number of logical cores being requested.
True to make the request block and wait for at least one core.
Number of logical cores actually granted. If is false, the call can return
zero. Otherwise the return value is positive.
Returns CPU resources to the scheduler.
Number of logical cores being returned.
Represents an object which can build targets for a project.
Builds the specified targets.
The logging context for the project.
The BuildRequestEntry for which we are building targets.
The callback to be used to handle new project build requests.
The targets to build.
The Lookup containing all current items and properties for this target.
The cancellation token used to cancel processing of targets.
A Task representing the work to be done.
Flags indicating the mode in which the task builder should operate.
This entry is necessary to use the enum with binary math. It is never used outside
intermediate calculations.
In this mode, the task engine actually runs the task and retrieves its outputs.
In this mode, the task engine only infers the task's outputs from its <Output> tags.
Interface representing an object which can build tasks.
Executes the specified task, batching it is necessary.
The logging context for the target
The build request entry
The callback to use for handling new build requests.
The node for the task
The mode to use when executing the task.
The lookup used when we are inferring outputs from inputs.
The lookup used when executing the task to get its outputs.
The cancellation token used to cancel processing of the task.
A Task representing the work to be done.
This class represents a collection of items that are homogeneous w.r.t.
a certain set of metadata.
This single object contains all of the data necessary to perform expansion of metadata, properties,
and items.
Metadata in this bucket
The items for this bucket.
When buckets are being created for batching purposes, this indicates which order the
buckets were created in, so that the target/task being batched gets called with the items
in the same order as they were declared in the project file. For example, the first
bucket created gets bucketSequenceNumber=0, the second bucket created gets
bucketSequenceNumber=1, etc.
The entry we enter when we create the bucket.
Private default constructor disallows parameterless instantiation.
Creates an instance of this class using the given bucket data.
Item types being batched on: null indicates no batching is occurring
Hashtable of item metadata values: null indicates no batching is occurring
The to use for the items in the bucket.
A sequence number indication what order the buckets were created in.
Compares this item bucket against the given one. The comparison is
solely based on the values of the item metadata in the buckets.
-1, if this bucket is "less than" the second one
0, if this bucket is equivalent to the second one
+1, if this bucket is "greater than" the second one
Constructs a token bucket object that can be compared against other
buckets. This dummy bucket is a patently invalid bucket, and cannot
be used for any other operations besides comparison.
PERF NOTE: A dummy bucket is intentionally very light-weight, and it
allocates a minimum of memory compared to a real bucket.
An item bucket that is invalid for everything except comparisons.
Returns the object that knows how to handle all kinds of expansion for this bucket.
When buckets are being created for batching purposes, this indicates which order the
buckets were created in, so that the target/task being batched gets called with the items
in the same order as they were declared in the project file. For example, the first
bucket created gets bucketSequenceNumber=0, the second bucket created gets
bucketSequenceNumber=1, etc.
The items for this bucket.
Adds a new item to this bucket.
Leaves the lookup scope created for this bucket.
Contains a list of item and property collections, optimized to allow
- very fast "cloning"
- quick lookups
- scoping down of item subsets in nested scopes (useful for batches)
- isolation of adds, removes, modifies, and property sets inside nested scopes
When retrieving the item group for an item type, each table is consulted in turn,
starting with the primary table (the "top" or "innermost" table), until a table is found that has an entry for that type.
When an entry is found, it is returned without looking deeper.
This makes it possible to let callers see only a subset of items without affecting or cloning the original item groups,
by populating a scope with item groups that are empty or contain subsets of items in lower scopes.
Instances of this class can be cloned with Clone() to share between batches.
When EnterScope() is called, a fresh primary table is inserted, and all adds and removes will be invisible to
any clones made before the scope was entered and anyone who has access to item groups in lower tables.
When LeaveScope() is called, the primary tables are merged into the secondary tables, and the primary tables are discarded.
This makes the adds and removes in the primary tables visible to clones made during the previous scope.
Scopes can be populated (before Adds, Removes, and Lookups) using PopulateWithItem(). This reduces the set of items of a particular
type that are visible in a scope, because lookups of items of this type will stop at this level and see the subset, rather than the
larger set in a scope below.
Items can be added or removed by calling AddNewItem() and RemoveItem(). Only the primary level is modified.
When items are added or removed they enter into a primary table exclusively for adds or removes, instead of the main primary table.
This allows the adds and removes to be applied to the scope below on LeaveScope(). Even when LeaveScope() is called, the adds and removes
stay in their separate add and remove tables: if they were applied to a main table, they could truncate the downward traversal performed by lookups
and hide items in a lower main table. Only on the final call of LeaveScope() can all adds and removes be applied to the outermost table, i.e., the project.
Much the same applies to properties.
For sensible semantics, only the current primary scope can be modified at any point.
Ordered list of scope used for lookup.
Each scope contains multiple tables:
- the main item table (populated with subsets of lists, in order to create batches)
- the add table (items that have been added during execution)
- the remove table (items that have been removed during execution)
- the modify table (item metadata modifications)
- the main property table (populated with properties that are visible in this scope)
- the property set table (changes made to properties)
All have to be consulted to find the items and properties available in the current scope.
We have to keep them separate, because the adds and removes etc need to be applied to the table
below when we leave a scope.
When we are asked for all the items of a certain type using the GetItems() method, we may have to handle items
that have been modified earlier with ModifyItems(). These pending modifications can't be applied immediately to
the item because that would affect other batches. Instead we clone the item, apply the modification, and hand that over.
The problem is that later we might get asked to remove or modify that item. We want to make sure that we record that as
a remove or modify of the real item, not the clone we handed over. So we keep a lookup of (clone, original) to consult.
Construct a lookup over specified items and properties.
Copy constructor (called via Clone() - clearer semantics)
Compares the primary property sets of the passed in lookups to determine if there are properties which are shared between
the lookups. We find these shared property names because this indicates that the current Lookup is overriding the property value of another Lookup
When an override is detected a messages is generated to inform the users that the property is being changed between batches
array or error messages to log
Clones this object, to create another one with its own list, but the same contents.
Then the clone can enter scope and have its own fresh primary list without affecting the other object.
Enters the scope using the specified description.
Callers keep the scope in order to pass it to LeaveScope.
Leaves the specified scope, which must be the active one.
Moves all tables up one: the tertiary table becomes the secondary table, and so on. The primary
and secondary table are merged. This has the effect of "applying" the adds applied to the primary
table into the secondary table.
Leaving an arbitrary scope, just merging all the adds, removes, modifies, and sets into the scope below.
Merge the current scope down into the base scope. This means applying the adds, removes, modifies, and sets
directly into the item and property tables in this scope.
Gets the effective property for the current scope.
taking the name from the provided string within the specified start and end indexes.
If no match is found, returns null.
Caller must not modify the property returned.
Gets the effective property for the current scope.
If no match is found, returns null.
Caller must not modify the property returned.
Gets the items of the specified type that are visible in the current scope.
If no match is found, returns an empty list.
Caller must not modify the group returned.
Populates with an item group. This is done before the item lookup is used in this scope.
Assumes all the items in the group have the same, provided, type.
Assumes there is no item group of this type in the primary table already.
Should be used only by batching buckets, and if no items are passed,
explicitly stores a marker for this item type indicating this.
Populates with an item. This is done before the item lookup is used in this scope.
There may or may not already be a group for it.
Apply a property to this scope.
Implements a true add, an item that has been created in a batch.
Implements a true add, an item that has been created in a batch.
Remove a bunch of items from this scope
Remove an item from this scope
Modifies items in this scope with the same set of metadata modifications.
Assumes all the items in the group have the same, provided, type.
Apply modifies to a temporary result group.
Items to be modified are virtual-cloned so the original isn't changed.
Applies the specified modifications to the supplied item.
Look up the "real" item by using its clone, and return the real item.
See for explanation of the clone table.
Applies a list of modifications to the appropriate in a main table.
If any modifications conflict, these modifications win.
Applies a modification to an item in a table of modifications.
If the item already exists in the table, merges in the modifications; if there is a conflict
the mergeType indicates which should win.
Add/remove/modify/set directly on an outer scope would need to be handled separately - it would apply
directly to the main tables. Our code isn't expected to do this.
When merging metadata, we can deal with a conflict two different ways:
FirstWins = any previous metadata with the name takes precedence
SecondWins = the new metadata with the name takes precedence
A class representing a set of additions, modifications or removal of metadata from items.
Flag indicating if the modifications should be interpreted such that the lack of an explicit entry for a metadata name
means that that metadata should be removed.
A set of explicitly-specified modifications.
Constructor.
When true, metadata which is not explicitly-specified here but which is present on the target
item should be removed. When false, only explicitly-specified modifications apply.
Cloning constructor.
The metadata modifications to clone.
Clones this modification set.
A copy of the modifications.
A flag indicating whether or not there are any changes which might apply.
A flag indicating whether only those metadata explicitly-specified should be retained on a target item.
Applies the modifications from the specified modifications to this one, performing a proper merge.
The set of metadata modifications to merge into this one.
Returns true if this block contains an explicitly-specified modification for the provided metadata name.
The name of the metadata.
True if there is an explicit modification for this metadata, false otherwise.
The return value of this method is unaffected by the property.
Adds metadata to the modification table.
The name of the metadata to add (or change) in the target item.
The metadata value.
Provides an enumeration of the explicit metadata modifications.
Sets or retrieves a modification from the modifications table.
The metadata name.
If is true, this will return a modification with
set to true if the metadata has no other explicitly-specified modification. Otherwise it will return only the explicitly-specified
modification if one exists.
When if false, this is thrown if the metadata
specified does not exist when attempting to retrieve a metadata modification.
A type of metadata modification.
Indicates the metadata value should be kept unchanged.
Indicates the metadata value should be changed.
Indicates the metadata value should be removed.
Represents a modification for a single metadata.
When true, indicates the metadata should be removed from the target item.
The value to which the metadata should be set. If null, the metadata value should be retained unmodified.
A modification which indicates the metadata value should be retained without modification.
A modification which indicates the metadata should be removed.
Constructor for metadata modifications of type Keep or Remove.
The type of modification to make.
Constructor for metadata modifications of type Update.
The new value for the metadata.
Creates a metadata modification of type Keep.
The metadata modification.
Creates a metadata modification of type Update with the specified metadata value.
The new metadata value.
The metadata modification.
Creates a metadata modification of type Remove.
The metadata modification.
When true, this modification indicates the associated metadata should be removed.
When true, this modification indicates the associated metadata should retain its existing value.
The new value of the metadata. Only valid when is false.
Represents an entry in the lookup list.
Class rather than a struct so that it can be modified in the list.
Contains all of the original items at this level in the Lookup
Contains all of the items which have been added at this level in the Lookup
Contails all of the items which have been removed at this level in the Lookup
Contains all of the metadata which has been changed for items at this level in the Lookup.
Schema: { K=type, V= { K=item, V=table of { K=metadata name, V=metadata value }}}
Contains all of the original properties at this level in the Lookup
Contains all of the properties which have been set at this level or above in the Lookup
The managed thread id which entered this scope.
A description of this scope, for error checking
The lookup which owns this scope, for error checking.
Indicates whether or not further levels in the Lookup should be consulted beyond this one
to find the actual value for the desired item or property.
The main table, populated with items that
are initially visible in this scope. Does not
include adds or removes unless it's the table in
the outermost scope.
Adds made in this scope or above.
Removes made in this scope or above.
Modifications made in this scope or above.
The main property table, populated with properties
that are initially visible in this scope. Does not
include sets unless it's the table in the outermost scope.
Properties set in this scope or above.
ID of thread owning this scope
Whether to stop lookups going beyond this scope downwards
The description assigned to this scope.
Leaves the current lookup scope.
Implementation of IRequestBuilder
The dedicated scheduler object.
The event used to signal that this request should immediately terminate.
The event used to signal that this request should wake up from its wait state.
The results used when a build request entry continues.
Queue of actions to call when a resource request is responded to.
The task representing the currently-executing build request.
The cancellation token source for the currently-executing build request.
The build request entry being built.
The component host.
The node logging context
The project logging context
The target builder.
Block type
Flag indicating we are in an MSBuild callback
Flag indicating whether this request builder has been zombied by a cancellation request.
Creates a new request builder.
The event raised when a new build request should be issued.
The event raised when the build request has completed.
The event raised when the build request has completed.
The event raised when resources are requested.
The current block type
We are blocked waiting on a target in progress.
We are blocked waiting for results from child requests.
We are blocked because we have yielded control
We are not blocked at all.
Retrieves the request entry associated with this RequestBuilder.
Returns true if this RequestBuilder has an active build request
Starts a build request
The logging context for the node.
The entry to build.
Continues a build request
Continues a build request after receiving a resource response.
Terminates the build request
Once we have entered this method, no more methods will be invoked on this class (save ShutdownComponent)
as we should no longer be receiving any messages from the BuildManager.
Starts to cancel an existing request.
Waits for the cancellation until it's completed, and cleans up the internal states.
This method instructs the request builder to build the specified projects using the specified parameters. This is
what is ultimately used by something like an MSBuild task which needs to invoke a project-to-project reference. IBuildEngine
and IBuildEngine2 have BuildProjectFile methods which boil down to an invocation of this method as well.
An array of projects to be built.
The property groups to use for each project. Must be the same number as there are project files.
The tools version to use for each project. Must be the same number as there are project files.
The targets to be built. Each project will be built with the same targets.
True to wait for the results
If set, skip targets that are not defined in the projects to be built.
True if the requests were satisfied, false if they were aborted.
This method is called when the current request needs to build a target which is already in progress on this configuration, but which
is being built by another request.
The id of the request on which we are blocked.
The target on which we are blocked.
A BuildResult with results from an incomplete build request.
Yields the node.
Waits for the node to be reacquired.
Enters the state where we are going to perform a build request callback.
Exits the build request callback state.
Requests CPU resources from the scheduler.
Returns CPU resources to the scheduler.
Sets the component host.
The component host.
Shuts down this component
Returns true if this builder is using legacy threading semantics.
This method waits for the specified handles, but will also spawn a request builder "thread" if that event is set.
This mechanism is used to implement running RequestBuilder threads on the main UI thread in VS.
The index of the handle which was signaled.
Class factory for component creation.
Starts the thread used to build
Set some parameters common to all worker threads we use
Asserts that the entry is in the ready state.
Asserts that the entry is in the active state.
Asserts that the entry is in the active or waiting state.
The entry point for the request builder thread.
Launch the project and gather the results, reporting them back to the BuildRequestEngine.
Reports this result to the engine and cleans up.
This is called back when this request needs to issue new requests and possible wait on them. This method will
block the builder's thread if any of the requests require us to wait for their results.
The list of build requests to be built.
The results, or null if the build should terminate.
Gets the results uses to continue the current build request.
Invokes the OnNewBuildRequests event
The requests to be fulfilled.
Invokes the OnBuildRequestCompleted event
Invokes the OnBlockedRequest event
Invokes the OnResourceRequest event
This method is called to reset the current directory to the one appropriate for this project. It should be called any time
the project is resumed.
If the directory does not exist, does nothing.
This is because if the project has not been saved, this directory may not exist, yet it is often useful to still be able to build the project.
No errors are masked by doing this: errors loading the project from disk are reported at load time, if necessary.
Kicks off the build of the project file. Doesn't return until the build is complete (or aborted.)
Saves the current operating environment.
Sets the operationg environment to the initial build environment.
Restores a previously saved operating environment.
Sets the environment block to the set of saved variables.
Clears from the current environment any variables which do not exist in the saved environment
Updates the current environment with values in the saved environment which differ or are not yet set.
Throws if the RequestBuilder has been zombied.
Configure warnings as messages and errors based on properties defined in the project.
The Target Builder is responsible for building a single target within a given project.
The Target Builder is a stack machine which builds project targets. Each time a target needs to be built, it is
pushed onto the stack. The main loop for the Target Builder simply evaluates the top item on the stack to determine
which action to take. These actions comprise the target state machine, as represented by the states of the
TargetEntry object.
When a target completes, all of its outputs are available in the Lookup contained in the TargetEntry. In fact, everything that it changed
in the global state is available by virtue of its Lookup being merged with the current Target's lookup.
For CallTarget tasks, this behavior is not the same. Rather the Lookup from a CallTarget call does not get merged until the calling
Target has completed. This is considered erroneous behavior and 'normal' version of CallTarget will be implemented which does not exhibit
this.
The cancellation token.
The current stack of targets and dependents. The top-most entry on the stack is the target
currently being built.
The component host.
The BuildRequestEntry for which we are building targets.
The lookup representing the project's state.
The callback interface used to invoke new project builds.
The project logging context
The aggregate build result from running the targets
The project instance we are building
Flag indicating whether we are under the influence of the legacy CallTarget's ContinueOnError behavior.
Builds the specified targets.
The logging context for the project.
The BuildRequestEntry for which we are building targets.
The callback to be used to handle new project build requests.
The names of the targets to build.
The Lookup containing all current items and properties for this target.
The to use when building the targets.
The target's outputs and result codes
Sets the component host.
The component host.
Shuts down the component.
Invokes the specified targets using Dev9 behavior.
The targets to build.
True to continue building the remaining targets if one fails.
The of the task.
The results for each target.
Dev9 behavior refers to the following:
1. The changes made during the calling target up to this point are NOT visible to this target.
2. The changes made by this target are NOT visible to the calling target.
3. Changes made by the calling target OVERRIDE changes made by this target.
Forwarding implementation of BuildProjects
Required for interface - this should never be called.
Yields the node.
Reacquires the node.
Enters the MSBuild callback state for asynchronous processing of referenced projects.
Exits the MSBuild callback state.
Requests CPU resources from the scheduler.
This method is called from the .
Returns CPU resources to the scheduler.
This method is called from the .
Class factory for component creation.
Processes the target stack until its empty or we hit a recursive break (due to CallTarget etc.)
Determines if the current target should be skipped, and logs the appropriate message.
True to skip the target, false otherwise.
When a target build fails, we don't just stop building that target; we also pop all of the other dependency targets of its
parent target off the stack. Extract that logic into a standalone method so that it can be used when dealing with targets that
are skipped-unsuccessful as well as first-time failures.
Pushes the list of targets specified onto the target stack in reverse order specified, so that
they will be built in the order specified.
List of targets to build.
The target which should be considered the parent of these targets.
The lookup to be used to build these targets.
True if this should be considered an error target.
True if target stack processing should terminate when the last target in the list is processed.
The reason the target is being built by the parent.
True if we actually pushed any targets, false otherwise.
Represents which state the target entry is currently in.
The target's dependencies need to be evaluated and pushed onto the target stack.
Transitions:
Execution, ErrorExecution
The target is ready to execute its tasks, batched as needed.
Transitions:
ErrorExecution, Completed
The target is ready to provide error tasks.
Transitions:
None
The target has finished building. All of the results are in the Lookup.
Transitions:
None
This class represents a single target in the TargetBuilder. It maintains the state machine for a particular target as well as
relevant information on outputs generated while a target is running.
The BuildRequestEntry to which this target invocation belongs
The specification of the target being built.
The Target being built. This will be null until the GetTargetInstance() is called, which
will cause us to attempt to resolve the actual project instance. At that point
if the target doesn't exist, we will throw an InvalidProjectFileException. We do this lazy
evaluation because the 'target doesn't exist' message is not supposed to be emitted until
the target is actually needed, as opposed to when it is specified, such as in an OnError
clause, DependsOnTargets or on the command-line.
The current state of this entry
The completion state of the target.
The parent entry, which is waiting for us to complete before proceeding.
Why the parent target built this target.
The expander used to expand item and property markup to evaluated values.
The lookup containing our environment.
The build component host.
The target builder callback
A queue of legacy CallTarget lookup scopes to leave when this target is finished.
The cancellation token.
Flag indicating whether we are currently executing this target. Used for assertions.
The current task builder.
The constructor.
The build request entry for the target.
The target builder callback.
The specification for the target to build.
The lookup to use.
The parent of this entry, if any.
The reason the parent built this target.
The Build Component Host to use.
True if the target builder should stop processing the current target stack when this target is complete.
Gets or sets a flag indicating if this entry is the result of being listed as an error target in
an OnError clause.
Sets or sets the location from which this target was referred.
Gets or sets a flag indicating that the target builder should stop processing the target
stack when this target completes.
Retrieves the name of the target.
Gets the current state of the target
The result of this target.
Retrieves the Lookup this target was initialized with, including any modifications which have
been made to it while running.
The target contained by the entry.
The build request entry to which this target belongs.
The target entry for which we are a dependency.
Why the parent target built this target.
Determines equivalence of two target entries. They are considered the same
if their names are the same.
The entry to which we compare this one.
True if they are equivalent, false otherwise.
Retrieves the list of dependencies this target needs to have built and moves the target to the next state.
Never returns null.
A collection of targets on which this target depends.
Runs all of the tasks for this target, batched as necessary.
Retrieves the error targets for this target.
The project logging context.
A list of error targets.
Gathers the results from the target into the base lookup of the target.
The base lookup for this target.
Enters a legacy calltarget scope.
The lookup to enter with.
This method is used by the Target Builder to indicate that the target should run in error mode rather than normal mode.
This method is used by the Target Builder to indicate that a child of this target has failed and that work should not
continue in Completed / Skipped mode. We do not want to mark the state to run in ErrorExecution mode so that the
OnError targets do not run (the target was skipped due to condition so OnError targets should not run).
Leaves all the call target scopes in the order they were entered.
Walks through the set of tasks for this target and processes them by handing them off to the TaskBuilder.
The result of the tasks, based on the last task which ran.
Gets the task execution mode based
The result of the up-to-date check.
The mode to be used to execute tasks.
Verifies that the target's state is as expected.
The actual value
The expected value
Gets the list of parameters which are batchable for a target
PERF: (Refactor) This used to be a method on the target, and it would
cache its values so this would only be computed once for each
target. We should consider doing something similar for perf reasons.
A list of batchable parameters
Resolves the target. If it doesn't exist in the project, throws an InvalidProjectFileException.
Enumeration of the results of target dependency analysis.
This class is used for performing dependency analysis on targets to determine if they should be built/rebuilt/skipped.
Creates an instance of this class for the given target.
Gets the target to perform dependency analysis on.
Target object.
Gets the value of the target's "Inputs" attribute.
Input specification string (can be empty).
Gets the value of the target's "Outputs" attribute.
Output specification string (can be empty).
Compares the target's inputs against its outputs to determine if the target needs to be built/rebuilt/skipped.
The collections of changed and up-to-date inputs returned from this method are valid IFF this method decides an
incremental build is needed.
DependencyAnalysisResult.SkipUpToDate, if target is up-to-date;
DependencyAnalysisResult.SkipNoInputs, if target has no inputs;
DependencyAnalysisResult.SkipNoOutputs, if target has no outputs;
DependencyAnalysisResult.IncrementalBuild, if only some target outputs are out-of-date;
DependencyAnalysisResult.FullBuild, if target is out-of-date
Does appropriate logging to indicate why this target is being built fully or partially.
Returns a string indicating why a full build is occurring.
Returns a string indicating why an incremental build is occurring.
Extract only the unique inputs and outputs from all the inputs and outputs gathered
during depedency analysis
Parses the target's "Inputs" and "Outputs" attributes and gathers up referenced items.
Determines if the target needs to be built/rebuilt/skipped if it has no inputs (because they evaluated to empty).
Determines if the target needs to be built/rebuilt/skipped if it has no outputs (because they evaluated to empty).
Indication of how to build the target.
Determines if the target needs to be built/rebuilt/skipped if it has discrete inputs.
Indication of how to build the target.
Determines if the target needs to be built/rebuilt/skipped if its inputs and outputs can be correlated.
The set of items which are in the inputs
The set of items which are in the outputs.
A list of item types referenced in both the inputs and the outputs
The inputs which are "changed" and require a build
The inpurt which are "up to date" and do not require a build
Indication of how to build the target.
Determines if the target needs to be built/rebuilt/skipped if it has discrete outputs.
Indication of how to build the target.
Separates item vectors from discrete items, and discards duplicates. If requested, item vector transforms are also
separated out. The item vectors (and the transforms) are partitioned by type, since there can be more than one item
vector of the same type.
The item vector collection is a table of tables, where the top-level table is indexed by item type, and
each "partition" table is indexed by the item vector itself.
Collection for item vectors
Collection for transforms if they should be collected separately, else null
Retrieves the item-specs of all items in the given item vector collection.
list of item-specs
Retrieves the item-specs of all items of the specified type in the given item vector collection.
list of item-specs
Finds the differences in the keys between the two given hashtables.
Compares the set of files/directories designated as "inputs" against the set of files/directories designated as
"outputs", and indicates if any "output" file/directory is out-of-date w.r.t. any "input" file/directory.
NOTE: Internal for unit test purposes only.
true, if any "input" is newer than any "output", or if any input or output does not exist.
Record the unique input and output files so that the "up to date" message
can list them in the log later.
Compares the file/directory designated as "input" against the file/directory designated as "output", and indicates if
the "output" file/directory is out-of-date w.r.t. the "input" file/directory.
If the "input" does not exist on disk, we treat its disappearance as a change, and consider the "input" to be newer
than the "output", regardless of whether the "output" itself exists.
true, if "input" is newer than "output"
Add timestamp comparison results to a list, to log them together later.
Compares the last-write times of the given files/directories.
Existing files/directories are always considered newer than non-existent ones, and two non-existent files/directories
are considered to have the same last-write time.
[out] indicates if the first file/directory does not exist on disk
[out] indicates if the second file/directory does not exist on disk
-1 if the first file/directory is older than the second;
0 if the files/directories were both last written to at the same time;
+1 if the first file/directory is newer than the second
By default we do not sort target inputs and outputs as it has significant perf impact.
But allow suites to enable this so they get consistent results.
The unique target inputs.
The unique target outputs.
Why TLDA decided this entry was out of date
A logging detail entry. Describes what TLDA decided about inputs / outputs
The reason that we are logging this entry
The input item name (can be null)
The output item name (can be null)
The input file
The output file
Construct a log detail element
Input file
Output file
Input item name (can be null)
Output item name (can be null)
The reason we are logging
The possible values for a task's ContinueOnError attribute.
If the task fails, error and stop.
If the task fails, error and continue.
If the task fails, warn and continue.
The TaskBuilder is one of two components related to building tasks, the other being the TaskExecutionHost. The TaskBuilder is
responsible for all parts dealing with the XML/task declaration. It determines if the task is intrinsic or extrinsic,
looks up the task in the task registry, determines the task parameters and requests them to be set, and requests outputs
when task execution has been completed. It is not responsible for reflection over the task instance or anything which
requires dealing with the task instance directly - those actions are handled by the TaskExecutionHost.
The Build Request Entry for which this task is executing.
The cancellation token
The build component host.
The original target child instance
The task instance for extrinsic tasks
Host callback for host-aware tasks.
indicates whether to ignore task execution failures
The logging context for the target in which we are executing.
Full path to the project, for errors
The target builder callback.
The task execution host for in-proc tasks.
The object used to synchronize access to the task execution host.
Constructor
Builds the task specified by the XML.
The logging context of the target
The build request entry being built
The target builder callback.
The task instance.
The mode in which to execute tasks.
The lookup to be used for inference.
The lookup to be used during execution.
The to use when executing the task.
The result of running the task batch.
The ExecuteTask method takes a task as specified by XML and executes it. This procedure is comprised
of the following steps:
1. Loading the Task from its containing assembly by looking it up in the task registry
2. Determining if the task is batched. If it is, create the batches and execute each as if it were a non-batched task
3. If the task is not batched, execute it.
4. If the task was batched, hold on to its Lookup until all of the natches are done, then merge them.
Sets the build component host.
The component host.
Shuts down the component.
Class factory for component creation.
Build up a list of all parameters on the task, including those in any Output tags,
in order to find batchable metadata references
The list of parameter values
Called to execute a task within a target. This method instantiates the task, sets its parameters, and executes it.
true, if successful
Execute a single bucket
true if execution succeeded
Returns the set of parameters that can contribute to a task's identity, and their values for this particular task.
Executes the task using an STA thread.
STA thread launching also being used in XMakeCommandLine\OutOfProcTaskAppDomainWrapperBase.cs, InstantiateAndExecuteTaskInSTAThread method.
Any bug fixes made to this code, please ensure that you also fix that code.
Logs a task skipped message if necessary.
Runs an intrinsic task.
Initializes and executes the task.
Recomputes the task's "ContinueOnError" setting.
The bucket being executed.
The task host to use.
There are four possible values:
false - Error and stop if the task fails.
true - Warn and continue if the task fails.
ErrorAndContinue - Error and continue if the task fails.
WarnAndContinue - Same as true.
Execute a task object for a given bucket.
The host used to execute the task.
The logging context.
The task host for the task.
The batching bucket
The task execution mode
The result of running the task.
Gathers task outputs in two ways:
1) Given an instantiated task that has finished executing, it extracts the outputs using .NET reflection.
2) Otherwise, it parses the task's output specifications and (statically) infers the outputs.
The task execution host.
The task execution mode
The bucket to which the task execution belongs.
true, if successful
Uses the given task output specification to (statically) infer the task's outputs.
The lookup
The task output specification
The task parameter name
can be null
can be null
The bucket for the batch.
The task host object which allows tasks to interface with the rest of the build system.
Implementation of IBuildEngineX is thread-safe, so, for example, tasks can log concurrently on multiple threads.
True if the "secret" environment variable MSBUILDNOINPROCNODE is set.
Help diagnose tasks that log after they return.
The build component host
The build request entry
Location of the task node in the original file
The task logging context
True if the task connected to this proxy is alive
The callback used to invoke the target builder.
This reference type is used to block access to a single entry methods of the interface
A client sponsor is a class
which will respond to a lease renewal request and will
increase the lease time allowing the object to stay in memory
Legacy continue on error value per batch exposed via IBuildEngine
Flag indicating if errors should be converted to warnings.
The thread on which we yielded.
Constructor
The component host
The build request entry
The of the task.
An to use to invoke targets and build projects.
Returns true in the multiproc case
If MSBUILDNOINPROCNODE is set, then even if there's only one node in the buildparameters, it will be an out-of-proc node.
Reflects the value of the ContinueOnError attribute.
The line number this task is on
The column number this task is on
The project file this task is in.
Typically this is an imported .targets file.
Unfortunately the interface has shipped with a poor name, so we cannot change it.
Indicates whether or not errors should be converted to warnings.
Sets or retrieves the logging context
For configuring child AppDomains.
Whether or not this is out of proc.
Builds a single project file
Thread safe.
The project file
The list of targets to build
The global properties to use
The outputs from the targets
The tools version to use
True on success, false otherwise.
Builds multiple project files in parallel. This is the method the old MSBuild task invokes.
Thread safe.
The list of projects to build
The set of targets to build
The global properties to use for each project
The outputs for each target on each project
The tools versions to use
Whether to use the results cache
Whether to unload projects when we are done.
True on success, false otherwise.
Builds multiple project files in parallel.
Thread safe.
The list of projects to build
The set of targets to build
The global properties to use for each project
The list of global properties to undefine
The tools versions to use
Should the target outputs be returned in the BuildEngineResult
A structure containing the result of the build, success or failure and the list of target outputs per project
Requests to yield the node.
Thread safe, however Yield cannot be called unless the
last call to Yield or Reacquire was Reacquire.
Requests to reacquire the node.
Thread safe, however Reacquire cannot be called unless the
last call to Yield or Reacquire was Yield.
Logs an error event for the current task
Thread safe.
The event args
Logs a warning event for the current task
Thread safe.
The event args
Logs a message event for the current task
Thread safe.
The event args
Logs a custom event for the current task
Thread safe.
The event args
Builds a single project file
Thread safe.
The project file name
The set of targets to build.
The global properties to use
The outputs from the targets
True on success, false otherwise.
Disposes of all of the objects with the specified lifetime.
Gets a previously registered task object.
Unregisters a task object.
Logs a telemetry event for the current task.
The event name.
The list of properties associated with the event.
Gets the global properties for the current project.
An containing the global properties of the current project.
Enables or disables emitting a default error when a task fails without logging errors
Contains all warnings that should be logged as errors.
Non-null empty set when all warnings should be treated as errors.
Contains all warnings that should be logged as errors.
Non-null empty set when all warnings should be treated as errors.
Determines if the given warning should be treated as an error.
True if the warning should not be treated as a message and WarningsAsErrors is an empty set or contains the given warning code.
Additional cores granted to the task by the scheduler. Does not include the one implicit core automatically granted to all tasks.
True if the one implicit core has been allocated by , false otherwise.
Total number of cores granted to the task, including the one implicit core.
Allocates shared CPU resources. Called by a task when it's about to do potentially multi-threaded/multi-process work.
The number of cores the task wants to use.
The number of cores the task is allowed to use given the current state of the build. This number is always between
1 and . If the task has allocated its one implicit core, this call may block, waiting for
at least one core to become available.
Frees shared CPU resources. Called by a task when it's finished doing multi-threaded/multi-process work.
The number of cores the task wants to return. This number must be between 0 and the number of cores
granted and not yet released.
Frees all CPU resources granted so far.
Called by the internal MSBuild task.
Does not take the lock because it is called by another request builder thread.
InitializeLifetimeService is called when the remote object is activated.
This method will determine how long the lifetime for the object will be.
The lease object to control this object's lifetime.
Indicates to the TaskHost that it is no longer needed.
Called by TaskBuilder when the task using the EngineProxy is done.
Determine if the event is serializable. If we are running with multiple nodes we need to make sure the logging events are serializable. If not
we need to log a warning.
Async version of BuildProjectFilesInParallel.
The list of projects to build
The set of targets to build
The global properties to use for each project
The list of global properties to undefine
The tools versions to use
Should the target outputs be returned in the BuildEngineResult
If set, skip targets that are not defined in the projects to be built.
A Task returning a structure containing the result of the build, success or failure and the list of target outputs per project
Verify the task host is active or not
Thread safe.
A build request contains information about the configuration used to build as well
as which targets need to be built.
The invalid global request id
The invalid node request id
The results transfer request id
The submission with which this request is associated.
The configuration id.
The global build request id, assigned by the Build Manager
The global request id of the request which spawned this one.
The build request id assigned by the node originating this request.
The build event context of the parent
The build event context of this request
Whether or not the issued in response to this request should include .
Filter describing properties, items, and metadata of interest for this request.
Constructor for serialization.
Initializes a build request with a parent context.
The id of the build submission.
The id of the node issuing the request
The configuration id to use.
Host services if any. May be null.
Additional flags for the request.
Filter for desired build results.
Initializes a build request with a parent context.
The id of the build submission.
The id of the node issuing the request
The configuration id to use.
The targets to be built
Host services if any. May be null.
The build event context of the parent project.
The parent build request, if any.
Additional flags for the request.
Filter for desired build results.
Private constructor for deserialization
Returns true if the configuration has been resolved, false otherwise.
Returns the submission id
Returns the configuration id
Gets the global request id
Gets the global request id of the parent request.
Gets the node request id
The targets specified when the request was made. Doesn't include default or initial targets.
Either this is null or is null;
See . Either this is null, or is null;
Returns the type of packet.
Returns the build event context of the parent, if any.
Returns the build event context for this request, if any.
The of the currently executing task, if any.
Used to correlate a project's build with the parent task that spawned it
(usually the MSBuild task).
The set of flags specified in the BuildRequestData for this request.
Filter describing properties, items, and metadata of interest for this request.
The route for host-aware tasks back to the host
Returns true if this is a root request (one which has no parent.)
Whether static graph isolation constraints should be skipped for this request
Sets the configuration id to a resolved id.
The new configuration id for this request.
Reads/writes this packet
Factory for serialization.
Indicates what the action is for requests which are yielding.
The request is yielding its control of the node.
The request is ready to reacquire control of the node.
There is no yield action
This class is used to inform the Scheduler that a request on a node is being blocked from further progress. There
are two cases for this:
1) The request may be blocked waiting for a target to complete in the same project but which is assigned to
another request.
2) The request may be blocked because it has child requests which need to be satisfied to proceed.
The yield action, if any.
The global request id of the request which is being blocked from continuing.
The set of targets which are currently in progress for the blocked global request ID.
The request on which we are blocked, if any.
The name of the blocking target, if any.
The requests which need to be built to unblock the request, if any.
Constructor for deserialization.
Constructor for the blocker where we are blocked waiting for a target.
Constructor for the blocker where we are blocked waiting for requests to be satisfied.
Constructor for a blocker used by yielding requests.
Constructor for a blocker used by results-transfer requests
The request needing results transferred
Constructor for common values.
Returns the type of packet.
Accessor for the blocked request id.
Accessor for the set of targets currently in progress.
Accessor for the blocking request id, if any.
Accessor for the blocking request id, if any.
Accessor for the blocking build requests, if any.
Accessor for the yield action.
Serialization method.
Factory for serialization.
A build request configuration represents all of the data necessary to know which project to build
and the environment in which it should be built.
The invalid configuration id
This is the ID of the configuration as set by the generator of the configuration. When
a node generates a configuration, this is set to a negative number. The Build Manager will
generate positive IDs
The full path to the project to build.
The tools version specified for the configuration.
Always specified.
May have originated from a /tv switch, or an MSBuild task,
or a Project tag, or the default.
Whether the tools version was set by the /tv switch or passed in through an msbuild callback
directly or indirectly.
The set of global properties which should be used when building this project.
Flag indicating if the project in this configuration is a traversal
Synchronization object. Currently this just prevents us from caching and uncaching at the
same time, causing a race condition. This class is not made 100% threadsafe by the presence
and current usage of this lock.
The project object, representing the project to be built.
The state of a project instance which has been transferred from one node to another.
The project instance properties we should transfer.
and are mutually exclud
The initial targets for the project
The default targets for the project
This is the lookup representing the current project items and properties 'state'.
This is the set of targets which are currently building but which have not yet completed.
{ targetName -> globalRequestId }
The node where this configuration's master results are stored.
Holds a snapshot of the environment at the time we blocked.
Holds a snapshot of the current working directory at the time we blocked.
The target names that were requested to execute.
Initializes a configuration from a BuildRequestData structure. Used by the BuildManager.
Figures out the correct tools version to use, falling back to the provided default if necessary.
May throw InvalidProjectFileException.
The data containing the configuration information.
The default ToolsVersion to use as a fallback
Initializes a configuration from a BuildRequestData structure. Used by the BuildManager.
Figures out the correct tools version to use, falling back to the provided default if necessary.
May throw InvalidProjectFileException.
The configuration ID to assign to this new configuration.
The data containing the configuration information.
The default ToolsVersion to use as a fallback
Creates a new BuildRequestConfiguration based on an existing project instance.
Used by the BuildManager to populate configurations from a solution.
The configuration id
The project instance.
Creates a new configuration which is a clone of the old one but with a new id.
Private constructor for deserialization
Flag indicating whether the configuration is allowed to cache. This does not mean that the configuration will
actually cache - there are several criteria which must for that.
When reset caches is false we need to only keep around the configurations which are being asked for during the design time build.
Other configurations need to be cleared. If this configuration is marked as ExplicitlyLoadedConfiguration then it should not be cleared when
Reset Caches is false.
Flag indicating whether or not the configuration is actually building.
Flag indicating whether or not the configuration has been loaded before.
Flag indicating if the configuration is cached or not.
Flag indicating if this configuration represents a traversal project. Traversal projects
are projects which typically do little or no work themselves, but have references to other
projects (and thus are used to find more work.) The scheduler can treat these differently
in order to fill its work queue with other options for scheduling.
Returns true if this configuration was generated on a node and has not yet been resolved.
Sets or returns the configuration id
Returns the filename of the project to build.
The tools version specified for the configuration.
Always specified.
May have originated from a /tv switch, or an MSBuild task,
or a Project tag, or the default.
Returns the global properties to use to build this project.
Sets or returns the project to build.
Loads the project specified by the configuration's parameters into the configuration block.
Returns true if the default and initial targets have been resolved.
Gets the initial targets for the project
Gets the default targets for the project
Returns the node packet type
Returns the lookup which collects all items and properties during the run of this project.
Retrieves the set of targets currently building, mapped to the request id building them.
Holds a snapshot of the environment at the time we blocked.
Holds a snapshot of the current working directory at the time we blocked.
Whether the tools version was set by the /tv switch or passed in through an msbuild callback
directly or indirectly.
Gets or sets the node on which this configuration's results are stored.
Implementation of the equality operator.
The left hand argument
The right hand argument
True if the objects are equivalent, false otherwise.
Implementation of the inequality operator.
The left-hand argument
The right-hand argument
True if the objects are not equivalent, false otherwise.
Requests that the configuration be cached to disk.
Retrieves the configuration data from the cache.
Gets the list of targets which are used to build the specified request, including all initial and applicable default targets
The request
An array of t
This override is used to provide a hash code for storage in dictionaries and the like.
If two objects are Equal, they must have the same hash code, for dictionaries to work correctly.
Two configurations are Equal if their global properties are equivalent, not necessary reference equals.
So only include filename and tools version in the hashcode.
A hash code
Returns a string representation of the object
String representation of the object
Determines object equality
The object to compare with
True if they contain the same data, false otherwise
Equality of the configuration is the product of the equality of its members.
The other configuration to which we will compare ourselves.
True if equal, false otherwise.
Reads or writes the packet to the serializer.
Factory for serialization.
Applies the state from the specified instance to the loaded instance. This overwrites the items and properties.
Used when we transfer results and state from a previous node to the current one.
Gets the name of the cache file for this configuration.
Deletes the cache file
Clones this BuildRequestConfiguration but sets a new configuration id.
Compares this object with another for equality
The object with which to compare this one.
True if the objects contain the same data, false otherwise.
Determines what the real tools version is.
Gets the translator for this configuration.
This packet is sent by a node to request or release resources from/to the scheduler.
The global request id of the request which is asking for resources.
True if this is a request to acquire resources, false if this is a request to release resources.
True if the request should be blocking until the resources become available. False if the request should
be responded to immediately even if the desired resources are not available.
Number of CPU cores being requested or released.
Constructor for deserialization.
Private constructor, use CreateAcquireRequest or CreateReleaseRequest to make instances.
Factory method for acquiring.
Factory method for releasing.
Returns the type of packet.
Accessor for the global request id.
Accessor for _isResourceAcquire.
Accessor fro _isBlocking.
Accessor for _numCores.
Serialization method.
Factory for serialization.
This packet is sent by the scheduler in response to to grant resources to a node.
The global request id of the request which is being responded to.
Number of CPU cores being granted.
Constructor for deserialization.
Constructor for granting cores.
Returns the type of packet.
Accessor for the global request id.
Accessor for _numCores.
Serialization method.
Factory for serialization.
This class is used by the Scheduler to unblock a blocked build request on the BuildRequestEngine.
There are two cases:
1. The request was blocked waiting on a target in the same project. In this case this class will contain
no information other than the request id.
2. The request was blocked on some set of build requests. This class will then contain the build results
needed to satisfy those requests.
The node request id of the request which is blocked and now will either result or have results reported.
The build result which we wish to report.
Constructor for deserialization.
Constructor for the unblocker where we are blocked waiting for a target.
Constructor for the unblocker where we are blocked waiting for results.
Constructor for the unblocker for circular dependencies
Returns the type of packet.
Accessor for the blocked node request id.
Accessor for the build results, if any.
Serialization method.
Factory for serialization.
An interface representing results for a build request
The exception, if any, generated while the build ran.
The overall build result code.
Returns an enumerator for all target results in this build result
Set of environment variables for the configuration this result came from
The current directory for the configuration this result came from
Gets the results for a target in the build request
The target name
The target results
Returns true if there are results for the specified target
The target name
True if results exist, false otherwise.
The result of executing the task or target.
The work unit was skipped.
The work unit succeeded.
The work unit failed.
The work unit was cancelled.
Indicates whether further work should be done.
Work should proceed with the next work unit.
No further work units should be executed.
A result of executing a target or task.
The result.
The next action to take.
The exception from the failure, if any.
Creates a new work result ready for aggregation during batches.
Creates a work result with the specified result codes.
Translator constructor
Get the result code.
Get the action code.
Get the exception
Translator.
Factory for serialization.
Aggregates the specified result with this result and returns the aggregation.
The rules are:
1. Errors take precedence over success.
2. Success takes precedence over skipped.
3. Stop takes precedence over continue.
4. The first exception in the result wins.
Callback for event raised when a build request is completed
The request which completed
The result for the request
Callback for event raised when a request is resumed
The request being resumed
Callback for event raised when a new build request is generated by an MSBuild callback
Information about what is blocking the engine.
Callback for event raised when the build request engine's status changes.
The new status for the engine
Callback for event raised when a new configuration needs an ID resolved.
The configuration needing an ID
Callback for event raised when a resource is requested.
The resources being requested
Callback for event raised when there is an unhandled exception in the engine.
The exception.
Status types for the build request engine
The engine has not yet been initialized, and cannot accept requests.
The engine has no active or waiting build requests.
The engine is presently working on a build request.
The engine has only build requests which are waiting for build results to continue.
The engine has shut down.
Objects implementing this interface may be used by a Node to process build requests
and generate build results.
Raised when a build request is completed and results are available.
Raised when a build request is resumed from a previously waiting state.
Raised when a new build request is generated by an MSBuild callback.
Raised when the engine status changes.
Raised when a configuration needs an id.
Raised when resources are requested.
Raised when an unhandled exception occurs in the engine.
Gets the current engine status.
Prepares the engine for a new build and spins up the engine thread.
The engine must be in the Idle state, and not already be initialized.
The logging context for the node.
Cleans up after a build but leaves the engine thread running. Aborts
any outstanding requests. Blocks until the engine has cleaned up
everything. After this method is called, InitializeForBuild may be
called to start a new build, or the component may be shut down.
Submits the specified request to the build queue.
The request to build.
It is only valid to call this method when the engine is in the Idle or
Waiting state because the engine can only service one active request at a time.
Notifies the engine of a build result for a waiting build request.
The unblocking information
Notifies the engine of a resource response granting the node resources.
The resource response.
Notifies the engine of a configuration response packet, typically generated by the Build Request Manager. This packet is used to set
the global configuration ID for a specific configuration.
The build configuration response.
Represents a collection of all node providers in the system. Reports events concerning
the topology of the system and provides a means to send and receive data to nodes.
Requests that a new node be created.
The configuration to use to create the node.
The to use.
Information about the node created
Throws an exception if the node could not be created.
Sends a data packet to a specific node
The node to which the data packet should be sent.
The packet to send.
Shuts down all of the managed nodes. This is an asynchronous method - the nodes are
not considered shut down until a NodeShutdown packet has been received.
Flag indicating if nodes should prepare for reuse.
Shuts down all of the managed nodes permanently. This is an asynchronous method - the nodes are
not considered shut down until a NodeShutdown packet has been received.
The node manager contains state which is not supposed to persist between builds, make sure this is cleared.
The type of nodes provided by the node provider.
The provider provides the in-proc node.
The provider provides out-of-proc nodes.
The provider provides remote nodes.
This interface represents a collection of nodes in the system. It provides methods to
enumerate active nodes as well as send data and receive events from those nodes.
The type of nodes provided by this node provider.
The number of nodes this provider can create.
Requests that a new node be created on the specified machine.
The id to assign to the node.
The packet factory used to create packets when data is
received on this node.
The configuration to use to create the remote node.
True if the node was created, false otherwise.
Sends data to a specific node.
The node to which data should be sent.
The packet to be sent.
Shuts down all of the connected, managed nodes. This call will not return until all nodes are shut down.
Flag indicating if nodes should prepare for reuse.
Shuts down all of the managed nodes. This call will not return until all nodes are shut down.
This is an implementation of INodeEndpoint for in-proc nodes. This endpoint can use either
synchronous or asynchronous packet processing methods. When synchronous processing methods are
used, the SendData method will cause the OnDataReceived event on the receiving endpoint to be called
on the same thread, blocking until the handler returns. The asynchronous method more closely emulates
the way other kinds of endpoints work, as the recipient processes the packet on a different thread
than that from which the packet originated, but with the cost of the extra thread.
An object for the two inproc endpoints to synchronize on.
The current communication status of the node.
The communications mode
The peer endpoint
The build component host
The packet factory used to route packets.
Object used as a lock source for the async data
Set when a packet is available in the packet queue
Set when the asynchronous packet pump should terminate
The thread which runs the asynchronous packet pump
Set to true if our peer is connected to us.
The asynchronous packet queue.
Operations on this queue must be synchronized since it is accessible by multiple threads.
Use a lock on the packetQueue itself.
Instantiates a Node and initializes it to unconnected.
The communications mode for this endpoint.
The component host.
Raised when the link status has changed.
Represents the style of communications used by the in-proc endpoint.
The DataReceived event is raised on the same thread as that which called SendData.
The DataReceived event is raised on a separate thread from that which called SendData
Returns the link status of this node.
Causes this endpoint to wait for the remote endpoint to connect
Unused
Causes this node to connect to the matched endpoint.
Unused
Shuts down the link
Sends data to the peer endpoint.
The packet to send.
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.
The communications mode for the endpoints.
The component host.
A matched pair of endpoints.
Invokes the OnLinkStatusChanged event in a thread-safe manner.
The new status of the endpoint link.
This method is called by the other endpoint when it is ready to establish the connection.
This method is called by either side to notify this endpoint that the link is inactive.
This does the actual work of changing the status and shutting down any threads we may have for
disconnection.
Updates the current link status if it has changed and notifies any registered delegates.
The status the node should now be in.
Adds a packet to the packet queue when asynchronous mode is enabled.
The packet to be transmitted.
Initializes the packet pump thread and the supporting events as well as the packet queue.
Shuts down the packet pump thread and cleans up associated data.
This method handles the asynchronous message pump. It waits for messages to show up on the queue
and calls FireDataAvailable for each such packet. It will terminate when the terminate event is
set.
Used to return a matched pair of endpoints for in-proc nodes to use with the Build Manager.
The endpoint destined for use by a node.
The endpoint destined for use by the Build Manager
Creates an endpoint pair
The node-side endpoint.
The manager-side endpoint.
Contains information about the state of a node.
The node ID
The provider type
The configuration IDs the node knows about. These are not necessarily the ones
currently assigned to the node, as that can change.
Constructor.
The ID of the node.
The type of provider which manages this node.
Assigns the specific configuration ID to the node.
True if the configuration is not already known to the node and must be sent to it, false otherwise.
Determines whether the specified configuration if is known to the node.
Returns true if this node can service requests with the specified affinity.
An implementation of a node provider for in-proc nodes.
The invalid in-proc node id
Flag indicating we have disposed.
Value used to ensure multiple in-proc nodes which save the operating environment are not created.
The component host.
The in-proc node.
The in-proc node endpoint.
The packet factory used to route packets from the node.
The in-proc node thread.
Event which is raised when the in-proc endpoint is connected.
The ID of the in-proc node.
Check to allow the inproc node to have exclusive ownership of the operating environment
Initializes the node provider.
Finalizer
Returns the type of nodes managed by this provider.
Returns the number of nodes available to create on this provider.
Sets the build component host.
The component host.
Shuts down this component.
Sends data to the specified node.
The node to which data should be sent.
The data to send.
Causes all connected nodes to be shut down.
Flag indicating if the nodes should prepare for reuse.
Causes all nodes to be shut down permanently - for InProc nodes it is the same as ShutdownConnectedNodes
with enableReuse = false
Requests that a node be created on the specified machine.
The id of the node to create.
The factory to use to create packets from this node.
The configuration for the node.
Registers a packet handler. Not used in the in-proc node.
Unregisters a packet handler. Not used in the in-proc node.
Deserializes and routes a packet. Not used in the in-proc node.
Routes a packet.
The id of the node from which the packet is being routed.
The packet to route.
IDisposable implementation
Factory for component creation.
Creates a new in-proc node.
Thread proc which runs the in-proc node.
Callback invoked when the link status of the endpoint has changed.
The endpoint whose status has changed.
The new link status.
Callback invoked when the endpoint shuts down.
The reason the endpoint is shutting down.
Any exception which was raised that caused the endpoint to shut down.
Dispose implementation.
Each component in the build system which is registered with the Build Manager or a Node must
implement this interface.
REFACTOR: Maybe these could all implement IDisposable.
Called by the build component host when a component is first initialized
The host for the component.
Called by the build component host when the component host is about to shutdown
Factory delegate which instantiates a component of the type specified.
The type of component to be instantiated.
An instance of the component.
An enumeration of all component types recognized by the system
Request Manager
Scheduler
Results Cache
Property Cache
The Build Request Configuration Cache
Node Manager
InProcNodeProvider
OutOfProcNodeProvider
RemoteNodeProvider
Node packet factory
Request engine
File monitor
The endpoint on a Node
The logging service
The component responsible for building requests.
The component responsible for building targets.
The component responsible for building tasks.
The component which is responsible for providing test data to the variour components
OutOfProcTaskHostNodeProvider
Node manager for task host nodes
The cache of registered disposable objects.
The SDK resolution service.
This interface is implemented by objects which host build components.
Retrieves the name of the host.
Retrieves the BuildParameters used during the build.
The data structure which holds the data for the use of legacy threading semantics
Retrieves the logging service associated with a particular build
Registers a factory which will be used to create the necessary components of the build
system.
The type which is created by this factory.
The factory to be registered.
It is not necessary to register any factories. If no factory is registered for a specific kind
of object, the system will use the default factory.
Gets an instance of the specified component type from the host.
The component type to be retrieved
The component
Represents an object which provides scheduling services for BuildRequests over Nodes.
Retrieves the minimum assignable configuration id
Determines if the specified configuration is currently being built
The configuration to query for
True if the configuration is being built somewhere, false otherwise.
Retrieves a configuration id for a configuration which has a matching path
The path for the configuration
A positive configuration id if one exists in the plan, 0 otherwise.
Reports to the scheduler that a request is blocked.
The node making the report.
The thing blocking the active request on the node.
Action to be taken.
Reports to the scheduler that a new result has been generated for a build request.
The node reporting the request.
The result.
Action to be taken.
Reports to the scheduler that a node has been created.
Info about the created nodes.
Action to be taken.
Reports to the scheduler than a node aborted the build.
The node which aborted.
Resets the scheduler.
Writes a detailed summary of the build state which includes information about the scheduling plan.
Requests CPU resources.
Returns CPU resources.
The type of action to take in response to a scheduling request.
The response indicates that no action should be taken.
The response indicates that the request should be sent to the specified node.
The response indicates that the request should be send to the specified node,
along with the configuration for the request.
The response has results for a particular blocked request
The specified request id should now resume execution
The response indicates that a new node should be created rather than scheduling this request.
The request may be scheduled at a later time.
The response indicates that the submission is complete.
The last action caused a circular dependency which cannot be resolved.
A response from the scheduler indicating where a build request should be handled.
The type of action to take on this response.
The node ID to which the request should be sent.
The results for a completed submission.
The build request to send.
The unblocking information.
The type of node we must create.
The number of nodes of the requested affinity to create.
Constructs a response where no action should be taken.
Constructs a response indicating what type of node we need to create.
Constructs a response indicating that a specific submission has completed.
Constructs a response indicating there is a circular dependency caused by the specified request.
Constructs a response where a request should be scheduled.
The node ID to which the request should be sent.
The request to send.
true to send the configuration, otherwise false.
Constructs a response where a result should be sent or execution should be resumed.
The node ID to which the result should be sent.
The result to send.
Creates a Schedule or ScheduleWithConfiguration response
The node to which the response should be sent.
The request to be scheduled.
Flag indicating whether or not the configuration for the request must be sent to the node as well.
The ScheduleResponse.
Creates a ReportResult response.
The node to which the response should be sent.
The result to be reported.
The ScheduleResponse.
Creates a ResumeExecution response.
The node to which the response should be sent.
The request which should resume executing.
The ScheduleResponse.
Creates a CircularDependency response.
The node to which the response should be sent.
The request which attempted to invoke the request causing the circular dependency.
The request which caused the circular dependency.
The ScheduleResponse.
Creates a SubmissionComplete response.
The result for the submission's root request.
The ScheduleResponse.
Create a CreateNode response
The type of node to create.
The number of new nodes of that particular affinity to create.
The ScheduleResponse.
Returns the schedule response as a descriptive string.
Delegate is called when a node shuts down.
The reason for the shutdown
The exception which caused an unexpected shutdown, if any.
This interface is implemented by a build node, and allows the host process to control its execution.
Runs the Node. Returns the reason the node shut down.
Flags requrned by ITaskExecutionHost.FindTask().
The task was not found.
The task must be executed on an STA thread.
The task must be executed in a separate AppDomain.
This interface represents the host for task execution. When used in the in-proc scenario, these method calls essentially
are pass-throughs to just set some member variables and call methods directly on the task and associated objects.
In the out-of-proc/AppDomain-isolated case, the object implementing these methods may break apart the information
in the parameters to be consumed by the IContract representing the remote object through MAF.
REFACTOR - Eliminate this interface.
The associated project.
Flag to determine whether or not to log task inputs.
Initialize the host with the objects required to communicate with the host process.
Ask the task host to find its task in the registry and get it ready for initializing the batch
The task requirements if the task is found, null otherwise.
Initializes for running a particular batch
True if the task is instantiated, false otherwise.
Sets a task parameter using an unevaluated value, which will be expanded by the batch bucket.
Gets all of the outputs and stores them in the batch bucket.
Signal that we are done with this bucket.
Signal that we are done with this task.
Executes the task.
True if execution succeeded, false otherwise.
The TaskExecutionHost is responsible for instantiating tasks, setting their parameters and gathering outputs using
reflection, and executing the task in the appropriate context.The TaskExecutionHost does not deal with any part of the task declaration or
XML.
Time interval in miliseconds to wait between receiving a cancelation signal and emitting the first warning that a non-cancelable task has not finished
Time interval in miliseconds between subsequent warnings that a non-cancelable task has not finished
Resolver to assist in resolving types when a new appdomain is created
The interface used to call back into the build engine.
The project instance in whose context we are executing
The logging context for the target.
The logging context for the task.
The registration which handles the callback when task cancellation is invoked.
The name of the task to execute.
The XML location of the task element.
The arbitrary task host object.
The bucket used to evaluate items and properties.
The task type retrieved from the assembly.
Set to true if the execution has been cancelled.
Event which is signalled when a task is not executing. Used for cancellation.
The task items that we remoted across the appdomain boundary
we use this list to disconnect the task items once we're done.
We need access to the build component host so that we can get at the
task host node provider when running a task wrapped by TaskHostTask
The set of intrinsic tasks mapped for this process.
Constructor
Constructor, for unit testing only.
Finalizer
Flag to determine whether or not to log task inputs.
The associated project.
Gets the task instance
FOR UNIT TESTING ONLY
App domain configuration.
Whether or not this is out-of-proc.
Implementation of IDisposable
Initialize to run a specific task.
Ask the task host to find its task in the registry and get it ready for initializing the batch
True if the task is found in the task registry false if otherwise.
Initialize to run a specific batch of the current task.
Sets all of the specified parameters on the task.
The name/value pairs for the parameters.
True if the parameters were set correctly, false otherwise.
Retrieve the outputs from the task.
True of the outputs were gathered successfully, false otherwise.
Cleans up after running a batch.
Cleans up after running the task.
Executes the task.
Implementation of IDisposable
Disposes of the cancellation token registration.
Cancels the currently-running task.
Kick off a task to wait for the currently-running task and log the wait message.
Called on the local side.
Called on the local side.
Called on the local side.
Remember this TaskItem so that we can disconnect it when this Task has finished executing
Only if we're passing TaskItems to another AppDomain is this necessary. This call
Will make that determination for you.
Gets the outputs (as an array of ITaskItem) from the specified output parameter.
Gets the outputs (as an array of string values) from the specified output parameter.
Given the task name, this method tries to find the task. It uses the following search order:
1) checks the tasks declared by the project, searching by exact name and task identity parameters
2) checks the global task declarations (in *.TASKS in MSbuild bin dir), searching by exact name and task identity parameters
3) checks the tasks declared by the project, searching by fuzzy match (missing namespace, etc.) and task identity parameters
4) checks the global task declarations (in *.TASKS in MSbuild bin dir), searching by fuzzy match (missing namespace, etc.) and task identity parameters
5) 1-4 again in order without the task identity parameters, to gather additional information for the user (if the task identity
parameters don't match, it is an error, but at least we can return them a more useful error in this case than just "could not
find task")
The search ordering is meant to reduce the number of assemblies we scan, because loading assemblies can be expensive.
The tasks and assemblies declared by the project are scanned first, on the assumption that if the project declared
them, they are likely used.
If the set of task identity parameters are defined, only tasks that match that identity are chosen.
The Type of the task, or null if it was not found.
Instantiates the task.
Set the specified parameter based on its type.
Given an instantiated task, this helper method sets the specified scalar parameter based on its type.
Given an instantiated task, this helper method sets the specified vector parameter. Vector parameters can be composed
of multiple item vectors. The semicolon is the only separator allowed, and white space around the semicolon is
ignored. Any item separator strings are not allowed, and embedded item vectors are not allowed.
This method is marked "internal" for unit-testing purposes only -- it should be "private" ideally.
If @(CPPFiles) is a vector for the files a.cpp and b.cpp, and @(IDLFiles) is a vector for the files a.idl and b.idl:
"@(CPPFiles)" converts to { a.cpp, b.cpp }
"@(CPPFiles); c.cpp; @(IDLFiles); c.idl" converts to { a.cpp, b.cpp, c.cpp, a.idl, b.idl, c.idl }
"@(CPPFiles,';')" converts to <error>
"xxx@(CPPFiles)xxx" converts to <error>
Variation to handle arrays, to help with logging the parameters.
Logging currently enabled only by an env var.
Given an instantiated task, this helper method sets the specified parameter
Gets task item outputs
Gather task outputs in array form
Finds all the task properties that are required.
Returns them as keys in a dictionary.
Gets a list of properties which are required.
Show a message that cancel has not yet finished.
The assembly task factory is used to wrap and construct tasks which are from .net assemblies.
The type loader to load types which derrive from ITask or ITask2
Name of the task wrapped by the task factory
The loaded type (type, assembly name / file) of the task wrapped by the factory
A cache of tasks and the AppDomains they are loaded in.
the set of parameters owned by this particular task host
Tracks whether, in the UsingTask invocation, we were specifically asked to use
the task host. If so, that overrides all other concerns, and we will launch
the task host even if the requested runtime / architecture match that of the
current MSBuild process.
Need to store away the taskloggingcontext used by CreateTaskInstance so that
TaskLoader will be able to call back with errors.
Initializes a new instance of the class.
Name of the factory. In this case the name is the assembly name which is wrapped by the factory
Gets the type of task this factory creates.
Initializes this factory for instantiating tasks with a particular inline task block.
Name of the task.
The parameter group.
The task body.
The task factory logging host.
A value indicating whether initialization was successful.
MSBuild engine will call this to initialize the factory. This should initialize the factory enough so that the factory can be asked
whether or not task names can be created by the factory.
The taskFactoryLoggingHost will log messages in the context of the target where the task is first used.
Initializes this factory for instantiating tasks with a particular inline task block and a set of UsingTask parameters.
Name of the task.
Special parameters that the task factory can use to modify how it executes tasks,
such as Runtime and Architecture. The key is the name of the parameter and the value is the parameter's value. This
is the set of parameters that was set on the UsingTask using e.g. the UsingTask Runtime and Architecture parameters.
The parameter group.
The task body.
The task factory logging host.
A value indicating whether initialization was successful.
MSBuild engine will call this to initialize the factory. This should initialize the factory enough so that the
factory can be asked whether or not task names can be created by the factory. If a task factory implements ITaskFactory2,
this Initialize method will be called in place of ITaskFactory.Initialize.
The taskFactoryLoggingHost will log messages in the context of the target where the task is first used.
Get a list of parameters for the task.
Create an instance of the task to be used.
The task factory logging host will log messages in the context of the task.
The task factory logging host will log messages in the context of the task.
The generated task, or null if the task failed to be created.
Create an instance of the task to be used.
The task factory logging host will log messages in the context of the task.
Special parameters that the task factory can use to modify how it executes tasks, such as Runtime and Architecture.
The key is the name of the parameter and the value is the parameter's value. This is the set of parameters that was
set to the task invocation itself, via e.g. the special MSBuildRuntime and MSBuildArchitecture parameters.
If a task factory implements ITaskFactory2, MSBuild will call this method instead of ITaskFactory.CreateTask.
The generated task, or null if the task failed to be created.
Cleans up any context or state that may have been built up for a given task.
The task to clean up.
For many factories, this method is a no-op. But some factories may have built up
an AppDomain as part of an individual task instance, and this is their opportunity
to shutdown the AppDomain.
Initialize the factory from the task registry
Create an instance of the wrapped ITask for a batch run of the task.
Is the given task name able to be created by the task factory. In the case of an assembly task factory
this question is answered by checking the assembly wrapped by the task factory to see if it exists.
Validates the given set of parameters, logging the appropriate errors as necessary.
Given the set of parameters that are set to the factory, and the set of parameters coming from the task invocation that we're searching for
a matching record to, determine whether the parameters match this record.
Given a set of task parameters from the UsingTask and from the task invocation, generate a dictionary that combines the two, or throws if the merge
is impossible (we shouldn't ever get to this point if it is ...)
Returns true if the provided set of task host parameters matches the current process,
and false otherwise.
Log errors from TaskLoader.
The wrapper task for tasks that wish to take advantage of the
task host factory feature. Generated by AssemblyTaskFactory
when it wants to run the loaded task in the task host.
The IBuildEngine callback object.
The host object that can be passed to this task.
Logging context for logging errors / issues
encountered in the TaskHostTask itself.
Location of the task in the project file.
The provider for the task host nodes.
The packet factory.
The event which is set when we receive packets.
The packet that is the end result of the task host task execution process
The set of parameters used to decide which host to launch.
The type of the task that we are wrapping.
The AppDomainSetup we'll want to apply to the AppDomain that we may
want to load the OOP task into.
The task host context of the task host we're launching -- used to
communicate with the task host.
True if currently connected to the task host; false otherwise.
The provider for task host nodes.
Lock object to serialize access to the task host.
Keeps track of whether the wrapped task has had cancel called against it.
The set of parameters that has been set to this wrapped task -- save them
here so that we can forward them on to the task host.
Did the task succeed?
Constructor
THe IBuildEngine callback object
The host object that can be passed to this task.
Sets the requested task parameter to the requested value.
Returns the value of the requested task parameter
Cancels the currently executing task
Executes the task.
Registers the specified handler for a particular packet type.
The packet type.
The factory for packets of the specified type.
The handler to be called when packets of the specified type are received.
Unregisters a packet handler.
The packet type.
Takes a serializer, deserializes the packet and routes it to the appropriate handler.
The node from which the packet was received.
The packet type.
The translator containing the data from which the packet should be reconstructed.
Routes the specified packet
The node from which the packet was received.
The packet to route.
This method is invoked by the NodePacketRouter when a packet is received and is intended for
this recipient.
The node from which the packet was received.
The packet.
Called by TaskHostFactory to let the task know that if it needs to do any additional cleanup steps,
now would be the time.
Handles the packets received from the task host.
Task completed executing in the task host
The task host node failed for some reason
Handle logged messages from the task host.
Since we log that we weren't able to connect to the task host in a couple of different places,
extract it out into a separate method.
The host allows task factories access to method to allow them to log message during the construction of the task factories.
Location of the task node in the original file
The task factory logging context
Is the system running in multi-process mode and requires events to be serializable
A client sponsor is a class
which will respond to a lease renewal request and will
increase the lease time allowing the object to stay in memory
True if the task connected to this proxy is alive
Constructor
Returns true in the multiproc case
REVIEW: Should this mean the same thing in the distributed build case? If we have
a build which happens to be on a distributed cluster, but the build manager has only
alotted a single machine to this build, is this true? Because the build manager
could later decide to add more nodes to this build.
UNDONE: This means we are building with multiple processes. If we are building on
one machine then I think the maxcpu-count is still 1. In my mind this means multiple nodes either distributed or on the same machine.
Reflects the value of the ContinueOnError attribute.
The line number this task is on
The column number this task is on
The project file this task is in.
Typically this is an imported .targets file.
Unfortunately the interface has shipped with a poor name, so we cannot change it.
Sets or retrieves the logging context
Logs an error event for the current task
The event args
Logs a warning event for the current task
The event args
Logs a message event for the current task
The event args
Logs a custom event for the current task
The event args
Builds a single project file
The project file name
The set of targets to build.
The global properties to use
The outputs from the targets
True on success, false otherwise.
InitializeLifetimeService is called when the remote object is activated.
This method will determine how long the lifetime for the object will be.
The lease object to control this object's lifetime.
Indicates to the TaskHost that it is no longer needed.
Called by TaskBuilder when the task using the EngineProxy is done.
Determine if the event is serializable. If we are running with multiple nodes we need to make sure the logging events are serializable. If not
we need to log a warning.
Verify the task host is active or not
Represents toggleable features of the MSBuild engine
Do not expand wildcards that match a certain pattern
Cache file existence for the entire process
Cache wildcard expansions for the entire process
Enable restore first functionality in MSBuild.exe
Allow the user to specify that two processes should not be communicating via an environment variable.
Setting the associated environment variable to 1 restores the pre-15.8 single
threaded (slower) copy behavior. Zero implies Int32.MaxValue, less than zero
(default) uses the empirical default in Copy.cs, greater than zero can allow
perf tuning beyond the defaults chosen.
Instruct MSBuild to write out the generated "metaproj" file to disk when building a solution file.
Log statistics about property functions which require reflection
Log property tracking information.
Do not log command line information to build loggers. Useful to unbreak people who parse the msbuild log and who are unwilling to change their code.
https://github.com/microsoft/msbuild/pull/4975 started expanding qualified metadata in Update operations. Before they'd expand to empty strings.
This escape hatch turns back the old empty string behavior.
Force whether Project based evaluations should evaluate elements with false conditions.
Always use the accurate-but-slow CreateFile approach to timestamp extraction.
Truncate task inputs when logging them. This can reduce memory pressure
at the expense of log usefulness.
Disables truncation of Condition messages in Tasks/Targets via ExpanderOptions.Truncate.
Disables skipping full drive/filesystem globs that are behind a false condition.
Emit events for project imports.
Emit events for project imports.
Read information only once per file per ResolveAssemblyReference invocation.
Never use the slow (but more accurate) CreateFile approach to timestamp extraction.
Allow node reuse of TaskHost nodes. This results in task assemblies locked past the build lifetime, preventing them from being rebuilt if custom tasks change, but may improve performance.
Whether or not to ignore imports that are considered empty. See ProjectRootElement.IsEmptyXmlFile() for more info.
Whether to respect the TreatAsLocalProperty parameter on the Project tag.
Whether to write information about why we evaluate to debug output.
Whether to warn when we set a property for the first time, after it was previously used.
MSBUILDUSECASESENSITIVEITEMNAMES is an escape hatch for the fix
for https://github.com/Microsoft/msbuild/issues/1751. It should
be removed (permanently set to false) after establishing that
it's unneeded (at least by the 16.0 timeframe).
Disable the use of paths longer than Windows MAX_PATH limits (260 characters) when running on a long path enabled OS.
Disable the use of any caching when resolving SDKs.
Disable the NuGet-based SDK resolver.
Don't delete TargetPath metadata from associated files found by RAR.
Disable AssemblyLoadContext isolation for plugins.
Enables the user of autorun functionality in CMD.exe on Windows which is disabled by default in MSBuild.
Disables switching codepage to UTF-8 after detection of characters that can't be represented in the current codepage.
Workaround for https://github.com/Microsoft/vstest/issues/1503.
Use the original, string-only resx parsing in .NET Core scenarios.
Escape hatch for problems arising from https://github.com/microsoft/msbuild/pull/4420.
Overrides the default behavior of property expansion on evaluation of a .
Escape hatch for problems arising from https://github.com/dotnet/msbuild/pull/5552.
Simple replacement for System.Version used to implement version
comparison intrinic property functions.
Allows major version only (e.g. "3" is 3.0.0.0), ignores leading 'v'
(e.g. "v3.0" is 3.0.0.0).
Ignores semver prerelease and metadata portions (e.g. "1.0.0-preview+info"
is 1.0.0.0).
Treats unspecified components as 0 (e.g. x == x.0 == x.0.0 == x.0.0.0).
Unlike System.Version, does not tolerate whitespace, and '+' is ignored as
semver metadata as described above, not tolerated as positive sign of integer
component.
Tolerating leading 'v' allows using $(TargetFrameworkVersion) directly.
Ignoring semver portions allows, for example, checking >= major.minor
while still in development of that release.
Implemented as a struct to avoid heap allocation. Parsing is done
without heap allocation at all on .NET Core. However, on .NET Framework,
the integer component substrings are allocated as there is no int.Parse
on span there.
Reasons for a node to shutdown.
The BuildManager sent a command instructing the node to terminate.
The BuildManager sent a command instructing the node to terminate, but to restart for reuse.
The communication link failed.
The NodeEngine caught an exception which requires the Node to shut down.
This class is the public entry point for executing builds.
The object used for thread-safe synchronization of static members.
The object used for thread-safe synchronization of BuildManager shared data and the Scheduler.
The singleton instance for the BuildManager.
The next build id;
The next build request configuration ID to use.
These must be unique across build managers, as they
are used as part of cache file names, for example.
The cache for build request configurations.
The cache for build results.
The object responsible for creating and managing nodes.
The object responsible for creating and managing task host nodes.
The object which determines which projects to build, and where.
The node configuration to use for spawning new nodes.
Any exception which occurs on a logging thread will go here.
Set of active nodes in the system.
Event signalled when all nodes have shutdown.
Mapping of nodes to the configurations they know about.
Flag indicating if we are currently shutting down. When set, we stop processing packets other than NodeShutdown.
The current state of the BuildManager.
The name given to this BuildManager as the component host.
The parameters with which the build was started.
The current pending and active submissions.
{ submissionId, BuildSubmission }
The current pending and active graph build submissions.
{ submissionId, GraphBuildSubmission }
Event signalled when all build submissions are complete.
The overall success of the build.
The next build submission id.
Mapping of unnamed project instances to the file names assigned to them.
The next ID to assign to a project which has no name.
The build component factories.
Mapping of submission IDs to their first project started events.
Whether a cache has been provided by a project instance, meaning
we've acquired at least one build submission that included a project instance.
Once that has happened, we use the provided one, rather than our default.
The project started event handler
The project finished event handler
The logging exception event handler
Legacy threading semantic data associated with this build manager.
The worker queue.
A cancellation token source used to cancel graph build scheduling
Flag indicating we have disposed.
When the BuildManager was created.
Creates a new unnamed build manager.
Normally there is only one build manager in a process, and it is the default build manager.
Access it with
Creates a new build manager with an arbitrary distinct name.
Normally there is only one build manager in a process, and it is the default build manager.
Access it with
Finalizer
Enumeration describing the current state of the build manager.
This is the default state. may be called in this state. All other methods raise InvalidOperationException
This is the state the BuildManager is in after has been called but before has been called.
, , , , and may be called in this state.
This is the state the BuildManager is in after has been called but before all existing submissions have completed.
Gets the singleton instance of the Build Manager.
Retrieves a hosted instance for resolving SDKs.
Retrieves the logging service associated with a particular build
The logging service.
Retrieves the name of the component host.
Retrieves the build parameters associated with this build.
The build parameters.
Retrieves the LegacyThreadingData associated with a particular build manager
Prepares the BuildManager to receive build requests.
The build parameters. May be null.
Build messages to be logged before the build begins.
Thrown if a build is already in progress.
Prepares the BuildManager to receive build requests.
The build parameters. May be null.
Thrown if a build is already in progress.
Cancels all outstanding submissions asynchronously.
Clears out all of the cached information.
This methods requests the BuildManager to find a matching ProjectInstance in its cache of previously-built projects.
If none exist, a new instance will be created from the specified project.
The Project for which an instance should be retrieved.
The instance.
Submits a build request to the current build but does not start it immediately. Allows the user to
perform asynchronous execution or access the submission ID prior to executing the request.
Thrown if StartBuild has not been called or if EndBuild has been called.
Submits a graph build request to the current build but does not start it immediately. Allows the user to
perform asynchronous execution or access the submission ID prior to executing the request.
Thrown if StartBuild has not been called or if EndBuild has been called.
Convenience method. Submits a build request and blocks until the results are available.
Thrown if StartBuild has not been called or if EndBuild has been called.
Convenience method. Submits a graph build request and blocks until the results are available.
Thrown if StartBuild has not been called or if EndBuild has been called.
Signals that no more build requests are expected (or allowed) and the BuildManager may clean up.
This call blocks until all currently pending requests are complete.
Thrown if there is no build in progress.
Convenience method. Submits a lone build request and blocks until results are available.
Thrown if a build is already in progress.
Convenience method. Submits a lone graph build request and blocks until results are available.
Thrown if a build is already in progress.
Shuts down all idle MSBuild nodes on the machine
Dispose of the build manager.
This method is invoked by the NodePacketRouter when a packet is received and is intended for
this recipient.
The node from which the packet was received.
The packet.
Registers a factory which will be used to create the necessary components of the build
system.
The type which is created by this factory.
The factory to be registered.
It is not necessary to register any factories. If no factory is registered for a specific kind
of object, the system will use the default factory.
Gets an instance of the specified component type from the host.
The component type to be retrieved
The component
This method adds the request in the specified submission to the set of requests being handled by the scheduler.
This method adds the graph build request in the specified submission to the set of requests being handled by the scheduler.
Creates the traversal and metaproject instances necessary to represent the solution and populates new configurations with them.
Gets the next build id.
Creates and optionally populates a new configuration.
Processes the next action in the work queue.
The action to be processed.
Processes a packet
Deals with exceptions that may be thrown as a result of ExecuteSubmission.
Deals with exceptions that may be thrown as a result of ExecuteSubmission.
The submission is a top level build request entering the BuildManager.
Sends the request to the scheduler with optional legacy threading semantics behavior.
Asks the nodeManager to tell the currently connected nodes to shut down and sets a flag preventing all non-shutdown-related packets from
being processed.
Retrieves the next build submission id.
Errors if the BuildManager is in the specified state.
Verifies the BuildManager is in the required state, and throws a if it is not.
Verifies the BuildManager is in the required state, and throws a if it is not.
Method called to reset the state of the system after a build.
Returns a new, valid configuration id.
Finds a matching configuration in the cache and returns it, or stores the configuration passed in.
Handles a new request coming from a node.
Handles a resource request coming from a node.
Handles a configuration request coming from a node.
Handles a build result coming from a node.
Handles the NodeShutdown packet
If there are no more active nodes, cleans up any remaining submissions.
Must only be called from within the sync lock.
Carries out the actions specified by the scheduler.
Completes a submission using the specified overall results.
Completes a submission using the specified overall results.
Determines if the submission is fully completed.
Determines if the submission is fully completed.
Retrieves the configuration structure for a node.
Handler for thread exceptions (logging thread, communications thread). This handler will only get called if the exception did not previously
get handled by a node exception handlers (for instance because the build is complete for the node.) In this case we
get the exception and will put it into the OverallBuildResult so that the host can see what happened.
Raised when a project finished logging message has been processed.
Raised when a project started logging message is about to be processed.
Creates a logging service around the specified set of loggers.
Ensures that the packet type matches the expected type
The instance-type of packet being expected
Shutdown the logging service
Dispose implementation
The logger registered to the logging service when no other one is.
The logger verbosity.
The logger parameters.
Initialize.
Shutdown.
This class represents all of the settings which must be specified to start a build.
The default thread stack size for threads owned by MSBuild.
The timeout for endpoints to shut down.
The timeout for the engine to shutdown.
The shutdown timeout for the logging thread.
The shutdown timeout for the request builder.
The maximum number of idle request builders to retain before we start discarding them.
The startup directory.
Indicates whether we should warn when a property is uninitialized when it is used.
Indicates if we should dump string interning stats.
Indicates if we should debug the expander.
Indicates if we should keep duplicate target outputs.
Indicates if we should enable the build plan
The maximum number of idle request builders we will retain.
Location that msbuild.exe was last successfully found at.
The build id
The culture
The default tools version.
Flag indicating whether node reuse should be enabled.
By default, it is enabled.
The original process environment.
The environment properties for the build.
The forwarding logger records.
The build-global properties.
The loggers.
The maximum number of nodes to use.
The maximum amount of memory to use.
The location of the node exe. This is the full path including the exe file itself.
Flag indicating if we should only log critical events.
The UI culture.
The toolset provider
Should the logging service be done Synchronously when the number of cps's is 1
Should the inprocess node be shutdown when the build finishes. By default this is false
since visual studio needs to keep the inprocess node around after the build has finished.
When true, the in-proc node will not be available.
When true, the build should log task inputs to the loggers.
When true, the build should log the input parameters. Note - logging these is very expensive!
The settings used to load the project under build
Constructor for those who intend to set all properties themselves.
Creates BuildParameters from a ProjectCollection.
The ProjectCollection from which the BuildParameters should populate itself.
Private constructor for translation
Copy constructor
Gets or sets the desired thread priority for building.
By default if the number of processes is set to 1 we will use Asynchronous logging. However if we want to use synchronous logging when the number of cpu's is set to 1
this property needs to be set to true.
Indicates whether to emit a default error if a task returns false without logging an error.
Gets the environment variables which were set when this build was created.
The name of the culture to use during the build.
The default tools version for the build.
When true, indicates that the build should emit a detailed summary at the end of the log.
When true, indicates the in-proc node should not be used.
When true, indicates that the task parameters should be logged.
When true, indicates that the initial properties and items should be logged.
Indicates that the build should reset the configuration and results caches.
Flag indicating whether out-of-proc nodes should remain after the build and wait for further builds.
Gets an immutable collection of environment properties.
This differs from the BuildProcessEnvironment in that there are certain MSBuild-specific properties which are added, and those environment variables which
would not be valid as MSBuild properties are removed.
The collection of forwarding logger descriptions.
Sets or retrieves an immutable collection of global properties.
Interface allowing the host to provide additional control over the build process.
Enables or disables legacy threading semantics
Legacy threading semantics indicate that if a submission is to be built
only on the in-proc node and the submission is executed synchronously, then all of its
requests will be built on the thread which invoked the build rather than a
thread owned by the BuildManager.
The collection of loggers to use during the build.
The maximum number of nodes this build may use.
The amount of memory the build should limit itself to using, in megabytes.
The location of the build node executable.
Flag indicating if non-critical logging events should be discarded.
A list of warnings to treat as errors. To treat all warnings as errors, set this to an empty .
A list of warnings to treat as low importance messages.
Locations to search for toolsets.
Returns all of the toolsets.
toolsetProvider.Toolsets is already a readonly collection.
The name of the UI culture to use during the build.
Flag indicating if the operating environment such as the current directory and environment be saved and restored between project builds and task invocations.
This should be set to false for any other build managers running in the system so that we do not have two build managers trampling on each others environment.
Shutdown the inprocess node when the build finishes. By default this is false
since visual studio needs to keep the inprocess node around after the build finishes.
Gets the internal msbuild thread stack size.
Gets the endpoint shutdown timeout.
Gets or sets the engine shutdown timeout.
Gets the maximum number of idle request builders to retain.
Gets the logging thread shutdown timeout.
Gets the request builder shutdown timeout.
Gets the startup directory.
Indicates whether the build plan is enabled or not.
Indicates whether we should warn when a property is uninitialized when it is used.
Indicates whether we should dump string interning stats
Indicates whether we should dump debugging information about the expander
Indicates whether we should keep duplicate target outputs
Gets or sets the build id.
Gets or sets the environment properties.
This is not the same as BuildProcessEnvironment. See EnvironmentProperties. These properties are those which
are used during evaluation of a project, and exclude those properties which would not be valid MSBuild properties
because they contain invalid characters (such as 'Program Files (x86)').
Gets the global properties.
Gets or sets the node id.
Gets the toolset provider.
The one and only project root element cache to be used for the build.
Information for configuring child AppDomains.
(for diagnostic use) Whether or not this is out of proc
Gets or sets a value indicating if the build is allowed to interact with the user.
Gets or sets a value indicating whether projects should build in isolation.
Input cache files that MSBuild will use to read build results from.
Setting this also turns on isolated builds.
Output cache file where MSBuild will write the contents of its build result caches during EndBuild.
Setting this also turns on isolated builds.
Determines whether MSBuild will save the results of builds after EndBuild to speed up future builds.
Gets or sets a value indicating whether the build process should run as low priority.
If set, the BuildManager will query all
incoming requests against the specified project cache.
Any requests will also use this project cache instead of
the potential project caches described in graph node's evaluations.
Retrieves a toolset.
Creates a clone of this BuildParameters object. This creates a clone of the logger collections, but does not deep clone
the loggers within.
Implementation of the serialization mechanism.
The class factory for deserialization.
Gets the value of a boolean environment setting which is not expected to change.
Gets the value of an integer environment variable, or returns the default if none is set or it cannot be converted.
Centralization of the common parts of construction.
Loads the toolsets if we don't have them already.
This method determines where MSBuild.Exe is and sets the NodeExePath to that by default.
Helper to avoid doing an expensive disk check for MSBuild.exe when
we already checked in a previous build.
This File.Exists otherwise can show up in profiles when there's a lot of
design time builds going on.
A callback used to receive notification that a build has completed.
When this delegate is invoked, the WaitHandle on the BuildSubmission will have been be signalled and the OverallBuildResult will be valid.
A BuildSubmission represents an build request which has been submitted to the BuildManager for processing. It may be used to
execute synchronous or asynchronous build requests and provides access to the results upon completion.
This class is thread-safe.
The callback to invoke when the submission is complete.
The completion event.
Flag indicating if logging is done.
True if it has been invoked
Flag indicating whether synchronous wait should support legacy threading semantics.
Constructor
The BuildManager with which this submission is associated.
An ID uniquely identifying this request from among other submissions within the same build.
The asynchronous context provided to , if any.
A which will be signalled when the build is complete. Valid after or returns, otherwise null.
Returns true if this submission is complete.
The result of the build. Valid only after WaitHandle has become signalled.
The BuildRequestData being used for this submission.
The build request for execution.
Starts the request and blocks until results are available.
The request has already been started or is already complete.
Starts the request asynchronously and immediately returns control to the caller.
The request has already been started or is already complete.
Sets the event signaling that the build is complete.
Indicates that all logging events for this submission are complete.
Starts the request asynchronously and immediately returns control to the caller.
The request has already been started or is already complete.
Determines if we are completely done with this submission and can complete it so the user may access results.
This class represents the data which is used for legacy threading semantics for the build
Store the pair of start/end events used by a particular submission to track their ownership
of the legacy thread.
Item1: Start event, tracks when the submission has permission to start building.
Item2: End event, signalled when that submission is no longer using the legacy thread.
The current submission id building on the main thread, if any.
The instance to be used when the new request builder is started on the main thread.
Lock object for startNewRequestBuilderMainThreadEventsById, since it's possible for multiple submissions to be
submitted at the same time.
The instance to be used when the new request builder is started on the main thread.
The current submission id building on the main thread, if any.
Given a submission ID, assign it "start" and "finish" events to track its use of
the legacy thread.
This submission is completely done with the legacy thread, so unregister it
from the dictionary so that we don't leave random events lying around.
Given a submission ID, return the event being used to track when that submission is ready
to be executed on the legacy thread.
Given a submission ID, return the event being used to track when that submission is ready
to be executed on the legacy thread.
Signal that the legacy thread is starting work.
Signal that the legacy thread has finished its work.
Interface defining properties, items, and metadata of interest for a .
Properties of interest.
Items and metadata of interest.
Creates an instance of this exception using the given message.
Creates an instance of this exception using projectFile, targetName, taskName and inner exception.
Adds the inner exception's details to the exception message because most bug reporters don't bother
to provide the inner exception details which is typically what we care about.
Creates an instance of this exception using projectFile, targetName, taskName and message.
Wrapper for the COM Running Object Table.
See https://docs.microsoft.com/en-us/windows/desktop/api/objidl/nn-objidl-irunningobjecttable.
Attempts to retrieve an item from the ROT.
Flags providing additional control over the build request
No flags.
When this flag is present, the existing ProjectInstance in the build will be replaced by this one.
When this flag is present, the issued in response to this request will
include .
When this flag is present and the project has previously been built on a node whose affinity is
incompatible with the affinity this request requires, we will ignore the project state (but not
target results) that were previously generated.
This usually is not desired behavior. It is only provided for those cases where the client
knows that the new build request does not depend on project state generated by a previous request. Setting
this flag can provide a performance boost in the case of incompatible node affinities, as MSBuild would
otherwise have to serialize the project state from one node to another, which may be
expensive depending on how much data the project previously generated.
This flag has no effect on target results, so if a previous request already built a target, the new
request will not re-build that target (nor will any of the project state mutations which previously
occurred as a consequence of building that target be re-applied.)
When this flag is present, caches including the will be cleared
after the build request completes. This is used when the build request is known to modify a lot of
state such as restoring packages or generating parts of the import graph.
When this flag is present, the top level target(s) in the build request will be skipped if those targets
are not defined in the Project to build. This only applies to this build request (if another target calls
the "missing target" at any other point this will still result in an error).
When this flag is present, the issued in response to this request will
include a that includes ONLY the
explicitly-requested properties, items, and metadata.
When this flag is present, projects loaded during build will ignore missing imports ( and ).
This is especially useful during a restore since some imports might come from packages that haven't been restored yet.
When this flag is present, an unresolved MSBuild project SDK will fail the build. This flag is used to
change the behavior to still fail when an SDK is missing
because those are more fatal.
BuildRequestData encapsulates all of the data needed to submit a build request.
Constructs a BuildRequestData for build requests based on project instances.
The instance to build.
The targets to build.
Constructs a BuildRequestData for build requests based on project instances.
The instance to build.
The targets to build.
The host services to use, if any. May be null.
Constructs a BuildRequestData for build requests based on project instances.
The instance to build.
The targets to build.
The host services to use, if any. May be null.
Flags controlling this build request.
Constructs a BuildRequestData for build requests based on project instances.
The instance to build.
The targets to build.
The host services to use, if any. May be null.
Flags controlling this build request.
The list of properties whose values should be transferred from the project to any out-of-proc node.
Constructs a BuildRequestData for build requests based on project instances.
The instance to build.
The targets to build.
The host services to use, if any. May be null.
Flags controlling this build request.
The list of properties whose values should be transferred from the project to any out-of-proc node.
A describing properties, items, and metadata that should be returned. Requires setting .
Constructs a BuildRequestData for build requests based on project files.
The full path to the project file.
The global properties which should be used during evaluation of the project. Cannot be null.
The tools version to use for the build. May be null.
The targets to build.
The host services to use. May be null.
Constructs a BuildRequestData for build requests based on project files.
The full path to the project file.
The global properties which should be used during evaluation of the project. Cannot be null.
The tools version to use for the build. May be null.
The targets to build.
The host services to use. May be null.
The to use.
A describing properties, items, and metadata that should be returned. Requires setting .
Constructs a BuildRequestData for build requests based on project files.
The full path to the project file.
The global properties which should be used during evaluation of the project. Cannot be null.
The tools version to use for the build. May be null.
The targets to build.
The host services to use. May be null.
The to use.
Common constructor.
The actual project, in the case where the project doesn't come from disk.
May be null.
The project instance.
The project file.
The project file to be built.
The name of the targets to build.
An array of targets in the project to be built.
Extra flags for this BuildRequest.
The global properties to use.
The set of global properties to be used to build this request.
The explicitly requested tools version to use.
Gets the HostServices object for this request.
Returns a list of properties to transfer out of proc for the build.
Returns the properties, items, and metadata that will be returned
by this build.
Whether the tools version used originated from an explicit specification,
for example from an MSBuild task or /tv switch.
Returns the global properties as a dictionary.
This class represents an implementation of INode for out-of-proc nodes.
Whether the current appdomain has an out of proc node.
For diagnostics.
The one and only project root element cache to be used for the build
on this out of proc node.
The endpoint used to talk to the host.
The saved environment for the process.
The component factories.
The build system parameters.
The logging service.
The node logging context.
The global config cache.
The global node manager
The build request engine.
The packet factory.
The current node configuration
The queue of packets we have received but which have not yet been processed.
The event which is set when we receive packets.
The event which is set when we should shut down.
The reason we are shutting down.
The exception, if any, which caused shutdown.
Flag indicating if we should debug communications or not.
Data for the use of LegacyThreading semantics.
The current instance.
Constructor.
Get the logging service for a build.
The logging service.
Retrieves the LegacyThreadingData associated with a particular build manager
Retrieves the name of this component host.
Retrieves the build parameters for the current build.
The build parameters.
Whether the current appdomain has an out of proc node.
Starts up the node and processes messages until the node is requested to shut down.
Assumes no node reuse.
Assumes low priority is disabled.
The exception which caused shutdown, if any.
The reason for shutting down.
Starts up the node and processes messages until the node is requested to shut down.
Assumes low priority is disabled.
Whether this node is eligible for reuse later.
The exception which caused shutdown, if any.
The reason for shutting down.
Starts up the node and processes messages until the node is requested to shut down.
Whether this node is eligible for reuse later.
Whether this node should be running with low priority.
The exception which caused shutdown, if any.
The reason for shutting down.
Registers a factory with the component host.
The factory type to register.
The factory method.
Get a component from the host.
The component type to get.
The component.
Registers a packet handler.
The packet type for which the handler should be registered.
The factory used to create packets.
The handler for the packets.
Unregisters a packet handler.
The type of packet for which the handler should be unregistered.
Deserializes and routes a packer to the appropriate handler.
The node from which the packet was received.
The packet type.
The translator to use as a source for packet data.
Routes a packet to the appropriate handler.
The node id from which the packet was received.
The packet to route.
Called when a packet has been received.
The node from which the packet was received.
The packet.
Event handler for the BuildEngine's OnRequestComplete event.
Event handler for the BuildEngine's OnNewRequest event.
Event handler for the BuildEngine's OnNewConfigurationRequest event.
Event handler for the BuildEngine's OnResourceRequest event.
Event handler for the LoggingService's OnLoggingThreadException event.
Event handler for the BuildEngine's OnEngineException event.
Perform necessary actions to shut down the node.
Clears all the caches used during the build.
Event handler for the node endpoint's LinkStatusChanged event.
Callback for logging packets to be sent.
Dispatches the packet to the correct handler.
Handles the BuildRequest packet.
Handles the BuildRequestConfiguration packet.
Handles the BuildRequestConfigurationResponse packet.
Handles the BuildResult packet.
Handles the ResourceResponse packet.
Handles the NodeConfiguration packet.
Handles the NodeBuildComplete packet.
Overall results for targets and requests
The target or request was a complete success.
The target or request failed in some way.
Contains the current results for all of the targets which have produced results for a particular configuration.
The submission with which this result is associated.
The configuration ID with which this result is associated.
The global build request ID for which these results are intended.
The global build request ID which issued the request leading to this result.
The build request ID on the originating node.
The first build request to generate results for a configuration will set this so that future
requests may be properly satisfied from the cache.
The first build request to generate results for a configuration will set this so that future
requests may be properly satisfied from the cache.
The set of results for each target.
The request caused a circular dependency in scheduling.
The exception generated while this request was running, if any.
Note that this can be set if the request itself fails, or if it receives
an exception from a target or task.
The overall result calculated in the constructor.
Snapshot of the environment from the configuration this results comes from.
This should only be populated when the configuration for this result is moved between nodes.
Snapshot of the current directory from the configuration this result comes from.
This should only be populated when the configuration for this result is moved between nodes.
state after the build. This is only provided if
includes or
for the build request which this object is a result of,
and will be null otherwise. Where available, it may be a non buildable-dummy object, and should only
be used to retrieve , and
from it. No other operation is guaranteed to be supported.
Constructor for serialization.
Constructor creates an empty build result
The build request to which these results should be associated.
Constructs a build result with an exception
The build request to which these results should be associated.
The exception, if any.
Constructor creates a build result indicating a circular dependency was created.
The build request to which these results should be associated.
Set to true if a circular dependency was detected.
Constructs a new build result based on existing results, but filtered by a specified set of target names
The existing results.
The target names whose results we will take from the existing results, if they exist.
Constructs a new build result with existing results, but associated with the specified request.
The build request with which these results should be associated.
The existing results, if any.
The exception, if any
Constructs a new build result with existing results, but associated with the specified request.
The build request with which these results should be associated.
The existing results, if any.
The list of target names that are the subset of results that should be returned.
The exception, if any
Constructor which allows reporting results for a different nodeRequestId
Constructor for deserialization
Returns the submission id.
Returns the configuration ID for this result.
Returns the build request id for which this result was generated
Returns the build request id for the parent of the request for which this result was generated
Returns the node build request id for which this result was generated
Returns the exception generated while this result was run, if any.
Returns a flag indicating if a circular dependency was detected.
Returns the overall result for this result set.
Returns an enumerator for all target results in this build result
state after the build. In general, it may be a non buildable-dummy object, and should only
be used to retrieve , and
from it. Any other operation is not guaranteed to be supported.
Returns the node packet type.
Holds a snapshot of the environment at the time we blocked.
Holds a snapshot of the current working directory at the time we blocked.
Returns the initial targets for the configuration which requested these results.
Returns the default targets for the configuration which requested these results.
Container used to transport errors from the scheduler (issued while computing a build result)
to the TaskHost that has the proper logging context (project id, target id, task id, file location)
Indexer which sets or returns results for the specified target
The target
The results for the specified target
KeyNotFoundException is returned if the specified target doesn't exist when reading this property.
ArgumentException is returned if the specified target already has results.
Adds the results for the specified target to this result collection.
The target to which these results apply.
The results for the target.
Merges the specified results with the results contained herein.
The results to merge in.
Determines if there are any results for the specified target.
The target for which results are desired.
True if results exist, false otherwise.
Reads or writes the packet to the serializer.
Factory for serialization
Caches all of the targets results we can.
Clear cached files from disk.
Clones the build result (the resultsByTarget field is only a shallow copy).
Sets the overall result.
true if the result is success, otherwise false.
Creates the target result dictionary.
Creates the target result dictionary and populates it with however many target results are
available given the list of targets passed.
The result code for a given target.
The target was skipped because its condition was not met.
The target successfully built.
The target failed to build.
An interface representing results for a specific target
The exception generated when the target ran, if any.
The set of build items output by the target.
These are ITaskItem's, so they have no item-type.
The result code for the target run.
Contains the result items for a single target as well as the overall result code.
The result for this target.
Flag indicating whether to consider this target failure as having caused a build failure.
Flag indicating whether at least one target which has run after us (transitively via AfterTargets) failed.
The store of items in this result.
The context under which these results have been cached.
Initializes the results with specified items and result.
The items produced by the target.
The overall result for the target.
Private constructor for deserialization
Returns the exception which aborted this target, if any.
The exception which aborted this target, if any.
Returns the items produced by the target.
These are ITaskItem's, so they have no item-type.
The items produced by the target.
Returns the result code for the target.
The result code for the target.
Returns the internal result for the target.
Sets or gets a flag indicating whether or not a failure results should cause the build to fail.
Sets or gets a flag indicating whether at least one target which has run after us (transitively via AfterTargets) failed.
Reads or writes the packet to the serializer.
Factory for serialization.
Gets the name of the cache file for this configuration.
Gets the name of the cache file for this configuration.
Cache the items.
Performs the actual translation
Retrieve the items from the cache.
Gets the translator for this configuration.
Information about where the cache for the items in this result are stored.
Constructor.
Retrieves the configuration id.
Retrieves the target name.
A reflection-generated TaskPropertyInfo instance.
The reflection-produced PropertyInfo.
The type of the generated tasks.
Initializes a new instance of the class.
The original property info that generated this instance.
The type to reflect over to get the reflection propertyinfo later.
Initializes a new instance of the class.
The PropertyInfo used to discover this task property.
Gets or sets the reflection-produced PropertyInfo.
Controls where projects must be built.
The project may only be scheduled on the in-proc node. This happens automatically if there is a host object or if a ProjectInstance
was specified. A host may wish to specify it if they know a task depends explicitly on shared static data or other host-provided
objects.
The project may only be scheduled on an out-of-proc node. A host may wish to specify this if it is known the project being built
could contaminate the host environment (or the host contaminates the environment while a build is proceeding.)
The project may be scheduled anywhere.
Implementation of HostServices that
mediates access from the build to the host.
Collection storing host objects for particular project/task/target combinations.
A mapping of project file names to their node affinities. An entry for String.Empty means that
all projects which don't otherwise have an affinity should use that affinity.
Gets any host object applicable to this task name
where the task appears within a target and project with the specified names.
If no host object exists, returns null.
Register a host object for a particular task/target pair.
Overwrites any existing host object.
Register a remote host object for a particular task/target pair.
The remote host object require registered in Running Object Table(ROT) already.
Overwrites any existing host object.
It's caller's responsibly:
To maintain the live cycle of the host object.
Register and unregister from ROT.
Ensure the host object has appropriate COM interface that can be used in task.
project file name
target name
task name
the Moniker used to register host object in ROT
Unregister the project's host objects, if any and remove any node affinities associated with it.
Retrieves the node affinity for a particular project file.
Sets the node affinity for a particular project file.
The project file. If set to String.Empty, all projects will use the specified affinity. If set to null, all affinities will be cleared.
The to set.
Updates the host object table when a project is renamed.
Old full path may be null.
Returns true if there is any in process host object registered for this project file.
Retrieves the node affinity for a particular project file.
Test only
Bag holding host object information for a single project file.
The mapping of targets and tasks to host objects.
Constructor
Accessor which indicates if there are any registered in process host objects.
Registers a host object for this project file
Registers a host object for this project file
Gets any host object for this project file matching the task and target names specified.
Equatable key for the table
Target name
Task name
Constructor
Implementation of IEquatable.
Type for ProjectTaskInstance and ProjectPropertyGroupTaskInstance and ProjectItemGroupTaskInstance
allowing them to be used in a single collection of target children
Condition on the element
Full path to the file in which the originating element was originally
defined.
If it originated in a project that was not loaded and has never been
given a path, returns an empty string.
Location of the original element
Location of the original condition attribute
if any
Type for TaskOutputItem and TaskOutputProperty
allowing them to be used in a single collection
Condition on the element
Location of the original element
Location of the TaskParameter attribute
Location of the original condition attribute, if any
Enum for controlling project instance creation
no options
create immutable version of project instance
create project instance with some look up table that improves performance
What the user gets when they clone off a ProjectInstance.
They can hold onto this, change/query items and properties,
and call it several times to build it.
Neither this class nor any of its constituents are allowed to have
references to any of the Construction or Evaluation objects.
This class is immutable except for adding instance items and setting instance properties.
It only exposes items and properties: targets, host services, and the task registry are not exposed as they are only the concern of build.
Constructors are internal in order to direct users to Project class instead; these are only createable via Project objects.
Targets in the project after overrides have been resolved.
This is an unordered collection keyed by target name.
Only the wrapper around this collection is exposed.
Targets in the project after overrides have been resolved.
This is an immutable, unordered collection keyed by target name.
It is just a wrapper around actualTargets.
The global properties evaluation occurred with.
Needed by the build as they traverse between projects.
List of names of the properties that, while global, are still treated as overridable
Whether the tools version used originated from an explicit specification,
for example from an MSBuild task or /tv switch.
Properties in the project. This is a dictionary of name, value pairs.
Properties originating from environment variables, gotten from the project collection
Items in the project. This is a dictionary of ordered lists of a single type of items keyed by item type.
Items organized by evaluatedInclude value
The project's root directory, for evaluation of relative paths and
setting the current directory during build.
Is never null.
If the project has not been loaded from disk and has not been given a path, returns the current directory from
the time the project was loaded - this is the same behavior as Whidbey/Orcas.
If the project has not been loaded from disk but has been given a path, this path may not exist.
The project file location, for logging.
If the project has not been loaded from disk and has not been given a path, returns null.
If the project has not been loaded from disk but has been given a path, this path may not exist.
The item definitions from the parent Project.
The HostServices to use during a build.
Whether when we read a ToolsVersion that is not equivalent to the current one on the Project tag, we
treat it as the current one.
The toolsversion that was originally on the project's Project root element
Whether the instance is immutable.
The object is always mutable during evaluation.
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Uses the default project collection.
The name of the project file.
A new project instance
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Uses the default project collection.
The name of the project file.
The global properties to use.
The tools version.
A new project instance
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Global properties may be null.
Tools version may be null.
The name of the project file.
The global properties to use.
The tools version.
Project collection
A new project instance
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Global properties may be null.
Tools version may be null.
The name of the project file.
The global properties to use.
The tools version.
The sub-toolset version, used in tandem with the ToolsVersion to determine the set of toolset properties.
Project collection
A new project instance
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Global properties may be null.
Tools version may be null.
Evaluation context may be null.
The name of the project file.
The global properties to use.
The tools version.
The sub-toolset version, used in tandem with the ToolsVersion to determine the set of toolset properties.
Project collection
Project load settings
The context to use for evaluation.
A new project instance
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Uses the default project collection.
The project root element
A new project instance
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Global properties may be null.
Tools version may be null.
The project root element
The global properties to use.
The tools version.
Project collection
A new project instance
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Global properties may be null.
Tools version may be null.
Sub-toolset version may be null, but if specified will override all other methods of determining the sub-toolset.
The project root element
The global properties to use.
The tools version.
The sub-toolset version, used in tandem with the ToolsVersion to determine the set of toolset properties.
Project collection
A new project instance
Creates a ProjectInstance from an external created .
Properties and items are cloned immediately and only the instance data is stored.
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Global properties may be null.
Tools version may be null.
Sub-toolset version may be null, but if specified will override all other methods of determining the sub-toolset.
The project root element
The global properties to use.
The tools version.
The sub-toolset version, used in tandem with the ToolsVersion to determine the set of toolset properties.
Project collection
Project load settings
The context to use for evaluation.
A new project instance
Creates a ProjectInstance directly. Used to generate solution metaprojects.
The full path to give to this project.
The traversal project from which global properties and tools version will be inherited.
An containing global properties.
Creates a ProjectInstance directly.
No intermediate Project object is created.
This is ideal if the project is simply going to be built, and not displayed or edited.
Global properties may be null.
Tools version may be null.
Used by SolutionProjectGenerator so that it can explicitly pass the vsVersionFromSolution in for use in
determining the sub-toolset version.
The project root element
The global properties to use.
The tools version.
The version of the solution, used to help determine which sub-toolset to use.
Project collection
An instance to use when resolving SDKs.
The current build submission ID.
A new project instance
Creates a mutable ProjectInstance directly, using the specified logging service.
Assumes the project path is already normalized.
Used by the RequestBuilder.
Creates a mutable ProjectInstance directly, using the specified logging service.
Assumes the project path is already normalized.
Used by this class when generating legacy solution wrappers.
Constructor called by Project's constructor to create a fresh instance.
Properties and items are cloned immediately and only the instance data is stored.
Constructor for deserialization.
Deep clone of this object.
Useful for compiling a single file; or for keeping resolved assembly references between builds.
Create a file based ProjectInstance.
The file to evaluate the ProjectInstance from.
The to use.
Create a based ProjectInstance.
The to evaluate the ProjectInstance from.
The to use.
Global properties this project was evaluated with, if any.
Read only collection.
Traverses project references.
This is the publicly exposed getter, that translates into a read-only dead IDictionary<string, string>.
The tools version this project was evaluated with, if any.
Not necessarily the same as the tools version on the Project tag, if any;
it may have been externally specified, for example with a /tv switch.
Enumerator over item types of the items in this project
Enumerator over properties in this project
Enumerator over items in this project.
Gets a object containing evaluated items.
Serialize the entire project instance state.
When false, only a part of the project instance state is serialized (properties and items).
In this case out of proc nodes re-evaluate the project instance from disk to obtain the un-serialized state.
This partial state recombination may lead to build issues when the project instance state differs from what is on disk.
The ID of the evaluation that produced this ProjectInstance.
See .
The project's root directory, for evaluation of relative paths and
setting the current directory during build.
Is never null: projects not loaded from disk use the current directory from
the time the build started.
The full path to the project, for logging.
If the project was never given a path, returns empty string.
Read-only dictionary of item definitions in this project.
Keyed by item type
The full file paths of all the files that during evaluation contributed to this project instance.
This does not include projects that were never imported because a condition on an Import element was false.
The outer ProjectRootElement that maps to this project instance itself is not included.
This list will contain duplicate imports if an import is imported multiple times. However, only the first import was used in evaluation.
DefaultTargets specified in the project, or
the logically first target if no DefaultTargets is
specified in the project.
The build builds these if no targets are explicitly specified
to build.
InitialTargets specified in the project, plus those
in all imports, gathered depth-first.
The build runs these before anything else.
Targets in the project. The build process can find one by looking for its name
in the dictionary.
This collection is read-only.
Whether the instance is immutable.
This is set permanently when the instance is created.
Task classes and locations known to this project.
This is the project-specific task registry, which is consulted before
the toolset's task registry.
Only set during evaluation, so does not check for immutability.
Gets the Toolset
The sub-toolset version we should use during the build, used to determine which set of sub-toolset
properties we should merge into this toolset.
The externally specified tools version, if any.
For example, the tools version from a /tv switch.
Not necessarily the same as the tools version from the project tag or of the toolset used.
May be null.
Flows through to called projects.
Gets the global properties
List of names of the properties that, while global, are still treated as overridable
Gets the properties
Gets the item definitions
Gets the items
Sets the initial targets
Only set during evaluation, so does not check for immutability.
Gets or sets the default targets
Only set during evaluation, so does not check for immutability.
Gets or sets the before targets
Only set during evaluation, so does not check for immutability.
Gets or sets the after targets
Only set during evaluation, so does not check for immutability.
List of possible values for properties inferred from certain conditions,
keyed by the property name.
Because ShouldEvaluateForDesignTime returns false, this should not be called.
Whether evaluation should collect items ignoring condition,
as well as items respecting condition; and collect
conditioned properties, as well as regular properties
Location of the originating file itself, not any specific content within it.
Never returns null, even if the file has not got a path yet.
Gets the global properties this project was evaluated with, if any.
Traverses project references.
The tools version we should use during the build, used to determine which toolset we should access.
If we are treating a missing toolset as the current ToolsVersion
The toolsversion that was originally specified on the project's root element
The externally specified tools version, if any.
For example, the tools version from a /tv switch.
Not necessarily the same as the tools version from the project tag or of the toolset used.
May be null.
Flows through to called projects.
Whether the tools version used originated from an explicit specification,
for example from an MSBuild task or /tv switch.
The sub-toolset version we should use during the build, used to determine which set of sub-toolset
properties we should merge into this toolset.
Actual collection of properties in this project,
for the build to start with.
Actual collection of items in this project,
for the build to start with.
Task classes and locations known to this project.
This is the project-specific task registry, which is consulted before
the toolset's task registry.
UsingTask tags have already been evaluated and entered into this task registry.
Number of targets in the project.
The project root element cache from the project collection
that began the build. This is a thread-safe object.
It's held here so it can get passed to the build.
Returns the evaluated, escaped value of the provided item's include.
Returns the evaluated, escaped value of the provided item definition's include.
Gets the escaped value of the provided metadatum.
Gets the escaped value of the metadatum with the provided name on the provided item.
Gets the escaped value of the metadatum with the provided name on the provided item definition.
Get the escaped value of the provided property
Gets items of the specified type.
For internal use.
Already a readonly collection
Initializes the object for evaluation.
Only called during evaluation, so does not check for immutability.
Indicates to the data block that evaluation has completed,
so for example it can mark datastructures read-only.
Adds a new item
Only called during evaluation, so does not check for immutability.
Adds a new item to the collection of all items ignoring condition
Because ShouldEvaluateForDesignTime returns false, this should not be called.
Adds a new item definition
Only called during evaluation, so does not check for immutability.
Properties encountered during evaluation. These are read during the first evaluation pass.
Unlike those returned by the Properties property, these are ordered, and include any properties that
were subsequently overridden by others with the same name. It does not include any
properties whose conditions did not evaluate to true.
Because ShouldEvaluateForDesignTime returns false, this should not be called.
Item definition metadata encountered during evaluation. These are read during the second evaluation pass.
Unlike those returned by the ItemDefinitions property, these are ordered, and include any metadata that
were subsequently overridden by others with the same name and item type. It does not include any
elements whose conditions did not evaluate to true.
Because ShouldEvaluateForDesignTime returns false, this should not be called.
Items encountered during evaluation. These are read during the third evaluation pass.
Unlike those returned by the Items property, these are ordered.
It does not include any elements whose conditions did not evaluate to true.
It does not include any items added since the last evaluation.
Because ShouldEvaluateForDesignTime returns false, this should not be called.
Retrieves an existing item definition, if any.
Sets a property which does not come from the Xml.
This is where global, environment, and toolset properties are added to the project instance by the evaluator, and we mark them
immutable if we are immutable.
Only called during evaluation, so does not check for immutability.
Sets a property which comes from the Xml.
Predecessor is discarded as it is a design time only artefact.
Only called during evaluation, so does not check for immutability.
Retrieves an existing target, if any.
Adds a new target.
Only called during evaluation, so does not check for immutability.
Record an import opened during evaluation.
Record an import opened during evaluation. Include duplicates
Get any property in the item that has the specified name,
otherwise returns null
Get any property in the item that has the specified name,
otherwise returns null.
Name is the segment of the provided string with the provided start and end indexes.
Get the value of a property in this project, or
an empty string if it does not exist.
A property with a value of empty string and no property
at all are not distinguished between by this method.
This is because the build does not distinguish between the two.
The reason this method exists when users can simply do GetProperty(..).EvaluatedValue,
is that the caller would have to check for null every time. For properties, empty and undefined are
not distinguished, so it much more useful to also have a method that returns empty string in
either case.
This function returns the unescaped value.
Add a property with the specified name and value.
Overwrites any property with the same name already in the collection.
We don't take a ProjectPropertyInstance to make sure we don't have one that's already
in use by another ProjectPropertyInstance.
Adds an item with no metadata to the project
We don't take a ProjectItemInstance to make sure we don't have one that's already
in use by another ProjectInstance.
For purposes of declaring the project that defined this item (for use with e.g. the
DeclaringProject* metadata), the entrypoint project is used for synthesized items
like those added by this API.
Adds an item with metadata to the project.
Metadata may be null.
We don't take a ProjectItemInstance to make sure we don't have one that's already
in use by another ProjectInstance.
For purposes of declaring the project that defined this item (for use with e.g. the
DeclaringProject* metadata), the entrypoint project is used for synthesized items
like those added by this API.
Get a list of all the items in the project of the specified
type, or an empty list if there are none.
This is a read-only list.
get items by item type and evaluated include value
Removes an item from the project, if present.
Returns true if it was present, false otherwise.
Removes any property with the specified name.
Returns true if the property had a value (possibly empty string), otherwise false.
Create an independent, deep clone of this object and everything in it.
Useful for compiling a single file; or for keeping build results between builds.
Clone has the same mutability as the original.
Create an independent clone of this object, keeping ONLY the explicitly
requested project state.
Useful for reducing the wire cost of IPC for out-of-proc nodes used during
design-time builds that only need to populate a known set of data.
Project state that should be returned.
Create an independent, deep clone of this object and everything in it, with
specified mutability.
Useful for compiling a single file; or for keeping build results between builds.
Build default target/s with loggers of the project collection.
Returns true on success, false on failure.
Only valid if mutable.
Build default target/s with specified loggers.
Returns true on success, false on failure.
Loggers may be null.
Only valid if mutable.
If any of the loggers supplied are already attached to the logging service we
were passed, throws InvalidOperationException.
Build default target/s with specified loggers.
Returns true on success, false on failure.
Loggers may be null.
Only valid if mutable.
If any of the loggers supplied are already attached to the logging service we
were passed, throws InvalidOperationException.
Build a target with specified loggers.
Returns true on success, false on failure.
Target may be null.
Loggers may be null.
Only valid if mutable.
If any of the loggers supplied are already attached to the logging service we
were passed, throws InvalidOperationException.
Build a target with specified loggers.
Returns true on success, false on failure.
Target may be null.
Loggers may be null.
Remote loggers may be null.
Only valid if mutable.
If any of the loggers supplied are already attached to the logging service we
were passed, throws InvalidOperationException.
Build a list of targets with specified loggers.
Returns true on success, false on failure.
Targets may be null.
Loggers may be null.
Only valid if mutable.
If any of the loggers supplied are already attached to the logging service we
were passed, throws InvalidOperationException.
Build a list of targets with specified loggers.
Returns true on success, false on failure.
Targets may be null.
Loggers may be null.
Remote loggers may be null.
Only valid if mutable.
If any of the loggers supplied are already attached to the logging service we
were passed, throws InvalidOperationException.
Build a list of targets with specified loggers.
Returns true on success, false on failure.
Targets may be null.
Loggers may be null.
Only valid if mutable.
If any of the loggers supplied are already attached to the logging service we
were passed, throws InvalidOperationException.
Build a list of targets with specified loggers.
Returns true on success, false on failure.
Targets may be null.
Loggers may be null.
Remote loggers may be null.
Only valid if mutable.
If any of the loggers supplied are already attached to the logging service we
were passed, throws InvalidOperationException.
Evaluates the provided string by expanding items and properties,
using the current items and properties available.
This is useful for some hosts, or for the debugger immediate window.
Does not expand bare metadata expressions.
Not for internal use.
Evaluates the provided string as a condition by expanding items and properties,
using the current items and properties available, then doing a logical evaluation.
This is useful for the immediate window.
Does not expand bare metadata expressions.
Not for internal use.
Creates a ProjectRootElement from the contents of this ProjectInstance.
A ProjectRootElement which represents this instance.
Replaces the project state (, and ) with that
from the provided.
with the state to use.
When project instances get serialized between nodes, they need to be initialized with node specific information.
The node specific information cannot come from the constructor, because that information is not available to INodePacketTranslators
Translate the project instance to or from a stream.
Only translates global properties, properties, items, and mutability.
Creates a set of project instances which represent the project dependency graph for a solution build.
Factory for deserialization.
Throws invalid operation exception if the project instance is immutable.
Called before an edit.
Builds a list of targets with the specified loggers.
Builds a list of targets with the specified loggers.
Retrieves the list of targets which should run before the specified target.
Never returns null.
Retrieves the list of targets which should run after the specified target.
Never returns null.
Cache the contents of this project instance to the translator.
The object is retained, but the bulk of its content is released.
Retrieve the contents of this project from the translator.
Adds the specified target to the instance.
Removes the specified target from the instance.
Throws invalid operation exception if the project instance is immutable.
Called before an edit.
Generate a 4.0+-style solution wrapper project.
The solution file to generate a wrapper for.
The global properties of this solution.
The ToolsVersion to use when generating the wrapper.
The logging service used to log messages etc. from the solution wrapper generator.
The build event context in which this project is being constructed.
A collection of target names that the user requested be built.
The ProjectRootElement for the root traversal and each of the metaprojects.
Spawn the old engine to generate a solution wrapper project, so that our build ordering is somewhat more correct
when solutions with toolsVersions < 4.0 are passed to us.
#############################################################################################
#### Segregated into another method to avoid loading the old Engine in the regular case. ####
####################### Do not move back in to the main code path! ##########################
#############################################################################################
We have marked this method as NoInlining because we do not want Microsoft.Build.Engine.dll to be loaded unless we really execute this code path
The solution file to generate a wrapper for.
The global properties of this solution.
The ToolsVersion to use when generating the wrapper.
The root element cache which should be used for the generated project.
The build parameters.
The logging service used to log messages etc. from the solution wrapper generator.
The build event context in which this project is being constructed.
true if the project is explicitly loaded, otherwise false.
An to use when resolving SDKs.
An appropriate ProjectRootElement
Creates a copy of a dictionary and returns a read-only dictionary around the results.
The value stored in the dictionary
Dictionary to clone.
The to use for the cloned dictionary.
Creates a copy of a dictionary and returns a read-only dictionary around the results.
The value stored in the dictionary
Dictionary to clone.
Common code for the constructors that evaluate directly.
Global properties may be null.
Tools version may be null.
Does not set mutability.
Get items by evaluatedInclude value
Create various target snapshots
Create various imports snapshots
Create environment variable properties snapshot
Create global properties snapshot
Create evaluated include cache snapshot
Create Items snapshot
Create ItemDefinitions snapshot
create property snapshot
An evaluated item definition for a particular item-type, divested of all references to XML.
Immutable.
Item type, for example "Compile", that this item definition applies to
Collection of metadata that link the XML metadata and instance metadata
Since evaluation has occurred, this is an unordered collection.
Is never null or empty.
Constructs an empty project item definition instance.
The type of item this definition object represents.
Called when a ProjectInstance is created.
Assumes that the itemType string originated in a ProjectItemDefinitionElement and therefore
was already validated.
Type of this item definition.
Metadata on the item definition.
If there is no metadata, returns empty collection.
This is a read-only collection.
Number of pieces of metadata on this item definition.
Names of all metadata on this item definition
Implementation of IKeyed exposing the item type, so these
can be put in a dictionary conveniently.
Get any metadata in the item that has the specified name,
otherwise returns null
Returns the specified metadata.
The metadata name.
The metadata value, or an empty string if none exists.
Returns the metadata for the specified item type.
The item type.
The metadata name.
The metadata value, or an empty string if none exists.
Returns the metadata for the specified item type.
The item type.
The metadata name.
The metadata value, or an null if none exists.
Sets a new metadata value. Called by the evaluator only.
Discards predecessor as this information is only useful at design time.
Creates a ProjectItemDefinitionElement representing this instance.
Wraps an unevaluated itemgroup under a target.
Immutable.
Condition, if any
Child items.
Not ProjectItemInstances, as these are evaluated during the build.
Location of this element
Location of the condition, if any
Constructor called by the Evaluator.
Assumes ProjectItemGroupTaskItemInstance is an immutable type.
Cloning constructor
Condition, if any.
May be empty string.
Child items
Location of the original element
Location of the condition, if any
Deep clone
Wraps an unevaluated item under an itemgroup in a target.
Immutable.
Item type, for example "Compile"
Unevaluated include
Unevaluated exclude
Unevaluated remove
The list of metadata Remove should match on.
The options for MatchOnMetadata.
The list of metadata to keep.
The list of metadata to remove.
True to remove duplicates during the add.
Unevaluated condition
Location of this element
Location of the include, if any.
Location of the exclude, if any.
Location of the remove, if any.
Location of matchOnMetadata, if any.
Location of metadataMatchingSchema, if any.
Location of keepMetadata, if any.
Location of removeMetadata, if any.
Location of keepDuplicates, if any.
Location of the condition, if any.
Ordered collection of unevaluated metadata.
May be null.
There is no need for a PropertyDictionary here as the build always
walks through all metadata sequentially.
Lazily created, as so many items have no metadata at all.
Constructor called by the Evaluator.
Metadata may be null, indicating no metadata.
Metadata collection is ordered.
Assumes ProjectItemGroupTaskMetadataInstance is an immutable type.
Cloning constructor
Item type, for example "Compile"
Unevaluated include value
Unevaluated exclude value
Unevaluated remove value
Unevaluated MatchOnMetadata value.
Unevaluated MatchOnMetadataOptions value.
Unevaluated keepMetadata value.
Unevaluated removeMetadata value.
Unevaluated keepDuplicates value.
Unevaluated condition value.
Ordered collection of unevaluated metadata on the item.
If there is no metadata, returns an empty collection.
IEnumerable
Location of the element.
Location of the include attribute, if any.
Location of the exclude attribute, if any.
Location of the remove attribute, if any.
Location of the matchOnMetadata attribute, if any.
Location of the matchOnMetadataOptions attribute, if any.
Location of the keepMetadata attribute, if any.
Location of the removeMetadata attribute, if any.
Location of the keepDuplicates attribute, if any.
Location of the condition attribute if any.
Deep clone
Wraps an unevaluated metadatum under an item in an itemgroup in a target
Immutable.
Name of the metadatum
Unevaluated value
Unevaluated condition
Location of this element
Location of the condition, if any
Constructor called by the Evaluator.
Cloning constructor
Name of the metadatum
Unevaluated value
Unevaluated condition value
Location of the element
Location of the condition attribute if any
Deep clone
Wraps an evaluated item for build purposes
Does not store XML location information. That is not needed by the build process as all correctness checks
and evaluation has already been performed, so it is unnecessary bulk.
The project instance to which this item belongs.
Never null.
Item type, for example "Compile"
Never null.
Backing task item holding the other data.
Never null.
Constructor for items with no metadata.
Include may be empty.
Called before the build when virtual items are added,
and during the build when tasks emit items.
Mutability follows the project.
Constructor for items with no metadata.
Include may be empty.
Called before the build when virtual items are added,
and during the build when tasks emit items.
Mutability follows the project.
Constructor for items with metadata.
Called before the build when virtual items are added,
and during the build when tasks emit items.
Include may be empty.
Direct metadata may be null, indicating no metadata. It will be cloned.
Builtin metadata may be null, indicating it has not been populated. It will be cloned.
Inherited item definition metadata may be null. It is assumed to ALREADY HAVE BEEN CLONED.
Mutability follows the project.
Not public since the only creation scenario is setting on a project.
Constructor for items with metadata.
Called when a ProjectInstance is created.
Include may be empty.
Direct metadata may be null, indicating no metadata. It will be cloned.
Metadata collection provided is cloned.
Mutability follows the project.
Not public since the only creation scenario is setting on a project.
Cloning constructor, retaining same parentage.
Cloning constructor.
Constructor for serialization
Owning project
Item type, for example "Compile"
This cannot be set, as it is used as the key into
the project's items table.
Evaluated include value.
May be empty string.
Evaluated include value, escaped as necessary.
May be empty string.
Evaluated include value, escaped as necessary.
May be empty string.
Unordered collection of evaluated metadata on the item.
If there is no metadata, returns an empty collection.
Does not include built-in metadata.
Includes any from item definitions.
This is a read-only collection. To modify the metadata, use .
Computed, not necessarily fast.
Number of pieces of metadata on this item
Implementation of IKeyed exposing the item type
Returns all the metadata names on this item.
Includes names from any applicable item definitions.
Includes names of built-in metadata.
Computed, not necessarily fast.
ITaskItem implementation
ITaskItem implementation
Computed, not necessarily fast.
Returns the number of metadata entries.
Includes any from applicable item definitions.
Includes both custom and built-in metadata.
Computed, not necessarily fast.
The directory of the project being built
Never null: If there is no project filename yet, it will use the current directory
Retrieves the comparer used for determining equality between ProjectItemInstances.
The full path to the project file being built
Can be null: if the project hasn't been saved yet it will be null
Get any metadata in the item that has the specified name,
otherwise returns null.
Includes any metadata inherited from item definitions.
Includes any built-in metadata.
Get the value of a metadata on this item, or
String.Empty if it does not exist or has no value.
Includes any metadata inherited from item definitions and any built-in metadata.
To determine whether a piece of metadata is actually present
but with an empty value, use HasMetadata.
Returns true if a particular piece of metadata is defined on this item (even if
its value is empty string) otherwise false.
This includes built-in metadata and metadata from item definitions.
It has to include all of these because it's used for batching, which doesn't
care where the metadata originated.
Add a metadata with the specified name and value.
Overwrites any metadata with the same name already in the collection.
Add a metadata with the specified names and values.
Overwrites any metadata with the same name already in the collection.
Removes a metadatum with the specified name.
Used by TaskItem
Produce a string representation.
Get the value of a metadata on this item, or
String.Empty if it does not exist or has no value.
Includes any metadata inherited from item definitions and any built-in metadata.
To determine whether a piece of metadata is actually present
but with an empty value, use HasMetadata.
Sets the specified metadata. Discards the xml part except for the name.
Discards the location of the original element. This is not interesting in the Execution world
as it should never be needed for any messages, and is just extra bulk.
Predecessor is discarded as it is only needed for design time.
ITaskItem implementation.
ITaskItem should not return null if metadata is not present.
ITaskItem2 implementation.
ITaskItem2 should not return null if metadata is not present.
ITaskItem implementation
MetadataValue is assumed to be in its escaped form.
ITaskItem2 implementation
Assumes metadataValue is unescaped.
ITaskItem implementation
ITaskItem implementation
Returns a dictionary of the UNESCAPED values of the metadata
ITaskItem2 implementation
Returns a dictionary of the ESCAPED values of the metadata
Retrieves any value we have in our metadata table for the metadata name specified.
If no value is available, returns empty string.
Retrieves any value we have in our metadata table for the metadata name and item type specified.
If no value is available, returns empty string.
If item type is null, it is ignored, otherwise it must match.
Returns the value if it exists.
If no value is available, returns null.
If item type is null, it is ignored, otherwise it must match.
Translation method.
Deep clone the item.
Any metadata inherited from item definitions are also copied.
Set all the supplied metadata on all the supplied items.
Factory for deserialization.
Add a metadata with the specified names and values.
Overwrites any metadata with the same name already in the collection.
Sets metadata where one built-in metadata is allowed to be set: RecursiveDir.
This is not normally legal to set outside of evaluation. However, the CreateItem
needs to be able to set it as a task output, because it supports wildcards. So as a special exception we allow
tasks to set this particular metadata as a task output.
Other built in metadata names are ignored. That's because often task outputs are items that were passed in,
which legally have built-in metadata. If necessary we can calculate it on the new items we're making if requested.
We don't copy them too because tasks shouldn't set them (they might become inconsistent)
Deep clone the item.
Any metadata inherited from item definitions are also copied.
Deep clone the item.
Any metadata inherited from item definitions are also copied.
Generates a ProjectItemElement representing this instance.
The root element to which the element will belong.
The new element.
Common constructor code.
Direct metadata may be null, indicating no metadata. It will be cloned.
Builtin metadata may be null, indicating it has not been populated. It will be cloned.
Inherited item definition metadata may be null. It is assumed to ALREADY HAVE BEEN CLONED.
Mutability follows the project.
An item without an item type. Cast to an ITaskItem, this is
what is given to tasks. It is also used for target outputs.
The source file that defined this item.
Evaluated include, escaped as necessary.
The evaluated (escaped) include prior to wildcard expansion. Used to determine the
RecursiveDir build-in metadata value.
Evaluated metadata.
May be null.
Lazily created, as there are huge numbers of items generated in
a build that have no metadata at all.
Cached value of the fullpath metadata. All other metadata are computed on demand.
All the item definitions that apply to this item, in order of
decreasing precedence. At the bottom will be an item definition
that directly applies to the item type that produced this item. The others will
be item definitions inherited from items that were
used to create this item.
Directory of the associated project. If this is available,
it is used to calculate built-in metadata. Otherwise,
the current directory is used.
Whether the task item is immutable.
Creates an instance of this class given the item-spec.
Creates an instance of this class given the item-spec and a built-in metadata collection.
Parameters are assumed to be ALREADY CLONED.
Creates a task item by copying the information from a .
Parameters are cloned.
Constructor for deserialization only.
Creates an instance of this class given the backing item.
Does not copy immutability, since there is no connection with the original.
Private constructor used for serialization.
Private constructor used for serialization.
Gets or sets the unescaped include, or "name", for the item.
This one is a bit tricky. Orcas assumed that the value being set was escaped, but
that the value being returned was unescaped. Maintain that behaviour here. To get
the escaped value, use ITaskItem2.EvaluatedIncludeEscaped.
Gets or sets the escaped include, or "name", for the item.
Taking the opportunity to fix the property name, although this doesn't
make it obvious it's an improvement on ItemSpec.
Gets the names of metadata on the item.
Includes all built-in metadata.
Computed, not necessarily fast.
Gets the number of metadata set on the item.
Computed, not necessarily fast.
Gets the names of custom metadata on the item.
If there is none, returns an empty collection.
Does not include built-in metadata.
Computed, not necessarily fast.
Gets the number of custom metadata set on the item.
Does not include built-in metadata.
Computed, not necessarily fast.
Gets the evaluated include for this item, unescaped.
Gets the evaluated include for this item, escaped.
The directory of the project owning this TaskItem.
May be null if this is not well defined.
Returns some value useful for a key in a dictionary
The escaped include for this item
The value of the include after evaluation but before wildcard expansion.
Used to determine %(RecursiveDir)
Number of pieces of metadata directly on this item
Efficient way to retrieve metadata used by packet serialization
and binary logger.
Used to return metadata from another AppDomain. Can't use yield return because the
generated state machine is not marked as [Serializable], so we need to allocate.
The source list to return metadata from.
An array of string key-value pairs representing metadata.
Unordered collection of evaluated metadata on the item.
If there is no metadata, returns an empty collection.
Does not include built-in metadata.
Includes any from item definitions not masked by directly set metadata.
This is a read-only collection. To modify the metadata, use .
Computed, not necessarily fast.
This allows an explicit typecast from a "TaskItem" to a "string", returning the ItemSpec for this item.
The equivalence operator.
The left hand operand.
The right hand operand.
True if the items are equivalent, false otherwise.
The non-equivalence operator.
The left hand operand.
The right hand operand.
False if the items are equivalent, true otherwise.
Produce a string representation.
Overridden to give this class infinite lease time. Otherwise we end up with a limited
lease (5 minutes I think) and instances can expire if they take long time processing.
Returns the metadata with the specified key.
Returns the escaped value of the metadata with the specified key.
Returns the escaped value of the metadata with the specified key.
Gets any existing ProjectMetadata on the item, or
else any on an applicable item definition.
This is ONLY called during evaluation.
Evaluation never creates ITaskItems, so this should never be called.
Set metadata
ITaskItem implementation which returns the specified metadata value, unescaped.
If metadata is not defined, returns empty string.
Returns the specified metadata value, escaped.
If metadata is not defined, returns empty string.
ITaskItem implementation which sets metadata.
The value is assumed to be escaped.
ITaskItem2 implementation which sets the literal value of metadata -- it is escaped
internally as necessary.
ITaskItem implementation which removed the named piece of metadata.
If the metadata is not present, does nothing.
ITaskItem implementation which copies the metadata on this item to the specified item.
Does not copy built-in metadata, and will not overwrite existing, non-empty metadata.
If the destination implements ITaskItem2, this avoids losing the escaped nature of values.
ITaskItem implementation which copies the metadata on this item to the specified item.
Copies direct and item definition metadata.
Does not copy built-in metadata, and will not overwrite existing, non-empty metadata.
If the destination implements ITaskItem2, this avoids losing the escaped nature of values.
When copying metadata to a task item which can be accessed from a task (Utilities task item)
this method will merge and expand any metadata originating with item definitions.
destination item to copy the metadata from this to
Whether the OriginalItemSpec should be added as a piece
of magic metadata. For copying of items this is useful but for cloning of items this adds
additional metadata which is not useful because the OriginalItemSpec will always be identical
to the ItemSpec, and the addition will and will cause copy-on-write to trigger.
ITaskItem implementation which returns a clone of the metadata on this object.
Values returned are unescaped. To get the original escaped values, use ITaskItem2.CloneCustomMetadataEscaped instead.
The cloned metadata.
ITaskItem2 implementation which returns a clone of the metadata on this object.
Values returned are in their original escaped form.
The cloned metadata.
Reads or writes the packet to the serializer.
Built-in metadata is not transmitted, but other metadata is.
Does not lose escaped nature.
Override of GetHashCode.
Override of Equals
Test for item equivalence. Items are equivalent if their item specs are the same,
and they have the same custom metadata, case insensitive.
The metadata value check has to be case insensitive as batching bucketing is case
insensitive.
The item against which to compare.
True if the items are equivalent, false otherwise.
Returns true if a particular piece of metadata is defined on this item (even if
its value is empty string) otherwise false.
This includes built-in metadata and metadata from item definitions.
It has to include all of these because it's used for batching, which doesn't
care where the metadata originated.
Add a metadata with the specified names and values.
Overwrites any metadata with the same name already in the collection.
Assumes that metadataDictionary contains escaped values
Factory for serialization.
Factory for serialization.
Reads or writes the task item to the translator using an interner for metadata.
Gets any metadata with the specified name.
Does not include built-in metadata.
Add a metadata with the specified name and value.
Overwrites any metadata with the same name already in the collection.
Add a metadata with the specified name and value.
Overwrites any metadata with the same name already in the collection.
Does not allow built-in metadata unless allowItemSpecModifiers is set.
Sets metadata where one built-in metadata is allowed to be set: RecursiveDir.
This is not normally legal to set outside of evaluation. However, the CreateItem
needs to be able to set it as a task output, because it supports wildcards. So as a special exception we allow
tasks to set this particular metadata as a task output.
Other built in metadata names are ignored. That's because often task outputs are items that were passed in,
which legally have built-in metadata. If necessary we can calculate it on the new items we're making if requested.
We don't copy them too because tasks shouldn't set them (they might become inconsistent)
Deep clone this into another TaskItem
Deep clone this into another TaskItem
Helper to get the value of a built-in metadatum with
the specified name, if any.
If value is not available, returns empty string.
Retrieves the named metadata from the item definition, if any.
If it is not present, returns null.
A class factory for instance model items.
The project to which item instances created by this factory will belong.
Constructor not taking an item type.
This indicates that the user of this factory should set the item type
on it before using it to create items.
Constructor taking the itemtype for the generated items.
The item type that generated items should have
Sets the item type via the item xml.
Used by the evaluator only.
Creates an instance-model item.
The include.
The project that defined the item.
A new instance item.
Create a ProjectItemInstance, changing the item type but keeping the include.
This is to support the scenario Include="@(i)" where we are copying
metadata.
Create a ProjectItemInstance, changing the item type and include but retaining the
metadata of the original item.
This is to support this scenario: Include="@(i->'xxx')"
Create a new item from the specified include and include before wildcard expansion.
This is to support the scenario Include="@(i)" where we are creating new items before adding metadata.
Applies the supplied metadata to the destination item.
Create a ProjectItemInstance from another item, changing the item type and include.
A class factory for task items.
The singleton instance.
Private constructor for singleton creation.
The item type of items created by this factory.
Since TaskItems don't have an item type, this returns null, and cannot be set.
The item xml for items in this factory.
The singleton instance. Can be cast to the interface required.
Creates a taskitem.
The include.
The project that defined the item.
A new instance item.
Creates a task item from a ProjectItem
Creates a task item from a ProjectItem but changing the itemspec
Create a task item from a ProjectItemInstance.
Creates a task item from a ProjectItem
Creates a task item using the specified include and include before wildcard expansion.
Applies the supplied metadata to the destination item.
Implementation of IMetadataTable that can be passed to expander to expose only built-in metadata on this item.
Built-in metadata is stored in a separate table so it can be cleared out when the item is renamed, as this invalidates the values.
Also, more importantly, because typically the same regular metadata values can be shared by many items,
and keeping item-specific metadata out of it could allow it to be implemented as a copy-on-write table.
Item type
Backing item
Constructor.
Retrieves any value we have in our metadata table for the metadata name specified.
If no value is available, returns empty string.
Retrieves any value we have in our metadata table for the metadata name and item type specified.
If item type is null, it is ignored.
If no value is available, returns empty string.
Returns the value if it exists, null otherwise.
If item type is null, it is ignored.
Implementation of a comparer that determines equality between ProjectItemInstances
The singleton comparer.
Constructor.
Returns the default comparer instance.
Implemtnation of IEqualityComparer.Equals.
The left hand side.
The right hand side.
True of the instances are equivalent, false otherwise.
Implementation of IEqualityComparer.GetHashCode.
The item instance.
The hash code of the instance.
Wraps an evaluated piece of metadata for build purposes
Added and removed via methods on the ProjectItemInstance object.
IMMUTABLE OBJECT.
Name of the metadatum
Evaluated value
Never null.
Constructor for metadata.
Does not allow item spec modifiers.
Discards the location of the original element. This is not interesting in the Execution world
as it should never be needed for any subsequent messages, and is just extra bulk.
IMMUTABLE OBJECT.
Not public since the only creation scenario is setting on an item
Constructor for metadata.
Called when a ProjectInstance is created, before the build
when virtual items are added, and during the build when tasks
emit items.
Discards the location of the original element. This is not interesting in the Execution world
as it should never be needed for any subsequent messages, and is just extra bulk.
IMMUTABLE OBJECT.
If the value passed in is null, will be changed to String.Empty.
Not public since the only creation scenario is setting on an item
Constructor for metadata from a ProjectMetadata.
Called when a ProjectInstance is created.
IMMUTABLE OBJECT.
Private constructor used for serialization
Name of the metadata
This cannot be set, as it is used as the key into
the item's metadata table.
Evaluated value of the metadatum.
Never null.
Implementation of IKeyed exposing the metadatum name
Implementation of IValued
Evaluated and escaped value of the metadata.
Never null.
String representation handy for tracing
Reads or writes the packet to the serializer.
Compares this metadata to another for equivalence.
The other metadata
True if they are equivalent, false otherwise.
Deep clone the metadata
Strings are immutable (copy on write) so there is no work to do.
Allows built-in metadata names, as they are still valid on the new metadatum.
A new metadata instance.
Factory for serialization.
Wraps an onerror element
This is an immutable class
Unevaluated executetargets value.
Condition on the element.
Location of this element
Location of the condition, if any
Location of the executeTargets attribute
Constructor called by Evaluator.
All parameters are in the unevaluated state.
Unevaluated condition.
May be empty string.
Unevaluated ExecuteTargets value.
May be empty string.
Location of the element
Location of the condition, if any
Location of the execute targets attribute, if any
Wraps an unevaluated propertygroup under a target.
Immutable.
Condition, if any
Child properties.
Not ProjectPropertyInstances, as these are evaluated during the build.
Location of this element
Location of the condition, if any
Constructor called by the Evaluator.
Assumes ProjectPropertyGroupTaskPropertyInstance is an immutable type.
Cloning constructor
Condition, if any.
May be empty string.
Child properties
Location of the element itself
Location of the condition, if any
Deep clone
Wraps an unevaluated property under an propertygroup in a target.
Immutable.
Name of the property
Unevaluated value
Unevaluated condition
Location of this element
Location of the condition, if any
Constructor called by the Evaluator.
Cloning constructor
Property name
Unevaluated value
Unevaluated condition value
Location of the original element
Location of the condition, if any
Deep clone
Wraps an evaluated property for build purposes.
Added and removed via methods on the ProjectInstance object.
Name of the property
Evaluated value: stored escaped.
Private constructor
Name of the property
This cannot be set, as it is used as the key into
the project's properties table.
Evaluated value of the property.
Setter assumes caller has protected global properties, if necessary
SETTER ASSUMES CALLER ONLY CALLS IF PROJECTINSTANCE IS MUTABLE because it cannot always be verified.
Whether this object is immutable.
An immutable object can not be made mutable.
Evaluated value of the property, escaped as necessary.
Setter assumes caller has protected global properties, if necessary.
Implementation of IKeyed exposing the property name
Implementation of IValued
Compares this property to another for equivalence.
The other property.
True if the properties are equivalent, false otherwise.
Reads or writes the packet to the serializer.
Performs a deep clone
String representation handy for tracing
Called before the build when virtual properties are added,
and during the build when tasks emit properties.
If name is invalid or reserved, throws ArgumentException.
Creates mutable object.
Not public since the only creation scenario is setting on a project.
Called before the build when virtual properties are added,
and during the build when tasks emit properties.
If name is invalid or reserved, throws ArgumentException.
Creates mutable object.
Not public since the only creation scenario is setting on a project.
Called by the Evaluator during creation of the ProjectInstance.
Reserved properties can be set with this constructor using the appropriate flag.
This flags should ONLY be set by the evaluator or by cloning; after the ProjectInstance is created, they must be illegal.
If name is invalid or reserved, throws ArgumentException.
Called during project build time to create a property. Reserved properties will cause
an invalid project file exception.
Creates mutable object.
Called during project build time to create a property. Reserved properties will cause
an invalid project file exception.
Cloning constructor.
Strings are immutable (copy on write) so there is no work to do
Cloning constructor.
Strings are immutable (copy on write) so there is no work to do
Factory for serialization
Performs a deep clone
Performs a deep clone, optionally changing mutability
Creates a ProjectPropertyElement representing this instance.
The root element to which this element will belong.
The new element.
Private constructor which throws the right sort of exception depending on whether it is invoked as a result of
a design-time or build-time call.
Discards the location of the original element after error checking. This is not interesting in the Execution world
as it should never be needed for any subsequent messages, and is just extra bulk.
Inherits mutability from project if any.
Version of the class that's immutable.
Could have a single class with a boolean field, but there are large numbers of these
so it's important to avoid adding another field. Both types of objects are 16 bytes instead of 20.
Private constructor.
Called by outer class factory method.
Whether this object can be changed.
An immutable object can not be made mutable.
Usually gotten from the parent ProjectInstance.
Wraps a target element
This is an immutable class.
Name of the target
Condition on the target.
Evaluated during the build.
Inputs on the target
Outputs on the target
Return values on the target.
Semicolon separated list of targets it depends on
Semicolon separated list of targets it runs before
Semicolon separated list of targets it runs after
Condition for whether to trim duplicate outputs
Child entries of the target which refer to OnError targets
Whether the project file that this target lives in has at least one target
with a Returns attribute on it. If so, the default behaviour for all targets
in the file without Returns attributes changes from returning the Outputs, to
returning nothing.
Location of this element
Location of the condition, if any
Location of the inputs attribute, if any
Location of the outputs attribute, if any
Location of the returns attribute, if any
Location of KeepDuplicateOutputs attribute, if any
Location of the DependsOnTargets attribute ,if any
Location of the BeforeTargets attribute ,if any
Location of the AfterTargets attribute ,if any
Child tasks below the target (both regular tasks and "intrinsic tasks" like ItemGroup and PropertyGroup).
This is a read-only list unless the instance has been modified using AddTask.
Constructor called by Evaluator.
All parameters are in the unevaluated state.
All location parameters may be null if not applicable, except for the main location parameter.
Name of the target
Unevaluated condition on the task.
May be empty string.
Unevaluated inputs on the target element.
May be empty string.
Unevaluated outputs on the target element
May be empty string.
Unevaluated return values on the target element
May be empty string or null, if no return value is specified.
Unevaluated condition on which we will trim duplicate outputs from the target outputs
May be empty string.
Unevaluated semicolon separated list of targets it depends on.
May be empty string.
Unevaluated semicolon separated list of targets it runs before.
May be empty string.
Unevaluated semicolon separated list of targets it runs after.
May be empty string.
Children below the target. The build iterates through this to get each task to execute.
This is an ordered collection.
This is a read-only list; the ProjectTargetInstance class is immutable.
This collection does not contain the OnError target references.
The children below the target which refer to OnError targets.
This is an ordered collection.
This is a read-only list; the ProjectTargetInstance class is immutable.
Just the tasks below this target, if any.
Other kinds of children are not included.
Full path to the file from which this target originated.
If it originated in a project that was not loaded and has never been
given a path, returns an empty string.
Location of the original element
Location of the condition, if any
Location of the inputs
Location of the outputs
Location of the returns
Location of the KeepDuplicatOutputs attribute
Location of the dependsOnTargets
Location of the beforeTargets
Location of the afterTargets
Implementation of IKeyed exposing the target name
Whether the project file that this target lives in has at least one target
with a Returns attribute on it. If so, the default behaviour for all targets
in the file without Returns attributes changes from returning the Outputs, to
returning nothing.
Creates a ProjectTargetElement representing this instance. Attaches it to the specified root element.
The root element to which the new element will belong.
The new element.
Adds new child instance.
Child instance.
Creates a new task and adds it to the end of the list of tasks.
The name of the task to create.
The task's condition.
The continue on error flag.
The new task instance.
Creates a new task and adds it to the end of the list of tasks.
The name of the task to create.
The task's condition.
The continue on error flag.
The MSBuild runtime.
The MSBuild architecture.
The new task instance.
Wraps a task element
This is an immutable class
Name of the task, possibly qualified, as it appears in the project
Condition on the task, if any
May be empty string
Continue on error on the task, if any
May be empty string
Runtime on the task, if any
May be empty string
Architecture on the task, if any
May be empty string
Unordered set of task parameter names and unevaluated values.
This is a dead, read-only collection.
Output properties and items below this task. This is an ordered collection
as one may depend on another.
This is a dead, read-only collection.
Location of this element
Location of the condition, if any
Location of the continueOnError attribute, if any
Location of the MSBuildRuntime attribute, if any
Location of the MSBuildArchitecture attribute, if any
Constructor called by Evaluator.
All parameters are in the unevaluated state.
Locations other than the main location may be null.
Creates a new task instance directly. Used for generating instances on-the-fly.
The task name.
The location for this task.
The unevaluated condition.
The unevaluated continue on error.
The MSBuild runtime.
The MSBuild architecture.
Name of the task, possibly qualified, as it appears in the project
Unevaluated condition on the task
May be empty string.
Unevaluated ContinueOnError on the task.
May be empty string.
Unevaluated MSBuildRuntime on the task.
May be empty string.
Unevaluated MSBuildArchitecture on the task.
May be empty string.
Read-only dead unordered set of task parameter names and unevaluated values.
Condition and ContinueOnError, which have their own properties, are not included in this collection.
Ordered set of output property and item objects.
This is a read-only dead collection.
Location of the ContinueOnError attribute, if any
Location of the MSBuildRuntime attribute, if any
Location of the MSBuildArchitecture attribute, if any
Location of the original element
Location of the condition, if any
Retrieves the parameters dictionary as used during the build.
Returns the value of a named parameter, or null if there is no such parameter.
The name of the parameter to retrieve.
The parameter value, or null if it does not exist.
Sets the unevaluated value for the specified parameter.
The name of the parameter to set.
The unevaluated value for the parameter.
Adds an output item to the task.
The name of the parameter on the task which produces the output.
The item which will receive the output.
The condition.
Adds an output property to the task.
The name of the parameter on the task which produces the output.
The property which will receive the output.
The condition.
Wraps an output item element under a task element
Immutable.
Name of the property to put the output in
Property on the task class to retrieve the output from
Condition on the output element
Location of the original element
Location of the original item type attribute
Location of the original task parameter attribute
Location of the original condition attribute
Constructor called by evaluator
Name of the item type that the outputs go into
Property on the task class to retrieve the outputs from
Condition on the element.
If there is no condition, returns empty string.
Location of the original element
Location of the condition, if any
Location of the TaskParameter attribute
Location of the ItemType attribute
Represents an output property element beneath a task element
Immutable.
Name of the property to put the output in
Property on the task class to retrieve the output from
Condition on the output element
Location of the original element
Location of the original property name attribute
Location of the original task parameter attribute
Location of the original condition attribute
Constructor called by Evaluator
Name of the property to put the output in
Property on the task class to retrieve the output from
Condition on the output element.
If there is no condition, returns empty string.
Location of the original PropertyName attribute
Location of the original element
Location of the condition, if any
Location of the TaskParameter attribute
This class packages information about task which has been loaded from a task factory.
Factory which is wrapped by the wrapper
Cache of names of required properties on this type
Cache of names of output properties on this type
Cache of names of properties on this type whose names are ambiguous
Cache of PropertyInfos for this type
The name of the task this factory can create.
The set of special parameters that, along with the name, contribute to the identity of
this factory.
Creates an instance of this class for the given type.
Load information about the task factory itself
The task factory wrapped by the wrapper
Gets the list of names of public instance properties that have the required attribute applied.
Caches the result - since it can't change during the build.
Gets the list of names of public instance properties that have the output attribute applied.
Caches the result - since it can't change during the build.
Get the name of the factory wrapped by the wrapper
The set of task identity parameters that were set on
this particular factory's UsingTask statement.
Get the cached propertyinfo of the given name
property name
PropertyInfo
Sets the given property on the task.
Gets the value of a given property on the given task.
Determines whether a task with the given name is instantiable by this factory.
Name of the task.
true if this factory can instantiate such a task; otherwise, false.
Populate the cache of PropertyInfos for this type
This class is used to track tasks used by a project. Tasks are declared in project files with the <UsingTask> tag.
Task and assembly names must be specified per .NET guidelines, however, the names do not need to be fully qualified if
they provide enough information to locate the tasks they refer to. Assemblies can also be referred to using file paths --
this is useful when it is not possible/desirable to place task assemblies in the GAC, or in the same directory as MSBuild.
1) specifying a task assembly using BOTH its assembly name (strong or weak) AND its file path is not allowed
2) when specifying the assembly name, the file extension (usually ".dll") must NOT be specified
3) when specifying the assembly file, the file extension MUST be specified
<UsingTask TaskName="Microsoft.Build.Tasks.Csc" ==> look for the "Csc" task in the
AssemblyName="Microsoft.Build.Tasks"/> weakly-named "Microsoft.Build.Tasks" assembly
<UsingTask TaskName="t1" ==> look for the "t1" task in the
AssemblyName="mytasks, Culture=en, Version=1.0.0.0"/> strongly-named "mytasks" assembly
<UsingTask TaskName="foo" ==> look for the "foo" task in the
AssemblyFile="$(MyDownloadedTasks)\utiltasks.dll"/> "utiltasks" assembly file
<UsingTask TaskName="UtilTasks.Bar" ==> invalid task declaration
AssemblyName="utiltasks.dll"
AssemblyFile="$(MyDownloadedTasks)\"/>
The fallback task registry
If true, we will force all tasks to run in the MSBuild task host EXCEPT
a small well-known set of tasks that are known to depend on IBuildEngine
callbacks; as forcing those out of proc would be just setting them up for
known failure.
Simple name for the MSBuild tasks (v4), used for shimming in loading
task factory UsingTasks
Filename for the MSBuild tasks (v4), used for shimming in loading
task factory UsingTasks
Expected location that MSBuild tasks (v4) is picked up from if the user
references it with just a simple name, used for shimming in loading
task factory UsingTasks
Simple name for the MSBuild tasks (v12), used for shimming in loading
task factory UsingTasks
Filename for the MSBuild tasks (v12), used for shimming in loading
task factory UsingTasks
Expected location that MSBuild tasks (v12) is picked up from if the user
references it with just a simple name, used for shimming in loading
task factory UsingTasks
Simple name for the MSBuild tasks (v14+), used for shimming in loading
task factory UsingTasks
Filename for the MSBuild tasks (v14+), used for shimming in loading
task factory UsingTasks
Expected location that MSBuild tasks (v14+) is picked up from if the user
references it with just a simple name, used for shimming in loading
task factory UsingTasks
Cache of tasks already found using exact matching,
keyed by the task identity requested.
Cache of tasks already found using fuzzy matching,
keyed by the task name requested.
Value is a dictionary of all possible matches for that
task name, by unique identity.
Cache of task declarations i.e. the <UsingTask> tags fed to this registry,
keyed by the task name declared.
Task name may be qualified or not.
This field may be null.
The cache to load the *.tasks files into
Creates a task registry that does not fall back to any other task registry.
Default constructor does no work because the tables are initialized lazily when a task is registered
Creates a task registry that defers to the specified toolset's registry for those tasks it cannot resolve.
UNDONE: (Logging.) We can't pass the base task registry from the Toolset because we can't call GetTaskRegistry
without logging context information. When the Project load code is altered to contain logging service
references, we can load the toolset task registry at the time this registry is created and pass it to
this constructor instead of the toolset state.
The Toolset containing the toolser task registry
The to use.
Returns the toolset state used to initialize this registry, if any.
Access list of task registrations.
FOR UNIT TESTING ONLY.
Evaluate the usingtask and add the result into the data passed in
A type derived from IProperty
A type derived from IItem
Given a task name, this method retrieves the task class. If the task has been requested before, it will be found in
the class cache; otherwise, <UsingTask> declarations will be used to search the appropriate assemblies.
Retrieves the task registration record for the specified task.
The name of the task to retrieve.
The task's project file.
The set of task identity parameters to be used to identify the
correct task record match.
True if an exact name match is required.
The logging context.
The location of the task element in the project file.
True if the record was retrieved from the cache.
The task registration record, or null if none was found.
Is the class being loaded a task factory class
Searches all task declarations for the given task name.
If no exact match is found, looks for partial matches.
A task name that is not fully qualified may produce several partial matches.
Registers an evaluated using task tag for future
consultation
Given a task name and a list of records which may contain the task, this helper method will ask the records to see if the task name
can be created by the factories which are wrapped by the records. (this is done by instantiating the task factory and asking it).
An object representing the identity of a task -- not just task name, but also
the set of identity parameters
Constructor
The name of the task
The identity parameters
Comparer used to figure out whether two RegisteredTaskIdentities are equal or not.
The singleton comparer to use when an exact match is desired
The singleton comparer to use when a fuzzy match is desired. Note that this still does an exact match on the
name, but does a fuzzy match on the task identity parameters.
Keeps track of whether we're doing exact or fuzzy equivalency
Constructor
The singleton comparer to use for when an exact match is desired
The singleton comparer to use for when a fuzzy match is desired
Returns true if these two identities match "fuzzily" -- if the names pass a partial type name
match and the task identity parameters would constitute a valid merge (e.g. "don't care" and
something explicit). Otherwise returns false.
Returns true if the two task identities are equal; false otherwise.
Returns a hash code for the given task identity
Returns true if the two dictionaries representing sets of task identity parameters match; false otherwise.
Internal so that RegisteredTaskRecord can use this function in its determination of whether the task factory
supports a certain task identity.
A record for a task registration which also contains the factory which matches the record
Default task factory to use if one is not specified
Default task factory to use if one is not specified and runtime or architecture is specified
Task factory used to create CodeDom-based inline tasks. Special-cased as one of two officially
supported task factories in Microsoft.Build.Tasks.vX.Y.dll to deal with versioning issue.
Task factory used to create CodeDom-based inline tasks. Special-cased as one of two officially
supported task factories in Microsoft.Build.Tasks.vX.Y.dll to deal with versioning issue.
Lock for the taskFactoryTypeLoader
Type filter to make sure we only look for taskFactoryClasses
Identity of this task.
Typeloader for taskFactories
The task name this record was registered with from the using task element
The assembly information about the task factory to be instantiated. For
AssemblyTaskFactories this is the task assembly which should be loaded
The task factory class name which will be used to lookup the task factory from the assembly specified in the assemblyName or assemblyFile.
A task factory wrapper which caches and combines information related to the parameters of the task.
Cache of task names which can be created by the factory.
When ever a taskName is checked against the factory we cache the result so we do not have to
make possibly expensive calls over and over again.
Set of parameters that can be used by the task factory specifically.
Encapsulates the parameters and the body of the task element for the inline task.
Constructor
Gets the task name this record was registered with.
Gets the assembly load information.
Gets the task factory attribute value.
Gets the set of parameters for the task factory
Gets the inline task record
Identity of this task.
Ask the question, whether or not the task name can be created by the task factory.
To answer this question we need to instantiate and initialize the task factory and ask it if it can create the given task name.
This question is useful for assembly tasks where the task may or may not be in an assembly, this can also be useful if the task factory
loads an external file and uses that to generate the tasks.
true if the task can be created by the factory, false if it cannot be created
Given a Registered task record and a task name. Check create an instance of the task factory using the record.
If the factory is a assembly task factory see if the assemblyFile has the correct task inside of it.
Create an instance of the task factory and load it from the assembly.
If the task factory could not be properly created an InvalidProjectFileException will be thrown
Keep track of the xml which will be sent to the inline task factory and the parameters if any which will also be passed in
The list of parameters found in the using task along with a corosponding UsingTaskParameterInfo which contains the specific information about it
Populated lazily as it is often empty.
The body of the task element which will be passed to the task factory.
Was the task body evaluated or not
Create an empty ParameterGroupAndTaskElementRecord
The parameters from the ParameterGroup from the using task element which will be passed to the task factory.
The body of the task element which will be passed to the task factory.
Has the task body been passed to the expander to be expanded
Keep track of the xml which will be sent to the inline task factory and the parameters if any which will also be passed in
Property type
Item Type
Evaluate the task body of the using task
IProperttyTypes
IItems
Convert the UsingTaskParameterGroupElement into a list of parameter names and UsingTaskParameters
Property type
Item types
Enumeration of all possible (currently supported) options for handshakes.
Process is a TaskHost
Using the 2.0 CLR
64-bit Intel process
Node reuse enabled
Building with BelowNormal priority
Building with administrator privileges
This class contains utility methods for the MSBuild engine.
Indicates to the NodeEndpoint that all the various parts of the Handshake have been sent.
The version of the handshake. This should be updated each time the handshake structure is altered.
The timeout to connect to a node.
Whether to trace communications
Place to dump trace
Ticks at last time logged
Delegate to debug the communication utilities.
Gets or sets the node connection timeout.
Get environment block
Free environment block
Copied from the BCL implementation to eliminate some expensive security asserts.
Returns key value pairs of environment variables in a new dictionary
with a case-insensitive key comparer.
Updates the environment to match the provided dictionary.
Indicate to the client that all elements of the Handshake have been sent.
Extension method to write a series of bytes to a stream
Extension method to read a series of bytes from a stream.
If specified, leading byte matches one in the supplied array if any, returns rejection byte and throws IOException.
Given the appropriate information, return the equivalent HandshakeOptions.
Gets the value of an integer environment variable, or returns the default if none is set or it cannot be converted.
Writes trace information to a log file
Writes trace information to a log file
Gets a hash code for this string. If strings A and B are such that A.Equals(B), then
they will return the same hash code.
This is as implemented in CLR String.GetHashCode() [ndp\clr\src\BCL\system\String.cs]
but stripped out architecture specific defines
that causes the hashcode to be different and this causes problem in cross-architecture handshaking
Contains a list of the special (reserved) properties that are settable by MSBuild code only.
Lookup for reserved property names. Intentionally do not include MSBuildExtensionsPath* or MSBuildUserExtensionsPath in this list. We need tasks to be able to override those.
Indicates if the given property is a reserved property.
true, if specified property is reserved
Constants used by the Engine
If no default tools version is specified in the config file or registry, we'll use 2.0.
The engine will use its binpath for the matching toolset path.
The toolsversion we will fall back to as a last resort if the default one cannot be found, this fallback should be the most current toolsversion known
The toolsversion we will use when we construct the solution wrapper metaprojects; this should be the most current toolsversion known
Name of the property used to specify a Visual Studio version.
Name of the property used to select which sub-toolset to use.
Value we should be setting VisualStudioVersion as the ultimate fallback when Dev10 is installed.
Current version of this MSBuild Engine assembly in the
form, e.g, "4.0"
The set of available static methods.
NOTE: Do not allow methods here that could do "bad" things under any circumstances.
These must be completely benign operations, as they run during project load, which must be safe in VS.
Key = Type or Type::Method, Value = AssemblyQualifiedTypeName (where null = mscorlib)
Placed here to avoid StyleCop error.
Static methods that are allowed in constants. Key = Type or Type::Method, Value = Tuple of AssemblyQualifiedTypeName (where null = mscorlib) or the actual type object
Locker to protect initialization
Whether a key is present
Add an entry if not already present
Constructs the fully qualified method name and adds it to the cache
Get an entry if present
Get an entry or null if not present
Tries to retrieve the type information for a type name / method name combination.
It does 2 lookups:
1st try: 'typeFullName'
2nd try: 'typeFullName::simpleMethodName'
namespace qualified type name
name of the method
Returns the fully qualified format for the given method: see typeFullName::methodName
namespace qualified type name
simple name of the method
Re-initialize.
Unit tests need this when they enable "unsafe" methods -- which will then go in the collection,
and mess up subsequent tests.
Fill up the dictionary for first use
Gets the of Microsoft.Build.dll.
Gets a singleton instance of .
Gets the assembly file version in the format major.minor.
Used for the purposes of evaluating an item specification. Given a filespec that may include wildcard characters * and
?, we translate it into an actual list of files. If the input filespec doesn't contain any wildcard characters, and it
doesn't appear to point to an actual file on disk, then we just give back the input string as an array of length one,
assuming that it wasn't really intended to be a filename (as items are not required to necessarily represent files).
Any wildcards passed in that are unescaped will be treated as real wildcards.
The "include" of items passed back from the filesystem will be returned canonically escaped.
The ordering of the list returned is deterministic (it is sorted).
Will never throw IO exceptions. If path is invalid, just returns filespec verbatim.
The directory to evaluate, escaped.
The filespec to evaluate, escaped.
Array of file paths, unescaped.
Used for the purposes of evaluating an item specification. Given a filespec that may include wildcard characters * and
?, we translate it into an actual list of files. If the input filespec doesn't contain any wildcard characters, and it
doesn't appear to point to an actual file on disk, then we just give back the input string as an array of length one,
assuming that it wasn't really intended to be a filename (as items are not required to necessarily represent files).
Any wildcards passed in that are unescaped will be treated as real wildcards.
The "include" of items passed back from the filesystem will be returned canonically escaped.
The ordering of the list returned is deterministic (it is sorted).
Will never throw IO exceptions. If path is invalid, just returns filespec verbatim.
The directory to evaluate, escaped.
The filespec to evaluate, escaped.
Filespecs to exclude, escaped.
Whether to force file glob expansion when eager expansion is turned off
Array of file paths, escaped.
Used for the purposes of evaluating an item specification. Given a filespec that may include wildcard characters * and
?, we translate it into an actual list of files. If the input filespec doesn't contain any wildcard characters, and it
doesn't appear to point to an actual file on disk, then we just give back the input string as an array of length one,
assuming that it wasn't really intended to be a filename (as items are not required to necessarily represent files).
Any wildcards passed in that are unescaped will be treated as real wildcards.
The "include" of items passed back from the filesystem will be returned canonically escaped.
The ordering of the list returned is deterministic (it is sorted).
Will never throw IO exceptions: if there is no match, returns the input verbatim.
The directory to evaluate, escaped.
The filespec to evaluate, escaped.
true to return escaped specs.
Whether to force file glob expansion when eager expansion is turned off
The exclude specification, escaped.
Array of file paths.
Returns a Func that will return true IFF its argument matches any of the specified filespecs
Assumes filespec may be escaped, so it unescapes it
The returned function makes no escaping assumptions or escaping operations. Its callers should control escaping.
Thin wrapper around Microsoft.Win32.RegistryKey that can be
subclassed for testing purposes
Has the object been disposed yet.
Initializes this RegistryKeyWrapper to wrap the specified key.
Does not check for a null key.
Initializes this RegistryKeyWrapper to wrap the key at the specified path
and assumes the key is underneath HKLM
Note that registryKeyPath should be relative to HKLM.
Initializes this RegistryKeyWrapper to wrap the key at the specified path
Initializes this RegistryKeyWrapper to wrap the key at the specified path
Name of the registry key
Convenient static helper method on RegistryKeyWrapper, for when someone is only intersted in knowing
whether a particular registry key exists or not.
Gets the value with name "name" stored under this registry key
Gets the names of all values underneath this registry key
Gets the names of all sub keys immediately below this registry key
Returns the RegistryKeyWrapper around the sub key with name "name". If that does
not exist, returns a RegistryKeyWrapper around null.
Returns true if the wrapped registry key exists.
Lazy getter for the root tools version registry key: means that this class
will never throw registry exceptions from the constructor
This class contains utility methods for the MSBuild engine.
Save off the contents of the environment variable that specifies whether we should treat higher toolsversions as the current
toolsversion. (Some hosts require this.)
Save off the contents of the environment variable that specifies whether we should treat all toolsversions, regardless of
whether they are higher or lower, as the current toolsversion. (Some hosts require this.)
If set, default to the ToolsVersion from the project file (or if that doesn't isn't set, default to 2.0). Otherwise, use Dev12+
defaulting logic: first check the MSBUILDDEFAULTTOOLSVERSION environment variable, then check for a DefaultOverrideToolsVersion,
then if both fail, use the current ToolsVersion.
If set, will be used as the ToolsVersion to build with (unless MSBUILDLEGACYDEFAULTTOOLSVERSION is set).
Delegate for a method that, given a ToolsVersion string, returns the matching Toolset.
INTERNAL FOR UNIT-TESTING ONLY
We've got several environment variables that we read into statics since we don't expect them to ever
reasonably change, but we need some way of refreshing their values so that we can modify them for
unit testing purposes.
Sets the inner XML/text of the given XML node, escaping as necessary.
Can be empty string, but not null.
Extracts the inner XML/text of the given XML node, unescaping as necessary.
Inner XML/text of specified node.
Figure out whether there are any XML tags, other than comment tags,
in the string.
We know the string coming in is a valid XML fragment. (The project loaded after all.)
So for example we can ignore an open comment tag without a matching closing comment tag.
Removes the xmlns attribute from an XML string.
XML string to process.
The modified XML string.
Creates a comma separated list of valid tools versions suitable for an error message.
Figure out what ToolsVersion to use to actually build the project with.
The user-specified ToolsVersion (through e.g. /tv: on the command line)
The ToolsVersion from the project file
Delegate used to test whether a toolset exists for a given ToolsVersion. May be null, in which
case we act as though that toolset existed.
The default ToolsVersion
true if the project file specifies an explicit toolsversion but a different one is chosen
The ToolsVersion we should use to build this project. Should never be null.
Retrieves properties derived from the current
environment variables.
Extension to IEnumerable to get the count if it
can be quickly gotten, otherwise 0.
Extension to IEnumerable of KVP of string, something to just return the somethings.
Project-related Xml utilities
Gets child elements, ignoring whitespace and comments.
Throws InvalidProjectFileException for unexpected XML node types.
Gets child elements, ignoring whitespace and comments.
Throws InvalidProjectFileException for unexpected XML node types if parameter is set.
Throw an invalid project exception if there are any child elements at all
Throw an invalid project exception indicating that the child is not valid beneath the element because it is a duplicate
Throw an invalid project exception indicating that the child is not valid beneath the element
Verify that if a namespace is specified it matches the default MSBuild namespace.
Element to check namespace.
True when the namespace is in the MSBuild namespace or no namespace.
Verifies that if the attribute is present on the element, its value is not empty
Verifies that if the attribute is present on the element, its value is not empty
If there are any attributes on the element, throws an InvalidProjectFileException complaining that the attribute is not valid on this element.
If the condition is false, throws an InvalidProjectFileException complaining that the attribute is not valid on this element.
Verify that the element has the specified required attribute on it and
it has a value other than empty string
Verify that all attributes on the element are on the list of legal attributes
Throws an InvalidProjectFileException complaining that the attribute is not valid on this element.
Sets the value of an attribute, but if the value to set is null or empty, just
removes the attribute. Returns the attribute, or null if it was removed.
UNDONE: Make this return a bool if the attribute did not change, so we can avoid dirtying.
Sets the value of an attribute, removing the attribute if the value is null, but still setting it
if the value is the empty string. Returns the attribute, or null if it was removed.
UNDONE: Make this return a bool if the attribute did not change, so we can avoid dirtying.
Returns the value of the attribute.
If the attribute is null, returns an empty string.
Returns the value of the attribute.
If the attribute is not present, returns an empty string.
Returns the value of the attribute.
If the attribute is not present, returns either null or an empty string, depending on the value
of nullIfNotExists.
Disposable helper class to wrap XmlReader / XmlTextReader functionality.
Creates an XmlReaderExtension with handle to an XmlReader.
Path to the file on disk.
Whther to load the file in real only mode.
Disposable XmlReaderExtension object.
Caches a representing the "Normalization" internal property on the -derived
type returned from . The cache is process/AppDomain-wide
and lock-free, so we use volatile access for thread safety, i.e. to ensure that when the field is updated the PropertyInfo
it's pointing to is seen as fully initialized by all CPUs.
Returns of the "Normalization" internal property on the given -derived type.
Get the Encoding type from the XML declaration tag
XML Reader object
Encoding if specified, else null.
A debug only helper class for tracing
A dictionary of named counters
Last time logging happened
How often to log
A place callers can put something worth logging later
Short name of the current assembly - to distinguish statics when this type is shared into different assemblies
Put something in the slot
Put something in the slot
The key type.
The value type.
Increment the named counter, and dump if it's time to do so
Log the provided items
The item type.
Dump all the named counters, if any
Replacement for BinaryReader which attempts to intern the strings read by ReadString.
The maximum size, in bytes, to read at once.
Shared buffer saves allocating these arrays many times.
The decoder used to translate from UTF8 (or whatever).
Comment about constructing.
Read a string while checking the string precursor for intern opportunities.
Taken from ndp\clr\src\bcl\system\io\binaryreader.cs-ReadString()
A shared buffer to avoid extra allocations in InterningBinaryReader.
Create a BinaryReader. It will either be an interning reader or standard binary reader
depending on whether the interning reader is possible given the buffer and stream.
Holds thepreallocated buffer.
Yes, we are constructing.
The char buffer.
The byte buffer.
Opaque holder of shared buffer.
Holds various information about the current msbuild execution that the cache might use.
The cache may need to know about the top level projects or the entire project graph, so MSBuild
provides a graph when one is available. When it isn't available, MSBuild provides the top level projects
and the plugin can construct its own graph based on those.
So either is null, or is null. But not both.
Result types that a plugin can return for a given build request.
The plugin failed and couldn't return a result. The plugin should log an error detailing the failure. MSBuild will stop the build.
The plugin determined that it supports a build request and found that it can be skipped. MSBuild won't build the request.
The plugin determined that it supports a build request and found that it cannot be skipped. MSBuild will build the request.
The plugin determined that it does not support a certain build request. MSBuild will build the request.
For example, a plugin may not support projects with a certain extension, certain properties, or certain called targets.
Represents the cache result a plugin returns back to MSBuild when queried about a certain project.
Results representing cache hits (with == )
contain information about what MSBuild should use for the queried project.
It is assumed that all cache hits result in a successful .
Events logged with this logger will get pushed into MSBuild's logging infrastructure.
See
A cache hit can use this to instruct MSBuild to construct a BuildResult with the target result specified in this
type.
The path to the assembly containing the project cache plugin.
The entry points with which the plugin will be initialized.
The graph with which the plugin will be initialized.
This exception is used to wrap an unhandled exception from a project cache plugin. This exception aborts the build, and it can only be
thrown by the MSBuild engine.
The project cache has already logged this as an error.
Should not get logged again.
Gets the error code associated with this exception's message (not the inner exception).
The error code string.
Only one plugin instance can exist for a given BuildManager BeginBuild / EndBuild session.
Any exceptions thrown by the plugin will cause MSBuild to fail the build.
Called once before the build, to have the plugin instantiate its state.
Errors are checked via .
Called once for each build request.
Operation needs to be atomic. Any side effects (IO, environment variables, etc) need to be reverted upon
cancellation.
MSBuild may choose to cancel this method and build the project itself.
Errors are checked via .
Called once after all the build to let the plugin do any post build operations (log metrics, cleanup, etc).
Errors are checked via .
A cache hit can use this to instruct MSBuild to build the cheaper version of the targets that the plugin avoided
running.
For example, GetTargetPath is the cheaper version of Build.
MSBuild will build the proxy targets and assign their target results to the real targets the mapping points to.
The proxy targets are left in the build result (i.e., both GetTargetPath and Build will appear in the build result).
Real targets can be committed in which case msbuild only keeps the proxy target in the build result.
Mapping from proxy targets to real targets. Case insensitive.
Abstracts away some file system operations.
Implementations:
- must be thread safe
- may cache some or all the calls.
Use this for var sr = new StreamReader(path)
Use this for new FileStream(path, mode, access, share)
Use this for File.ReadAllText(path)
Use this for File.ReadAllBytes(path)
Use this for Directory.EnumerateFiles(path, pattern, option)
Use this for Directory.EnumerateFolders(path, pattern, option)
Use this for Directory.EnumerateFileSystemEntries(path, pattern, option)
Use this for File.GetAttributes()
Use this for File.GetLastWriteTimeUtc(path)
Use this for Directory.Exists(path)
Use this for File.Exists(path)
Use this for File.Exists(path) || Directory.Exists(path)
Wraps the NuGet.Frameworks assembly, which is referenced by reflection.
NuGet Types
Wraps an existing allowing the property usage to be tracked.
The type of properties to be produced.
The type of items to be produced.
The type of metadata on those items.
The type of item definitions to be produced.
Creates an instance of the PropertyTrackingEvaluatorDataWrapper class.
The underlying to wrap for property tracking.
The used to log relevant events.
Property tracking setting value
Returns a property with the specified name, or null if it was not found.
The property name.
The property.
Returns a property with the specified name, or null if it was not found.
Name is the segment of the provided string with the provided start and end indexes.
Sets a property which does not come from the Xml.
Sets a property which comes from the Xml.
Predecessor is any immediately previous property that was overridden by this one during evaluation.
This would include all properties with the same name that lie above in the logical
project file, and whose conditions evaluated to true.
If there are none above this is null.
Logic containing what to do when a property is read.
The name of the property.
The value of the property that was read (null if there is no value).
Logs an EnvironmentVariableRead event.
The name of the environment variable read.
Logs an UninitializedPropertyRead event.
The name of the uninitialized property read.
If the property's initial value is set, it logs a PropertyInitialValueSet event.
The property being set.
The source of the property.
If the property's value has changed, it logs a PropertyReassignment event.
The property's preceding state. Null if none.
The property's current state.
The location of this property's reassignment.
Determines the source of a property given the variables SetProperty arguments provided. This logic follows what's in .
The available sources for a property.
Flags to control options when creating a new, in memory, project.
Do not include any options.
Include the XML declaration element.
Include the ToolsVersion attribute on the Project element.
Include the default MSBuild namespace on the Project element.
Include all file options.
Properties or other mutable state associated with a .
The property changed.
The toolsets changed.
The loggers changed.
The global properties changed.
The property changed.
The property changed.
The property changed.
The property changed.
The property changed.
Event arguments for the event.
Initializes a new instance of the class.
Gets the nature of the change made to the .
Class representing a reference to a project import path with property fall-back
ProjectImportPathMatch instance representing no fall-back
String representation of the property reference - eg. "MSBuildExtensionsPath32"
Returns the corresponding property name - eg. "$(MSBuildExtensionsPath32)"
Enumeration of the search paths for the property.
Factory for serialization.
Flags for controlling the project load.
This is a "flags" enum, allowing future settings to be added
in an additive, non breaking fashion.
Normal load. This is the default.
Ignore nonexistent targets files when evaluating the project
Record imports including duplicate, but not circular, imports on the ImportsIncludingDuplicates property
Throw an exception and stop the evaluation of a project if any circular imports are detected
Record the item elements that got evaluated
Ignore empty targets files when evaluating the project
By default, evaluations performed via evaluate and collect elements whose conditions were false (e.g. ).
This flag turns off this behaviour. members that collect such elements will throw when accessed.
Ignore invalid target files when evaluating the project
Whether to profile the evaluation
Used in combination with to still treat an unresolved MSBuild project SDK as an error.
An object used by the caller to extend the lifespan of evaluation caches (by passing the object on to other
evaluations).
The caller should throw away the context when the environment changes (IO, environment variables, SDK resolution
inputs, etc).
This class and its closure needs to be thread safe since API users can do evaluations in parallel.
Instructs the to reuse state between the different project evaluations that use it.
Instructs the not to reuse state between the different project evaluations that use it.
Key to file entry list. Example usages: cache glob expansion and intermediary directory expansions during glob expansion.
Factory for
Factory for
The to use.
The to use.
This parameter is compatible only with .
The method throws if a file system is used with .
The reasoning is that means not reusing any caches between evaluations,
and the passed in might cache state.
Pretty prints an evaluation location in markdown format
Pretty prints an evaluation location with its associated profiled location
Appends the header of all the locations to the string builder
Appends a pretty printed location with its associated profiled data
Normalizes the expression returned by
Appends a default header with a given separator
Appends a default representation of an evaluation location with a given separator
Pretty prints an evaluation location in tab separated value (TSV) format
Tracks an assortment of evaluation elements in a stack-like fashion, keeping inclusive and exclusive times for each of them.
If is false, then requesting to track a given element has no effect and a null is returned.
Contains each evaluated location with its associated timed entry
Returns true when the evaluation stack is empty.
A frame in the evaluation tracker
Each frame keeps track of its inclusive and exclusive times
Constructs a new evaluation frame and pushes it to the tracker stack
Pops this from the tracker stack and computes inclusive and exclusive times
Represents the elements of an item specification string (e.g. Include="*.cs;foo;@(i)") and
provides some operations over them (like matching items against a given ItemSpec)
The fragments that compose an item spec string (values, globs, item references)
The expander needs to have a default item factory set.
The xml attribute where this itemspec comes from
The string containing item syntax
Expects the expander to have a default item factory set
The xml location the itemspec comes from
The directory that the project is in.
Expand properties before breaking down fragments. Defaults to true
Return true if the given matches this itemspec
The item to attempt to find a match for.
Return the fragments that match against the given
The item to match.
Total number of matches. Some fragments match more than once (item expression may contain multiple instances of
)
Return an MSBuildGlob that represents this ItemSpec.
Returns all the fragment strings that represent it.
"1;*;2;@(foo)" gets returned as ["1", "2", "*", "a", "b"], given that @(foo)=["a", "b"]
Order is not preserved. Globs are not expanded. Item expressions get replaced with their referring item instances.
The substring from the original itemspec representing this fragment
Path of the project the itemspec is coming from
The number of times the
appears in this fragment
True if TextFragment starts with /**/ or a variation thereof with backslashes.
A Trie representing the sets of values of specified metadata taken on by the referenced items.
A single flat list or set of metadata values would not work in this case because we are matching
on multiple metadata. If one item specifies NotTargetFramework to be net46 and TargetFramework to
be netcoreapp3.1, we wouldn't want to match that to an item with TargetFramework 46 and
NotTargetFramework netcoreapp3.1.
Implementing this as a list of sets where each metadatum key has its own set also would not work
because different items could match on different metadata, and we want to check to see if any
single item matches on all the metadata. As an example, consider this scenario:
Item Baby has metadata GoodAt="eating" BadAt="talking" OkAt="sleeping"
Item Child has metadata GoodAt="sleeping" BadAt="eating" OkAt="talking"
Item Adolescent has metadata GoodAt="talking" BadAt="sleeping" OkAt="eating"
Specifying these three metadata:
Item Forgind with metadata GoodAt="sleeping" BadAt="talking" OkAt="eating"
should match none of them because Forgind doesn't match all three metadata of any of the items.
With a list of sets, Forgind would match Baby on BadAt, Child on GoodAt, and Adolescent on OkAt,
and Forgind would be erroneously removed.
With a Trie as below, Items specify paths in the tree, so going to any child node eliminates all
items that don't share that metadatum. This ensures the match is proper.
Todo: Tries naturally can have different shapes depending on in what order the metadata are considered.
Specifically, if all the items share a single metadata value for the one metadatum and have different
values for a second metadatum, it will have only one node more than the number of items if the first
metadatum is considered first. If the metadatum is considered first, it will have twice that number.
Users can theoretically specify the order in which metadata should be considered by reordering them
on the line invoking this, but that is extremely nonobvious from a user's perspective.
It would be nice to detect poorly-ordered metadata and account for it to avoid making more nodes than
necessary. This would need to order if appropriately both in creating the MetadataTrie and in using it,
so it could best be done as a preprocessing step. For now, wait to find out if it's necessary (users'
computers run out of memory) before trying to implement it.
Property type
Item type
Wrapper of two tables for a convenient method return value.
The item set
The metadata dictionary.
The key is the possibly qualified metadata name, for example
"EmbeddedResource.Culture" or "Culture"
Constructs a pair from an item set and metadata
The item set
The metadata dictionary
Gets or sets the item set
Gets or sets the metadata dictionary
The key is the possibly qualified metadata name, for example
"EmbeddedResource.Culture" or "Culture"
COMPAT: Whidbey used the "current project file/targets" directory for evaluating Import and PropertyGroup conditions
Orcas broke this by using the current root project file for all conditions
For Dev10+, we'll fix this, and use the current project file/targets directory for Import, ImportGroup and PropertyGroup
but the root project file for the rest. Inside of targets will use the root project file as always.
Somebody is referencing this operation
Applies uncached item operations (include, remove, update) in order. Since Remove effectively overwrites Include or Update,
Remove operations are preprocessed (adding to globsToIgnore) to create a longer list of globs we don't need to process
properly because we know they will be removed. Update operations are batched as much as possible, meaning rather
than being applied immediately, they are combined into a dictionary of UpdateOperations that need to be applied. This
is to optimize the case in which as series of UpdateOperations, each of which affects a single ItemSpec, are applied to all
items in the list, leading to a quadratic-time operation.
Apply the Update operation to the item if it matches.
The item to check for a match.
The updated item.
This sets the function used to determine whether an item matches an item spec.
Apply the Remove operation.
This operation is mostly implemented in terms of the default .
This override exists to apply the removing-everything short-circuit.
Produce the items to operate on. For example, create new ones or select existing ones
Is this spec a single reference to a specific item?
True if the item is a simple reference to the referenced item type.
This struct represents a reference to a piece of item metadata. For example,
%(EmbeddedResource.Culture) or %(Culture) in the project file. In this case,
"EmbeddedResource" is the item name, and "Culture" is the metadata name.
The item name is optional.
The item name
The metadata name
Constructor
Name of the item
Name of the metadata
Pretty prints a profiled result to a variety of formats
Gets a profiled result in a markdown-like form.
Gets a profiled result in a tab separated value form.
Event arguments for the event.
Initializes a new instance of the class.
The changed project.
Gets the project that was marked dirty.
Never null.
Event arguments for the event.
The unformatted reason for dirtying the project collection.
The formatting parameter.
Initializes a new instance of the class
that represents a change to a specific project root element.
The ProjectRootElement whose content was actually changed.
The unformatted (may contain {0}) reason for the dirty event.
The formatting parameter to use with .
Gets the project root element which was just changed..
Never null.
Gets the reason for the change.
May be null.
Interface for an object which can provide toolsets for evaulation.
Gets an enumeration of all toolsets in the provider.
Retrieves a specific toolset.
The tools version for the toolset.
The requested toolset.
This class encapsulates the behavior and collection of built-in metadata. These metadatum
are inferred from the content of the include and sometimes the context of the project or
current directory.
Retrieves the count of built-in metadata.
Retrieves the list of metadata names.
Retrieves a built-in metadata value and caches it.
Never returns null.
The current directory for evaluation. Null if this is being called from a task, otherwise
it should be the project's directory.
The evaluated include prior to wildcard expansion.
The evaluated include for the item.
The path to the project that defined this item
The name of the metadata.
The generated full path, for caching
The unescaped metadata value.
Retrieves a built-in metadata value and caches it.
If value is not available, returns empty string.
The current directory for evaluation. Null if this is being called from a task, otherwise
it should be the project's directory.
The evaluated include prior to wildcard expansion.
The evaluated include for the item.
The path to the project that defined this item
The name of the metadata.
The generated full path, for caching
The escaped as necessary metadata value.
Extract the value for "RecursiveDir", if any, from the Include.
If there is none, returns an empty string.
Inputs to and outputs of this function are all escaped.
Flags for controlling the toolset initialization.
Do not read toolset information from any external location.
Read toolset information from the exe configuration file.
Read toolset information from the registry (HKLM\Software\Microsoft\MSBuild\ToolsVersions).
Read toolset information from the current exe path
Use the default location or locations.
This class encapsulates a set of related projects, their toolsets, a default set of global properties,
and the loggers that should be used to build them.
A global version of this class acts as the default ProjectCollection.
Multiple ProjectCollections can exist within an appdomain. However, these must not build concurrently.
The object to synchronize with when accessing certain fields.
The global singleton project collection used as a default for otherwise
unassociated projects.
Gets the file version of the file in which the Engine assembly lies.
This is the Windows file version (specifically the value of the ProductVersion
resource), not necessarily the assembly version.
If you want the assembly version, use Constants.AssemblyVersion.
The display version of the file in which the Engine assembly lies.
The projects loaded into this collection.
External projects support
Single logging service used for all builds of projects in this project collection
Any object exposing host services.
May be null.
A mapping of tools versions to Toolsets, which contain the public Toolsets.
This is the collection we use internally.
The default global properties.
The properties representing the environment.
The default tools version obtained by examining all of the toolsets.
A counter incremented every time the toolsets change which would necessitate a re-evaluation of
associated projects.
This is the default value used by newly created projects for whether or not the building
of projects is enabled. This is for security purposes in case a host wants to closely
control which projects it allows to run targets/tasks.
We may only wish to log critical events, record that fact so we can apply it to build requests
Whether reevaluation is temporarily disabled on projects in this collection.
This is useful when the host expects to make a number of reads and writes
to projects, and wants to temporarily sacrifice correctness for performance.
Whether MarkDirty() is temporarily disabled on
projects in this collection.
This allows, for example, global properties to be set without projects getting
marked dirty for reevaluation as a consequence.
The maximum number of nodes which can be started during the build
Instantiates a project collection with no global properties or loggers that reads toolset
information from the configuration file and registry.
Instantiates a project collection using toolsets from the specified locations,
and no global properties or loggers.
May throw InvalidToolsetDefinitionException.
The locations from which to load toolsets.
Instantiates a project collection with specified global properties, no loggers,
and that reads toolset information from the configuration file and registry.
May throw InvalidToolsetDefinitionException.
The default global properties to use. May be null.
Instantiates a project collection with specified global properties and loggers and using the
specified toolset locations.
May throw InvalidToolsetDefinitionException.
The default global properties to use. May be null.
The loggers to register. May be null.
The locations from which to load toolsets.
Instantiates a project collection with specified global properties and loggers and using the
specified toolset locations, node count, and setting of onlyLogCriticalEvents.
Global properties and loggers may be null.
Throws InvalidProjectFileException if any of the global properties are reserved.
May throw InvalidToolsetDefinitionException.
The default global properties to use. May be null.
The loggers to register. May be null and specified to any build instead.
Any remote loggers to register. May be null and specified to any build instead.
The locations from which to load toolsets.
The maximum number of nodes to use for building.
If set to true, only critical events will be logged.
Instantiates a project collection with specified global properties and loggers and using the
specified toolset locations, node count, and setting of onlyLogCriticalEvents.
Global properties and loggers may be null.
Throws InvalidProjectFileException if any of the global properties are reserved.
May throw InvalidToolsetDefinitionException.
The default global properties to use. May be null.
The loggers to register. May be null and specified to any build instead.
Any remote loggers to register. May be null and specified to any build instead.
The locations from which to load toolsets.
The maximum number of nodes to use for building.
If set to true, only critical events will be logged.
If set to true, load all projects as read-only.
Handler to receive which project got added to the project collection.
Event that is fired when a project is added to the ProjectRootElementCache of this project collection.
Raised when state is changed on this instance.
This event is NOT raised for changes in individual projects.
Raised when a contained by this instance is changed.
This event is NOT raised for changes to global properties, or any other change that doesn't actually dirty the XML.
Raised when a contained by this instance is directly changed.
This event is NOT raised for direct project XML changes via the construction model.
Retrieves the global project collection object.
This is a singleton project collection with no global properties or loggers that reads toolset
information from the configuration file and registry.
May throw InvalidToolsetDefinitionException.
Thread safe.
Gets the file version of the file in which the Engine assembly lies.
This is the Windows file version (specifically the value of the FileVersion
resource), not necessarily the assembly version.
If you want the assembly version, use Constants.AssemblyVersion.
This is not the ToolsetCollectionVersion.
Gets a version of the Engine suitable for display to a user.
This is in the form of a SemVer v2 version, Major.Minor.Patch-prerelease+metadata.
The default tools version of this project collection. Projects use this tools version if they
aren't otherwise told what tools version to use.
This value is gotten from the .exe.config file, or else in the registry,
or if neither specify a default tools version then it is hard-coded to the tools version "2.0".
Setter throws InvalidOperationException if a toolset with the provided tools version has not been defined.
Always defined.
Returns default global properties for all projects in this collection.
Read-only dead dictionary.
This is the publicly exposed getter, that translates into a read-only dead IDictionary<string, string>.
To be consistent with Project, setting and removing global properties is done with
SetGlobalProperty and RemoveGlobalProperty.
All the projects currently loaded into this collection.
Each has a unique combination of path, global properties, and tools version.
Number of projects currently loaded into this collection.
Loggers that all contained projects will use for their builds.
Loggers are added with the .
Returns an empty collection if there are no loggers.
Returns the toolsets this ProjectCollection knows about.
ValueCollection is already read-only
Returns the locations used to find the toolsets.
This is the default value used by newly created projects for whether or not the building
of projects is enabled. This is for security purposes in case a host wants to closely
control which projects it allows to run targets/tasks.
When true, only log critical events such as warnings and errors. Has to be in here for API compat
Object exposing host services to tasks during builds of projects
contained by this project collection.
By default, HostServices is used.
May be set to null, but the getter will create a new instance in that case.
Whether reevaluation is temporarily disabled on projects in this collection.
This is useful when the host expects to make a number of reads and writes
to projects, and wants to temporarily sacrifice correctness for performance.
Whether MarkDirty() is temporarily disabled on
projects in this collection.
This allows, for example, global properties to be set without projects getting
marked dirty for reevaluation as a consequence.
Global collection id.
Can be used for external providers to optimize the cross-site link exchange
External project support.
Establish a remote project link for this collection.
Logging service that should be used for project load and for builds
Gets default global properties for all projects in this collection.
Dead copy.
Returns the property dictionary containing the properties representing the environment.
Returns the internal version for this object's state.
Updated when toolsets change, indicating all contained projects are potentially invalid.
The maximum number of nodes which can be started during the build
The cache of project root elements associated with this project collection.
Each is associated with a specific project collection for two reasons:
- To help protect one project collection from any XML edits through another one:
until a reload from disk - when it's ready to accept changes - it won't see the edits;
- So that the owner of this project collection can force the XML to be loaded again
from disk, by doing .
Escape a string using MSBuild escaping format. For example, "%3b" for ";".
Only characters that are especially significant to MSBuild parsing are escaped.
Callers can use this method to make a string safe to be parsed to other methods
that would otherwise expand it; or to make a string safe to be written to a project file.
Unescape a string using MSBuild escaping format. For example, "%3b" for ";".
All escaped characters are unescaped.
Returns true if there is a toolset defined for the specified
tools version, otherwise false.
Add a new toolset.
Replaces any existing toolset with the same tools version.
Remove a toolset.
Returns true if it was present, otherwise false.
Removes all toolsets.
Get the toolset with the specified tools version.
If it is not present, returns null.
Figure out what ToolsVersion to use to actually build the project with.
The user-specified ToolsVersion (through e.g. /tv: on the command line). May be null
The ToolsVersion from the project file. May be null
The ToolsVersion we should use to build this project. Should never be null.
Returns any and all loaded projects with the provided path.
There may be more than one, if they are distinguished by global properties
and/or tools version.
Returns any and all loaded projects with the provided path.
There may be more than one, if they are distinguished by global properties
and/or tools version.
Loads a project with the specified filename, using the collection's global properties and tools version.
If a matching project is already loaded, it will be returned, otherwise a new project will be loaded.
The project file to load
A loaded project.
Loads a project with the specified filename and tools version, using the collection's global properties.
If a matching project is already loaded, it will be returned, otherwise a new project will be loaded.
The project file to load
The tools version to use. May be null.
A loaded project.
Loads a project with the specified filename, tools version and global properties.
If a matching project is already loaded, it will be returned, otherwise a new project will be loaded.
The project file to load
The global properties to use. May be null, in which case the containing project collection's global properties will be used.
The tools version. May be null.
A loaded project.
Loads a project with the specified reader, using the collection's global properties and tools version.
The project will be added to this project collection when it is named.
Xml reader to read project from
A loaded project.
Loads a project with the specified reader and tools version, using the collection's global properties.
The project will be added to this project collection when it is named.
Xml reader to read project from
The tools version to use. May be null.
A loaded project.
Loads a project with the specified reader, tools version and global properties.
The project will be added to this project collection when it is named.
Xml reader to read project from
The global properties to use. May be null in which case the containing project collection's global properties will be used.
The tools version. May be null.
A loaded project.
Adds a logger to the collection of loggers used for builds of projects in this collection.
If the logger object is already in the collection, does nothing.
Adds some loggers to the collection of loggers used for builds of projects in this collection.
If any logger object is already in the collection, does nothing for that logger.
May be null.
Adds some remote loggers to the collection of remote loggers used for builds of projects in this collection.
May be null.
Removes all loggers from the collection of loggers used for builds of projects in this collection.
Unloads the specific project specified.
Host should call this when they are completely done with the project.
If project was not already loaded, throws InvalidOperationException.
Unloads a project XML root element from the weak cache.
The project XML root element to unload.
Thrown if the project XML root element to unload is still in use by a loaded project or its imports.
This method is useful for the case where the host knows that all projects using this XML element
are unloaded, and desires to discard any unsaved changes.
Unloads all the projects contained by this ProjectCollection.
Host should call this when they are completely done with all the projects.
Get any global property on the project collection that has the specified name,
otherwise returns null.
Set a global property at the collection-level,
and on all projects in the project collection.
Removes a global property from the collection-level set of global properties,
and all projects in the project collection.
If it was on this project collection, returns true.
Called when a host is completely done with the project collection.
Initializes the component with the component host.
The component host.
Shuts down the component.
Unloads a project XML root element from the cache entirely, if it is not
in use by project loaded into this collection.
Returns true if it was unloaded successfully, or was not already loaded.
Returns false if it was not unloaded because it was still in use by a loaded .
The project XML root element to unload.
Called by a Project object to load itself into this collection.
If the project was already loaded under a different name, it is unloaded.
Stores the project in the list of loaded projects if it has a name.
Does not store the project if it has no name because it has not been saved to disk yet.
If the project previously had a name, but was not in the collection already, throws InvalidOperationException.
If the project was not previously in the collection, sets the collection's global properties on it.
Called after a loaded project's global properties are changed, so we can update
our loaded project table.
Project need not already be in the project collection yet, but it can't be in another one.
We have to remove and re-add so that there's an error if there's already an equivalent
project loaded.
Following standard framework guideline dispose pattern.
Shut down logging service if the project collection owns one, in order
to shut down the logger thread and loggers.
true to release both managed and unmanaged resources; false to release only unmanaged resources..
Remove a toolset and does not raise events. The caller should have acquired a write lock on this method's behalf.
The toolset to remove.
true if the toolset was found and removed; false otherwise.
Adds a logger to the collection of loggers used for builds of projects in this collection.
If the logger object is already in the collection, does nothing.
Handler which is called when a project is added to the RootElementCache of this project collection. We then fire an event indicating that a project was added to the collection itself.
Handler which is called when a project that is part of this collection is dirtied. We then fire an event indicating that a project has been dirtied.
Handler which is called when a project is dirtied.
Raises the event.
The event arguments that indicate ProjectRootElement-specific details.
Raises the event.
The event arguments that indicate Project-specific details.
Raises the event.
The event arguments that indicate details on what changed on the collection.
Shutdown the logging service
Create a new logging service
Reset the toolsets using the provided toolset reader, used by unit tests
Reset the toolsets using the provided toolset reader, used by unit tests
Populate Toolsets with a dictionary of (toolset version, Toolset)
using information from the registry and config file, if any.
Event to provide information about what project just got added to the project collection.
The root element which was added to the project collection.
Root element which was added to the project collection.
The ReusableLogger wraps a logger and allows it to be used for both design-time and build-time. It internally swaps
between the design-time and build-time event sources in response to Initialize and Shutdown events.
The logger we are wrapping.
The design-time event source
The build-time event source
The Any event handler
The BuildFinished event handler
The BuildStarted event handler
The Custom event handler
The Error event handler
The Message event handler
The ProjectFinished event handler
The ProjectStarted event handler
The Status event handler
The TargetFinished event handler
The TargetStarted event handler
The TaskFinished event handler
The TaskStarted event handler
The Warning event handler
The telemetry event handler.
Constructor.
The Message logging event
The Error logging event
The Warning logging event
The BuildStarted logging event
The BuildFinished logging event
The ProjectStarted logging event
The ProjectFinished logging event
The TargetStarted logging event
The TargetFinished logging event
The TashStarted logging event
The TaskFinished logging event
The Custom logging event
The Status logging event
The Any logging event
The telemetry sent event.
Should evaluation events include generated metaprojects?
Should evaluation events include profiling information?
Should task events include task inputs?
The logger verbosity
The logger parameters
If we haven't yet been initialized, we register for design time events and initialize the logger we are holding.
If we are in design-time mode
If we haven't yet been initialized, we register for design time events and initialize the logger we are holding.
If we are in design-time mode
If we are in build-time mode, we unregister for build-time events and re-register for design-time events.
If we are in design-time mode, we unregister for design-time events and shut down the logger we are holding.
Registers for all of the events on the specified event source.
Unregisters for all events on the specified event source.
Handler for Warning events.
Handler for TaskStarted events.
Handler for TaskFinished events.
Handler for TargetStarted events.
Handler for TargetFinished events.
Handler for Status events.
Handler for ProjectStarted events.
Handler for ProjectFinished events.
Handler for Message events.
Handler for Error events.
Handler for Custom events.
Handler for BuildStarted events.
Handler for BuildFinished events.
Handler for Any events.
Handler for telemetry events.
Holder for the projects loaded into this collection.
The collection of all projects already loaded into this collection.
Key is the full path to the project, value is a list of projects with that path, each
with different global properties and/or tools version.
If hosts tend to load lots of projects with the same path, the value will have to be
changed to a more efficient type of collection.
Lock on this object. Concurrent load must be thread safe.
Not using ConcurrentDictionary because some of the add/update
semantics would get convoluted.
Count of loaded projects
Returns the number of projects currently loaded
Enumerate all the projects
Enumerate all the projects.
Get all projects with the provided path.
Returns an empty list if there are none.
Returns the project in the collection matching the path, global properties, and tools version provided.
There can be no more than one match.
If none is found, returns null.
Adds the provided project to the collection.
If there is already an equivalent project, throws InvalidOperationException.
Removes the provided project from the collection.
If project was not loaded, returns false.
Removes a project, using the specified full path to use as the key to find it.
This is specified separately in case the project was previously stored under a different path.
Removes all projects from the collection.
Returns true if the global properties and tools version provided are equivalent to
those in the provided project, otherwise false.
Represents an evaluated project with design time semantics.
Always backed by XML; can be built directly, or an instance can be cloned off to add virtual items/properties and build.
Edits to this project always update the backing XML.
Whether to write information about why we evaluate to debug output.
* and ? are invalid file name characters, but they occur in globs as wild cards.
Context to log messages and events in.
Default project template options (include all features).
Certain item operations split the item element in multiple elements if the include
contains globs, references to items or properties, or multiple item values.
The items operations that may expand item elements are:
-
-
-
-
-
-
-
-
-
When this property is set to true, the previous item operations throw an
instead of expanding the item element.
Construct an empty project, evaluating with the global project collection's
global properties and default tools version.
Project will be added to the global project collection when it is named.
Construct an empty project, evaluating with the global project collection's
global properties and default tools version.
Project will be added to the global project collection when it is named.
Construct an empty project, evaluating with the specified project collection's
global properties and default tools version.
Project will be added to the specified project collection when it is named.
Construct an empty project, evaluating with the specified project collection's
global properties and default tools version.
Project will be added to the specified project collection when it is named.
Construct an empty project, evaluating with the specified project collection and
the specified global properties and default tools version, either of which may be null.
Project will be added to the specified project collection when it is named.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
The the project is added to.
Construct an empty project, evaluating with the specified project collection and
the specified global properties and default tools version, either of which may be null.
Project will be added to the specified project collection when it is named.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
The the project is added to.
The to use for the new project.
Construct over a ProjectRootElement object, evaluating with the global project collection's
global properties and default tools version.
Project is added to the global project collection if it has a name, or else when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
ProjectRootElement to use.
Construct over a ProjectRootElement object, evaluating with specified
global properties and toolset, either or both of which may be null.
Project is added to the global project collection if it has a name, or else when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
ProjectRootElement to use.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
Construct over a ProjectRootElement object, evaluating with specified
global properties and toolset, either or both of which may be null.
Project is added to the global project collection if it has a name, or else when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
ProjectRootElement to use.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
The the project is added to.
Construct over a ProjectRootElement object, evaluating with specified
global properties and toolset, either or both of which may be null.
Project is added to the global project collection if it has a name, or else when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
ProjectRootElement to use.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
The the project is added to.
The to use for evaluation.
Construct over a ProjectRootElement object, evaluating with specified
global properties and toolset, either or both of which may be null.
Project is added to the global project collection if it has a name, or else when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
ProjectRootElement to use.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
Sub-toolset version to explicitly evaluate the toolset with. May be null.
The the project is added to.
The to use for evaluation.
Construct over a text reader over project xml, evaluating with the global project collection's
global properties and default tools version.
Project will be added to the global project collection when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
Xml reader to read project from.
Construct over a text reader over project xml, evaluating with specified
global properties and toolset, either or both of which may be null.
Project will be added to the global project collection when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
Xml reader to read project from.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
Construct over a text reader over project xml, evaluating with specified
global properties and toolset, either or both of which may be null.
Project will be added to the specified project collection when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
Xml reader to read project from.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
The collection with which this project should be associated. May not be null.
Construct over a text reader over project xml, evaluating with specified
global properties and toolset, either or both of which may be null.
Project will be added to the specified project collection when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
Xml reader to read project from.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
The collection with which this project should be associated. May not be null.
The to use for evaluation.
Construct over a text reader over project xml, evaluating with specified
global properties and toolset, either or both of which may be null.
Project will be added to the specified project collection when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
Xml reader to read project from.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
Sub-toolset version to explicitly evaluate the toolset with. May be null.
The collection with which this project should be associated. May not be null.
The load settings for this project.
Construct over an existing project file, evaluating with the global project collection's
global properties and default tools version.
Project is added to the global project collection.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
May throw IO-related exceptions.
If the evaluation fails.
Construct over an existing project file, evaluating with specified
global properties and toolset, either or both of which may be null.
Project is added to the global project collection.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
May throw IO-related exceptions.
Construct over an existing project file, evaluating with the specified global properties and
using the tools version provided, either or both of which may be null.
Project is added to the global project collection.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
May throw IO-related exceptions.
The project file.
The global properties. May be null.
The tools version. May be null.
The collection with which this project should be associated. May not be null.
Construct over an existing project file, evaluating with the specified global properties and
using the tools version provided, either or both of which may be null.
Project is added to the global project collection.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
May throw IO-related exceptions.
The project file.
The global properties. May be null.
The tools version. May be null.
The collection with which this project should be associated. May not be null.
The load settings for this project.
Construct over an existing project file, evaluating with the specified global properties and
using the tools version provided, either or both of which may be null.
Project is added to the global project collection.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
May throw IO-related exceptions.
The project file.
The global properties. May be null.
The tools version. May be null.
Sub-toolset version to explicitly evaluate the toolset with. May be null.
The collection with which this project should be associated. May not be null.
The load settings for this project.
Create a file based project.
The file to evaluate the project from.
The to use.
Create a based project.
The to evaluate the project from.
The to use.
Create a based project.
The to evaluate the project from.
The to use.
Whether build is enabled for this project.
Explicitly enabled
Explicitly disabled
No explicit setting, uses the setting on the
project collection.
This is the default.
Gets or sets the project collection which contains this project.
Can never be null.
Cannot be modified.
The backing Xml project.
Can never be null.
There is no setter here as that doesn't make sense. If you have a new ProjectRootElement, evaluate it into a new Project.
Whether this project is dirty such that it needs reevaluation.
This may be because its underlying XML has changed (either through this project or another)
either the XML of the main project or an imported file;
or because its toolset may have changed.
Read only dictionary of the global properties used in the evaluation
of this project.
This is the publicly exposed getter, that translates into a read-only dead IDictionary<string, string>.
In order to easily tell when we're dirtied, setting and removing global properties is done with
SetGlobalProperty and RemoveGlobalProperty.
Item types in this project.
This is an ordered collection.
data.ItemTypes is a KeyCollection, so it doesn't need any
additional read-only protection.
Properties in this project.
Since evaluation has occurred, this is an unordered collection.
Collection of possible values implied for properties contained in the conditions found on properties,
property groups, imports, and whens.
For example, if the following conditions existed on properties in a project:
Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"
Condition="'$(Configuration)' == 'Release'"
the table would be populated with
{ "Configuration", { "Debug", "Release" }}
{ "Platform", { "x86" }}
This is used by Visual Studio to determine the configurations defined in the project.
Read-only dictionary of item definitions in this project.
Keyed by item type.
Items in this project, ordered within groups of item types.
Items in this project, ordered within groups of item types,
including items whose conditions evaluated to false, or that were
contained within item groups who themselves had conditioned evaluated to false.
This is useful for hosts that wish to display all items, even if they might not be part
of the build in the current configuration.
All the files that during evaluation contributed to this project, as ProjectRootElements,
with the ProjectImportElement that caused them to be imported.
This does not include projects that were never imported because a condition on an Import element was false.
The outer ProjectRootElement that maps to this project itself is not included.
This can be used by the host to figure out what projects might be impacted by a change to a particular file.
It could also be used, for example, to find the .user file, and use its ProjectRootElement to modify properties in it.
This list will contain duplicate imports if an import is imported multiple times. However, only the first import was used in evaluation.
Targets in the project. The key to the dictionary is the target's name.
Overridden targets are not included in this collection.
This collection is read-only.
Properties encountered during evaluation. These are read during the first evaluation pass.
Unlike those returned by the Properties property, these are ordered, and includes any properties that
were subsequently overridden by others with the same name. It does not include any
properties whose conditions did not evaluate to true.
It does not include any properties added since the last evaluation.
Item definition metadata encountered during evaluation. These are read during the second evaluation pass.
Unlike those returned by the ItemDefinitions property, these are ordered, and include any metadata that
were subsequently overridden by others with the same name and item type. It does not include any
elements whose conditions did not evaluate to true.
It does not include any item definition metadata added since the last evaluation.
Items encountered during evaluation. These are read during the third evaluation pass.
Unlike those returned by the Items property, these are ordered with respect to all other items
encountered during evaluation, not just ordered with respect to items of the same item type.
In some applications, like the F# language, this complete mutual ordering is significant, and such hosts
can use this property.
It does not include any elements whose conditions did not evaluate to true.
It does not include any items added since the last evaluation.
The tools version this project was evaluated with, if any.
Not necessarily the same as the tools version on the Project tag, if any;
it may have been externally specified, for example with a /tv switch.
The actual tools version on the Project tag, can be gotten from Xml.ToolsVersion.
Cannot be changed once the project has been created.
Set by construction.
The sub-toolset version that, combined with the ToolsVersion, was used to determine
the toolset properties for this project.
The root directory for this project.
Is never null: in-memory projects use the current directory from the time of load.
The full path to this project's file.
May be null, if the project was not loaded from disk.
Setter renames the project, if it already had a name.
Whether ReevaluateIfNecessary is temporarily disabled.
This is useful when the host expects to make a number of reads and writes
to the project, and wants to temporarily sacrifice correctness for performance.
Whether MarkDirty() is temporarily disabled.
This allows, for example, a global property to be set without the project getting
marked dirty for reevaluation as a consequence.
This controls whether or not the building of targets/tasks is enabled for this
project. This is for security purposes in case a host wants to closely
control which projects it allows to run targets/tasks. By default, for a newly
created project, we will use whatever setting is in the parent project collection.
When build is disabled, the Build method on this class will fail. However if
the host has already created a ProjectInstance, it can still build it. (It is
free to put a similar check around where it does this.)
Location of the originating file itself, not any specific content within it.
If the file has not been given a name, returns an empty location.
Obsolete. Use instead.
The ID of the last evaluation for this Project.
A project is always evaluated upon construction and can subsequently get evaluated multiple times via
It is an arbitrary number that changes when this project reevaluates.
Hosts don't know whether an evaluation actually happened in an interval, but they can compare this number to
their previously stored value to find out, and if so perhaps decide to update their own state.
Note that the number may not increase monotonically.
This number corresponds to the and can be used to connect
evaluation logging events back to the Project instance.
List of names of the properties that, while global, are still treated as overridable.
The logging service used for evaluation errors.
Returns the evaluated, escaped value of the provided item's include.
Returns the evaluated, escaped value of the provided item definition's include.
Finds all the globs specified in item includes.
*.txt
(both outside and inside project cone)
(both outside and inside project cone)
(If Bar has globs, they will have been included when querying Bar ProjectItems for globs)
Example result:
[
GlobResult(glob: "C:\**\*.foo", exclude: []),
GlobResult(glob: ["*.a", "*.b"], exclude=["3.a"], remove=["2.a"]),
GlobResult(glob: "**\*.b", exclude=["1.b, **\obj\*.b", **\bar\*.b"]),
GlobResult(glob: "*.txt", exclude=[]),
GlobResult(glob: "*.a", exclude=[]),
GlobResult(glob: "*.cs", exclude=["bar"])
].
is a that combines all globs in the include element and ignores
all the fragments in the exclude attribute and all the fragments in all Remove elements that apply to the include element.
Users can construct a composite glob that incorporates all the globs in the Project:
var uberGlob = new CompositeGlob(project.GetAllGlobs().Select(r => r.MSBuildGlob).ToArray());
uberGlob.IsMatch("foo.cs");
List of .
See .
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
Overload of .
Confine search to item elements of this type.
See .
Type of the item.
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
Finds all the item elements in the logical project with itemspecs that match the given string:
- elements that would include (or exclude) the string
- elements that would update the string (not yet implemented)
- elements that would remove the string (not yet implemented).
The following snippet shows what GetItemProvenance("a.cs") returns for various item elements.
// Occurrences:2; Operation: Include; Provenance: StringLiteral | Glob
// Occurrences: 1; Operation: Exclude; Provenance: StringLiteral
// NA
// Occurrences: 2; Operation: Include; Provenance: Inconclusive (it is an indirect occurrence from a referenced item)
// Occurrences: 4; Operation: Include; Provenance: FromLiteral (direct reference in $P) | Glob (direct reference in $P) | Inconclusive (it is an indirect occurrence from referenced properties and items)
a.cs;*.cs;@(A)
This method and its overloads are useful for clients that need to inspect all the item elements
that might refer to a specific item instance. For example, Visual Studio uses it to inspect
projects with globs. Upon a file system or IDE file artifact change, VS calls this method to find all the items
that might refer to the detected file change (e.g. 'which item elements refer to "Program.cs"?').
It uses such information to know which elements it should edit to reflect the user or file system changes.
Literal string matching tries to first match the strings. If the check fails, it then tries to match
the strings as if they represented files: it normalizes both strings as files relative to the current project directory
GetItemProvenance suffers from some sources of inaccuracy:
- it is performed after evaluation, thus is insensitive to item data flow when item references are present
(it sees items as they are at the end of evaluation)
This API and its return types are prone to change.
The string to perform matching against.
A list of , sorted in project evaluation order.
See .
The string to perform matching against.
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
Overload of .
The string to perform matching against.
The item type to constrain the search in.
See .
The string to perform matching against.
The type of the item to perform matching against.
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
Overload of .
The ProjectItem object that indicates: the itemspec to match and the item type to constrain the search in.
The search is also constrained on item elements appearing before the item element that produced this .
The element that produced this is included in the results.
See .
The ProjectItem object that indicates: the itemspec to match and the item type to constrain the search in.
The search is also constrained on item elements appearing before the item element that produced this .
The element that produced this is included in the results.
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
Gets the escaped value of the provided metadatum.
Gets the escaped value of the metadatum with the provided name on the provided item.
Gets the escaped value of the metadatum with the provided name on the provided item definition.
Get the escaped value of the provided property.
Returns an iterator over the "logical project". The logical project is defined as
the unevaluated project obtained from the single MSBuild file that is the result
of inlining the text of all imports of the original MSBuild project manifest file.
Get any property in the project that has the specified name,
otherwise returns null.
Get the unescaped value of a property in this project, or
an empty string if it does not exist.
A property with a value of empty string and no property
at all are not distinguished between by this method.
That makes it easier to use. To find out if a property is set at
all in the project, use GetProperty(name).
Set or add a property with the specified name and value.
Overwrites the value of any property with the same name already in the collection if it did not originate in an imported file.
If there is no such existing property, uses this heuristic:
Updates the last existing property with the specified name that has no condition on itself or its property group, if any,
and is in this project file rather than an imported file.
Otherwise, adds a new property in the first property group without a condition, creating a property group if necessary after
the last existing property group, else at the start of the project.
Returns the property set.
Evaluates on a best-effort basis:
-expands with all properties. Properties that are defined in the XML below the new property may be used, even though in a real evaluation they would not be.
-only this property is evaluated. Anything else that would depend on its value is not affected.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
Change a global property after the project has been evaluated.
If the value changes, this makes the project require reevaluation.
If the value changes, returns true, otherwise false.
Adds an item with no metadata to the project.
Any metadata can be added subsequently.
Does not modify the XML if a wildcard expression would already include the new item.
Evaluates on a best-effort basis:
-expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be.
-only this item is evaluated. Other items that might depend on it is not affected.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
Adds an item with metadata to the project.
Metadata may be null, indicating no metadata.
Does not modify the XML if a wildcard expression would already include the new item.
Evaluates on a best-effort basis:
-expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be.
-only this item is evaluated. Other items that might depend on it is not affected.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
Adds an item with no metadata to the project.
Makes no effort to see if an existing wildcard would already match the new item, unless it is the first item in an item group.
Makes no effort to locate the new item near similar items.
Appends the item to the first item group that does not have a condition and has either no children or whose first child is an item of the same type.
Evaluates on a best-effort basis:
-expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be.
-only this item is evaluated. Other items that might depend on it is not affected.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
Adds an item with metadata to the project.
Metadata may be null, indicating no metadata.
Makes no effort to see if an existing wildcard would already match the new item, unless it is the first item in an item group.
Makes no effort to locate the new item near similar items.
Appends the item to the first item group that does not have a condition and has either no children or whose first child is an item of the same type.
Evaluates on a best-effort basis:
-expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be.
-only this item is evaluated. Other items that might depend on it is not affected.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
All the items in the project of the specified
type.
If there are none, returns an empty list.
Use AddItem or RemoveItem to modify items in this project.
data.GetItems returns a read-only collection, so no need to re-wrap it here.
All the items in the project of the specified
type, irrespective of whether the conditions on them evaluated to true.
This is a read-only list: use AddItem or RemoveItem to modify items in this project.
ItemDictionary[] returns a read only collection, so no need to wrap it.
Returns all items that have the specified evaluated include.
For example, all items that have the evaluated include "bar.cpp".
Typically there will be zero or one, but sometimes there are two items with the
same path and different item types, or even the same item types. This will return
them all.
data.GetItemsByEvaluatedInclude already returns a read-only collection, so no need
to wrap it further.
Removes the specified property.
Property must be associated with this project.
Property must not originate from an imported file.
Returns true if the property was in this evaluated project, otherwise false.
As a convenience, if the parent property group becomes empty, it is also removed.
Updates the evaluated project, but does not affect anything else in the project until reevaluation. For example,
if "p" is removed, it will be removed from the evaluated project, but "q" which is evaluated from "$(p)" will not be modified until reevaluation.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state.
Removes a global property.
If it was set, returns true, and marks the project
as requiring reevaluation.
Removes an item from the project.
Item must be associated with this project.
Item must not originate from an imported file.
Returns true if the item was in this evaluated project, otherwise false.
As a convenience, if the parent item group becomes empty, it is also removed.
If the item originated from a wildcard or semicolon separated expression, expands that expression into multiple items first.
Updates the evaluated project, but does not affect anything else in the project until reevaluation. For example,
if an item of type "i" is removed, "j" which is evaluated from "@(i)" will not be modified until reevaluation.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
Normally this will return true, since if the item isn't in the project, it will throw.
The exception is removing an item that was only in ItemsIgnoringCondition.
Removes all the specified items from the project.
Items that are not associated with this project are skipped.
Removing one item could cause the backing XML
to be expanded, which could zombie (disassociate) the next item.
To make this case easy for the caller, if an item
is not associated with this project it is simply skipped.
Evaluates the provided string by expanding items and properties,
as if it was found at the very end of the project file.
This is useful for some hosts for which this kind of best-effort
evaluation is sufficient.
Does not expand bare metadata expressions.
Returns an instance based on this project, but completely disconnected.
This instance can be used to build independently.
Before creating the instance, this will reevaluate the project if necessary, so it will not be dirty.
The created project instance.
Returns an instance based on this project, but completely disconnected.
This instance can be used to build independently.
Before creating the instance, this will reevaluate the project if necessary, so it will not be dirty.
The instance is immutable; none of the objects that form it can be modified. This makes it safe to
access concurrently from multiple threads.
The project instance creation settings.
The created project instance.
See .
The project instance creation settings.
The evaluation context to use in case reevaluation is required.
The created project instance.
Called to forcibly mark the project as dirty requiring reevaluation. Generally this is not necessary to set; all edits affecting
this project will automatically make it dirty. However there are potential corner cases where it is necessary to mark the project dirty
directly. For example, if the project has an import conditioned on a file existing on disk, and the file did not exist at
evaluation time, then someone subsequently creates that file, the project cannot know that reevaluation would be productive.
In such a case the host can help us by setting the dirty flag explicitly so that ReevaluateIfNecessary()
will recognize an evaluation is indeed necessary.
Does not mark the underlying project file as requiring saving.
Reevaluate the project to get it into a queryable state, if it's dirty.
This incorporates all changes previously made to the backing XML by editing this project.
Throws InvalidProjectFileException if the evaluation fails.
See .
The to use. See .
Save the project to the file system, if dirty.
Uses the default encoding.
Save the project to the file system, if dirty.
Save the project to the file system, if dirty or the path is different.
Uses the default encoding.
Save the project to the file system, if dirty or the path is different.
Save the project to the provided TextWriter, whether or not it is dirty.
Uses the encoding of the TextWriter.
Clears the Dirty flag.
Saves a "logical" or "preprocessed" project file, that includes all the imported
files as if they formed a single file.
Starts a build using this project, building the default targets.
Returns true on success, false on failure.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
Returns true on success and false on failure or disabled build.
Starts a build using this project, building the default targets and the specified logger.
Returns true on success, false on failure.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
Logger to use.
Returns true on success and false on failure or disabled build.
Starts a build using this project, building the default targets and the specified loggers.
Returns true on success, false on failure.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
List of loggers.
Returns true on success and false on failure or disabled build.
Starts a build using this project, building the default targets and the specified loggers.
Returns true on success, false on failure.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
List of loggers.
Remote loggers for multi proc logging.
Returns true on success and false on failure or disabled build.
Starts a build using this project, building the specified target.
Returns true on success, false on failure.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
Target to build.
Returns true on success and false on failure or disabled build.
Starts a build using this project, building the specified target with the specified loggers.
Returns true on success, false on failure.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
Target to build.
List of loggers.
Returns true on success and false on failure or disabled build.
Starts a build using this project, building the specified target with the specified loggers.
Returns true on success, false on failure.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
Target to build.
List of loggers.
Remote loggers for multi proc logging.
Returns true on success and false on failure or disabled build.
Starts a build using this project, building the specified targets.
Returns true on success, false on failure.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
Targets to build.
Returns true on success and false on failure or disabled build.
Starts a build using this project, building the specified targets with the specified loggers.
Returns true on success, false on failure.
If build is disabled on this project, does not build, and returns false.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
Targets to build.
List of loggers.
Returns true on success and false on failure or disabled build.
Starts a build using this project, building the specified targets with the specified loggers.
Returns true on success, false on failure.
If build is disabled on this project, does not build, and returns false.
Works on a privately cloned instance. To set or get
virtual items for build purposes, clone an instance explicitly and build that.
Does not modify the Project object.
Targets to build.
List of loggers.
Remote loggers for multi proc logging.
Returns true on success and false on failure or disabled build.
See .
Targets to build.
List of loggers.
Remote loggers for multi proc logging.
The evaluation context to use in case reevaluation is required.
Returns true on success and false on failure or disabled build.
Tests whether a given project IS or IMPORTS some given project xml root element.
The project xml root element in question.
True if this project is or imports the xml file; false otherwise.
If the ProjectItemElement evaluated to more than one ProjectItem, replaces it with a new ProjectItemElement for each one of them.
If the ProjectItemElement did not evaluate into more than one ProjectItem, does nothing.
Returns true if a split occurred, otherwise false.
A ProjectItemElement could have resulted in several items if it contains wildcards or item or property expressions.
Before any edit to a ProjectItem (remove, rename, set metadata, or remove metadata) this must be called to make
sure that the edit does not affect any other ProjectItems originating in the same ProjectItemElement.
For example, an item xml with an include of "@(x)" could evaluate to items "a", "b", and "c". If "b" is removed, then the original
item xml must be removed and replaced with three, then the one corresponding to "b" can be removed.
This is an unsophisticated approach; the best that can be said is that the result will likely be correct, if not ideal.
For example, perhaps the user would rather remove the item from the original list "x" instead of expanding the list.
Or, perhaps the user would rather the property in "$(p)\a;$(p)\b" not be expanded when "$(p)\b" is removed.
If that's important, the host can manipulate the ProjectItemElement's directly, instead, and it can be as fastidious as it wishes.
Examines the provided ProjectItemElement to see if it has a wildcard that would match the
item we wish to add, and does not have a condition or an exclude.
Works conservatively - if there is anything that might cause doubt, considers the candidate to not be suitable.
Returns true if it is suitable, otherwise false.
Outside this class called ONLY from ProjectItem.Rename(string name).
Before an item changes its item type, it must be removed from
our datastructures, which key off item type.
This should be called ONLY by ProjectItems, in this situation.
After an item has changed its item type, it needs to be added back again,
since our data structures key off the item type.
This should be called ONLY by ProjectItems, in this situation.
Provided a property that is already part of this project, does a best-effort expansion
of the unevaluated value provided and sets it as the evaluated value.
On project in order to keep Project's expander hidden.
Provided an item element that has been renamed with a new unevaluated include,
returns a best effort guess at the evaluated include that results.
If the best effort expansion produces anything other than one item, it just
returns the unevaluated include.
This is not at all generalized, but useful for the majority case where an item is a very
simple file name with perhaps a property prefix.
On project in order to keep Project's expander hidden.
Provided a metadatum that is already part of this project, does a best-effort expansion
of the unevaluated value provided and returns the resulting value.
This is a interim expansion only: it may not be the value that a full project reevaluation would produce.
The metadata table passed in is that of the parent item or item definition.
On project in order to keep Project's expander hidden.
Called by the project collection to indicate to this project that it is no longer loaded.
Verify that the project has not been unloaded from its collection.
Once it's been unloaded, it cannot be used.
Verify that the provided object location is in the same file as the project.
If it is not, throws an InvalidOperationException indicating that imported evaluated objects should not be modified.
This prevents, for example, accidentally updating something like the OutputPath property, that you want be in the
main project, but for some reason was actually read in from an imported targets file.
Internal project evaluation implementation.
Backing data; stored in a nested class so it can be passed to the Evaluator to fill
in on re-evaluation, without having to expose property setters for that purpose.
Also it makes it easy to re-evaluate this project without creating a new project object.
The highest version of the backing ProjectRootElements (including imports) that this object was last evaluated from.
Edits to the ProjectRootElement either by this Project or another Project increment the number.
If that number is different from this one a reevaluation is necessary at some point.
The version of the tools information in the project collection against we were last evaluated.
Whether the project has been explicitly marked as dirty. Generally this is not necessary to set; all edits affecting
this project will automatically make it dirty. However there are potential corner cases where it is necessary to mark it dirty
directly. For example, if the project has an import conditioned on a file existing on disk, and the file did not exist at
evaluation time, then someone subsequently writes the file, the project will not know that reevaluation would be productive,
and would not dirty itself. In such a case the host should help us by setting the dirty flag explicitly.
This controls whether or not the building of targets/tasks is enabled for this
project. This is for security purposes in case a host wants to closely
control which projects it allows to run targets/tasks.
The load settings, such as to ignore missing imports.
This is retained after construction as it will be needed for reevaluation.
The delegate registered with the ProjectRootElement to be called if the file name
is changed. Retained so that ultimately it can be unregistered.
If it has been set to null, the project has been unloaded from its collection.
The owning project object.
ProjectRootElement to use.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
Sub-toolset version to explicitly evaluate the toolset with. May be null.
The to use for evaluation.
The evaluation context to use in case reevaluation is required.
Construct over a text reader over project xml, evaluating with specified
global properties and toolset, either or both of which may be null.
Project will be added to the specified project collection when it is named.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
The owning project object.
Xml reader to read project from.
Global properties to evaluate with. May be null in which case the containing project collection's global properties will be used.
Tools version to evaluate with. May be null.
Sub-toolset version to explicitly evaluate the toolset with. May be null.
The load settings for this project.
The evaluation context to use in case reevaluation is required.
Construct over an existing project file, evaluating with the specified global properties and
using the tools version provided, either or both of which may be null.
Project is added to the global project collection.
Throws InvalidProjectFileException if the evaluation fails.
Throws InvalidOperationException if there is already an equivalent project loaded in the project collection.
May throw IO-related exceptions.
The owning project object.
The project file.
The global properties. May be null.
The tools version. May be null.
Sub-toolset version to explicitly evaluate the toolset with. May be null.
The load settings for this project.
The evaluation context to use in case reevaluation is required.
Gets or sets the project collection which contains this project.
Can never be null.
Cannot be modified.
Certain item operations split the item element in multiple elements if the include
contains globs, references to items or properties, or multiple item values.
The items operations that may expand item elements are:
-
-
-
-
-
-
-
-
-
When this property is set to true, the previous item operations throw an
instead of expanding the item element.
Whether build is enabled for this project.
Explicitly enabled
Explicitly disabled
No explicit setting, uses the setting on the
project collection.
This is the default.
The backing Xml project.
Can never be null.
There is no setter here as that doesn't make sense. If you have a new ProjectRootElement, evaluate it into a new Project.
Whether this project is dirty such that it needs reevaluation.
This may be because its underlying XML has changed (either through this project or another)
either the XML of the main project or an imported file;
or because its toolset may have changed.
Read only dictionary of the global properties used in the evaluation
of this project.
This is the publicly exposed getter, that translates into a read-only dead IDictionary<string, string>.
In order to easily tell when we're dirtied, setting and removing global properties is done with
SetGlobalProperty and RemoveGlobalProperty.
Item types in this project.
This is an ordered collection.
data.ItemTypes is a KeyCollection, so it doesn't need any
additional read-only protection.
Properties in this project.
Since evaluation has occurred, this is an unordered collection.
Collection of possible values implied for properties contained in the conditions found on properties,
property groups, imports, and whens.
For example, if the following conditions existed on properties in a project:
Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"
Condition="'$(Configuration)' == 'Release'"
the table would be populated with
{ "Configuration", { "Debug", "Release" }}
{ "Platform", { "x86" }}
This is used by Visual Studio to determine the configurations defined in the project.
Read-only dictionary of item definitions in this project.
Keyed by item type.
Items in this project, ordered within groups of item types.
Items in this project, ordered within groups of item types,
including items whose conditions evaluated to false, or that were
contained within item groups who themselves had conditioned evaluated to false.
This is useful for hosts that wish to display all items, even if they might not be part
of the build in the current configuration.
All the files that during evaluation contributed to this project, as ProjectRootElements,
with the ProjectImportElement that caused them to be imported.
This does not include projects that were never imported because a condition on an Import element was false.
The outer ProjectRootElement that maps to this project itself is not included.
This can be used by the host to figure out what projects might be impacted by a change to a particular file.
It could also be used, for example, to find the .user file, and use its ProjectRootElement to modify properties in it.
This list will contain duplicate imports if an import is imported multiple times. However, only the first import was used in evaluation.
Targets in the project. The key to the dictionary is the target's name.
Overridden targets are not included in this collection.
This collection is read-only.
Properties encountered during evaluation. These are read during the first evaluation pass.
Unlike those returned by the Properties property, these are ordered, and includes any properties that
were subsequently overridden by others with the same name. It does not include any
properties whose conditions did not evaluate to true.
It does not include any properties added since the last evaluation.
Item definition metadata encountered during evaluation. These are read during the second evaluation pass.
Unlike those returned by the ItemDefinitions property, these are ordered, and include any metadata that
were subsequently overridden by others with the same name and item type. It does not include any
elements whose conditions did not evaluate to true.
It does not include any item definition metadata added since the last evaluation.
Items encountered during evaluation. These are read during the third evaluation pass.
Unlike those returned by the Items property, these are ordered with respect to all other items
encountered during evaluation, not just ordered with respect to items of the same item type.
In some applications, like the F# language, this complete mutual ordering is significant, and such hosts
can use this property.
It does not include any elements whose conditions did not evaluate to true.
It does not include any items added since the last evaluation.
The tools version this project was evaluated with, if any.
Not necessarily the same as the tools version on the Project tag, if any;
it may have been externally specified, for example with a /tv switch.
The actual tools version on the Project tag, can be gotten from Xml.ToolsVersion.
Cannot be changed once the project has been created.
Set by construction.
The sub-toolset version that, combined with the ToolsVersion, was used to determine
the toolset properties for this project.
The root directory for this project.
Is never null: in-memory projects use the current directory from the time of load.
The full path to this project's file.
May be null, if the project was not loaded from disk.
Setter renames the project, if it already had a name.
Whether ReevaluateIfNecessary is temporarily disabled.
This is useful when the host expects to make a number of reads and writes
to the project, and wants to temporarily sacrifice correctness for performance.
Whether MarkDirty() is temporarily disabled.
This allows, for example, a global property to be set without the project getting
marked dirty for reevaluation as a consequence.
This controls whether or not the building of targets/tasks is enabled for this
project. This is for security purposes in case a host wants to closely
control which projects it allows to run targets/tasks. By default, for a newly
created project, we will use whatever setting is in the parent project collection.
When build is disabled, the Build method on this class will fail. However if
the host has already created a ProjectInstance, it can still build it. (It is
free to put a similar check around where it does this.)
Location of the originating file itself, not any specific content within it.
If the file has not been given a name, returns an empty location.
Obsolete. Use instead.
The ID of the last evaluation for this Project.
A project is always evaluated upon construction and can subsequently get evaluated multiple times via
It is an arbitrary number that changes when this project reevaluates.
Hosts don't know whether an evaluation actually happened in an interval, but they can compare this number to
their previously stored value to find out, and if so perhaps decide to update their own state.
Note that the number may not increase monotonically.
This number corresponds to the and can be used to connect
evaluation logging events back to the Project instance.
List of names of the properties that, while global, are still treated as overridable.
The logging service used for evaluation errors.
See .
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
See .
The type of items to return.
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
See .
The string to perform matching against.
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
See .
The string to perform matching against.
The type of items to return.
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
See .
///
The ProjectItem object that indicates: the itemspec to match and the item type to constrain the search in.
The search is also constrained on item elements appearing before the item element that produced this .
The element that produced this is included in the results.
The evaluation context to use in case reevaluation is required.
To avoid reevaluation use .
Some project APIs need to do analysis that requires the Evaluator to record more data than usual as it evaluates.
This method checks if the Evaluator was run with the extra required settings and if not, does a re-evaluation.
If a re-evaluation was necessary, it saves this information so a next call does not re-evaluate.
Using this method avoids storing extra data in memory when its not needed.
Since:
- we have no proper AST and interpreter for itemspecs that we can do analysis on
- GetItemProvenance needs to have correct counts for exclude strings (as correct as it can get while doing it after evaluation)
The temporary hack is to use the expander to expand the strings, and if any property or item references were encountered, return Provenance.Inconclusive.
Returns an iterator over the "logical project". The logical project is defined as
the unevaluated project obtained from the single MSBuild file that is the result
of inlining the text of all imports of the original MSBuild project manifest file.
Get any property in the project that has the specified name,
otherwise returns null.
Get the unescaped value of a property in this project, or
an empty string if it does not exist.
A property with a value of empty string and no property
at all are not distinguished between by this method.
That makes it easier to use. To find out if a property is set at
all in the project, use GetProperty(name).
Set or add a property with the specified name and value.
Overwrites the value of any property with the same name already in the collection if it did not originate in an imported file.
If there is no such existing property, uses this heuristic:
Updates the last existing property with the specified name that has no condition on itself or its property group, if any,
and is in this project file rather than an imported file.
Otherwise, adds a new property in the first property group without a condition, creating a property group if necessary after
the last existing property group, else at the start of the project.
Returns the property set.
Evaluates on a best-effort basis:
-expands with all properties. Properties that are defined in the XML below the new property may be used, even though in a real evaluation they would not be.
-only this property is evaluated. Anything else that would depend on its value is not affected.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
Change a global property after the project has been evaluated.
If the value changes, this makes the project require reevaluation.
If the value changes, returns true, otherwise false.
Adds an item with metadata to the project.
Metadata may be null, indicating no metadata.
Does not modify the XML if a wildcard expression would already include the new item.
Evaluates on a best-effort basis:
-expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be.
-only this item is evaluated. Other items that might depend on it is not affected.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
Adds an item with metadata to the project.
Metadata may be null, indicating no metadata.
Makes no effort to see if an existing wildcard would already match the new item, unless it is the first item in an item group.
Makes no effort to locate the new item near similar items.
Appends the item to the first item group that does not have a condition and has either no children or whose first child is an item of the same type.
Evaluates on a best-effort basis:
-expands with all items. Items that are defined in the XML below the new item may be used, even though in a real evaluation they would not be.
-only this item is evaluated. Other items that might depend on it is not affected.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
All the items in the project of the specified
type.
If there are none, returns an empty list.
Use AddItem or RemoveItem to modify items in this project.
data.GetItems returns a read-only collection, so no need to re-wrap it here.
All the items in the project of the specified
type, irrespective of whether the conditions on them evaluated to true.
This is a read-only list: use AddItem or RemoveItem to modify items in this project.
ItemDictionary[] returns a read only collection, so no need to wrap it.
Returns all items that have the specified evaluated include.
For example, all items that have the evaluated include "bar.cpp".
Typically there will be zero or one, but sometimes there are two items with the
same path and different item types, or even the same item types. This will return
them all.
data.GetItemsByEvaluatedInclude already returns a read-only collection, so no need
to wrap it further.
Removes the specified property.
Property must be associated with this project.
Property must not originate from an imported file.
Returns true if the property was in this evaluated project, otherwise false.
As a convenience, if the parent property group becomes empty, it is also removed.
Updates the evaluated project, but does not affect anything else in the project until reevaluation. For example,
if "p" is removed, it will be removed from the evaluated project, but "q" which is evaluated from "$(p)" will not be modified until reevaluation.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state.
Removes a global property.
If it was set, returns true, and marks the project
as requiring reevaluation.
Removes an item from the project.
Item must be associated with this project.
Item must not originate from an imported file.
Returns true if the item was in this evaluated project, otherwise false.
As a convenience, if the parent item group becomes empty, it is also removed.
If the item originated from a wildcard or semicolon separated expression, expands that expression into multiple items first.
Updates the evaluated project, but does not affect anything else in the project until reevaluation. For example,
if an item of type "i" is removed, "j" which is evaluated from "@(i)" will not be modified until reevaluation.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state until reevaluation.
Normally this will return true, since if the item isn't in the project, it will throw.
The exception is removing an item that was only in ItemsIgnoringCondition.
Removes all the specified items from the project.
Items that are not associated with this project are skipped.
Removing one item could cause the backing XML
to be expanded, which could zombie (disassociate) the next item.
To make this case easy for the caller, if an item
is not associated with this project it is simply skipped.
Evaluates the provided string by expanding items and properties,
as if it was found at the very end of the project file.
This is useful for some hosts for which this kind of best-effort
evaluation is sufficient.
Does not expand bare metadata expressions.
See .
Project instance creation settings.
The evaluation context to use in case reevaluation is required.
Called to forcibly mark the project as dirty requiring reevaluation. Generally this is not necessary to set; all edits affecting
this project will automatically make it dirty. However there are potential corner cases where it is necessary to mark the project dirty
directly. For example, if the project has an import conditioned on a file existing on disk, and the file did not exist at
evaluation time, then someone subsequently creates that file, the project cannot know that reevaluation would be productive.
In such a case the host can help us by setting the dirty flag explicitly so that ReevaluateIfNecessary()
will recognize an evaluation is indeed necessary.
Does not mark the underlying project file as requiring saving.
See .
The to use. See .
Saves a "logical" or "preprocessed" project file, that includes all the imported
files as if they formed a single file.
See .
Targets to build.
List of loggers.
Remote loggers for multi proc logging.
The evaluation context to use in case reevaluation is required.
Tests whether a given project IS or IMPORTS some given project xml root element.
The project xml root element in question.
True if this project is or imports the xml file; false otherwise.
If the ProjectItemElement evaluated to more than one ProjectItem, replaces it with a new ProjectItemElement for each one of them.
If the ProjectItemElement did not evaluate into more than one ProjectItem, does nothing.
Returns true if a split occurred, otherwise false.
A ProjectItemElement could have resulted in several items if it contains wildcards or item or property expressions.
Before any edit to a ProjectItem (remove, rename, set metadata, or remove metadata) this must be called to make
sure that the edit does not affect any other ProjectItems originating in the same ProjectItemElement.
For example, an item xml with an include of "@(x)" could evaluate to items "a", "b", and "c". If "b" is removed, then the original
item xml must be removed and replaced with three, then the one corresponding to "b" can be removed.
This is an unsophisticated approach; the best that can be said is that the result will likely be correct, if not ideal.
For example, perhaps the user would rather remove the item from the original list "x" instead of expanding the list.
Or, perhaps the user would rather the property in "$(p)\a;$(p)\b" not be expanded when "$(p)\b" is removed.
If that's important, the host can manipulate the ProjectItemElement's directly, instead, and it can be as fastidious as it wishes.
Examines the provided ProjectItemElement to see if it has a wildcard that would match the
item we wish to add, and does not have a condition or an exclude.
Works conservatively - if there is anything that might cause doubt, considers the candidate to not be suitable.
Returns true if it is suitable, otherwise false.
Outside this class called ONLY from ProjectItem.Rename(string name).
Before an item changes its item type, it must be removed from
our datastructures, which key off item type.
This should be called ONLY by ProjectItems, in this situation.
After an item has changed its item type, it needs to be added back again,
since our data structures key off the item type.
This should be called ONLY by ProjectItems, in this situation.
Provided a property that is already part of this project, does a best-effort expansion
of the unevaluated value provided and sets it as the evaluated value.
On project in order to keep Project's expander hidden.
Provided an item element that has been renamed with a new unevaluated include,
returns a best effort guess at the evaluated include that results.
If the best effort expansion produces anything other than one item, it just
returns the unevaluated include.
This is not at all generalized, but useful for the majority case where an item is a very
simple file name with perhaps a property prefix.
On project in order to keep Project's expander hidden.
Provided a metadatum that is already part of this project, does a best-effort expansion
of the unevaluated value provided and returns the resulting value.
This is a interim expansion only: it may not be the value that a full project reevaluation would produce.
The metadata table passed in is that of the parent item or item definition.
On project in order to keep Project's expander hidden.
Called by the project collection to indicate to this project that it is no longer loaded.
Verify that the provided object location is in the same file as the project.
If it is not, throws an InvalidOperationException indicating that imported evaluated objects should not be modified.
This prevents, for example, accidentally updating something like the OutputPath property, that you want be in the
main project, but for some reason was actually read in from an imported targets file.
Common code for the AddItem methods.
Helper for and .
If the item is not associated with a project, returns false.
If the item is not present in the evaluated project, returns false.
If the item is associated with another project, throws ArgumentException.
Otherwise removes the item and returns true.
Re-evaluates the project using the specified logging service.
Re-evaluates the project using the specified logging service and load settings.
Creates a project instance based on this project using the specified logging service.
Common code for the constructors.
Applies global properties that are on the collection.
Global properties provided for the project overwrite any global properties from the collection that have the same name.
Global properties may be null.
Tools version may be null.
Raised when any XML in the underlying ProjectRootElement has changed.
Tries to find a ProjectItemElement already in the project file XML that has a wildcard that would match the
item we wish to add, does not have a condition or an exclude, and is within an itemgroup without a condition.
For perf reasons, this method does several jobs in one.
If it finds a suitable existing item element, it returns that as the out parameter, otherwise the out parameter returns null.
Otherwise, if it finds an item element suitable to be just below our new element, it returns that.
Otherwise, if it finds an item group at least that's suitable to put our element in somewhere, it returns that.
Returns null if the include of the item being added itself has wildcards, or semicolons, as the case is too difficult.
Recursive helper for GetLogicalProject.
Internal
Note: For deeper integration of remote project we might need to expose [some] of this functionality via IProjectLink3.
Encapsulates the backing data of a Project, so that it can be passed to the Evaluator to
fill in on a re-evaluation without having to expose property setters.
This object is only passed to the Evaluator.
Almost always, projects have the same set of targets because they all import the same ones.
So we keep around the last set seen and if ours is the same at the end of evaluation, unify the references.
List of names of the properties that, while global, are still treated as overridable.
Constructor taking the immutable global properties and tools version.
Tools version may be null.
Whether evaluation should collect items ignoring condition,
as well as items respecting condition; and collect
conditioned properties, as well as regular properties.
Collection of all evaluated item definitions, one per item-type.
DefaultTargets specified in the project, or
the logically first target if no DefaultTargets is
specified in the project.
The global properties to evaluate with, if any.
Can never be null.
Read-only; to use different global properties, evaluate yourself a new project.
A dictionary of all of the properties read from environment variables during evaluation.
List of names of the properties that, while global, are still treated as overridable.
InitialTargets specified in the project, plus those
in all imports, gathered depth-first.
Sets or retrieves the list of targets which run before the keyed target.
Sets or retrieves the list of targets which run after the keyed target.
The externally specified tools version, if any.
For example, the tools version from a /tv switch.
Not necessarily the same as the tools version from the project tag or of the toolset used.
May be null.
Flows through to called projects.
The toolset data used during evaluation.
The externally specified sub-toolset version that, combined with the ToolsVersion, is used to determine
the toolset properties for this project.
The sub-toolset version that, combined with the ToolsVersion, was used to determine
the toolset properties for this project.
Items in this project, ordered within groups of item types.
Protected by an upcast to IEnumerable.
List of items that link the XML items and evaluated items,
evaluated as if their conditions were true.
This is useful for hosts that wish to display all items regardless of their condition.
This is an ordered collection.
Collection of properties that link the XML properties and evaluated properties.
Since evaluation has occurred, this is an unordered collection.
Includes any global and reserved properties.
Collection of possible values implied for properties contained in the conditions found on properties,
property groups, imports, and whens.
For example, if the following conditions existed on properties in a project:
Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'"
Condition="'$(Configuration)' == 'Release'"
the table would be populated with
{ "Configuration", { "Debug", "Release" }}
{ "Platform", { "x86" }}
This is used by Visual Studio to determine the configurations defined in the project.
The root directory for this project.
Registry of usingtasks, for build.
Get the item types that have at least one item.
Read only collection.
item.ItemTypes is a KeyCollection, so it doesn't need any
additional read-only protection.
Properties encountered during evaluation. These are read during the first evaluation pass.
Unlike those returned by the Properties property, these are ordered, and includes any properties that
were subsequently overridden by others with the same name. It does not include any
properties whose conditions did not evaluate to true.
It does not include any properties added since the last evaluation.
Item definition metadata encountered during evaluation. These are read during the second evaluation pass.
Unlike those returned by the ItemDefinitions property, these are ordered, and include any metadata that
were subsequently overridden by others with the same name and item type. It does not include any
elements whose conditions did not evaluate to true.
It does not include any item definition metadata added since the last evaluation.
Items encountered during evaluation. These are read during the third evaluation pass.
Unlike those returned by the Items property, these are ordered.
It does not include any elements whose conditions did not evaluate to true.
It does not include any items added since the last evaluation.
Expander to use to expand any expressions encountered after the project has been fully evaluated.
For example, to expand the values of any properties added at design time.
It's convenient to store it here.
Whether something in this data has been modified since evaluation.
For example, a global property has been set.
Collection of all evaluated item definitions, one per item-type.
Project that owns this data.
Targets in the project, used to build.
Complete list of all imports pulled in during evaluation.
This includes the outer project itself.
Complete list of all imports pulled in during evaluation including duplicate imports.
This includes the outer project itself.
The toolsversion that was originally specified on the project's root element.
Whether when we read a ToolsVersion other than the current one in the Project tag, we treat it as the current one.
expose mutable precalculated cache to outside so that other can take advantage of the cache as well.
Prepares the data object for evaluation.
Indicates to the data block that evaluation has completed,
so for example it can mark datastructures read-only.
Adds a new item.
Adds a new item to the collection of all items ignoring condition.
Properties encountered during evaluation. These are read during the first evaluation pass.
Unlike those returned by the Properties property, these are ordered, and includes any properties that
were subsequently overridden by others with the same name. It does not include any
properties whose conditions did not evaluate to true.
Item definition metadata encountered during evaluation. These are read during the second evaluation pass.
Unlike those returned by the ItemDefinitions property, these are ordered, and include any metadata that
were subsequently overridden by others with the same name and item type. It does not include any
elements whose conditions did not evaluate to true.
Items encountered during evaluation. These are read during the third evaluation pass.
Unlike those returned by the Items property, these are ordered.
It does not include any elements whose conditions did not evaluate to true.
It does not include any items added since the last evaluation.
Adds a new item definition.
Gets an existing item definition, if any.
Sets a property which is not derived from Xml.
Sets a property derived from Xml.
Retrieves an existing target, if any.
Adds the specified target, overwriting any existing target with the same name.
Record an import opened during evaluation.
This is used to check later whether any of them have been changed.
This may include imported files that ended up contributing nothing to the evaluated project.
These might otherwise have no strong references to them at all.
If they are dirtied, though, they might affect the evaluated project; and that's why we record them.
Mostly these will be common imports, so they'll be shared anyway.
Record a duplicate import, possible a duplicate import opened during evaluation.
Evaluates the provided string by expanding items and properties,
using the current items and properties available.
This is useful for the immediate window.
Does not expand bare metadata expressions.
Not for internal use.
Evaluates the provided string as a condition by expanding items and properties,
using the current items and properties available, then doing a logical evaluation.
This is useful for the immediate window.
Does not expand bare metadata expressions.
Not for internal use.
Returns a list of items of the specified type.
If there are none, returns an empty list.
ItemDictionary returns a read-only collection, so no need to wrap it here.
The type of items to return.
A list of matching items.
Returns the property with the specified name or null if it was not present.
The property name.
The property.
Returns the property with the specified name or null if it was not present.
The property.
Removes an item.
Returns true if it was previously present, otherwise false.
Returns all items that have the specified evaluated include.
For example, all items that have the evaluated include "bar.cpp".
Typically there will be no more than one, but sometimes there are two items with the
same path and different item types, or even the same item types. This will return
them all.
Assumes that the evaluated include value is unescaped.
Get the value of a property in this project, or
an empty string if it does not exist.
Returns the unescaped value.
A property with a value of empty string and no property
at all are not distinguished between by this method.
That makes it easier to use. To find out if a property is set at
all in the project, use GetProperty(name).
Data class representing a result from and its overloads.
This represents all globs found in an item include together with the item element it came from,
the excludes that were present on that item, and all the Remove item elements pertaining to the Include item element.
Gets the original that contained the globs.
Gets all the evaluated glob strings (properties expanded) from the include.
A representing the include globs. It also takes the excludes and relevant removes into consideration.
Gets an containing strings that were excluded.
Gets an containing strings that were later removed via the Remove element.
Constructor.
Bit flag enum that specifies how a string representing an item matched against an itemspec.
Undefined is the bottom element and should not appear in actual results
A string matched against a string literal from an itemspec
A string matched against a glob pattern from an itemspec
Inconclusive means that the match is indirect, coming from either property or item references.
Enum that specifies how an item element references an item.
The element referenced the item by an Include.
The element referenced the item by an Exclude.
The element referenced the item by an Update.
The element referenced the item by a Remove.
Data class representing a result from and its overloads.
Gets the that was performed.
Gets the that contains the operation.
Gets the of how the item appeared in the operation.
Gets the number of occurrences of the item.
Initializes an instance of the ProvenanceResult class.
An evaluated design-time item
Edits to this object will indirectly dirty the containing project because they will modify the backing XML.
We cannot use a copy-on-write table for the metadata, as ProjectMetadata objects are mutable. However,
we do use it for build-time items.
Project that this item lives in.
ProjectItems always live in a project.
Used to get item definitions and project directory.
Fragment of the original include that led to this item,
with properties expanded but not wildcards. Escaped as necessary
This is ONLY used to figure out %(RecursiveDir) when it is requested.
It's likely too expensive to figure that out if it isn't needed, so we store
the necessary material here.
Item definitions are stored in one single table shared by all items of a particular item type.
When an item is created from another item, such as by using an expression like Include="@(x)",
any item definition metadata those source items have must override any item definition metadata
associated with the new item type.
Copying all those item definition metadata into real metadata on this item would be very inefficient, because
it would turn a single shared table into a separate table for every item.
Instead, we get a reference to the item definition of the source items, and consult
that table before we consult our own item type's item definition. Since item definitions can't change at this point,
it's safe to reference their original table.
If our item gets copied again, we need a reference to the inherited item definition and we need the real item
definition of the source items. Thus a list is created. On copying, a list is created, beginning with a clone
of any list the source item had, and ending with the item definition list of the source item type.
When we look up a metadata value we look at
(1) directly associated metadata and built-in metadata
(2) the inherited item definition list, starting from the top
(3) the item definition associated with our item type
Backing XML item.
Can never be null
Evaluated include.
The original XML may have evaluated to several of these items,
each with a different include.
May be empty, for example from expanding an empty list or from a transform with undefined metadata.
Escaped as necessary
Collection of metadata that link the XML metadata and evaluated metadata.
Since evaluation has occurred, this is an unordered collection.
May be null.
Lazily created, as there are lots of items
that have no metadata at all.
Cached value of the fullpath metadata. All other metadata are computed on demand.
External projects support
Called by the Evaluator during project evaluation.
Direct metadata may be null, indicating no metadata. It is assumed to have already been cloned.
Inherited item definition metadata may be null. It is assumed that its list has already been cloned.
ProjectMetadata objects may be shared with other items.
Backing XML item.
Can never be null.
Gets or sets the type of this item.
Gets or sets the unevaluated value of the Include.
Gets the evaluated value of the include, unescaped.
Gets the evaluated value of the include, escaped as necessary.
The directory of the project being built
Never null: If there is no project filename yet, it will use the current directory
Project that this item lives in.
ProjectItems always live in a project.
If the item originated in an imported file, returns true.
Otherwise returns false.
Metadata directly on the item, if any.
Does not include metadata from item definitions.
Does not include built-in metadata.
Never returns null.
Count of direct metadata on this item, if any.
Does NOT count any metadata inherited from item definitions.
Does not count built-in metadata, such as "FullPath".
Metadata on the item, if any. Includes metadata specified by the definition, if any.
If there is no metadata, returns an empty collection.
Does not include built-in metadata, such as "FullPath".
Get the values of built-in metadata using .
This is a read-only collection. To modify the metadata, use .
Count of metadata on this item, if any.
Includes any metadata inherited from item definitions.
Includes both custom and built-in metadata.
Implementation of IKeyed exposing the item type, so items
can be put in a dictionary conveniently.
Internal version of Metadata that returns
a full ICollection.
Unordered collection of evaluated metadata on the item.
If there is no metadata, returns an empty collection.
Does not include built-in metadata.
Includes any from item definitions not masked by directly set metadata.
This is a read-only collection. To modify the metadata, use .
Accesses the unescaped evaluated include prior to wildcard expansion
Accesses the evaluated include prior to wildcard expansion
Accesses the inherited item definitions, if any.
Used ONLY by the ProjectInstance, when cloning a ProjectItem.
Gets an evaluated metadata on this item.
Potentially includes a metadata from an item definition.
Does not return built-in metadata, such as "FullPath".
Returns null if not found.
Get the evaluated value of a metadata on this item, possibly from an item definition.
Returns empty string if it does not exist.
To determine whether a piece of metadata does not exist vs. simply has no value, use HasMetadata.
May be used to access the value of built-in metadata, such as "FullPath".
Attempting to get built-in metadata on a value that is not a valid path throws InvalidOperationException.
Returns true if a particular piece of metadata is defined on this item,
otherwise false.
Includes built-in metadata and metadata inherited from item definitions.
See GetMetadataValue for a more detailed explanation.
Returns the escaped value of the metadatum requested.
Gets any existing ProjectMetadata on the item, or
else any on an applicable item definition.
This is ONLY called during evaluation.
Does not return built-in metadata, such as "FullPath".
Returns null if not found.
Adds a ProjectMetadata to the item.
This is ONLY called during evaluation and does not affect the XML.
Adds metadata with the specified name and value to the item.
Updates an existing metadata if one already exists with the same name on the item directly, as opposed to inherited from an item definition.
Updates the evaluated project, but does not affect anything else in the project until reevaluation. For example,
if a piece of metadata named "m" is added on item of type "i", it does not affect "j" which is evaluated from "@(j->'%(m)')" until reevaluation.
Also if the unevaluated value of "m" is set to something that is modified by evaluation, such as "$(p)", the evaluated value will be set to literally "$(p)" until reevaluation.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state without a reevaluation.
Returns the new or existing metadatum.
Unevaluated value is assumed to be escaped as necessary
Overload of . Adds the option of not splitting the item element and thus affecting all sibling items.
Sibling items are defined as all ProjectItem instances that were created from the same item element.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state without a reevaluation
/// Metadata name
Metadata value
If true, adds direct metadata to the from which this originated. The intent is to affect all other sibling items.
Returns the new or existing metadatum.
Removes any metadata with the specified name.
Returns true if the evaluated metadata existed, otherwise false.
If the metadata name is one of the built-in metadata, like "FullPath", throws InvalidArgumentException.
If the metadata originates in an item definition, and was not overridden, throws InvalidOperationException.
Renames the item.
Equivalent to setting the value.
Generally, no expansion occurs. This is because it would potentially result in several items,
which is not meaningful semantics when renaming a single item.
However if the item does not need to be split (which would invalidate its ProjectItemElement),
and the new value expands to exactly one item, then its evaluated include is updated
with the expanded value, rather than the unexpanded value.
Even if the new value expands to zero items, we do not expand it.
The common case we are interested in for expansion here is setting something
like "$(sourcesroot)\foo.cs" and expanding that to a single item.
If say "@(foo)" is set as the new name, and it expands to blank, that might
be surprising to the host and maybe even unhandled, if on full reevaluation
it wouldn’t expand to blank. That’s why we're being cautious and supporting
the most common scenario only.
Many hosts will do a ReevaluateIfNecessary before reading anyway.
Retrieves any value we have in our metadata table for the metadata name specified.
If no value is available, returns empty string.
Value, if escaped, remains escaped.
Retrieves any value we have in our metadata table for the metadata name and item type specified.
If no value is available, returns empty string.
If item type is null, it is ignored, otherwise it must match.
Value, if escaped, remains escaped.
Returns the value if it exists.
If no value is available, returns null.
If item type is null, it is ignored, otherwise it must match.
Value, if escaped, remains escaped.
Changes the item type of this item.
Until reevaluation puts it in the correct place, it will be placed at
the end of the list of items of its new type.
This is a little involved, as it requires replacing
the XmlElement, and updating the project's datastructures.
Creates new xml objects for itself, disconnecting from the old xml objects.
Called ONLY by
Called when breaking up a single ProjectItemElement that evaluates into several ProjectItems.
Helper to get the value of a built-in metadatum with
the specified name, if any.
Retrieves the named metadata from the item definition, if any.
If it is not present, returns null
The metadata name.
The value if it exists, null otherwise.
A class factory for ProjectItems.
The Project with which each item should be associated.
The project item's XML
Creates an item factory which does not specify an item xml. The item xml must
be specified later.
The project for items generated.
Constructor
The project for items generated.
The xml for items generated.
Item type that items created by this factory will have.
Set the item xml from which items will be created.
Used by the evaluator only.
Creates an item with the specified type and evaluated include.
Used for making items from "just strings" and from expressions like "@(Compile, ';')"
The include.
The path to the project that defined the item.
A new project item.
NOTE: defining project is ignored because we already know the ItemElement associated with
this item, and use that for where it is defined.
Creates an item based on the provided item, but with
the project and xml of this factory. Metadata is cloned,
but continues to point to the original ProjectMetadataElement objects.
This is to support the scenario Include="@(i)" where we are copying
metadata, and are happy to see changes in the original metadata, but
setting metadata should create new XML.
NOTE: defining project is ignored because we already know the ItemElement associated with
this item, and use that for where it is defined.
Creates an item based on the provided item, but with
the project and xml of this factory and the specified include. Metadata is cloned,
but continues to point to the original ProjectMetadataElement objects.
This is to support this scenario: Include="@(i->'xxx')"
If the item type of the source is the same as the item type of the destination,
then it's not necessary to copy metadata originating in an item definition.
If it's not, we have to clone that too.
NOTE: defining project is ignored because we already know the ItemElement associated with
this item, and use that for where it is defined.
Creates an item with the specified include and include before wildcard expansion.
This is to support creating items from an include that may have a wildcard expression in it.
NOTE: defining project is ignored because we already know the ItemElement associated with
this item, and use that for where it is defined.
Applies the supplied metadata to the destination item.
Creates an item based on the provided item, with the specified include and item type.
Implementation of IMetadataTable that can be passed to expander
to expose only built-in metadata on this item.
Backing item
Constructor.
Retrieves any value we have in our metadata table for the metadata name specified.
If no value is available, returns empty string.
Retrieves any value we have in our metadata table for the metadata name and item type specified.
If item type is null, it is ignored.
If no value is available, returns empty string.
Returns the value if it exists, null otherwise.
If item type is null, it is ignored.
An evaluated item definition for a particular item-type.
Note that these are somewhat different to items. Like items, they can have metadata; like properties, the metadata
can override each other. So during evaluation all the item definitions for a type are rolled together (assuming
their conditions are true) to create one ProjectItemDefinition for each type. For this reason, the ProjectItemDefinition
often will not point to a single ProjectItemDefinitionElement. The metadata within, however, will each point to a single
ProjectMetadataElement, and these can be added, removed, and modified.
Project that this item definition lives in.
ProjectItemDefinitions always live in a project.
Used to evaluate any updates to child metadata.
Item type, for example "Compile", that this item definition applies to
Collection of metadata that link the XML metadata and instance metadata
Since evaluation has occurred, this is an unordered collection.
Called by the Evaluator during project evaluation.
Assumes that the itemType string originated in a ProjectItemDefinitionElement and therefore
was already validated.
Project that this item lives in.
ProjectDefinitions always live in a project.
Type of this item definition.
Metadata on the item definition.
If there is no metadata, returns empty collection.
This is a read-only collection.
Count of metadata on the item definition.
Implementation of IKeyed exposing the item type, so these
can be put in a dictionary conveniently.
Get any metadata in the item that has the specified name,
otherwise returns null
Get the value of any metadata in the item that has the specified
name, otherwise returns null
Sets a new metadata value on the ItemDefinition.
Unevaluated value is assumed to be escaped as necessary
Sets a new metadata value on the ItemDefinition.
This is ONLY called during evaluation and does not affect the XML.
Retrieves the value of the named metadatum.
The metadatum to retrieve.
The value, or an empty string if there is none by that name.
Retrieves the value of the named metadatum.
The type of item.
The metadatum to retrieve.
The value, or an empty string if there is none by that name.
Retrieves the value of the named metadatum, or null if it doesn't exist
The type of item.
The metadatum to retrieve.
The value, or null if there is none by that name.
An evaluated design-time metadatum.
Parented either by a ProjectItemDefinition or a ProjectItem.
Never used to represent built-in metadata, like %(Filename). There is always a backing XML object.
Parent item or item definition that this metadatum lives in.
ProjectMetadata's always live in a project and always have a parent.
The project can be gotten from this parent.
Used to evaluate any updates.
Backing XML metadata.
Can never be null.
Evaluated value
Any immediately previous metadatum (from item definition or item) that was overridden by this one during evaluation.
This would include all metadata with the same name that lie above in the logical
project file, who are on item definitions of the same type, and whose conditions evaluated to true.
If this metadatum is on an item, it would include any previous metadatum with the same name on the same item whose condition
evaluated to true, and following that any item definition metadata.
If there are none above this is null.
If the project has not been reevaluated since the last modification this value may be incorrect.
External projects support
Creates a metadata backed by XML.
Constructed during evaluation of a project.
Name of the metadata
Gets the evaluated metadata value.
Cannot be set directly: only the unevaluated value can be set.
Is never null.
Gets or sets the unevaluated metadata value.
As well as updating the unevaluated value, the setter updates the evaluated value, but does not affect anything else in the project until reevaluation. For example,
--if a piece of metadata named "m" is modified on item of type "i", it does not affect "j" which is evaluated from "@(j->'%(m)')" until reevaluation.
--if the unevaluated value of "m" is set to something that is modified by evaluation, such as "$(p)", the evaluated value will be set to "$(p)" until reevaluation.
This is a convenience that it is understood does not necessarily leave the project in a perfectly self consistent state.
Setting metadata through a ProjectItem may cause the underlying ProjectItemElement to be split, if it originated with an itemlist, wildcard, or semicolon expression,
because it was clear that the caller intended to only affect that particular item.
Setting metadata through a ProjectMetadata does not cause any splitting, because we assume the caller presumably intends to affect all items using the underlying
ProjectMetadataElement. At least, this seems a reasonable assumption, and it avoids the need for metadata to hold a pointer to their containing items.
The containing project will be dirtied by the XML modification. Unevaluated values are assumed to be passed in escaped as necessary.
Backing XML metadata.
Can never be null.
Project that this metadatum lives in.
ProjectMetadata's always live in a project.
The item type of the parent item definition or item.
Any immediately previous metadatum (from item definition or item) that was overridden by this one during evaluation.
This would include all metadata with the same name that lie above in the logical
project file, who are on item definitions of the same type, and whose conditions evaluated to true.
If this metadatum is on an item, it would include any previous metadatum with the same name on the same item whose condition
evaluated to true, and following that any item definition metadata.
If there are none above this is null.
If the project has not been reevaluated since the last modification this value may be incorrect.
If the metadatum originated in an imported file, returns true.
Otherwise returns false.
Location of the element
Location of the condition attribute
Implementation of IKeyed exposing the metadata name, so metadata
can be put in a dictionary conveniently.
Implementation of IValued
Gets the evaluated metadata value.
Cannot be set directly: only the unevaluated value can be set.
Is never null.
Compares this metadata to another for equivalence.
The other metadata
True if they are equivalent, false otherwise.
Deep clone a metadatum, retaining the same parent.
An evaluated design-time property
Project that this property lives in.
ProjectProperty's always live in a project.
Used to evaluate any updates.
Evaluated value of the property. Escaped as necessary.
Creates a property.
Name of the property.
Cannot be set.
If this could be set, it would be necessary to have a callback
so that the containing collections could be updated, as they use the name as
their key.
Gets the evaluated property value.
Cannot be set directly: only the unevaluated value can be set.
Is never null.
Unescaped value of the evaluated property
Gets the evaluated property value.
Cannot be set directly: only the unevaluated value can be set.
Is never null.
Evaluated property escaped as necessary
Gets or sets the unevaluated property value.
Updates the evaluated value in the project, although this is not sure to be correct until re-evaluation.
Whether the property originated from the environment (or the toolset)
Whether the property is a global property
Whether the property is a reserved property,
like 'MSBuildProjectFile'.
Backing XML property.
Null only if this is a global, environment, or built-in property.
Project that this property lives in.
ProjectProperty's always live in a project.
Any immediately previous property that was overridden by this one during evaluation.
This would include all properties with the same name that lie above in the logical
project file, and whose conditions evaluated to true.
If there are none above this is null.
If the project has not been reevaluated since the last modification this value may be incorrect.
If the property originated in an imported file, returns true.
If the property originates from the environment, a global property, or is a built-in property, returns false.
Otherwise returns false.
Implementation of IKeyed exposing the property name, so properties
can be put in a dictionary conveniently.
Implementation of IValued
Compares this property to another for equivalence.
The other property.
True if the properties are equivalent, false otherwise.
Creates a property without backing XML.
Property MAY BE global, and property MAY HAVE a reserved name (such as "MSBuildProjectDirectory") if indicated.
This is ONLY to be used by the Evaluator (and Project.SetGlobalProperty) and ONLY for Global, Environment, and Built-in properties.
All other properties originate in XML, and should have a backing XML object.
Creates a regular evaluated property, with backing XML.
Called by Project.SetProperty.
Property MAY NOT have reserved name and MAY NOT overwrite a global property.
Predecessor is any immediately previous property that was overridden by this one during evaluation and may be null.
Called ONLY by the project in order to update the evaluated value
after a property set occurring between full evaluations.
Method instead of a setter on EvaluatedValue to try to make clear its limited purpose.
Looks for a matching global property.
The reason we do this and not just look at project.GlobalProperties is
that when the project is being loaded, the GlobalProperties collection is already populated. When we do our
evaluation, we may attempt to add some properties, such as environment variables, to the master Properties
collection. As GlobalProperties are supposed to override these and thus be added last, we can't check against
the GlobalProperties collection as they are being added. The correct behavior is to always check against the
collection which is accumulating properties as we go, which is the Properties collection. Once the project has
been fully populated, this method will also ensure that further properties do not attempt to override global
properties, as those will have the global property flag set.
The project to compare with.
The property name to look up
True if there is a matching global property, false otherwise.
Regular property, originating in an XML node, but with no predecessor (property with same name that it overrode during evaluation)
Backing XML property.
Never null.
Creates a regular evaluated property, with backing XML.
Called by Project.SetProperty.
Property MAY NOT have reserved name and MAY NOT overwrite a global property.
Predecessor is any immediately previous property that was overridden by this one during evaluation and may be null.
Name of the property.
Cannot be set.
If this could be set, it would be necessary to have a callback
so that the containing collections could be updated, as they use the name as
their key.
Gets or sets the unevaluated property value.
Updates the evaluated value in the project, although this is not sure to be correct until re-evaluation.
The containing project will be dirtied by the XML modification.
If there is no XML backing, the evaluated value returned is the value of the property that has been
escaped as necessary.
Whether the property originated from the environment (or the toolset)
Whether the property is a global property
Whether the property is a reserved property,
like 'MSBuildProjectFile'.
Backing XML property.
Any immediately previous property that was overridden by this one during evaluation.
This would include all properties with the same name that lie above in the logical
project file, and whose conditions evaluated to true.
In this class this is null.
If the project has not been reevaluated since the last modification this value may be incorrect.
If the property originated in an imported file, returns true.
Otherwise returns false.
Regular property, originating in an XML node, and with a predecessor (property with same name that was overridden during evaluation)
Any immediately previous property that was overridden by this one during evaluation.
This would include all properties with the same name that lie above in the logical
project file, and whose conditions evaluated to true.
If there are none above this is null.
If the project has not been reevaluated since the last modification this value may be incorrect.
Creates a regular evaluated property, with backing XML.
Called by Project.SetProperty.
Property MAY NOT have reserved name and MAY NOT overwrite a global property.
Predecessor is any immediately previous property that was overridden by this one during evaluation and may be null.
Any immediately previous property that was overridden by this one during evaluation.
This would include all properties with the same name that lie above in the logical
project file, and whose conditions evaluated to true.
If there are none above this is null.
If the project has not been reevaluated since the last modification this value may be incorrect.
Global/environment/toolset properties are the minority;
they don't originate with XML, so we must store their name (instead)
Name of the property.
Creates a property without backing XML.
Property MAY BE global, and property MAY HAVE a reserved name (such as "MSBuildProjectDirectory") if indicated.
This is ONLY to be used by the Evaluator (and Project.SetGlobalProperty) and ONLY for Global, Environment, and Built-in properties.
All other properties originate in XML, and should have a backing XML object.
Name of the property.
Cannot be set.
If this could be set, it would be necessary to have a callback
so that the containing collections could be updated, as they use the name as
their key.
Gets or sets the unevaluated property value.
Updates the evaluated value in the project, although this is not sure to be correct until re-evaluation.
The containing project will be dirtied.
As there is no XML backing, the evaluated value returned is the value of the property that has been
escaped as necessary.
Whether the property originated from the environment (or the toolset)
Whether the property is a global property
Whether the property is a reserved property,
like 'MSBuildProjectFile'.
Backing XML property.
Null because this is a global, environment, or built-in property.
Any immediately previous property that was overridden by this one during evaluation.
Because these properties are not backed by XML, they cannot have precedessors.
Whether the property originated in an imported file.
Because these properties did not originate in an XML file, this always returns null.
Encapsulates an import relationship in an evaluated project
between a ProjectImportElement and the ProjectRootElement of the
imported project.
Initializes a new instance of the struct.
Initializes a new instance of the struct.
Gets the element doing the import.
Null if this is the top project
Gets one of the imported projects.
Non null if this import was an sdk import.
Whether the importing element is itself imported.
Aggregation of a set of properties that correspond to a particular sub-toolset.
VisualStudioVersion that corresponds to this subtoolset
The properties defined by the subtoolset.
Constructor that associates a set of properties with a sub-toolset version.
Private constructor for translation
VisualStudioVersion that corresponds to this subtoolset
The properties that correspond to this particular sub-toolset.
Translates the sub-toolset.
Factory for deserialization.
Delegate for loading an Xml file, for unit testing.
The path to load.
An Xml document.
Aggregation of a toolset version (eg. "2.0"), tools path, and optional set of associated properties.
Toolset is immutable.
these files list all default tasks and task assemblies that do not need to be explicitly declared by projects
these files list all Override tasks and task assemblies that do not need to be explicitly declared by projects
Regkey that we check to see whether Dev10 is installed. This should exist if any SKU of Dev10 is installed,
but is not removed even when the last version of Dev10 is uninstalled, due to 10.0\bsln sticking around.
Regkey that we check to see whether Dev10 Ultimate is installed. This will exist if it is installed, and be
properly removed after it has been uninstalled.
Regkey that we check to see whether Dev10 Premium is installed. This will exist if it is installed, and be
properly removed after it has been uninstalled.
Regkey that we check to see whether Dev10 Professional is installed. This will exist if it is installed, and be
properly removed after it has been uninstalled.
Regkey that we check to see whether C# Express 2010 is installed. This will exist if it is installed, and be
properly removed after it has been uninstalled.
Regkey that we check to see whether VB Express 2010 is installed. This will exist if it is installed, and be
properly removed after it has been uninstalled.
Regkey that we check to see whether VC Express 2010 is installed. This will exist if it is installed, and be
properly removed after it has been uninstalled.
Regkey that we check to see whether VWD Express 2010 is installed. This will exist if it is installed, and be
properly removed after it has been uninstalled.
Regkey that we check to see whether LightSwitch 2010 is installed. This will exist if it is installed, and be
properly removed after it has been uninstalled.
Null if it hasn't been figured out yet; true if (some variation of) Visual Studio 2010 is installed on
the current machine, false otherwise.
Name of the tools version
The MSBuildBinPath (and ToolsPath) for this tools version
The properties defined by the toolset.
Path to look for msbuild override task files.
ToolsVersion to use as the default ToolsVersion for this version of MSBuild
The environment properties
The build-global properties
indicates if the default tasks file has already been scanned
indicates if the override tasks file has already been scanned
holds all the default tasks we know about and the assemblies they exist in
holds all the override tasks we know about and the assemblies they exist in
Delegate to retrieving files. For unit testing only.
Delegate to check to see if a directory exists
Delegate for loading Xml. For unit testing only.
Expander to expand the properties and items in the using tasks files
Bag of properties for the expander to expand the properties and items in the using tasks files
SubToolsets that map to this toolset.
If no sub-toolset is specified, this is the default sub-toolset version. Null == no default
sub-toolset, just use the base toolset.
Map of project import properties to their list of fall-back search paths
Constructor taking only tools version and a matching tools path
Name of the toolset
Path to this toolset's tasks and targets
The project collection from which to obtain the properties.
The path to search for msbuild overridetasks files.
Constructor that also associates a set of properties with the tools version
Name of the toolset
Path to this toolset's tasks and targets
Properties that should be associated with the Toolset.
May be null, in which case an empty property group will be used.
The project collection that this toolset should inherit from
The override tasks path.
Constructor that also associates a set of properties with the tools version
Name of the toolset
Path to this toolset's tasks and targets
Properties that should be associated with the Toolset.
May be null, in which case an empty property group will be used.
The project collection that this toolset should inherit from
The set of sub-toolsets to add to this toolset
The override tasks path.
Constructor taking only tools version and a matching tools path
Name of the toolset
Path to this toolset's tasks and targets
A containing the environment properties.
A containing the global properties.
The override tasks path.
ToolsVersion to use as the default ToolsVersion for this version of MSBuild.
Constructor that also associates a set of properties with the tools version
Name of the toolset
Path to this toolset's tasks and targets
Properties that should be associated with the Toolset.
May be null, in which case an empty property group will be used.
A containing the environment properties.
A containing the global properties.
A list of to use.
The override tasks path.
ToolsVersion to use as the default ToolsVersion for this version of MSBuild.
Map of parameter name to property search paths for use during Import.
Additional constructor to make unit testing the TaskRegistry support easier
Internal for unit test purposes only.
Name of the toolset
Path to this toolset's tasks and targets
Properties that should be associated with the Toolset.
May be null, in which case an empty property group will be used.
The project collection.
A delegate to intercept GetFiles calls. For unit testing.
A delegate to intercept Xml load calls. For unit testing.
The override tasks path.
Private constructor for serialization.
Returns a ProjectImportPathMatch struct for the first property found in the expression for which
project import search paths is enabled.
Expression to search for properties in (first level only, not recursive)
List of search paths or ProjectImportPathMatch.None if empty
Name of this toolset
Path to this toolset's tasks and targets. Corresponds to $(MSBuildToolsPath) in a project or targets file.
Properties associated with the toolset
The set of sub-toolsets associated with this toolset.
Returns the default sub-toolset version for this sub-toolset. Heuristic used is:
1) If Visual Studio 2010 is installed and our ToolsVersion is "4.0", use the base toolset, and return
a sub-toolset version of "10.0", to be set as a publicly visible property so that e.g. targets can
consume it. This is to handle the fact that Visual Studio 2010 did not have any concept of sub-toolsets.
2) Otherwise, use the highest-versioned sub-toolset found. Sub-toolsets with numbered versions will
be ordered numerically; any additional sub-toolsets will be prepended to the beginning of the list in
the order found. We use the highest-versioned sub-toolset because, in the absence of any other information,
we assume that higher-versioned tools will be more likely to be able to generate something more correct.
Will return null if there is no sub-toolset available (and Dev10 is not installed).
Null if it hasn't been figured out yet; true if (some variation of) Visual Studio 2010 is installed on
the current machine, false otherwise.
Internal so that unit tests can use it too.
Path to look for msbuild override task files.
ToolsVersion to use as the default ToolsVersion for this version of MSBuild
Map of properties to their list of fall-back search paths
Map of MSBuildExtensionsPath properties to their list of fallback search paths
Function for serialization.
Generates the sub-toolset version to be used with this toolset. Sub-toolset version is based on:
1. If "VisualStudioVersion" is set as a property on the toolset itself (global or environment),
use that.
2. Otherwise, use the default sub-toolset version for this toolset.
The sub-toolset version returned may be null; if so, that means that no sub-toolset should be used,
just the base toolset on its own. The sub-toolset version returned may not map to an existing
sub-toolset.
Generates the sub-toolset version to be used with this toolset. Sub-toolset version is based on:
1. If the "VisualStudioVersion" global property exists in the set of properties passed to us, use it.
2. Otherwise, if "VisualStudioVersion" is set as a property on the toolset itself (global or environment),
use that.
3. Otherwise, use Visual Studio version from solution file if it maps to an existing sub-toolset.
4. Otherwise, use the default sub-toolset version for this toolset.
The sub-toolset version returned may be null; if so, that means that no sub-toolset should be used,
just the base toolset on its own. The sub-toolset version returned may not map to an existing
sub-toolset.
The global properties dictionary may be null.
Given a property name and a sub-toolset version, searches for that property first in the
sub-toolset, then falls back to the base toolset if necessary, and returns the property
if it was found.
Factory for deserialization.
Given a search path and a task pattern get a list of task or override task files.
Generates the sub-toolset version to be used with this toolset. Sub-toolset version is based on:
1. If the "VisualStudioVersion" global property exists in the set of properties passed to us, use it.
2. Otherwise, if "VisualStudioVersion" is set as a property on the toolset itself (global or environment),
use that.
3. Otherwise, use Visual Studio version from solution file if it maps to an existing sub-toolset.
4. Otherwise, use the default sub-toolset version for this toolset.
The sub-toolset version returned may be null; if so, that means that no sub-toolset should be used,
just the base toolset on its own. The sub-toolset version returned may not map to an existing
sub-toolset.
The global properties dictionary may be null.
Generates the sub-toolset version to be used with this toolset. Sub-toolset version is based on:
1. If the "VisualStudioVersion" global property exists in the set of properties passed to us, use it.
2. Otherwise, if "VisualStudioVersion" is set as a property on the toolset itself (global or environment),
use that.
3. Otherwise, use Visual Studio version from solution file if it maps to an existing sub-toolset.
4. Otherwise, use the default sub-toolset version for this toolset.
The sub-toolset version returned may be null; if so, that means that no sub-toolset should be used,
just the base toolset on its own. The sub-toolset version returned may not map to an existing
sub-toolset.
The global properties dictionary may be null.
Return a task registry stub for the tasks in the *.tasks file for this toolset
The logging services used to log during task registration.
The build event context used to log during task registration.
The to use.
The task registry
Get SubToolset version using Visual Studio version from Dev 12 solution file
Return a task registry for the override tasks in the *.overridetasks file for this toolset
The logging services used to log during task registration.
The build event context used to log during task registration.
The to use.
The task registry
Used to load information about default MSBuild tasks i.e. tasks that do not need to be explicitly declared in projects
with the <UsingTask> element. Default task information is read from special files, which are located in the same
directory as the MSBuild binaries.
1) a default tasks file needs the <Project> root tag in order to be well-formed
2) the XML declaration tag <?xml ...> is ignored
3) comment tags are always ignored regardless of their placement
4) the rest of the tags are expected to be <UsingTask> tags
The logging services to use to log during this registration.
The build event context to use to log during this registration.
The to use.
Initialize the properties which are used to evaluate the tasks files.
Used to load information about MSBuild override tasks i.e. tasks that override tasks declared in tasks or project files.
Do the actual loading of the tasks or override tasks file and register the tasks in the task registry
Class used to read toolset configurations.
A section of a toolset configuration
Delegate used to read application configurations
Flag indicating that an attempt has been made to read the configuration
Character used to separate search paths specified for MSBuildExtensionsPath* in
the config file
Cached values of tools version -> project import search paths table
Default constructor
Constructor taking a delegate for unit test purposes only
Returns the list of tools versions
Returns the default tools version, or null if none was specified
Returns the path to find override tasks, or null if none was specified
DefaultOverrideToolsVersion attribute on msbuildToolsets element, specifying the tools version that should be used by
default to build projects with this version of MSBuild.
Lazy getter for the ToolsetConfigurationSection
Returns null if the section is not present
Provides an enumerator over property definitions for a specified tools version
Provides an enumerator over the set of sub-toolset names available to a particular
tools version. MSBuild config files do not currently support sub-toolsets, so
we return nothing.
The tools version.
An enumeration of the sub-toolsets that belong to that tools version.
Provides an enumerator over property definitions for a specified sub-toolset version
under a specified toolset version. In the ToolsetConfigurationReader case, breaks
immediately because we do not currently support sub-toolsets in the configuration file.
The tools version.
The sub-toolset version.
An enumeration of property definitions.
Returns a map of project property names / list of search paths for the specified toolsVersion and os
Returns a list of the search paths for a given search path property collection
Reads the application configuration file.
NOTE: this is abstracted into a method to support unit testing GetToolsetDataFromConfiguration().
Unit tests wish to avoid reading (nunit.exe) application configuration file.
Helper class for reading toolsets out of the configuration file.
Creating a ToolsetConfigurationReader, and also reading toolsets from the
configuration file, are a little expensive. To try to avoid this cost if it's
not necessary, we'll check if the file exists first. If it exists, we'll scan for
the string "toolsVersion" to see if it might actually have any tools versions
defined in it.
True if there may be toolset definitions, otherwise false
Class representing the Toolset element
Internal for unit testing only
ToolsVersion attribute of the element
Property element collection
Collection of all the search paths for project imports, per OS
Class representing all the per-OS search paths for MSBuildExtensionsPath*
We use this dictionary to track whether or not we've seen a given
searchPaths definition before, since the .NET configuration classes
won't perform this check without respect for case.
Type of the collection
This has to be public as cannot change access modifier when overriding
Throw exception if an element with a duplicate key is added to the collection
Name of the element
Gets an element with the specified name
OS of the element
element
Gets an element based at the specified position
position
element
Returns the key value for the given element
element whose key is returned
key
Creates a new element of the collection
Created element
overridden so we can track previously seen elements
overridden so we can track previously seen elements
Stores the name of the OS in a case-insensitive map
so we can detect if it is specified more than once but with
different case
Class representing searchPaths element for a single OS
OS attribute of the element
Property element collection
Class representing collection of property elements
We use this dictionary to track whether or not we've seen a given
property definition before, since the .NET configuration classes
won't perform this check without respect for case.
Collection type
This has to be public as cannot change access modifier when overriding
Throw exception if an element with a duplicate is added
name of the element
Gets an element with the specified name
name of the element
element
Gets an element at the specified position
position
element
Creates a new element
element
overridden so we can track previously seen property names
overridden so we can track previously seen property names
Gets the key for the element
element
key
Stores the name of the tools version in a case-insensitive map
so we can detect if it is specified more than once but with
different case
This class represents property element
name attribute
value attribute
Class representing the collection of toolset elements
Internal for unit testing only
We use this dictionary to track whether or not we've seen a given
toolset definition before, since the .NET configuration classes
won't perform this check without respect for case.
Type of the collection
This has to be public as cannot change access modifier when overriding
Throw exception if an element with a duplicate key is added to the collection
Name of the element
Gets an element with the specified name
toolsVersion of the element
element
Gets an element based at the specified position
position
element
Returns the key value for the given element
element whose key is returned
key
Creates a new element of the collection
Created element
overridden so we can track previously seen tools versions
overridden so we can track previously seen tools versions
Stores the name of the tools version in a case-insensitive map
so we can detect if it is specified more than once but with
different case
This class is used to programmatically read msbuildToolsets section
in from the configuration file. An example of application config file:
<configuration>
<msbuildToolsets default="2.0">
<toolset toolsVersion="2.0">
<property name="MSBuildBinPath" value="D:\windows\Microsoft.NET\Framework\v2.0.x86ret\"/>
<property name="SomeOtherProperty" value="SomeOtherPropertyValue"/>
</toolset>
<toolset toolsVersion="3.5">
<property name="MSBuildBinPath" value="D:\windows\Microsoft.NET\Framework\v3.5.x86ret\"/>
</toolset>
</msbuildToolsets>
</configuration>
Internal for unit testing only
toolsVersion element collection
default attribute on msbuildToolsets element, specifying the default ToolsVersion
MsBuildOverrideTasksPath attribute on msbuildToolsets element, specifying the path to find msbuildOverrideTasks files
DefaultOverrideToolsVersion attribute on msbuildToolsets element, specifying the toolsversion that should be used by
default to build projects with this version of MSBuild.
A class representing a property. Used internally by the toolset readers.
The property name
The property value
The property source
Creates a new property
The property name
The property value
The property source
The name of the property
The value of the property
A description of the location where the property was defined,
such as a registry key path or a path to a config file and
line number.
The abstract base class for all Toolset readers.
The global properties used to read the toolset.
The environment properties used to read the toolset.
Constructor
Returns the list of tools versions
Returns the default tools version, or null if none was specified
Returns the path to find override tasks, or null if none was specified
ToolsVersion to use as the default ToolsVersion for this version of MSBuild
Gathers toolset data from the registry and configuration file, if any:
allows you to specify which of the registry and configuration file to
read from by providing ToolsetInitialization
Gathers toolset data from the registry and configuration file, if any.
NOTE: this method is internal for unit testing purposes only.
Populates the toolset collection passed in with the toolsets read from some location.
Internal for unit testing only
the default tools version if available, or null otherwise
Provides an enumerator over property definitions for a specified tools version
The tools version.
An enumeration of property definitions.
Provides an enumerator over the set of sub-toolset names available to a particular
toolsversion
The tools version.
An enumeration of the sub-toolsets that belong to that toolsversion.
Provides an enumerator over property definitions for a specified sub-toolset version
under a specified toolset version.
The tools version.
The sub-toolset version.
An enumeration of property definitions.
Returns a map of MSBuildExtensionsPath* property names/kind to list of search paths
Reads all the toolsets and populates the given ToolsetCollection with them
Reads the settings for a specified tools version
Create a dictionary with standard properties.
Appends standard properties to a dictionary. These properties are read from
the registry under Windows (they are a part of a toolset definition).
Processes a particular ToolsetPropertyDefinition into the correct value and location in the initial and/or final property set.
The ToolsetPropertyDefinition being analyzed.
The final set of properties that we wish this toolset property to be added to.
The global properties, used for expansion and to make sure none are overridden.
The initial properties, used for expansion and added to if "accumulateProperties" is true.
If "true", we add this property to the initialProperties dictionary, as well, so that properties later in the toolset can use this value.
If this toolset property is the "MSBuildToolsPath" property, we will return the value in this parameter.
If this toolset property is the "MSBuildBinPath" property, we will return the value in this parameter.
The expander used to expand the value of the properties. Ref because if we are accumulating the properties, we need to re-create the expander to account for the new property value.
Expands the given unexpanded property expression using the properties in the
given expander.
Sets the given property in the given property group.
Given a path, de-relativizes it using the location of the currently
executing .exe as the base directory. For example, the path "..\foo"
becomes "c:\windows\microsoft.net\framework\foo" if the current exe is
"c:\windows\microsoft.net\framework\v3.5.1234\msbuild.exe".
If the path is not relative, it is returned without modification.
If the path is invalid, it is returned without modification.
struct representing a reference to MSBuildExtensionsPath* property
MSBuildExtensionsPathReferenceKind instance for property named "MSBuildExtensionsPath"
MSBuildExtensionsPathReferenceKind instance for property named "MSBuildExtensionsPath32"
MSBuildExtensionsPathReferenceKind instance for property named "MSBuildExtensionsPath64"
MSBuildExtensionsPathReferenceKind instance representing no MSBuildExtensionsPath* property reference
String representation of the property reference - eg. "MSBuildExtensionsPath32"
Returns the corresponding property name - eg. "$(MSBuildExtensionsPath32)"
Tries to find a reference to MSBuildExtensionsPath* property in the given string
Reads registry at the base key and returns a Dictionary keyed on ToolsVersion.
Dictionary contains another dictionary of (property name, property value) pairs.
If a registry value is not a string, this will throw a InvalidToolsetDefinitionException.
An example of how the registry will look (note that the DefaultToolsVersion is per-MSBuild-version)
[HKLM]\SOFTWARE\Microsoft
msbuild
3.5
@DefaultToolsVersion = 2.0
ToolsVersions
2.0
@MSBuildToolsPath = D:\SomeFolder
3.5
@MSBuildToolsPath = D:\SomeOtherFolder
@MSBuildBinPath = D:\SomeOtherFolder
@SomePropertyName = PropertyOtherValue
Registry location for storing tools version dependent data for msbuild
Cached registry wrapper at root of the msbuild entries
Default constructor
Constructor overload accepting a registry wrapper for unit testing purposes only
Returns the list of tools versions
Returns the default tools version, or null if none was specified
Returns the path to find override tasks, or null if none was specified
ToolsVersion to use as the default ToolsVersion for this version of MSBuild
Provides an enumerator over property definitions for a specified tools version
The tools version
An enumeration of property definitions
Provides an enumerator over the set of sub-toolset names available to a particular
toolsversion
The tools version.
An enumeration of the sub-toolsets that belong to that toolsversion.
Provides an enumerator over property definitions for a specified sub-toolset version
under a specified toolset version.
The tools version.
The sub-toolset version.
An enumeration of property definitions.
Returns a map of MSBuildExtensionsPath* property names/kind to list of search paths
Given a registry location containing a property name and value, create the ToolsetPropertyDefinition that maps to it
Wrapper for the key that we're getting values from
The name of the property whose value we wish to generate a ToolsetPropertyDefinition for.
A ToolsetPropertyDefinition instance corresponding to the property name requested.
Reads a string value from the specified registry key
wrapper around key
name of the value
string data in the value
Update our table which keeps track of all the properties that are referenced
inside of a condition and the string values that they are being tested against.
So, for example, if the condition was " '$(Configuration)' == 'Debug' ", we
would get passed in leftValue="$(Configuration)" and rightValueExpanded="Debug".
This call would add the string "Debug" to the list of possible values for the
"Configuration" property.
This method also handles the case when two or more properties are being
concatenated together with a vertical bar, as in '
$(Configuration)|$(Platform)' == 'Debug|x86'
For debugging leaks, a way to disable caching expression trees, to reduce noise
Evaluates a string representing a condition from a "condition" attribute.
If the condition is a malformed string, it throws an InvalidProjectFileException.
This method uses cached expression trees to avoid generating them from scratch every time it's called.
This method is thread safe and is called from engine and task execution module threads
Evaluates a string representing a condition from a "condition" attribute.
If the condition is a malformed string, it throws an InvalidProjectFileException.
This method uses cached expression trees to avoid generating them from scratch every time it's called.
This method is thread safe and is called from engine and task execution module threads
Logging service may be null.
Table of conditioned properties and their values.
Used to populate configuration lists in some project systems.
If this is null, as it is for command line builds, conditioned properties
are not recorded.
May return null if the expression would expand to non-empty and it broke out early.
Otherwise, returns the correctly expanded expression.
Expands the specified expression into a list of TaskItem's.
Expands the specified expression into a string.
PRE cache
All the state necessary for the evaluation of conditionals so that the expression tree
is stateless and reusable
Condition that was parsed. This does not belong here,
it belongs to the expression tree, not the condition evaluation state.
Table of conditioned properties and their values.
Used to populate configuration lists in some project systems.
If this is null, as it is for command line builds, conditioned properties
are not recorded.
PRE collection.
May return null if the expression would expand to non-empty and it broke out early.
Otherwise, returns the correctly expanded expression.
Expands the properties and items in the specified expression into a list of taskitems.
The expression to expand.
A list of items.
Expands the specified expression into a string.
The expression to expand.
The expanded string.
Performs logical AND on children
Does not update conditioned properties table
Evaluate as boolean
Compares for equality
Compare numbers
Compare booleans
Compare strings
Evaluates a function expression, such as "Exists('foo')"
Evaluate node as boolean
Expands properties and items in the argument, and verifies that the result is consistent
with a scalar parameter type.
Function name for errors
Argument to be expanded
True if this is afile name and the path should be normalized
Scalar result
Check that the number of function arguments is correct.
Base class for all expression nodes.
Returns true if this node evaluates to an empty string,
otherwise false.
(It may be cheaper to determine whether an expression will evaluate
to empty than to fully evaluate it.)
Implementations should cache the result so that calls after the first are free.
Value after any item and property expressions are expanded
Value before any item and property expressions are expanded
If any expression nodes cache any state for the duration of evaluation,
now's the time to clean it up
The main evaluate entry point for expression trees
Get display string for this node for use in the debugger.
Compares for left > right
Compare numerically
Compare Versions. This is only intended to compare version formats like "A.B.C.D" which can otherwise not be compared numerically
Compare mixed numbers and Versions
Compare mixed numbers and Versions
Compares for left >= right
Compare numerically
Compare Versions. This is only intended to compare version formats like "A.B.C.D" which can otherwise not be compared numerically
Compare mixed numbers and Versions
Compare mixed numbers and Versions
Compares for left < right
Compare numerically
left input
right input
true if right is higher than left, false otherwise
Compare Versions. This is only intended to compare version formats like "A.B.C.D" which can otherwise not be compared numerically
left version
right version
true if right version is higher than left, false otherwise
Compare mixed numbers and Versions
left version
right number
true if right is higher than major version of left, false otherwise
Compare mixed numbers and Versions
left number
right version
true if the major version of right is higher than left, false otherwise
Compares for left <= right
Compare numerically
Compare Versions. This is only intended to compare version formats like "A.B.C.D" which can otherwise not be compared numerically
Compare mixed numbers and Versions
Compare mixed numbers and Versions
Evaluates as boolean and evaluates children as boolean, numeric, or string.
Order in which comparisons are attempted is numeric, boolean, then string.
Updates conditioned properties table.
Compare numbers
Compare booleans
Compare strings
Evaluates as boolean and evaluates children as boolean, numeric, or string.
Order in which comparisons are attempted is numeric, boolean, then string.
Updates conditioned properties table.
Reset temporary state
Updates the conditioned properties table if it hasn't already been done.
Compares for inequality
Compare numbers
Compare booleans
Compare strings
Performs logical NOT on left child
Does not update conditioned properties table
Evaluate as boolean
Returns unexpanded value with '!' prepended. Useful for error messages.
Returns expanded value with '!' prepended. Useful for error messages.
Evaluates a numeric comparison, such as less-than, or greater-or-equal-than
Does not update conditioned properties table.
Compare numbers
Compare Versions. This is only intended to compare version formats like "A.B.C.D" which can otherwise not be compared numerically
Compare mixed numbers and Versions
Compare mixed numbers and Versions
Evaluate as boolean
Represents a number - evaluates as numeric.
Evaluate as boolean
Evaluate as numeric
Evaluate as a Version
Whether it can be evaluated as a boolean: never allowed for numerics
Whether it can be evaluated as numeric
Whether it can be evaluated as a Version
Get the unexpanded value
Get the expanded value
If any expression nodes cache any state for the duration of evaluation,
now's the time to clean it up
Base class for all nodes that are operands (are leaves in the parse tree)
Base class for nodes that are operators (have children in the parse tree)
Numeric evaluation is never allowed for operators
Version evaluation is never allowed for operators
Whether boolean evaluation is allowed: always allowed for operators
Whether the node can be evaluated as a numeric: by default,
this is not allowed
Whether the node can be evaluated as a version: by default,
this is not allowed
Value after any item and property expressions are expanded
Value before any item and property expressions are expanded
If any expression nodes cache any state for the duration of evaluation,
now's the time to clean it up
Storage for the left child
Storage for the right child
Performs logical OR on children
Does not update conditioned properties table
Evaluate as boolean
This class implements the grammar for complex conditionals.
The usage is:
Parser p = new Parser(CultureInfo);
ExpressionTree t = p.Parse(expression, XmlNode);
The expression tree can then be evaluated and re-evaluated as needed.
UNDONE: When we copied over the conditionals code, we didn't copy over the unit tests for scanner, parser, and expression tree.
Location contextual information which are attached to logging events to
say where they are in relation to the process, engine, project, target,task which is executing
Engine Logging Service reference where events will be logged to
Class: Scanner
This class does the scanning of the input and returns tokens.
The usage pattern is:
Scanner s = new Scanner(expression, CultureInfo)
do {
s.Advance();
while (s.IsNext(Token.EndOfInput));
After Advance() is called, you can get the current token (s.CurrentToken),
check it's type (s.IsNext()), get the string for it (s.NextString()).
Lazily format resource string to help avoid (in some perf critical cases) even loading
resources at all.
If the lexer errors, it has the best knowledge of the error message to show. For example,
'unexpected character' or 'illformed operator'. This method returns the name of the resource
string that the parser should display.
Intentionally not a property getter to avoid the debugger triggering the Assert dialog
Advance
returns true on successful advance
and false on an erroneous token
Doesn't return error until the bogus input is encountered.
Advance() returns true even after EndOfInput is encountered.
Parses either the $(propertyname) syntax or the %(metadataname) syntax,
and returns the parsed string beginning with the '$' or '%', and ending with the
closing parenthesis.
Scan for the end of the property expression
property expression to parse
current index to start from
If successful, the index corresponds to the end of the property expression.
In case of scan failure, it is the error position index.
result indicating whether or not the scan was successful.
Parses a string of the form $(propertyname).
Parses a string of the form %(itemmetadataname).
Helper to verify that any AllowBuiltInMetadata or AllowCustomMetadata
specifications are not respected.
Returns true if it is ok, otherwise false.
Parse any part of the conditional expression that is quoted. It may contain a property, item, or
metadata element that needs expansion during evaluation.
Node representing a string
Whether the string potentially has expandable content,
such as a property expression or escaped character.
Evaluate as boolean
Evaluate as numeric
Returns true if this node evaluates to an empty string,
otherwise false.
It may be cheaper to determine whether an expression will evaluate
to empty than to fully evaluate it.
Implementations should cache the result so that calls after the first are free.
Value before any item and property expressions are expanded
Value after any item and property expressions are expanded
If any expression nodes cache any state for the duration of evaluation,
now's the time to clean it up
Should this node be treated as an expansion of VisualStudioVersion, rather than
its literal meaning?
Needed to provide a compat shim for numeric/version comparisons
on MSBuildToolsVersion, which were fine when it was a number
but now cause the project to throw InvalidProjectException when
ToolsVersion is "Current". https://github.com/Microsoft/msbuild/issues/4150
This class represents a token in the Complex Conditionals grammar. It's
really just a bag that contains the type of the token and the string that
was parsed into the token. This isn't very useful for operators, but
is useful for strings and such.
Valid tokens
Constructor for types that don't have values
Constructor takes the token type and the string that
represents the token
Constructor takes the token type and the string that
represents the token.
If the string may contain content that needs expansion, expandable is set.
Whether the content potentially has expandable content,
such as a property expression or escaped character.
Implementation of a metadata table for use by the evaluator.
Accumulates ProjectMetadataElement objects and their evaluated value,
overwriting any previous metadata with that name.
The actual metadata dictionary.
The type of item the metadata should be considered to apply to.
Creates a new table using the specified item type.
Enumerator over the entries in this table
Retrieves any value we have in our metadata table for the metadata name specified,
whatever the item type.
If no value is available, returns empty string.
Retrieves any value we have in our metadata table for the metadata name and item type specified.
If no value is available, returns empty string.
Retrieves any value we have in our metadata table for the metadata name and item type specified.
If no value is available, returns null.
Adds a metadata entry to the table
An entry in the evaluator's metadata table.
Construct a new EvaluatorMetadata
Gets or sets the metadata Xml
Gets or sets the evaluated value, unescaped
Gets or sets the evaluated value, escaped as necessary
An interface for objects which the Evaluator can use as a destination for evaluation of ProjectRootElement.
The type of properties to be produced.
The type of items to be produced.
The type of metadata on those items.
The type of item definitions to be produced.
The ID of this evaluation
The (project) directory that should be used during evaluation
Task classes and locations known to this project.
This is the project-specific task registry, which is consulted before
the toolset's task registry.
The toolset data used during evaluation, and which should be used for build.
The sub-toolset version that should be used with this toolset to determine
the full set of properties to be used by the build.
The externally specified tools version to evaluate with, if any.
For example, the tools version from a /tv switch.
This is not the tools version specified on the Project tag, if any.
May be null.
Gets the global properties
List of names of the properties that, while global, are still treated as overridable
Sets the initial targets
Sets the default targets
Sets or retrieves the list of targets which run before the keyed target.
Sets or retrieves the list of targets which run after the keyed target.
List of possible values for properties inferred from certain conditions,
keyed by the property name.
Whether evaluation should collect items ignoring condition,
as well as items respecting condition; and collect
conditioned properties, as well as regular properties
Tells the evaluator whether it should evaluate elements with false conditions
Enumerator over properties in this project.
Exposed for debugging display.
Enumerator over all item definitions.
Exposed for debugging display.
Ideally the dictionary would be exposed, but there are
covariance problems. (A dictionary of Key, Value cannot be upcast
to a Dictionary of Key, IValue).
Enumerator over all items.
Exposed for debugging display.
Ideally the dictionary would be exposed, but there are
covariance problems. (A dictionary of Key, Value cannot be upcast
to a Dictionary of Key, IValue).
Evaluation ordered list of project item elements that were evaluated by the Evaluator
It means that both the item element's condition and the item group element's conditions evaluated to true
A dictionary of all of the environment variable properties.
Prepares the data block for a new evaluation pass
Indicates to the data block that evaluation has completed,
so for example it can mark datastructures read-only.
Adds a new item
Adds a new item to the collection of all items ignoring condition
Adds a new item definition
Properties encountered during evaluation. These are read during the first evaluation pass.
Unlike those returned by the Properties property, these are ordered, and include any properties that
were subsequently overridden by others with the same name. It does not include any
properties whose conditions did not evaluate to true.
Item definition metadata encountered during evaluation. These are read during the second evaluation pass.
Unlike those returned by the ItemDefinitions property, these are ordered, and include any metadata that
were subsequently overridden by others with the same name and item type. It does not include any
elements whose conditions did not evaluate to true.
Items encountered during evaluation. These are read during the third evaluation pass.
Unlike those returned by the Items property, these are ordered.
It does not include any elements whose conditions did not evaluate to true.
It does not include any items added since the last evaluation.
Retrieves an existing item definition, if any.
Sets a property which does not come from the Xml.
Sets a property which comes from the Xml.
Retrieves an existing target, if any.
Adds a new target, overwriting any existing target with the same name.
Record an import opened during evaluation, if appropriate.
Record an import opened during evaluation, if appropriate.
Evaluates the provided string by expanding items and properties,
using the current items and properties available.
This is useful for the immediate window.
Does not expand bare metadata expressions.
Not for internal use.
Evaluates the provided string as a condition by expanding items and properties,
using the current items and properties available, then doing a logical evaluation.
This is useful for the immediate window.
Does not expand bare metadata expressions.
Not for internal use.
This interface represents an item without exposing its type.
Gets the evaluated include value for this item, unescaped.
Gets the evaluated include value for this item, escaped as necessary.
The directory of the project being built
If there is no project filename defined, returns null.
Returns the metadata with the specified key.
Returns null if it does not exist.
Attempting to get built-in metadata on a value that is not a valid path throws InvalidOperationException.
Metadata value is unescaped.
Returns the metadata with the specified key.
Returns null if it does not exist.
Attempting to get built-in metadata on a value that is not a valid path throws InvalidOperationException.
Metadata value is the escaped value initially set.
Interface representing item definition objects for use by the Evaulator.
Type of metadata objects.
Gets any metadatum on this item definition with the specified name.
Adds the specified metadata to the item definition.
This interface is used to describe a class which can act as a factory for creating
items when the Expander expands certain expressions.
The type of items this factory can clone from.
The type of items this factory will create.
The item type of the items that this factory will create.
May be null, if the items will not have an itemtype (ie., for ITaskItems)
May not be settable (eg., for ITaskItems and for ProjectItems)
Used in the evaluator
Creates an item with the specified evaluated include and defining project.
Include must not be zero length.
The include
The project from which this item was created
A new item instance
Creates an item based off the provided item, with cloning semantics.
New item is associated with the passed in defining project, not that of the original item.
Creates an item with the specified include and the metadata from the specified base item
New item is associated with the passed in defining project, not that of the original item.
Creates an item using the specified evaluated include, include before wildcard expansion,
and defining project.
Applies the supplied metadata to the destination items.
This interface represents an item without exposing its type.
It's convenient to not genericise the base interface, to make it easier to use
for the majority of code that doesn't call these methods.
Type of metadata object.
Gets any existing metadatum on the item, or
else any on an applicable item definition.
Sets the specified metadata.
Predecessor is any preceding overridden metadata
This interface represents an object which can act as a source of items for the Expander.
The type of items provided by the implementation.
Returns a list of items with the specified item type.
If there are no items of this type, returns an empty list.
The item type of items to return.
A list of matching items.
Table of metadata useable to expand expressions
Retrieves any value we have in our metadata table for the metadata name specified.
If no value is available, returns empty string.
Retrieves any value we have in our metadata table for the metadata name and item type specified.
If item type is null, it is ignored.
If no value is available, returns empty string.
Returns the value if it exists, null otherwise.
If item type is null, it is ignored.
The Intrinsic class provides static methods that can be accessed from MSBuild's
property functions using $([MSBuild]::Function(x,y))
Add two doubles
Add two longs
Subtract two doubles
Subtract two longs
Multiply two doubles
Multiply two longs
Divide two doubles
Divide two longs
Modulo two doubles
Modulo two longs
Escape the string according to MSBuild's escaping rules
Unescape the string according to MSBuild's escaping rules
Perform a bitwise OR on the first and second (first | second)
Perform a bitwise AND on the first and second (first & second)
Perform a bitwise XOR on the first and second (first ^ second)
Perform a bitwise NOT on the first and second (~first)
Get the value of the registry key and value, default value is null
Get the value of the registry key and value
Get the value of the registry key from one of the RegistryView's specified
Given the absolute location of a file, and a disc location, returns relative file path to that disk location.
Throws UriFormatException.
The base path we want to relativize to. Must be absolute.
Should not include a filename as the last segment will be interpreted as a directory.
The path we need to make relative to basePath. The path can be either absolute path or a relative path in which case it is relative to the base path.
If the path cannot be made relative to the base path (for example, it is on another drive), it is returned verbatim.
relative path (can be the full path)
Searches upward for a directory containing the specified file, beginning in the specified directory.
The directory to start the search in.
The name of the file to search for.
The file system abstraction to use that implements file system operations
The full path of the directory containing the file if it is found, otherwise an empty string.
Searches upward for the specified file, beginning in the specified .
The name of the file to search for.
An optional directory to start the search in. The default location is the directory
The file system abstraction to use that implements file system operations
of the file containing the property function.
The full path of the file if it is found, otherwise an empty string.
Return the string in parameter 'defaultValue' only if parameter 'conditionValue' is empty
else, return the value conditionValue
Hash the string independent of bitness and target framework.
Returns true if a task host exists that can service the requested runtime and architecture
values, and false otherwise.
If the given path doesn't have a trailing slash then add one.
If the path is an empty string, does not modify it.
The path to check.
The specified path with a trailing slash.
Gets the canonicalized full path of the provided directory and ensures it contains the correct directory separator characters for the current operating system
while ensuring it has a trailing slash.
One or more directory paths to combine and normalize.
A canonicalized full directory path with the correct directory separators and a trailing slash.
Gets the canonicalized full path of the provided path and ensures it contains the correct directory separator characters for the current operating system.
One or more paths to combine and normalize.
A canonicalized full path with the correct directory separators.
Specify whether the current OS platform is
The platform string. Must be a member of . Case Insensitive
True if current OS is a Unix system.
True if current OS is a BSD system.
returns if the string contains escaped wildcards
Following function will parse a keyName and returns the basekey for it.
It will also store the subkey name in the out parameter.
If the keyName is not valid, we will throw ArgumentException.
The return value shouldn't be null.
Taken from: \ndp\clr\src\BCL\Microsoft\Win32\Registry.cs
This interface represents a metadata object.
Represents the parent of a ProjectMetadata object -
either a ProjectItem or a ProjectItemDefinition.
The owning project
The item type of the parent item definition or item.
An interface representing an object which can act as a property.
Name of the property
Returns the evaluated, unescaped value for the property.
Returns the evaluated, escaped value for the property
An interface representing an object which can provide properties to the Expander.
The type of properties provided.
Returns a property with the specified name, or null if it was not found.
The property name.
The property.
Returns a property with the specified name, or null if it was not found.
Name is the segment of the provided string with the provided start and end indexes.
Creates a view of an evaluated project's XML as if it had all been loaded from
a single file, instead of being assembled by pulling in imported files as it actually was.
Ideally the result would be buildable on its own, and *usually* this should be the case.
Known cases where it wouldn't be buildable:
-- $(MSBuildThisFile) and similar properties aren't corrected
-- relative path in exists(..) conditions is relative to the imported file
-- same for AssemblyFile on UsingTask
Paths in item includes are relative to the importing project, though.
Project to preprocess
Table to resolve import tags
Stack of file paths pushed as we follow imports
Used to keep track of nodes that were added to the document from implicit imports which will be removed later.
At the time of adding this feature, cloning is buggy so it is easier to just edit the DOM in memory.
Table of implicit imports by document. The list per document contains both top and bottom imports.
Constructor
Returns an XmlDocument representing the evaluated project's XML as if it all had
been loaded from a single file, instead of being assembled by pulling in imported files.
Root of the preprocessing.
Creates a table containing implicit imports by project document.
Adds all implicit import nodes to the specified document.
The document element to add nodes to.
Recursively called method that clones source nodes into nodes in the destination
document.
Handler for which project root element just got added to the cache
Delegate for StrongCacheEntryRemoved event
Callback to create a ProjectRootElement if need be
Event that is fired when an entry in the Strong Cache is removed.
Event which is fired when a project root element is added to this cache.
Event which is fired when a project root element in this cache is dirtied.
Event which is fired when a project is marked dirty.
Raises the event.
The dirtied project root element.
Details on the PRE and the nature of the change.
Raises the event.
The dirtied project.
Details on the Project and the change.
Raises an event which is raised when a project root element is added to the cache.
Raises an event which is raised when a project root element is removed from the strong cache.
This class is an event that holds which ProjectRootElement was added to the root element cache.
Takes the root element which was added to the results cache.
Root element which was just added to the cache.
Maintains a cache of all loaded ProjectRootElement's for design time purposes.
Weak references are held to add added ProjectRootElement's.
Strong references are held to a limited number of added ProjectRootElement's.
1. Loads of a ProjectRootElement will share any existing loaded ProjectRootElement, rather
than loading and parsing a new one. This is the case whether the ProjectRootElement
is loaded directly or imported.
2. For design time, only a weak reference needs to be held, because all users have a strong reference.
3. Because all loads of a ProjectRootElement consult this cache, they can be assured that any
entries in this cache are up to date. For example, if a ProjectRootElement is modified and saved,
the cached ProjectRootElement will be the loaded one that was saved, so it will be up to date.
4. If, after a project has been loaded, an external app changes the project file content on disk, it is
important that a subsequent load of that project does not return stale ProjectRootElement. To avoid this, the
timestamp of the file on disk is compared to the timestamp of the file at the time that the ProjectRootElement loaded it.
5. For build time, some strong references need to be held, as otherwise the ProjectRootElement's for reuseable
imports will be collected, and time will be wasted reparsing them. However we do not want to hold strong references
to all ProjectRootElement's, consuming memory without end. So a simple priority queue is used. All Adds and Gets boost their
entry to the top. As the queue gets too big, low priority entries are dropped.
No guesses are made at which files are more interesting to cache, beyond the most-recently-used list. For example, ".targets" files
or imported files are not treated specially, as this is a potentially unreliable heuristic. Besides, caching a project file itself could
be useful, if for example you want to build it twice with different sets of properties.
Because of the strongly typed list, some ProjectRootElement's will be held onto indefinitely. This is an acceptable price to pay for
being able to provide a commonly used ProjectRootElement immediately it's needed. It is mitigated by the list being finite and small, and
because we allow ProjectCollection.UnloadAllProjects to hint to us to clear the list.
Implicit references are those which were loaded as a result of a build, and not explicitly loaded through, for instance, the project
collection.
The maximum number of entries to keep strong references to.
This has to be strong enough to make sure that key .targets files aren't pushed
off by transient loads of non-reusable files like .user files.
Made this as large as 50 because VC has a large number of
regularly used property sheets and other imports.
If you change this, update the unit tests.
If this number is increased much higher, the datastructure may
need to be changed from a linked list, since it's currently O(n).
Whether the cache should log activity to the Debug.Out stream
The map of weakly-held ProjectRootElement's
Be sure that the string keys are strongly held, or unpredictable bad
behavior will ensue.
The list of strongly-held ProjectRootElement's
Whether the cache should check the timestamp of the file on disk
whenever it is requested, and update with the latest content of that
file if it has changed.
Locking object for this shared cache
Static constructor to choose cache size.
Creates an empty cache.
Returns an existing ProjectRootElement for the specified file path, if any.
If none exists, calls the provided delegate to load one, and adds that to the cache.
The reason that it calls back to do this is so that the cache is locked between determining
that the entry does not exist and adding the entry.
If was set to true, and the file on disk has changed since it was cached,
it will be reloaded before being returned.
Thread safe.
Never needs to consult the strong cache as well, since if the item is in there, it will
not have left the weak cache.
If item is found, boosts it to the top of the strong cache.
The project file which contains the ProjectRootElement. Must be a full path.
The delegate to use to load if necessary. May be null.
true if the project is explicitly loaded, otherwise false.
true to the project was loaded with the formated preserved, otherwise false.
The ProjectRootElement instance if one exists. Null otherwise.
Add an entry to the cache.
Rename an entry in the cache.
Entry must already be in the cache.
Returns any a ProjectRootElement in the cache with the provided full path,
otherwise null.
Returns any a ProjectRootElement in the cache with the provided full path,
otherwise null.
Discards strong references held by the cache.
The weak cache is never cleared, as we need it to guarantee that the appdomain never
has two ProjectRootElement's for a particular file. Attempts to clear out the weak cache
resulted in this guarantee being broken and subtle bugs popping up everywhere.
Clears out the cache.
Called when all projects are unloaded and possibly when a build is done.
Discard any entries (weak and strong) which do not have the explicitlyLoaded flag set.
Forces a removal of a project root element from the weak cache if it is present.
The project root element to remove.
No exception is thrown if this project root element is in use by currently loaded projects
by this method. The calling method must know that this is a safe operation.
There may of course be strong references to the project root element from customer code.
The assumption is that when they instruct the project collection to unload it, which
leads to this being called, they are releasing their strong references too (or it doesn't matter)
Add or rename an entry in the cache.
Old full path may be null iff it was not already in the cache.
Must be called within the cache lock.
Update the strong cache.
If the item is already a member of the list, move it to the top.
Otherwise, just add it to the top.
If the list is too large, remove an entry from the bottom.
Must be called within the cache lock.
If the size of strong cache gets large, this needs a faster data structure
than a linked list. It's currently O(n).
Completely remove an entry from this cache
Must be called within the cache lock.
Write debugging messages to the Debug.Out stream.
Write debugging messages to the Debug.Out stream.
Write debugging messages to the Debug.Out stream.
Maintains a cache of all loaded ProjectRootElement instances for design time purposes.
This avoids the LRU cache and class-wide lock used within ProjectRootElementCache and replaces these mechanisms
with a single ConcurrentDictionary as a tradeoff for increased performance when evaluating projects in parallel.
As a tradeoff, this implementation uses more memory, and is not intended for use when the cache needs to be
long-lived e.g. within Visual Studio.
SimpleProjectRootElementCache is not currently intended for use outside of evaluation. Several code paths
executed within a full build take a hard dependency on the strong/weak reference behavior used within
ProjectRootElementCache, and further investigation is required to determine the best way to hide these behind
an abstraction. As such, any method unused by evaluation will throw NotImplementedException.
Splits an expression into fragments at semicolons, except where the
semicolons are in a macro or separator expression.
Fragments are trimmed and empty fragments discarded.
These complex cases prevent us from doing a simple split on ';':
(1) Macro expression: @(foo->'xxx;xxx')
(2) Separator expression: @(foo, 'xxx;xxx')
(3) Combination: @(foo->'xxx;xxx', 'xxx;xxx')
We must not split on semicolons in macro or separator expressions like these.
Returns a whitespace-trimmed and possibly interned substring of the expression.
Start index of the substring.
Length of the substring.
Equivalent to _expression.Substring(startIndex, length).Trim() or null if the trimmed substring is empty.
Wraps a table of metadata values in which keys
may be qualified ("itemtype.name") or unqualified ("name").
Table of metadata values.
Each key may be qualified ("itemtype.name") or unqualified ("name").
Unqualified are considered to apply to all item types.
May be null, if empty.
Constructor taking a table of metadata in which keys
may be a mixture of qualified ("itemtype.name") and unqualified ("name").
Unqualified keys are considered to apply to all item types.
Metadata may be null, indicating it is empty.
Retrieves any value we have in our metadata table for the metadata name specified.
If no value is available, returns empty string.
Retrieves any value we have in our metadata table for the metadata name and item type specified.
If no value is available, returns empty string.
Retrieves any value we have in our metadata table for the metadata name and item type specified.
If no value is available, returns null.
What the shredder should be looking for.
Don't use
Shred item types
Shred metadata not contained inside of a transform.
Shred both items and metadata not contained in a transform.
A class which interprets and splits MSBuild expressions
Splits an expression into fragments at semi-colons, except where the
semi-colons are in a macro or separator expression.
Fragments are trimmed and empty fragments discarded.
See for rules.
List expression to split
Array of non-empty strings from split list.
Given a list of expressions that may contain item list expressions,
returns a pair of tables of all item names found, as K=Name, V=String.Empty;
and all metadata not in transforms, as K=Metadata key, V=MetadataReference,
where metadata key is like "itemname.metadataname" or "metadataname".
PERF: Tables are null if there are no entries, because this is quite a common case.
Returns true if there is a metadata expression (outside of a transform) in the expression.
Given a subexpression, finds referenced sub transform expressions
itemName and separator will be null if they are not found
return value will be null if no transform expressions are found
Given a subexpression, finds referenced sub transform expressions
itemName and separator will be null if they are not found
return value will be null if no transform expressions are found
Given a subexpression, finds referenced item names and inserts them into the table
as K=Name, V=String.Empty.
We can ignore any semicolons in the expression, since we're not itemizing it.
Returns true if a single quoted subexpression begins at the specified index
and ends before the specified end index.
Leaves index one past the end of the second quote.
Scan for the closing bracket that matches the one we've already skipped;
essentially, pushes and pops on a stack of parentheses to do this.
Takes the expression and the index to start at.
Returns the index of the matching parenthesis, or -1 if it was not found.
Skip all characters until we find the matching quote character
Returns true if a item function subexpression begins at the specified index
and ends before the specified end index.
Leaves index one past the end of the closing paren.
Returns true if a valid name begins at the specified index.
Leaves index one past the end of the name.
Returns true if the character at the specified index
is the specified char.
Leaves index one past the character.
Returns true if the next two characters at the specified index
are the specified sequence.
Leaves index one past the second character.
Moves past all whitespace starting at the specified index.
Returns the next index, possibly the string length.
Char.IsWhitespace() is not identical in behavior to regex's \s character class,
but it's extremely close, and it's what we use in conditional expressions.
The expression to process.
The start location for skipping whitespace, contains the next non-whitespace character on exit.
Represents one substring for a single successful capture.
Captures within this capture
The position in the original string where the first character of the captured
substring was found.
The length of the captured substring.
The captured substring from the input string.
The type of the item within this expression
The separator, if any, within this expression
The starting character of the separator within the expression
The function name, if any, within this expression
The function arguments, if any, within this expression
Create an Expression Capture instance
Represents a sub expression, shredded from a larger expression
Create an Expression Capture instance
Represents a sub expression, shredded from a larger expression
Captures within this capture
The position in the original string where the first character of the captured
substring was found.
The length of the captured substring.
Gets the captured substring from the input string.
Gets the captured itemtype.
Gets the captured itemtype.
The starting character of the separator.
The function name, if any, within this expression
The function arguments, if any, within this expression
Gets the captured substring from the input string.
Evaluates a ProjectRootElement, updating the fresh Project.Data passed in.
Handles evaluating conditions, expanding expressions, and building up the
lists of applicable properties, items, and itemdefinitions, as well as gathering targets and tasks
and creating a TaskRegistry from the using tasks.
The type of properties to produce.
The type of items to produce.
The type of metadata on those items.
The type of item definitions to be produced.
This class could be improved to do partial (minimal) reevaluation: at present we wipe all state and start over.
Character used to split InitialTargets and DefaultTargets lists
Expander for evaluating conditions
Data containing the ProjectRootElement to evaluate and the slots for
items, properties, etc originating from the evaluation.
List of ProjectItemElement's traversing into imports.
Gathered during the first pass to avoid traversing again.
List of ProjectItemDefinitionElement's traversing into imports.
Gathered during the first pass to avoid traversing again.
List of ProjectUsingTaskElement's traversing into imports.
Gathered during the first pass to avoid traversing again.
Key is the directory of the file importing the usingTask, which is needed
to handle any relative paths in the usingTask.
List of ProjectTargetElement's traversing into imports.
Gathered during the first pass to avoid traversing again.
Paths to imports already seen and where they were imported from; used to flag duplicate imports
Depth first collection of InitialTargets strings declared in the main
Project and all its imported files, split on semicolons.
Dictionary of project full paths and a boolean that indicates whether at least one
of their targets has the "Returns" attribute set.
The Project Xml to be evaluated.
The item factory used to create items from Xml.
Load settings, such as whether to ignore missing imports.
The maximum number of nodes to report for evaluation.
The to use.
The current build submission ID.
The environment properties with which evaluation should take place.
The cache to consult for any imports that need loading.
The logging context to be used and piped down throughout evaluation
The search paths are machine specific and should not change during builds
Keeps track of the project that is last modified of the project and all imports.
Keeps track of the FullPaths of ProjectRootElements that may have been modified as a stream.
Private constructor called by the static Evaluate method.
Delegate passed to methods to provide basic expression evaluation
ability, without having a language service.
Delegate passed to methods to provide basic expression evaluation
ability, without having a language service.
Evaluates the project data passed in.
This is the only non-private member of this class.
This is a helper static method so that the caller can just do "Evaluator.Evaluate(..)" without
newing one up, yet the whole class need not be static.
Helper that creates a list of ProjectItem's given an unevaluated Include and a ProjectRootElement.
Used by both Evaluator.EvaluateItemElement and by Project.AddItem.
Read the task into an instance.
Do not evaluate anything: this occurs during build.
Read the property-group-under-target into an instance.
Do not evaluate anything: this occurs during build.
Read an onError tag.
Do not evaluate anything: this occurs during build.
Read the item-group-under-target into an instance.
Do not evaluate anything: this occurs during build.
Read the provided target into a target instance.
Do not evaluate anything: this occurs during build.
Do the evaluation.
Called by the static helper method.
Evaluate the properties in the passed in XML, into the project.
Does a depth first traversal into Imports.
In the process, populates the item, itemdefinition, target, and usingtask lists as well.
Update the default targets value.
We only take the first DefaultTargets value we encounter in a project or import.
Evaluate the properties in the propertygroup and set the applicable ones on the data passed in
Evaluate the itemdefinitiongroup and update the definitions library
Evaluate the items in the itemgroup and add the applicable ones to the data passed in
Evaluate the usingtask and add the result into the data passed in
Retrieve the matching ProjectTargetInstance from the cache and add it to the provided collection.
If it is not cached already, read it and cache it.
Do not evaluate anything: this occurs during build.
Updates the evaluation maps for BeforeTargets and AfterTargets
Set the built-in properties, most of which are read-only
Pull in all the environment into our property bag
Put all the toolset's properties into our property bag
Put all the global properties into our property bag
Set a built-in property in the supplied bag.
NOT to be used for properties originating in XML.
NOT to be used for global properties.
NOT to be used for environment properties.
Evaluate a single ProjectPropertyElement and update the data as appropriate
Evaluates an itemdefinition element, updating the definitions library.
Evaluates an import element.
If the condition is true, loads the import and continues the pass.
UNDONE: Protect against overflowing the stack by having too many nested imports.
Evaluates an ImportGroup element.
If the condition is true, evaluates the contained imports and continues the pass.
UNDONE: Protect against overflowing the stack by having too many nested imports.
Choose does not accept a condition.
We enter here in both the property and item passes, since Chooses can contain both.
However, we only evaluate the When conditions on the first pass, so we only pulse
those states on that pass. On the other pass, it's as if they're not there.
Evaluates the children of a When or Choose.
Returns true if the condition was true, so subsequent
WhenElements and Otherwise can be skipped.
Expands and loads project imports.
Imports may contain references to "projectImportSearchPaths" defined in the app.config
toolset section. If this is the case, this method will search for the imported project
in those additional paths if the default fails.
Load and parse the specified project import, which may have wildcards,
into one or more ProjectRootElements, if it's Condition evaluates to true
Caches the parsed import into the provided collection, so future
requests can be satisfied without re-parsing it.
Load and parse the specified project import, which may have wildcards,
into one or more ProjectRootElements.
Caches the parsed import into the provided collection, so future
requests can be satisfied without re-parsing it.
Checks if an import matches with another import in its ancestor line of imports.
The import that is being added.
The importing element for this import.
True, if and only if this import introduces a circularity.
Evaluate a given condition
Evaluate a given condition, collecting conditioned properties.
COMPAT: Whidbey used the "current project file/targets" directory for evaluating Import and PropertyGroup conditions
Orcas broke this by using the current root project file for all conditions
For Dev10+, we'll fix this, and use the current project file/targets directory for Import, ImportGroup and PropertyGroup
but the root project file for the rest. Inside of targets will use the root project file as always.
Throws InvalidProjectException because we failed to import a project which contained a ProjectImportSearchPath fall-back.
MSBuildExtensionsPath reference kind found in the Project attribute of the Import element
The importing element for this import
Stringify a list of strings, like {"abc, "def", "foo"} to "abc, def and foo"
or {"abc"} to "abc"
List of strings to stringify
Stringified list
Represents result of attempting to load imports (ExpandAndLoadImportsFromUnescapedImportExpression*)
Indicates to the expander what exactly it should expand.
Invalid
Expand bare custom metadata, like %(foo), but not built-in
metadata, such as %(filename) or %(identity)
Expand bare built-in metadata, such as %(filename) or %(identity)
Expand all bare metadata
Expand only properties
Expand only item list expressions
If the expression is going to not be an empty string, break
out early
When an error occurs expanding a property, just leave it unexpanded.
This should only be used in cases where property evaluation isn't critcal, such as when attempting to log a
message with a best effort expansion of a string, or when discovering partial information during lazy evaluation.
When an expansion occurs, truncate it to Expander.DefaultTruncationCharacterLimit or Expander.DefaultTruncationItemLimit.
Expand only properties and then item lists
Expand only bare metadata and then properties
Expand only bare custom metadata and then properties
Expand bare metadata, then properties, then item expressions
Expands item/property/metadata in expressions.
Encapsulates the data necessary for expansion.
Requires the caller to explicitly state what they wish to expand at the point of expansion (explicitly does not have a field for ExpanderOptions).
Callers typically use a single expander in many locations, and this forces the caller to make explicit what they wish to expand at the point of expansion.
Requires the caller to have previously provided the necessary material for the expansion requested.
For example, if the caller requests ExpanderOptions.ExpandItems, the Expander will throw if it was not given items.
Type of the properties used.
Type of the items used.
A helper struct wrapping a and providing file path conversion
as used in e.g. property expansion.
If exactly one value is added and no concatenation takes places, this value is returned without
conversion. In other cases values are stringified and attempted to be interpreted as file paths
before concatenation.
The backing , null until the second value is added.
The first value added to the concatenator. Tracked in its own field so it can be returned
without conversion if no concatenation takes place.
The first value added to the concatenator if it is a span. Tracked in its own field so the
functionality doesn't have to be invoked if no concatenation
takes place.
True if this instance is already disposed.
Adds an object to be concatenated.
Adds a span to be concatenated.
Returns the result of the concatenation.
If only one value has been added and it is not a string, it is returned unchanged.
In all other cases (no value, one string value, multiple values) the result is a
concatenation of the string representation of the values, each additionally subjected
to file path adjustment.
Disposes of the struct by delegating the call to the underlying .
Throws if this concatenator is already disposed.
Lazily initializes and populates it with the first value
when the second value is being added.
A limit for truncating string expansions within an evaluated Condition. Properties, item metadata, or item groups will be truncated to N characters such as 'N...'.
Enabled by ExpanderOptions.Truncate.
A limit for truncating string expansions for item groups within an evaluated Condition. N items will be evaluated such as 'A;B;C;...'.
Enabled by ExpanderOptions.Truncate.
Those characters which indicate that an expression may contain expandable
expressions.
The CultureInfo from the invariant culture. Used to avoid allocations for
perfoming IndexOf etc.
Properties to draw on for expansion.
Items to draw on for expansion.
Metadata to draw on for expansion.
Set of properties which are null during expansion.
Creates an expander passing it some properties to use.
Properties may be null.
Creates an expander passing it some properties and items to use.
Either or both may be null.
Creates an expander passing it some properties, items, and/or metadata to use.
Any or all may be null.
Whether to warn when we set a property for the first time, after it was previously used.
Default is false, unless MSBUILDWARNONUNINITIALIZEDPROPERTY is set.
Accessor for the metadata.
Set temporarily during item metadata evaluation.
If a property is expanded but evaluates to null then it is considered to be un-initialized.
We want to keep track of these properties so that we can warn if the property gets set later on.
Tests to see if the expression may contain expandable expressions, i.e.
contains $, % or @.
Returns true if the expression contains an item vector pattern, else returns false.
Used to flag use of item expressions where they are illegal.
Expands embedded item metadata, properties, and embedded item lists (in that order) as specified in the provided options.
This is the standard form. Before using the expanded value, it must be unescaped, and this does that for you.
If ExpanderOptions.BreakOnNotEmpty was passed, expression was going to be non-empty, and it broke out early, returns null. Otherwise the result can be trusted.
Expands embedded item metadata, properties, and embedded item lists (in that order) as specified in the provided options.
Use this form when the result is going to be processed further, for example by matching against the file system,
so literals must be distinguished, and you promise to unescape after that.
If ExpanderOptions.BreakOnNotEmpty was passed, expression was going to be non-empty, and it broke out early, returns null. Otherwise the result can be trusted.
Used only for unit tests. Expands the property expression (including any metadata expressions) and returns
the result typed (i.e. not converted into a string if the result is a function return).
Expands embedded item metadata, properties, and embedded item lists (in that order) as specified in the provided options,
then splits on semi-colons into a list of strings.
Use this form when the result is going to be processed further, for example by matching against the file system,
so literals must be distinguished, and you promise to unescape after that.
Expands embedded item metadata, properties, and embedded item lists (in that order) as specified in the provided options
and produces a list of TaskItems.
If the expression is empty, returns an empty list.
If ExpanderOptions.BreakOnNotEmpty was passed, expression was going to be non-empty, and it broke out early, returns null. Otherwise the result can be trusted.
Expands embedded item metadata, properties, and embedded item lists (in that order) as specified in the provided options
and produces a list of items of the type for which it was specialized.
If the expression is empty, returns an empty list.
If ExpanderOptions.BreakOnNotEmpty was passed, expression was going to be non-empty, and it broke out early, returns null. Otherwise the result can be trusted.
Use this form when the result is going to be processed further, for example by matching against the file system,
so literals must be distinguished, and you promise to unescape after that.
Type of items to return.
This is a specialized method for the use of TargetUpToDateChecker and Evaluator.EvaluateItemXml only.
Extracts the items in the given SINGLE item vector.
For example, expands @(Compile->'%(foo)') to a set of items derived from the items in the "Compile" list.
If there is in fact more than one vector in the expression, throws InvalidProjectFileException.
If there are no item expressions in the expression (for example a literal "foo.cpp"), returns null.
If expression expands to no items, returns an empty list.
If item expansion is not allowed by the provided options, returns null.
If ExpanderOptions.BreakOnNotEmpty was passed, expression was going to be non-empty, and it broke out early, returns null. Otherwise the result can be trusted.
If the expression is a transform, any transformations to an expression that evaluates to nothing (i.e., because
an item has no value for a piece of metadata) are optionally indicated with a null entry in the list. This means
that the length of the returned list is always the same as the length of the referenced item list in the input string.
That's important for any correlation the caller wants to do.
If expression was a transform, 'isTransformExpression' is true, otherwise false.
Item type of the items returned is determined by the IItemFactory passed in; if the IItemFactory does not
have an item type set on it, it will be given the item type of the item vector to use.
Type of the items that should be returned.
Returns true if the supplied string contains a valid property name.
Returns true if ExpanderOptions.Truncate is set and EscapeHatches.DoNotTruncateConditions is not set.
Scan for the closing bracket that matches the one we've already skipped;
essentially, pushes and pops on a stack of parentheses to do this.
Takes the expression and the index to start at.
Returns the index of the matching parenthesis, or -1 if it was not found.
Also returns flags to indicate if a propertyfunction or registry property is likely
to be found in the expression.
Skip all characters until we find the matching quote character.
Add the argument in the StringBuilder to the arguments list, handling nulls
appropriately.
Extract the first level of arguments from the content.
Splits the content passed in at commas.
Returns an array of unexpanded arguments.
If there are no arguments, returns an empty array.
Expands bare metadata expressions, like %(Compile.WarningLevel), or unqualified, like %(Compile).
This is a private nested class, exposed only through the Expander class.
That allows it to hide its private methods even from Expander.
Expands all embedded item metadata in the given string, using the bucketed items.
Metadata may be qualified, like %(Compile.WarningLevel), or unqualified, like %(Compile).
The expression containing item metadata references.
The metadata to be expanded.
Used to specify what to expand.
The location information for error reporting purposes.
The string with item metadata expanded in-place, escaped.
A functor that returns the value of the metadata in the match
that is contained in the metadata dictionary it was created with.
Source of the metadata.
Whether to expand built-in metadata, custom metadata, or both kinds.
Constructor taking a source of metadata.
Expands a single item metadata, which may be qualified with an item type.
Expands property expressions, like $(Configuration) and $(Registry:HKEY_LOCAL_MACHINE\Software\Vendor\Tools@TaskLocation).
This is a private nested class, exposed only through the Expander class.
That allows it to hide its private methods even from Expander.
Type of the properties used to expand the expression.
This method takes a string which may contain any number of
"$(propertyname)" tags in it. It replaces all those tags with
the actual property values, and returns a new string. For example,
string processedString =
propertyBag.ExpandProperties("Value of NoLogo is $(NoLogo).");
This code might produce:
processedString = "Value of NoLogo is true."
If the sourceString contains an embedded property which doesn't
have a value, then we replace that tag with an empty string.
This method leaves the result escaped. Callers may need to unescape on their own as appropriate.
This method takes a string which may contain any number of
"$(propertyname)" tags in it. It replaces all those tags with
the actual property values, and returns a new string. For example,
string processedString =
propertyBag.ExpandProperties("Value of NoLogo is $(NoLogo).");
This code might produce:
processedString = "Value of NoLogo is true."
If the sourceString contains an embedded property which doesn't
have a value, then we replace that tag with an empty string.
This method leaves the result typed and escaped. Callers may need to convert to string, and unescape on their own as appropriate.
Expand the body of the property, including any functions that it may contain.
Convert the object into an MSBuild friendly string
Arrays are supported.
Will not return NULL.
Look up a simple property reference by the name of the property, e.g. "Foo" when expanding $(Foo).
Look up a simple property reference by the name of the property, e.g. "Foo" when expanding $(Foo).
If the property name provided is one of the special
per file properties named "MSBuildThisFileXXXX" then returns the value of that property.
If the location provided does not have a path (eg., if it comes from a file that has
never been saved) then returns empty string.
If the property name is not one of those properties, returns empty string.
Given a string like "Registry:HKEY_LOCAL_MACHINE\Software\Vendor\Tools@TaskLocation", return the value at that location
in the registry. If the value isn't found, returns String.Empty.
Properties may refer to a registry location by using the syntax for example
"$(Registry:HKEY_LOCAL_MACHINE\Software\Vendor\Tools@TaskLocation)", where "HKEY_LOCAL_MACHINE\Software\Vendor\Tools" is the key and
"TaskLocation" is the name of the value. The name of the value and the preceding "@" may be omitted if
the default value is desired.
Expands item expressions, like @(Compile), possibly with transforms and/or separators.
Item vectors are composed of a name, an optional transform, and an optional separator i.e.
@(<name>->'<transform>','<separator>')
If a separator is not specified it defaults to a semi-colon. The transform expression is also optional, but if
specified, it allows each item in the vector to have its item-spec converted to a different form. The transform
expression can reference any custom metadata defined on the item, as well as the pre-defined item-spec modifiers.
NOTE:
1) white space between <name>, <transform> and <separator> is ignored
i.e. @(<name>, '<separator>') is valid
2) the separator is not restricted to be a single character, it can be a string
3) the separator can be an empty string i.e. @(<name>,'')
4) specifying an empty transform is NOT the same as specifying no transform -- the former will reduce all item-specs
to empty strings
if @(files) is a vector for the files a.txt and b.txt, then:
"my list: @(files)" expands to string "my list: a.txt;b.txt"
"my list: @(files,' ')" expands to string "my list: a.txt b.txt"
"my list: @(files, '')" expands to string "my list: a.txtb.txt"
"my list: @(files, '; ')" expands to string "my list: a.txt; b.txt"
"my list: @(files->'%(Filename)')" expands to string "my list: a;b"
"my list: @(files -> 'temp\%(Filename).xml', ' ') expands to string "my list: temp\a.xml temp\b.xml"
"my list: @(files->'') expands to string "my list: ;".
This is a private nested class, exposed only through the Expander class.
That allows it to hide its private methods even from Expander.
Execute the list of transform functions.
class, IItem.
Expands any item vector in the expression into items.
For example, expands @(Compile->'%(foo)') to a set of items derived from the items in the "Compile" list.
If there is no item vector in the expression (for example a literal "foo.cpp"), returns null.
If the item vector expression expands to no items, returns an empty list.
If item expansion is not allowed by the provided options, returns null.
If there is an item vector but concatenated with something else, throws InvalidProjectFileException.
If ExpanderOptions.BreakOnNotEmpty was passed, expression was going to be non-empty, and it broke out early, returns null. Otherwise the result can be trusted.
If the expression is a transform, any transformations to an expression that evaluates to nothing (i.e., because
an item has no value for a piece of metadata) are optionally indicated with a null entry in the list. This means
that the length of the returned list is always the same as the length of the referenced item list in the input string.
That's important for any correlation the caller wants to do.
If expression was a transform, 'isTransformExpression' is true, otherwise false.
Item type of the items returned is determined by the IItemFactory passed in; if the IItemFactory does not
have an item type set on it, it will be given the item type of the item vector to use.
Type of the items provided by the item source used for expansion.
Type of the items that should be returned.
Expands an expression capture into a list of items
If the capture uses a separator, then all the items are concatenated into one string using that separator.
Returns true if ExpanderOptions.BreakOnNotEmpty was passed, expression was going to be non-empty, and so it broke out early.
List of items.
Item1 represents the item string, escaped
Item2 represents the original item.
Item1 differs from Item2's string when it is coming from a transform.
The expander whose state will be used to expand any transforms.
The representing the structure of an item expression.
to provide the inital items (which may get subsequently transformed, if is a transform expression)>.
Location of the xml element containing the .
expander options.
Wether to include items that evaluated to empty / null.
Expands all item vectors embedded in the given expression into a single string.
If the expression is empty, returns empty string.
If ExpanderOptions.BreakOnNotEmpty was passed, expression was going to be non-empty, and it broke out early, returns null. Otherwise the result can be trusted.
Type of the items provided.
Prepare the stack of transforms that will be executed on a given set of items.
class, IItem.
Expand the match provided into a string, and append that to the provided InternableString.
Returns true if ExpanderOptions.BreakOnNotEmpty was passed, expression was going to be non-empty, and so it broke out early.
Type of source items.
The set of functions that called during an item transformation, e.g. @(CLCompile->ContainsMetadata('MetaName', 'metaValue')).
class, IItem.
A cache of previously created item function delegates.
Delegate that represents the signature of all item transformation functions
This is used to support calling the functions by name.
Get a delegate to the given item transformation function by supplying the name and the
Item type that should be used.
Create an enumerator from a base IEnumerable of items into an enumerable
of transformation result which includes the new itemspec and the base item.
Intrinsic function that returns the number of items in the list.
Intrinsic function that returns the specified built-in modifer value of the items in itemsOfType
Tuple is {current item include, item under transformation}.
Intrinsic function that returns the subset of items that actually exist on disk.
Intrinsic function that combines the existing paths of the input items with a given relative path.
Intrinsic function that returns all ancestor directories of the given items.
Intrinsic function that returns the DirectoryName of the items in itemsOfType
UNDONE: This can be removed in favor of a built-in %(DirectoryName) metadata in future.
Intrinsic function that returns the contents of the metadata in specified in argument[0].
Intrinsic function that returns only the items from itemsOfType that have distinct Item1 in the Tuple
Using a case sensitive comparison.
Intrinsic function that returns only the items from itemsOfType that have distinct Item1 in the Tuple
Using a case insensitive comparison.
Intrinsic function that returns only the items from itemsOfType that have distinct Item1 in the Tuple
Using a case insensitive comparison.
Intrinsic function reverses the item list.
Intrinsic function that transforms expressions like the %(foo) in @(Compile->'%(foo)').
Intrinsic function that transforms expressions by invoking methods of System.String on the itemspec
of the item in the pipeline.
Intrinsic function that returns the items from itemsOfType with their metadata cleared, i.e. only the itemspec is retained.
Intrinsic function that returns only those items that have a not-blank value for the metadata specified
Using a case insensitive comparison.
Intrinsic function that returns only those items have the given metadata value
Using a case insensitive comparison.
Intrinsic function that returns a boolean to indicate if any of the items have the given metadata value
Using a case insensitive comparison.
Represents all the components of a transform function, including the ability to execute it.
class, IItem.
The delegate that points to the transform function.
Arguments to pass to the transform function as parsed out of the project file.
The element location of the transform expression.
The name of the function that this class will call.
TransformFunction constructor.
Arguments to pass to the transform function as parsed out of the project file.
The element location of the transform expression.
Execute this transform function with the arguments contained within this TransformFunction instance.
A functor that returns the value of the metadata in the match
that is on the item it was created with.
The current ItemSpec of the item being matched.
Item used as the source of metadata.
Location of the match.
Constructor.
Expands the metadata in the match provided into a string result.
The match is expected to be the content of a transform.
For example, representing "%(Filename.obj)" in the original expression "@(Compile->'%(Filename.obj)')".
Regular expressions used by the expander.
The expander currently uses regular expressions rather than a parser to do its work.
Regular expression used to match item metadata references embedded in strings.
For example, %(Compile.DependsOn) or %(DependsOn).
Name of the group matching the "name" of a metadatum.
Name of the group matching the prefix on a metadata expression, for example "Compile." in "%(Compile.Object)".
Name of the group matching the item type in an item expression or metadata expression.
regular expression used to match item metadata references outside of item vector transforms.
PERF WARNING: this Regex is complex and tends to run slowly.
Complete description of an item metadata reference, including the optional qualifying item type.
For example, %(Compile.DependsOn) or %(DependsOn).
description of an item vector with a transform, left hand side.
description of an item vector with a transform, right hand side.
The type of this function's receiver.
The name of the function.
The arguments for the function.
The expression that this function is part of.
The property name that this function is applied on.
The binding flags that will be used during invocation of this function.
The remainder of the body once the function and arguments have been extracted.
List of properties which have been used but have not been initialized yet.
This class represents the function as extracted from an expression
It is also responsible for executing the function.
Type of the properties used to expand the expression.
The type of this function's receiver.
The name of the function.
The arguments for the function.
The expression that this function is part of.
The property name that this function is applied on.
The binding flags that will be used during invocation of this function.
The remainder of the body once the function and arguments have been extracted.
List of properties which have been used but have not been initialized yet.
Construct a function that will be executed during property evaluation.
Part of the extraction may result in the name of the property
This accessor is used by the Expander
Examples of expression root:
[System.Diagnostics.Process]::Start
SomeMSBuildProperty.
Extract the function details from the given property function expression.
Execute the function on the given instance.
Shortcut to avoid calling into binding if we recognize some most common functions.
Binding is expensive and throws first-chance MissingMethodExceptions, which is
bad for debugging experience and has a performance cost.
A typical binding operation with exception can take ~1.500 ms; this call is ~0.050 ms
(rough numbers just for comparison).
See https://github.com/Microsoft/msbuild/issues/2217.
The value returned from the function call.
Object that the function is called on.
arguments.
True if the well known function call binding was successful.
Shortcut to avoid calling into binding if we recognize some most common constructors.
Analogous to TryExecuteWellKnownFunction but guaranteed to not throw.
The instance as created by the constructor call.
Arguments.
True if the well known constructor call binding was successful.
Given a type name and method name, try to resolve the type.
May be full name or assembly qualified name.
simple name of the method.
Gets the specified type using the namespace to guess the assembly that its in.
Get the specified type from the assembly partial name supplied.
Extracts the name, arguments, binding flags, and invocation type for an indexer
Also extracts the remainder of the expression that is not part of this indexer.
Extracts the name, arguments, binding flags, and invocation type for a static or instance function.
Also extracts the remainder of the expression that is not part of this function.
Coerce the arguments according to the parameter types
Will only return null if the coercion didn't work due to an InvalidCastException.
Make an attempt to create a string showing what we were trying to execute when we failed.
This will show any intermediate evaluation which may help the user figure out what happened.
Check the property function whitelist whether this method is available.
Construct and instance of objectType based on the constructor or method arguments provided.
Arguments must never be null.
This class wraps information about properties which have been used before they are initialized.
This class wraps information about properties which have been used before they are initialized.
Hash set of properties which have been used before being initialized.
Are we currently supposed to warn if we used an uninitialized property.
What is the currently evaluating property element, this is so that we do not add a un initialized property if we are evaluating that property.
Class which provides access to toolsets.
A mapping of tools versions to Toolsets, which contain the public Toolsets.
This is the collection we use internally.
Constructor which will load toolsets from the specified locations.
Constructor from an existing collection of toolsets.
Private constructor for deserialization
Retrieves the toolsets.
ValueCollection is already read-only.
Gets the specified toolset.
Translates to and from binary form.
Factory for deserialization.
Populate Toolsets with a dictionary of (toolset version, Toolset)
using information from the registry and config file, if any.
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Enable providing access to external [potentially remote] ProjectCollection.
Provide the list of remote projects (projects in the remote collection)
Note all returned objects will be local "linked" Project object proxies.
[optional] project full path. Can be null in which case function will return all projects
Called when External provider is "disconnected" from the local collection - aka it will be no longer used to extend
the projects list.
This is triggered by either project collection disposing or when another call to SetExternalProjectsProvider is invoked.
The purpose of this call is to allow the external provider release any associate data (caches/connections etc).
Attach an external project provider to a msbuild ProjectCollection.
Note at any time there could be only one ExternalProvider attached.
Can be called with link == null, in which case it will "clear" the external provider on the target collection
implemented by MSBuild objects that support remote linking;
Gets the current link, if any. For local objects returns null;
Provide facility to ExternalProjectsProvider implementation
to create local OM objects based on the remote link.
These object are fully useful for associated Collection.
Acquire a instance for a given ProjectCollection.
Allows creating a local MSBuild OM objects representing externally hosted Projects.
Get the underlying "link" proxy for a given MSBuild object model object (null if it is not linked).
can be used by ExternalProjectsProvider to prevent double linking when implementing remote calls.
Check if an msbuild object is local (aka not from External Project)
Local collection.
Gets only locally load projects, excluding external
Creates a regular evaluated property, with backing XML.
Called by Project.SetProperty.
Property MAY NOT have reserved name and MAY NOT overwrite a global property.
Predecessor is any immediately previous property that was overridden by this one during evaluation and may be null.
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Access to remote .
Facilitate remoting the and .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Access to remote .
Access to remote .
Facilitate remoting the and .
Facilitate remoting the and .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Helps implementing the item type change for remoted objects>.
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate support for remote build.
Called by the local project collection to indicate to this project that it is no longer loaded.
External projects support.
Allow for creating a local representation to external object of type
MSBuild object that this meta data belong to.
Can be either , or
Not a public property on original ProjectMetadata object, but int is needed to create a local proxy object.
Access to remote .
Access to remote .
Access to remote .
Helper utility for External projects provider implementation to get access of the parent object.
At this point this is internal property for .
Helper utility for External projects provider implementation to get access of the EvaluatedValueEscaped
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Access to remote .
Access to remote .
(note can not Use Xml.Name since for global properties Xml is null;
Allow implement the for remoted objects.
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Helper utility for External projects provider implementation to get access of the EvaluatedValueEscaped
External projects support.
Allow for creating a local representation to external construction objects derived from
Access to remote .
Access to remote .
Access to remote .
Facilitate remoting the .
Facilitate remoting the .
Helps implementation of the .
helps implementation the .
Facilitate remoting the .
ExternalProjectsProvider helpers
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
This interface will allow us to share a single field between
and
for construction objects so therefore not increasing the storage size while supporting
external linking.
and
Not null for "external" objects, null for internal objects
Null for "external" objects, not null for internal objects
External projects support.
Allow for creating a local representation to external construction objects derived from
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Supports .
Supports .
return raw xml content of the element if it has exactly 1 text child
Required to implement Attribute access for remote element.
Required to implement Attribute access for remote element.
Required to implement Attribute access for remote element.
Facilitate remoting to remote .
Facilitate remoting to remote .
Utility function for ExternalProjects provider
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Helps implementing sub element indexer.
Helps implementing sub element indexer.
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Access to remote .
External projects support.
Allow for creating a local representation to external object of type
Help implement ItemType setter for remote objects.
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Help implement rename.
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Help implement rename.
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Access to remote .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Access to remote .
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
Access to remote .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
Facilitate remoting the .
External projects support.
Allow for creating a local representation to external object of type
Access to remote .
The thread calling BuildGraph() will act as an implicit worker
Maintain the state of each node (InProcess and Processed) to detect cycles.
Assumes edges have been added between nodes.
Returns false if cycles were detected.
Load a graph with root node at entryProjectFile
Maintain a queue of projects to be processed and evaluate projects in parallel
Returns false if loading the graph is not successful
Provides deduping of expensive work by a key, or modeling of a set of deduped work that
can be awaited as a unit. Completed results are kept in the collection for reuse.
Number of workers to process work items.
Retrieves all completed work items.
Checks if the work set has been marked as completed.
Enqueues a work item to the work set.
Assists processing items until all the items added to the queue are processed, completes the work set, and
propagates any exceptions thrown by workers.
To avoid calling nuget at graph construction time, the graph is initially constructed with outer build nodes referencing inner build nodes.
However, at build time, for non root outer builds, the inner builds are NOT referenced by the outer build, but by the nodes referencing the
outer build. Change the graph to mimic this behaviour.
Examples
OuterAsRoot -> Inner go to OuterAsRoot -> Inner. Inner builds remain the same, parented to their outer build
Node -> Outer -> Inner go to: Node -> Outer; Node->Inner; Outer -> empty. Inner builds get reparented to Node
Gets the effective global properties for a project reference item.
The behavior of this method should match the logic in the SDK
Gets the effective global properties for an item that will get passed to .
The behavior of this method matches the hardcoded behaviour of the msbuild task
and the parameter can contain other mutations done at build time in targets / tasks
Given a project and a set of entry targets the project would get called with,
parse the project's project reference target specification and compute how the target would call its references.
The calling code should then call for each of the project's references
to get the concrete targets for each reference.
Project containing the PRT protocol
Targets with which will get called
Constructor creates a build result with results for each graph node.
The id of the build submission.
The set of results for each graph node.
Constructor creates a build result indicating a circular dependency was created.
The id of the build submission.
Set to true if a circular dependency was detected.
Constructs a graph build result with an exception
The id of the build submission.
The exception, if any.
Returns the submission id.
Returns a flag indicating if a circular dependency was detected.
Returns the exception generated while this result was run, if any.
Returns the overall result for this result set.
Returns an enumerator for all build results in this graph build result
Indexer which sets or returns results for the specified node
The node
The results for the specified node
KeyNotFoundException is returned if the specified node doesn't exist when reading this property.
A callback used to receive notification that a build has completed.
When this delegate is invoked, the WaitHandle on the BuildSubmission will have been be signalled and the OverallBuildResult will be valid.
A GraphBuildSubmission represents a graph build request which has been submitted to the BuildManager for processing. It may be used to
execute synchronous or asynchronous graph build requests and provides access to the results upon completion.
This class is thread-safe.
The callback to invoke when the submission is complete.
The completion event.
True if it has been invoked
Constructor
The BuildManager with which this submission is associated.
An ID uniquely identifying this request from among other submissions within the same build.
The asynchronous context provided to , if any.
A which will be signalled when the build is complete. Valid after or returns, otherwise null.
Returns true if this submission is complete.
The results of the build per graph node. Valid only after WaitHandle has become signalled.
The BuildRequestData being used for this submission.
Whether the graph build has started.
Starts the request and blocks until results are available.
The request has already been started or is already complete.
Starts the request asynchronously and immediately returns control to the caller.
The request has already been started or is already complete.
Sets the event signaling that the build is complete.
If false, the graph is constructed but the nodes are not built.
GraphBuildRequestData encapsulates all of the data needed to submit a graph build request.
Constructs a GraphBuildRequestData for build requests based on a project graph.
The graph to build.
The targets to build.
Constructs a GraphBuildRequestData for build requests based on a project graph.
The graph to build.
The targets to build.
The host services to use, if any. May be null.
Constructs a GraphBuildRequestData for build requests based on a project graph.
The graph to build.
The targets to build.
The host services to use, if any. May be null.
Flags controlling this build request.
Constructs a GraphBuildRequestData for build requests based on project files.
The full path to the project file.
The global properties which should be used during evaluation of the project. Cannot be null.
The targets to build.
The host services to use. May be null.
Constructs a GraphBuildRequestData for build requests based on project files.
The full path to the project file.
The global properties which should be used during evaluation of the project. Cannot be null.
The targets to build.
The host services to use. May be null.
The to use.
Constructs a GraphBuildRequestData for build requests based on a project graph entry points.
The entry point to use in the build.
The targets to build.
Constructs a GraphBuildRequestData for build requests based on a project graph entry points.
The entry point to use in the build.
The targets to build.
The host services to use, if any. May be null.
Constructs a GraphBuildRequestData for build requests based on a project graph entry points.
The entry point to use in the build.
The targets to build.
The host services to use, if any. May be null.
Flags controlling this build request.
Constructs a GraphBuildRequestData for build requests based on a project graph entry points.
The entry points to use in the build.
The targets to build.
Constructs a GraphBuildRequestData for build requests based on a project graph entry points.
The entry points to use in the build.
The targets to build.
The host services to use, if any. May be null.
Constructs a GraphBuildRequestData for build requests based on a project graph entry points.
The entry points to use in the build.
The targets to build.
The host services to use, if any. May be null.
Flags controlling this build request.
Common constructor.
The requested project graph to build.
May be null.
The project graph.
The project graph entry points.
May be null.
The project graph entry points.
The name of the targets to build.
An array of targets in the project to be built.
Extra flags for this BuildRequest.
Options for how the graph should be built.
Gets the HostServices object for this request.
Represents an entry point into the project graph which is comprised of a project file and a set of global properties
Constructs an entry point with the given project file and no global properties.
The project file to use for this entry point
Constructs an entry point with the given project file and global properties.
The project file to use for this entry point
The global properties to use for this entry point. May be null.
Gets the project file to use for this entry point.
Gets the global properties to use for this entry point.
Represents a graph of evaluated projects.
A callback used for constructing a for a specific
instance.
The path to the project file to parse.
The global properties to be used for creating the ProjectInstance.
The context for parsing.
A instance. This value must not be null.
The default version of this delegate used by ProjectGraph simply calls the
ProjectInstance constructor with information from the parameters. This delegate
is provided as a hook to allow scenarios like creating a
instance before converting it to a ProjectInstance for use by the ProjectGraph.
The returned ProjectInstance will be stored and provided with the ProjectGraph.
If this callback chooses to generate an immutable ProjectInstance, e.g. by
using with the flag
, the resulting ProjectGraph
nodes might not be buildable.
To avoid corruption of the graph and subsequent builds based on the graph:
- all callback parameters must be utilized for creating the ProjectInstance, without any mutations
- the project instance should not be mutated in any way, its state should be a
full fidelity representation of the project file
Various metrics on graph construction.
Gets the project nodes representing the entry points.
Get an unordered collection of all project nodes in the graph.
Get a topologically sorted collection of all project nodes in the graph.
Referenced projects appear before the referencing projects.
Constructs a graph starting from the given project file, evaluating with the global project collection and no
global properties.
The project file to use as the entry point in constructing the graph
If the evaluation of any project in the graph fails
Constructs a graph starting from the given project files, evaluating with the global project collection and no
global properties.
The project files to use as the entry points in constructing the graph
If the evaluation of any project in the graph fails
Constructs a graph starting from the given project file, evaluating with the provided project collection and no
global properties.
The project file to use as the entry point in constructing the graph
The collection with which all projects in the graph should be associated. May not be
null.
If the evaluation of any project in the graph fails
Constructs a graph starting from the given project files, evaluating with the provided project collection and no
global properties.
The project files to use as the entry points in constructing the graph
The collection with which all projects in the graph should be associated. May not be
null.
If the evaluation of any project in the graph fails
Constructs a graph starting from the given project file, evaluating with the global project collection and no
global properties.
The project file to use as the entry point in constructing the graph
The collection with which all projects in the graph should be associated. May not be
null.
A delegate used for constructing a , called for each
project created during graph creation. This value can be null, which uses
a default implementation that calls the ProjectInstance constructor. See the remarks
on the for other scenarios.
If the evaluation of any project in the graph fails, the InnerException contains
If a null reference is returned from , the InnerException contains
Constructs a graph starting from the given project file, evaluating with the provided global properties and the
global project collection.
The project file to use as the entry point in constructing the graph
The global properties to use for all projects. May be null, in which case no global
properties will be set.
If the evaluation of any project in the graph fails
Constructs a graph starting from the given project files, evaluating with the provided global properties and the
global project collection.
The project files to use as the entry points in constructing the graph
The global properties to use for all projects. May be null, in which case no global
properties will be set.
If the evaluation of any project in the graph fails
Constructs a graph starting from the given project file, evaluating with the provided global properties and the
provided project collection.
The project file to use as the entry point in constructing the graph
The global properties to use for all projects. May be null, in which case no global
properties will be set.
The collection with which all projects in the graph should be associated. May not be
null.
If the evaluation of any project in the graph fails
Constructs a graph starting from the given project files, evaluating with the provided global properties and the
provided project collection.
The project files to use as the entry points in constructing the graph
The global properties to use for all projects. May be null, in which case no global
properties will be set.
The collection with which all projects in the graph should be associated. May not be
null.
If the evaluation of any project in the graph fails
Constructs a graph starting from the given graph entry point, evaluating with the global project collection.
The entry point to use in constructing the graph
If the evaluation of any project in the graph fails
Constructs a graph starting from the given graph entry points, evaluating with the global project collection.
The entry points to use in constructing the graph
If the evaluation of any project in the graph fails
Constructs a graph starting from the given graph entry point, evaluating with the provided project collection.
The entry point to use in constructing the graph
The collection with which all projects in the graph should be associated. May not be
null.
If the evaluation of any project in the graph fails
Constructs a graph starting from the given graph entry points, evaluating with the provided project collection.
The entry points to use in constructing the graph
The collection with which all projects in the graph should be associated. May not be
null.
A delegate used for constructing a , called for each
project created during graph creation. This value can be null, which uses
a default implementation that calls the ProjectInstance constructor. See the remarks
on for other scenarios.
If the evaluation of any project in the graph fails
If a null reference is returned from
If the evaluation is successful but the project graph contains a circular
dependency
Constructs a graph starting from the given graph entry points, evaluating with the provided project collection.
The entry points to use in constructing the graph
The collection with which all projects in the graph should be associated. May not be
null.
A delegate used for constructing a , called for each
project created during graph creation. This value can be null, which uses
a default implementation that calls the ProjectInstance constructor. See the remarks
on for other scenarios.
The token to observe.
If the evaluation of any project in the graph fails
If a null reference is returned from
If the evaluation is successful but the project graph contains a circular
dependency
Constructs a graph starting from the given graph entry points, evaluating with the provided project collection.
The entry points to use in constructing the graph
The collection with which all projects in the graph should be associated. May not be
null.
A delegate used for constructing a , called for each
project created during graph creation. This value can be null, which uses
a default implementation that calls the ProjectInstance constructor. See the remarks
on for other scenarios.
Number of threads to participate in building the project graph.
The token to observe.
If the evaluation of any project in the graph fails
If a null reference is returned from
If the evaluation is successful but the project graph contains a circular
dependency
Gets the target list to be executed for every project in the graph, given a particular target list for the entry
project.
This method uses the ProjectReferenceTargets items to determine the targets to run per node. The results can then
be used to start building each project individually, assuming a given project is built after its references.
The target list for the . May be null or empty, in which case the entry projects' default
targets will be used.
A dictionary containing the target list for each node. If a node's target list is empty, then no targets were
inferred for that node and it should get skipped during a graph based build.
Represents the node for a particular project in a project graph.
A node is defined by (ProjectPath, ToolsVersion, GlobalProperties).
Gets an unordered collection of graph nodes for projects which this project references.
Gets a list of graph nodes for projects that have a project reference for this project
Gets the evaluated project instance represented by this node in the graph.
This class descibes a central/forwarding logger pair used in multiproc logging.
Constructor.
The central logger
The description for the forwarding logger.
Retrieves the central logger.
Retrieves the forwarding logger description.
Comparer for that ignores
both and
Listens to build evaluation finished events and collects profiling information when available
Accumulates the result of profiling each project. Computing the aggregated result is deferred till the end of the build
to interfere as less as possible with evaluation times
Aggregation of all profiled locations. Computed the first time is called.
If null, no file is saved to disk
Creates a logger for testing purposes that gathers profiling information but doesn't save a file to disk with the report
Verbosity is ignored by this logger
No specific parameters are used by this logger
Subscribes to status events, which is the category for the evaluation finished event.
On shutdown, the profiler report is written to disk
Returns the result of aggregating all profiled projects across a build
Whether small items should be pruned. This is called with false on some tests since the result may vary depending on the evaluator speed
Not thread safe. After this method is called, the assumption is that no new ProjectEvaluationFinishedEventArgs will arrive.
In the regular code path, this method is called only once per build. But some test cases may call it multiple times to validate
the aggregated data
Finds the first ancestor of parentId (which could be itself) that is either an evaluation pass location or a big enough profiled data
Pretty prints the aggregated results and saves it to disk
If the extension of the file to log is 'md', markdown content is generated. Otherwise, it falls
back to a tab separated format
A logger that serializes all incoming BuildEventArgs in a compressed binary file (*.binlog). The file
can later be played back and piped into other loggers (file, console, etc) to reconstruct the log contents
as if a real build was happening. Additionally, this format can be read by tools for
analysis or visualization. Since the file format preserves structure, tools don't have to parse
text logs that erase a lot of useful information.
The logger is public so that it can be instantiated from MSBuild.exe via command-line switch.
Describes whether to collect the project files (including imported project files) used during the build.
If the project files are collected they can be embedded in the log file or as a separate zip archive.
Don't collect any files during the build.
Embed all project files directly in the log file.
Create an external .ProjectImports.zip archive for the project files.
Gets or sets whether to capture and embed project and target source files used during the build.
The binary logger Verbosity is always maximum (Diagnostic). It tries to capture as much
information as possible.
The only supported parameter is the output log file path (e.g. "msbuild.binlog")
Initializes the logger by subscribing to events of IEventSource
Closes the underlying file stream.
Processes the parameters given to the logger from MSBuild.
Provides a method to read a binary log file (*.binlog) and replay all stored BuildEventArgs
by implementing IEventSource and raising corresponding events.
The class is public so that we can call it from MSBuild.exe when replaying a log file.
Touches the static constructor
to ensure it initializes
and
Read the provided binary log file and raise corresponding events for each BuildEventArgs
The full file path of the binary log file
Read the provided binary log file and raise corresponding events for each BuildEventArgs
The full file path of the binary log file
A indicating the replay should stop as soon as possible.
An implementation of IEventSource that raises appropriate events for a provided BuildEventArgs object.
This class is public because BinaryLogReplayEventSource is a derived class.
This is abstracted into its own class because it's a useful single-purpose helper that
can be used independently as a generic implementation of IEventSource.
This event is raised for all BuildEventArgs objects after a more type-specific event
Raised for BuildStatusEventArgs instances
Raised for CustomBuildEventArgs instances
Raised for BuildStartedEventArgs instances
Raised for BuildFinishedEventArgs instances
Raised for ProjectStartedEventArgs instances
Raised for ProjectFinishedEventArgs instances
Raised for TargetStartedEventArgs instances
Raised for TargetFinishedEventArgs instances
Raised for TaskStartedEventArgs instances
Raised for TaskFinishedEventArgs instances
Raised for BuildErrorEventArgs instances
Raised for BuildWarningEventArgs instances
Raised for BuildMessageEventArgs instances
Raise one of the events that is appropriate for the type of the BuildEventArgs
A bitmask to specify which fields on a BuildEventArgs object are present; used in serialization
Represents a collective set of common properties on BuildEventArgs. Used for deserialization.
Deserializes and returns BuildEventArgs-derived objects from a BinaryReader
A list of string records we've encountered so far. If it's a small string, it will be the string directly.
If it's a large string, it will be a pointer into a temporary page file where the string content will be
written out to. This is necessary so we don't keep all the strings in memory when reading large binlogs.
We will OOM otherwise.
A list of dictionaries we've encountered so far. Dictionaries are referred to by their order in this list.
This is designed to not hold on to strings. We just store the string indices and
hydrate the dictionary on demand before returning.
A "page-file" for storing strings we've read so far. Keeping them in memory would OOM the 32-bit MSBuild
when reading large binlogs. This is a no-op in a 64-bit process.
Initializes a new instance of BuildEventArgsReader using a BinaryReader instance
The BinaryReader to read BuildEventArgs from
The file format version of the log file being read.
Raised when the log reader encounters a binary blob embedded in the stream.
The arguments include the blob kind and the byte buffer with the contents.
Reads the next log record from the binary reader. If there are no more records, returns null.
For errors and warnings these 8 fields are written out explicitly
(their presence is not marked as a bit in the flags). So we have to
read explicitly.
Locates the string in the page file.
Offset in the file.
The length of the string in chars (not bytes).
Stores large strings in a temp file on disk, to avoid keeping all strings in memory.
Only creates a file for 32-bit MSBuild.exe, just returns the string directly on 64-bit.
Serializes BuildEventArgs-derived objects into a provided BinaryWriter
When writing the current record, first write it to a memory stream,
then flush to the originalStream. This is needed so that if we discover
that we need to write a string record in the middle of writing the
current record, we will write the string record to the original stream
and the current record will end up after the string record.
The binary writer around the originalStream.
The binary writer around the currentRecordStream.
The binary writer we're currently using. Is pointing at the currentRecordWriter usually,
but sometimes we repoint it to the originalBinaryWriter temporarily, when writing string
and name-value records.
Hashtable used for deduplicating strings. When we need to write a string,
we check in this hashtable first, and if we've seen the string before,
just write out its index. Otherwise write out a string record, and then
write the string index. A string record is guaranteed to precede its first
usage.
The reader will read the string records first and then be able to retrieve
a string by its index. This allows us to keep the format streaming instead
of writing one giant string table at the end. If a binlog is interrupted
we'll be able to use all the information we've discovered thus far.
Hashtable used for deduplicating name-value lists. Same as strings.
Index 0 is null, Index 1 is the empty string.
Reserve indices 2-9 for future use. Start indexing actual strings at 10.
Let's reserve a few indices for future use.
0 is null, 1 is empty string
2-9 are reserved for future use.
Start indexing at 10.
The index of the next record to be written.
A temporary buffer we use when writing a NameValueList record. Avoids allocating a list each time.
A temporary buffer we use when hashing a NameValueList record. Stores the indices of hashed strings
instead of the actual names and values.
Raised when an item is encountered with a hint to embed a file into the binlog.
Initializes a new instance of BuildEventArgsWriter with a BinaryWriter
A BinaryWriter to write the BuildEventArgs instances to
Write a provided instance of BuildEventArgs to the BinaryWriter
Switches the binaryWriter used by the Write* methods to the direct underlying stream writer
until the disposable is disposed. Useful to bypass the currentRecordWriter to write a string,
blob or NameValueRecord that should precede the record being currently written.
In the middle of writing the current record we may discover that we want to write another record
preceding the current one, specifically the list of names and values we want to reuse in the
future. As we are writing the current record to a MemoryStream first, it's OK to temporarily
switch to the direct underlying stream and write the NameValueList record first.
When the current record is done writing, the MemoryStream will flush to the underlying stream
and the current record will end up after the NameValueList record, as desired.
Compute the total hash of all items in the nameValueList
while simultaneously filling the nameValueIndexListBuffer with the individual
hashes of the strings, mirroring the strings in the original nameValueList.
This helps us avoid hashing strings twice (once to hash the string individually
and the second time when hashing it as part of the nameValueList)
Hash the string and write a String record if not already hashed.
Returns the string record index as well as the hash.
Creates a zip archive with all the .csproj and .targets encountered during the build.
The internal .zip file structure matches closely the layout of the original sources on disk.
The .zip file can be used to correlate the file names and positions in the build log file with the
actual sources.
Avoid visiting each file more than once.
This method doesn't need locking/synchronization because it's only called
from a task that is chained linearly
This method doesn't need locking/synchronization because it's only called
from a task that is chained linearly
Delegate to use for writing a string to some location like
the console window or the IDE build window.
Type of delegate used to set console color.
Text color
Type of delegate used to reset console color.
This class implements the default logger that outputs event data
to the console (stdout).
It is a facade: it creates, wraps and delegates to a kind of BaseConsoleLogger,
either SerialConsoleLogger or ParallelConsoleLogger.
This class is not thread safe.
Default constructor.
Create a logger instance with a specific verbosity. This logs to
the default console.
Verbosity level.
Initializes the logger, with alternate output handlers.
This is called by every event handler for compat reasons -- see DDB #136924
However it will skip after the first call
Gets or sets the level of detail to show in the event log.
Verbosity level.
A semi-colon delimited list of "key[=value]" parameter pairs.
null
Suppresses the display of project headers. Project headers are
displayed by default unless this property is set.
This is only needed by the IDE logger.
Suppresses the display of error and warnings summary.
Provide access to the write hander delegate so that it can be redirected
if necessary (e.g. to a file)
Apply a parameter.
NOTE: This method was public by accident in Whidbey, so it cannot be made internal now. It has
no good reason for being public.
Signs up the console logger for all build events.
Available events.
Initializes the logger.
The console logger does not need to release any resources.
This method does nothing.
Handler for build started events
sender (should be null)
event arguments
Handler for build finished events
sender (should be null)
event arguments
Handler for project started events
sender (should be null)
event arguments
Handler for project finished events
sender (should be null)
event arguments
Handler for target started events
sender (should be null)
event arguments
Handler for target finished events
sender (should be null)
event arguments
Handler for task started events
sender (should be null)
event arguments
Handler for task finished events
sender (should be null)
event arguments
Prints an error event
Prints a warning event
Prints a message event
Prints a custom event
This class will create a text file which will contain the build log for that node
Default constructor.
Initializes the logger.
Parses out the logger parameters from the Parameters string.
Apply a parameter
Initializes the logger.
Instructs the logger to shut down.
Gets or sets the object used to redirect build events.
Gets or sets the identifier of the node which the forwarding logger is attached to.
Gets or sets . This is currently hard-coded as .
Gets or sets the parameters.
Logger that forwards events to a central logger (e.g ConsoleLogger)
residing on the parent node.
Default constructor.
Gets or sets the level of detail to show in the event log.
Verbosity level.
The console logger takes a single parameter to suppress the output of the errors
and warnings summary at the end of a build.
null
This property is set by the build engine to allow a node loggers to forward messages to the
central logger
The identifier of the node.
Initialize the Forwarding Table with the default values
Parses out the logger parameters from the Parameters string.
Logger parameters can be used to enable and disable specific event types.
Otherwise, the verbosity is used to choose which events to forward.
Signs up the console logger for all build events.
Signs up the console logger for all build events.
Reset the states of per-build member variables.
Used when a build is finished, but the logger might be needed for the next build.
Called when Engine is done with this logger
Handler for build started events
sender (should be null)
event arguments
Handler for build finished events
sender (should be null)
event arguments
Handler for project started events
sender (should be null)
event arguments
Handler for project finished events
sender (should be null)
event arguments
Handler for target started events
sender (should be null)
event arguments
Handler for target finished events
sender (should be null)
event arguments
Handler for task started events
sender (should be null)
event arguments
Handler for task finished events
sender (should be null)
event arguments
Prints an error event
Prints a warning event
Prints a message event
Prints a custom event
Forwards the specified event.
The to forward.
Determines whether the current verbosity setting is at least the value
passed in.
Controls the amount of text displayed by the logger
Console logger parameters.
Console logger parameters delimiters.
Strings that users of this logger can pass in to enable specific events or logger output.
Also used as keys into our dictionary.
A table indicating if a particular event type should be forwarded
The value is type int rather than bool to avoid the problem of JITting generics.
is already compiled into mscorlib.
A pointer to the central logger
Indicates if the events to forward are being set by the parameters sent to the logger
if this is false the events to forward are based on verbosity else verbosity settings will be ignored
Console logger should show error and warning summary at the end of build?
When true, accumulate performance numbers.
When true the commandline message is sent
Id of the node the logger is attached to
This class is used to contain information about a logger as a collection of values that
can be used to instantiate the logger and can be serialized to be passed between different
processes.
Creates a logger description from given data
Creates a logger description from given data
This property exposes the logger id which identifies each distributed logger uniquiely
This property generates the logger name by appending together the class name and assembly name
Returns the string of logger parameters, null if there are none
Return the verbosity for this logger (from command line all loggers get same verbosity)
Create an IForwardingLogger out of the data in this description. This method may throw a variety of
reflection exceptions if the data is invalid. It is the resposibility of the caller to handle these
exceptions if desired.
Create an ILogger out of the data in this description. This method may throw a variety of
reflection exceptions if the data is invalid. It is the resposibility of the caller to handle these
exceptions if desired.
Loads a logger from its assembly, instantiates it, and handles errors.
Instantiated logger.
Used for finding loggers when reflecting through assemblies.
Used for finding loggers when reflecting through assemblies.
Checks if the given type is a logger class.
This method is used as a Type Filter delegate.
true, if specified type is a logger
Checks if the given type is a logger class.
This method is used as a TypeFilter delegate.
true, if specified type is a logger
Converts the path to the logger assembly to a full path
A specialization of the ConsoleLogger that logs to a file instead of the console.
The output in terms of what is written and how it looks is identical. For example you can
log verbosely to a file using the FileLogger while simultaneously logging only high priority events
to the console using a ConsoleLogger.
It's unfortunate that this is derived from ConsoleLogger, which is itself a facade; it makes things more
complex -- for example, there is parameter parsing in this class, plus in BaseConsoleLogger. However we have
to derive FileLogger from ConsoleLogger because it shipped that way in Whidbey.
Default constructor.
Signs up the console file logger for all build events.
This is the backward-compatible overload.
Available events.
Creates new file for logging
Multiproc aware initialization
The handler for the write delegate of the console logger we are deriving from.
The text to write to the log
Shutdown method implementation of ILogger - we need to flush and close our logfile.
Parses out the logger parameters from the Parameters string.
Apply a parameter parsed by the file logger.
logFileName is the name of the log file that we will generate
the default value is msbuild.log
fileWriter is the stream that has been opened on our log file.
Whether the logger should append to any existing file.
Default is to overwrite.
Whether the logger should flush aggressively to disk.
Default is true. This preserves the most information in the case
of a crash, but may slow the logger down.
Encoding for the output. Defaults to UTF-8.
File logger parameters delimiters.
File logger parameter value split character.
Represents the location of an implicit import.
The import is not implicitly added and is explicitly added in a user-specified location.
The import was implicitly added at the top of the project.
The import was implicitly added at the bottom of the project.
ProjectSdkElement represents the Sdk element within the MSBuild project.
External projects support
Initialize a parented ProjectSdkElement
Initialize an non-parented ProjectSdkElement
Gets or sets the name of the SDK.
Gets or sets the version of the SDK.
Gets or sets the minimum version of the SDK required to build the project.
Creates a non-parented ProjectSdkElement, wrapping an non-parented XmlElement.
Caller should then ensure the element is added to a parent
This class is used to generate an MSBuild wrapper project for a solution file.
Name of the property used to store the path to the solution being built.
The path node to add in when the output directory for a website is overridden.
The set of properties all projects in the solution should be built with
The set of properties which identify the configuration and platform to build a project with
A known list of target names to create. This is for backwards compatibility.
Version 2.0
Version 4.0
The list of global properties we set on each metaproject and which get passed to each project when building.
The SolutionFile containing information about the solution we're generating a wrapper for.
The global properties passed under which the project should be opened.
The ToolsVersion passed on the commandline, if any. May be null.
The context of this build (used for logging purposes).
The LoggingService used to log messages.
The list of targets specified to use.
The solution configuration selected for this build.
The to use.
The current build submission ID.
Constructor.
This method generates an MSBuild project file from the list of projects and project dependencies
that have been collected from the solution file.
The parser which contains the solution file.
The global properties.
Tools Version override (may be null). This should be any tools version explicitly passed to the command-line or from an MSBuild ToolsVersion parameter.
The logging context for this project.
The logging service.
A collection of target names the user requested to be built.
An to use.
The current build submission ID.
An array of ProjectInstances. The first instance is the traversal project, the remaining are the metaprojects for each project referenced in the solution.
Adds a new property group with contents of the given solution configuration to the project
Internal for unit-testing.
Add a new error/warning/message tag into the given target
Normally the active solution configuration/platform is determined when we build the solution
wrapper project, not when we create it. However, we need to know them to scan project references
for the right project configuration/platform. It's unlikely that references would be conditional,
but still possible and we want to get that case right.
Returns the name of the metaproject for an actual project.
The full path to the actual project
The metaproject path name
Figure out what tools version to build the solution wrapper project with. If a /tv
switch was passed in, use that; otherwise fall back to the default (12.0).
Add a call to the ResolveAssemblyReference task to crack the pre-resolved referenced
assemblies for the complete list of dependencies, PDBs, satellites, etc. The invoke
the Copy task to copy all these files (or at least the ones that RAR determined should
be copied local) into the web project's bin directory.
This code handles the *.REFRESH files that are in the "bin" subdirectory of
a web project. These .REFRESH files are just text files that contain absolute or
relative paths to the referenced assemblies. The goal of these tasks is to
search all *.REFRESH files and extract fully-qualified absolute paths for
each of the references.
Adds an MSBuild task to the specified target
Takes a project in the solution and a base property name, and creates a new property name
that can safely be used as an XML element name, and is also unique to that project (by
embedding the project's GUID into the property name.
Makes a legal item name from a given string by replacing invalid characters with '_'
Add a new error/warning/message tag into the given target
A helper method for constructing conditions for a solution configuration
Sample configuration condition:
'$(Configuration)' == 'Release' and '$(Platform)' == 'Any CPU'
Figure out what solution configuration we are going to build, whether or not it actually exists in the solution
file.
Returns true if the specified project will build in the currently selected solution configuration.
Private method: generates an MSBuild wrapper project for the solution passed in; the MSBuild wrapper
project to be generated is the private variable "msbuildProject" and the SolutionFile containing information
about the solution is the private variable "solutionFile"
Given a parsed solution, generate a top level traversal project and the metaprojects representing the dependencies for each real project
referenced in the solution.
Examine each project in the solution, add references and targets for it, and create metaprojects if necessary.
Adds the standard targets to the traversal project.
Creates the traversal project instance. This has all of the properties against which we can perform evaluations for the remainder of the process.
This method adds a new ProjectReference item to the specified instance. The reference will either be to its metaproject (if the project
is a web project or has reference of its own) or to the project itself (if it has no references and is a normal MSBuildable project.)
The value to be passed to the ToolsVersion attribute of the MSBuild task used to directly build a project.
The value to be passed to the ToolsVersion attribute of the MSBuild task used to directly build a project.
The value to be assigned to the metadata for a particular project reference. Contains only configuration and platform specified in the project configuration, evaluated.
Gets the project configuration and platform values as an attribute string for an MSBuild task used to build the project.
The value to be passed to the Properties attribute of the MSBuild task to build a specific project. Contains reference to project configuration and
platform as well as the solution configuration bits.
Returns true if the specified project can be built directly, without using a metaproject.
Produces a set of targets which allows the MSBuild scheduler to schedule projects in the order automatically by
following their dependencies without enforcing build levels.
We want MSBuild to be able to parallelize the builds of these projects where possible and still honor references.
Since the project files referenced by the solution do not (necessarily) themselves contain actual project references
to the projects they depend on, we need to synthesize this relationship ourselves. This is done by creating a target
which first invokes the project's dependencies, then invokes the actual project itself. However, invoking the
dependencies must also invoke their dependencies and so on down the line.
Additionally, we do not wish to create a separate MSBuild project to contain this target yet we want to parallelize
calls to these targets. The way to do this is to pass in different global properties to the same project in the same
MSBuild call. MSBuild easily allows this using the AdditionalProperties metadata which can be specified on an Item.
Assuming the solution project we are generating is called "foo.proj", we can accomplish this parallelism as follows:
We now have expressed the top level reference to all projects as @(SolutionReference) and each project's
set of references as @(PROJECTNAMEReference). We construct our target as:
The first MSBuild call re-invokes the solution project instructing it to build the reference projects for the
current project. The second MSBuild call invokes the actual project itself. Because all reference projects have
the same additional properties, MSBuild will only build the first one it comes across and the rest will be
satisfied from the cache.
Returns the metaproject name for a given project.
Adds a set of items which describe the references for this project.
Adds the targets which build the dependencies and actual project for a metaproject.
Adds an MSBuild task to a real project.
Adds an MSBuild task to a single metaproject. This is used in the traversal project.
Add a target for a Venus project into the XML doc that's being generated. This
target will call the AspNetCompiler task.
Helper method to add a call to the AspNetCompiler task into the given target.
Adds MSBuild tasks to a project target to pre-resolve its project references
Add a PropertyGroup to the project for a particular Asp.Net configuration. This PropertyGroup
will have the correct values for all the Asp.Net properties for this project and this configuration.
When adding a target to build a web project, we want to put a Condition on the Target node that
effectively says "Only build this target if the web project is active (marked for building) in the
current solution configuration.
Add a target to the project called "GetFrameworkPathAndRedistList". This target calls the
GetFrameworkPath task and then CreateItem to populate @(_CombinedTargetFrameworkDirectoriesItem) and
@(InstalledAssemblyTables), so that we can pass these into the ResolveAssemblyReference task
when building web projects.
Adds a target for a project whose type is unknown and we cannot build. We will emit an error or warning as appropriate.
Adds a target which verifies that all of the project references and configurations are valid.
Creates the target used to build all of the references in the traversal project.
Adds a task which builds the @(ProjectReference) items.
Adds a traversal target which invokes a specified target on a single project. This creates targets called "Project", "Project:Rebuild", "Project:Clean", "Project:Publish" etc.
Retrieves a dictionary representing the global properties which should be transferred to a metaproject.
The traversal from which the global properties should be obtained.
A dictionary of global properties.
Figures out what the ToolsVersion should be for child projects (used when scanning
for dependencies)
Normally the active solution configuration/platform is determined when we build the solution
wrapper project, not when we create it. However, we need to know them to scan project references
for the right project configuration/platform. It's unlikely that references would be conditional,
but still possible and we want to get that case right.
Loads each MSBuild project in this solution and looks for its project-to-project references so that
we know what build order we should use when building the solution.
Adds a dependency to the project based on the specified guid string.
If the string is null or empty, no dependency is added and this is not considered an error.
Creates default Configuration and Platform values based on solution configurations present in the solution
Adds a new property group with contents of the given solution configuration to the project.
Creates the default Venus configuration property based on the selected solution configuration.
Unfortunately, Venus projects only expose one project configuration in the IDE (Debug) although
they allow building Debug and Release from command line. This means that if we wanted to use
the project configuration from the active solution configuration for Venus projects, we'd always
end up with Debug and there'd be no way to build the Release configuration. To work around this,
we use a special mechanism for choosing ASP.NET project configuration: we set it to Release if
we're building a Release solution configuration, and to Debug if we're building a Debug solution
configuration. The property is also settable from the command line, in which case it takes
precedence over this algorithm.
Adds solution related build event macros and other global properties to the wrapper project
Special hack for web projects. It can happen that there is no Release configuration for solutions
containing web projects, yet we still want to be able to build the Release configuration for
those projects. Since the ASP.NET project configuration defaults to the solution configuration,
we allow Release even if it doesn't actually exist in the solution.
Adds the initial target to the solution wrapper project, necessary for a few message/error tags
Adds the target which validates that the solution configuration specified by the user is supported.
Adds the target which validates that the tools version is supported.
Adds the target to fetch solution configuration contents for given configuration|platform combo.
Abstract base class for MSBuild construction object model elements.
Parent container object.
Condition value cached for performance
Constructor called by ProjectRootElement only.
XmlElement is set directly after construction.
Should be protected+internal.
External projects support
Constructor called by derived classes, except from ProjectRootElement.
Parameters may not be null, except parent.
Allows data (for example, item metadata) to be represented as an attribute on the parent element instead of as a child element.
If this is true, then the will still be used to hold the data for this (pseudo) ProjectElement, but
it will not be added to the Xml tree.
Gets or sets the Condition value.
It will return empty string IFF a condition attribute is legal but it’s not present or has no value.
It will return null IFF a Condition attribute is illegal on that element.
Removes the attribute if the value to set is empty.
It is possible for derived classes to throw an if setting the condition is
not applicable for those elements.
For the "ProjectExtensions" element, the getter returns null and the setter
throws an exception for any value.
Gets or sets the Label value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Null if this is a ProjectRootElement.
Null if this has not been attached to a parent yet.
Parent should only be set by ProjectElementContainer.
All parent elements of this element, going up to the ProjectRootElement.
None if this itself is a ProjectRootElement.
None if this itself has not been attached to a parent yet.
Previous sibling element.
May be null.
Setter should ideally be "protected AND internal"
Next sibling element.
May be null.
Setter should ideally be "protected AND internal"
ProjectRootElement (possibly imported) that contains this Xml.
Cannot be null.
Setter ideally would be "protected and internal"
There are some tricks here in order to save the space of a field: there are a lot of these objects.
Location of the "Condition" attribute on this element, if any.
If there is no such attribute, returns null.
Location of the "Label" attribute on this element, if any.
If there is no such attribute, returns null;
Location of the corresponding Xml element.
May not be correct if file is not saved, or
file has been edited since it was last saved.
In the case of an unsaved edit, the location only
contains the path to the file that the element originates from.
Gets the XmlElement associated with this project element.
The setter is used when adding new elements.
Never null except during load or creation.
This should be protected, but "protected internal" means "OR" not "AND",
so this is not possible.
Gets the XmlDocument associated with this project element.
Never null except during load or creation.
This should be protected, but "protected internal" means "OR" not "AND",
so this is not possible.
Returns a shallow clone of this project element.
The cloned element.
Applies properties from the specified type to this instance.
The element to act as a template to copy from.
Hook for subclasses to specify whether the given should be cloned or not
Called only by the parser to tell the ProjectRootElement its backing XmlElement and its own parent project (itself)
This can't be done during construction, as it hasn't loaded the document at that point and it doesn't have a 'this' pointer either.
Called by ProjectElementContainer to clear the parent when
removing an element from its parent.
Called by a DERIVED CLASS to indicate its XmlElement has changed.
This normally shouldn't happen, so it's broken out into an explicit method.
An example of when it has to happen is when an item's type is changed.
We trust the caller to have fixed up the XmlDocument properly.
We ASSUME that attributes were copied verbatim. If this is not the case,
any cached attribute values would have to be cleared.
If the new element is actually the existing element, does nothing, and does
not mark the project dirty.
This should be protected, but "protected internal" means "OR" not "AND",
so this is not possible.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Marks this element as dirty.
The default implementation simply marks the parent as dirty.
If there is no parent, because the element has not been parented, do nothing. The parent
will be dirtied when the element is added.
Accepts a reason for debugging purposes only, and optional reason parameter.
Should ideally be protected+internal.
Called after a new parent is set. Parent may be null.
By default does nothing.
Returns a shallow clone of this project element.
The factory to use for creating the new instance.
The cloned element.
Returns a new instance of this same type.
Any properties that cannot be set after creation should be set to copies of values
as set for this instance.
The factory to use for creating the new instance.
Special derived variation of ProjectElementContainer used to wrap a ProjectRootElement.
This is part of a trick used in ProjectElement to avoid using a separate field for the containing PRE.
Constructor
Wrapped ProjectRootElement
Dummy required implementation
A container for project elements
External projects support
Constructor called by ProjectRootElement only.
XmlElement is set directly after construction.
Should ideally be protected+internal.
Constructor called by derived classes, except from ProjectRootElement.
Parameters may not be null, except parent.
Should ideally be protected+internal.
Get an enumerator over all children, gotten recursively.
Walks the children in a depth-first manner.
Get enumerable over all the children
Get enumerable over all the children, starting from the last
Number of children of any kind
First child, if any, otherwise null.
Cannot be set directly; use PrependChild().
Last child, if any, otherwise null.
Cannot be set directly; use AppendChild().
Insert the child after the reference child.
Reference child if provided must be parented by this element.
Reference child may be null, in which case this is equivalent to PrependChild(child).
Throws if the parent is not itself parented.
Throws if the reference node does not have this node as its parent.
Throws if the node to add is already parented.
Throws if the node to add was created from a different project than this node.
Semantics are those of XmlNode.InsertAfterChild.
Insert the child before the reference child.
Reference child if provided must be parented by this element.
Reference child may be null, in which case this is equivalent to AppendChild(child).
Throws if the parent is not itself parented.
Throws if the reference node does not have this node as its parent.
Throws if the node to add is already parented.
Throws if the node to add was created from a different project than this node.
Semantics are those of XmlNode.InsertBeforeChild.
Inserts the provided element as the last child.
Throws if the parent is not itself parented.
Throws if the node to add is already parented.
Throws if the node to add was created from a different project than this node.
Inserts the provided element as the first child.
Throws if the parent is not itself parented.
Throws if the node to add is already parented.
Throws if the node to add was created from a different project than this node.
Removes the specified child.
Throws if the child is not currently parented by this object.
This is O(1).
May be safely called during enumeration of the children.
This is actually safe to call during enumeration of children, because it
doesn't bother to clear the child's NextSibling (or PreviousSibling) pointers.
To determine whether a child is unattached, check whether its parent is null,
or whether its NextSibling and PreviousSibling point back at it.
DO NOT BREAK THIS VERY USEFUL SAFETY CONTRACT.
Remove all the children, if any.
It is safe to modify the children in this way
during enumeration. See RemoveChild.
Applies properties from the specified type to this instance.
The element to act as a template to copy from.
Appends the provided child.
Does not dirty the project, does not add an element, does not set the child's parent,
and does not check the parent's future siblings and parent are acceptable.
Called during project load, when the child can be expected to
already have a parent and its element is already connected to the
parent's element.
All that remains is to set FirstChild/LastChild and fix up the linked list.
Returns a clone of this project element and all its children.
The factory to use for creating the new instance.
The parent to append the cloned element to as a child.
The cloned element.
If child "element" is actually represented as an attribute, update the value in the corresponding Xml attribute
A child element which might be represented as an attribute
Adds a ProjectElement to the Xml tree
A child to add to the Xml tree, which has already been added to the ProjectElement tree
The MSBuild construction APIs keep a tree of ProjectElements and a parallel Xml tree which consists of
objects from System.Xml. This is a helper method which adds an XmlElement or Xml attribute to the Xml
tree after the corresponding ProjectElement has been added to the construction API tree, and fixes up
whitespace as necessary.
Sets the first child in this container
Common verification for insertion of an element.
Reference may be null.
Verifies that the provided element isn't this element or a parent of it.
If it is, throws InvalidOperationException.
Recurses into the provided container (such as a choose) and finds all child elements, even if nested.
Result does NOT include the element passed in.
The caller could filter these.
Enumerable over a series of sibling ProjectElement objects
The enumerator
Constructor allowing reverse enumeration
Get enumerator
Get non generic enumerator
Enumerator over a series of sibling ProjectElement objects
First element
Whether enumeration should go forwards or backwards.
If backwards, the "initial" will be the first returned, then each previous
node in turn.
Constructor taking the first element
Current element
Returns null if MoveNext() hasn't been called
Current element.
Throws if MoveNext() hasn't been called
Dispose. Do nothing.
Moves to the next item if any, otherwise returns false
Return to start
Initializes a ProjectImportElement instance.
External projects support
Initialize a parented ProjectImportElement
Initialize an unparented ProjectImportElement
Gets or sets the Project value.
Location of the project attribute
Gets or sets the SDK that contains the import.
Gets or sets the version associated with this SDK import
Gets or sets the minimum SDK version required by this import.
Location of the Sdk attribute
Gets the of the import. This indicates if the import was implicitly
added because of the attribute and the location where the project was
imported.
If the import is an implicit one ( != None) then this element points
to the original element which generated this implicit import.
if applicable to this import element.
Creates an unparented ProjectImportElement, wrapping an unparented XmlElement.
Validates the project value.
Caller should then ensure the element is added to a parent
Creates an implicit ProjectImportElement as if it was in the project.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Helper method to update the property if necessary (update only when changed).
True if the property was updated, otherwise false (no update necessary).
ProjectImportGroupElement represents the ImportGroup element in the MSBuild project.
External projects support
Initialize a parented ProjectImportGroupElement
Initialize an unparented ProjectImportGroupElement
Get any contained properties.
Convenience method that picks a location based on a heuristic:
Adds a new import after the last import in this import group.
Creates an unparented ProjectImportGroupElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectItemDefinitionGroupElement represents the ItemGroup element in the MSBuild project.
External projects support
Initialize a parented ProjectItemDefinitionGroupElement
Initialize an unparented ProjectItemDefinitionGroupElement
Get a list of child item definitions.
Convenience method that picks a location based on a heuristic:
Adds a new item definition after the last child.
Creates an unparented ProjectItemDefinitionGroupElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectItemDefinitionElement class represents the Item Definition element in the MSBuild project.
External projects support
Initialize a ProjectItemDefinitionElement instance from a node read from a project file
Initialize a ProjectItemDefinitionElement instance from a node read from a project file
Gets the definition's type.
Get any child metadata definitions.
Convenience method to add a piece of metadata to this item definition.
Adds after any existing metadata. Does not modify any existing metadata.
Convenience method to add a piece of metadata to this item definition.
Adds after any existing metadata. Does not modify any existing metadata.
The name of the metadata to add
The value of the metadata to add
If true, then the metadata will be expressed as an attribute instead of a child element, for example
<Content CopyToOutputDirectory="PreserveNewest" />
Creates an unparented ProjectItemDefinitionElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Do not clone attributes which can be metadata. The corresponding expressed as attribute project elements are responsible for adding their attribute
ProjectItemGroupElement represents the ItemGroup element in the MSBuild project.
External projects support
True if it is known that no child items have wildcards in their
include. An optimization helping Project.AddItem.
Only reliable if it is true.
Initialize a parented ProjectItemGroupElement
Initialize an unparented ProjectItemGroupElement
Get any child items.
This is a live collection.
True if it is known that no child items have wildcards in their
include. An optimization helping Project.AddItem.
Only reliable if it is true.
ONLY TO BE CALLED by ProjectItemElement.
Should be protected+internal.
Convenience method that picks a location based on a heuristic:
Adds a new item ordered by include.
Convenience method that picks a location based on a heuristic:
Adds a new item ordered by include.
Metadata may be null, indicating no metadata.
Creates an unparented ProjectItemGroupElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to the XmlDocument in the appropriate location.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectItemElement class represents the Item element in the MSBuild project.
External projects support
Include value cached for performance
Exclude value cached for performance
Remove value cached for performance
MatchOnMetadata value cached for performance
Update value cached for performance
Whether the include value has wildcards,
cached for performance.
Initialize a parented ProjectItemElement instance
Initialize an unparented ProjectItemElement instance
Gets the item's type.
Gets or sets the Include value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty or null.
Gets or sets the Exclude value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty or null.
Gets or sets the Remove value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty or null.
Gets or sets the Update value.
Gets or sets the MatchOnMetadata value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty or null.
Gets or sets the MatchOnMetadataOptions value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty or null.
Gets or sets the KeepMetadata value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty or null.
Gets or sets the RemoveMetadata value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty or null.
Gets or sets the KeepDuplicates value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty or null.
Whether there are any child metadata elements
Get any child metadata.
Location of the include attribute
Location of the exclude attribute
Location of the remove attribute
Location of the update attribute
Location of the MatchOnMetadata attribute
Location of the MatchOnMetadataOptions attribute
Location of the keepMetadata attribute
Location of the removeMetadata attribute
Location of the keepDuplicates attribute
Whether the include value has wildcards,
cached for performance.
Internal helper to get the next ProjectItemElement sibling.
If there is none, returns null.
Convenience method to add a piece of metadata to this item.
Adds after any existing metadata. Does not modify any existing metadata.
Convenience method to add a piece of metadata to this item.
Adds after any existing metadata. Does not modify any existing metadata.
The name of the metadata to add
The value of the metadata to add
If true, then the metadata will be expressed as an attribute instead of a child element, for example
<Reference Include="Libary.dll" HintPath="..\lib\Library.dll" Private="True" />
Creates an unparented ProjectItemElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent.
Changes the item type.
The implementation has to actually replace the element to do this.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Overridden to update the parent's children-have-no-wildcards flag.
Do not clone attributes which can be metadata. The corresponding expressed as attribute project elements are responsible for adding their attribute
ProjectMetadataElement class represents a Metadata element in the MSBuild project.
External projects support
Initialize a parented ProjectMetadataElement
Initialize an unparented ProjectMetadataElement
Gets or sets the metadata's type.
Gets or sets whether this piece of metadata is expressed as an attribute.
If true, then the metadata will be expressed as an attribute instead of a child element, for example
<Reference Include="Libary.dll" HintPath="..\lib\Library.dll" Private="True" />
Gets or sets the unevaluated value.
Returns empty string if it is not present.
Creates an unparented ProjectMetadataElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent.
Changes the name.
The implementation has to actually replace the element to do this.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectUsingTaskElement represents the Import element in the MSBuild project.
External projects support
Initialize a parented ProjectOnErrorElement
Initialize an unparented ProjectOnErrorElement
Gets and sets the value of the ExecuteTargets attribute.
'Attribute' suffix is for clarity.
Location of the "ExecuteTargets" attribute on this element, if any.
If there is no such attribute, returns null;
Creates an unparented ProjectOnErrorElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectOtherwiseElement represents the Otherwise element in the MSBuild project.
External projects support
Initialize a parented ProjectOtherwiseElement
Initialize an unparented ProjectOtherwiseElement
Condition should never be set, but the getter returns null instead of throwing
because a nonexistent condition is implicitly true
Get an enumerator over any child item groups
Get an enumerator over any child property groups
Get an enumerator over any child chooses
This does not allow conditions, so it should not be called.
Creates an unparented ProjectOtherwiseElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectOutputElement represents the Output element in the MSBuild project.
External projects support
Initialize a parented ProjectOutputElement
Initialize an unparented ProjectOutputElement
Gets or sets the TaskParameter value.
Returns empty string if it is not present.
Whether this represents an output item (as opposed to an output property)
Whether this represents an output property (as opposed to an output item)
Gets or sets the ItemType value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Unfortunately the attribute name chosen in Whidbey was "ItemName" not ItemType.
Gets or sets the PropertyName value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Location of the task parameter attribute
Location of the property name attribute, if any
Location of the item type attribute, if any
Creates an unparented ProjectOutputElement, wrapping an unparented XmlElement.
Validates the parameters.
Exactly one of item name and property name must have a value.
Caller should then ensure the element is added to a parent
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectExtensionsElement represents the ProjectExtensions element in the MSBuild project.
ProjectExtensions can contain arbitrary XML content.
The ProjectExtensions element is deprecated and provided only for backward compatibility.
Use a property instead. Properties can also contain XML content.
External projects support
Initialize a parented ProjectExtensionsElement instance
Initialize an unparented ProjectExtensionsElement instance
Condition should never be set, but the getter returns null instead of throwing
because a nonexistent condition is implicitly true
Gets and sets the raw XML content
This does not allow conditions, so it should not be called.
Get or set the content of the first sub-element
with the provided name.
Creates a ProjectExtensionsElement parented by a project
Creates an unparented ProjectExtensionsElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectPropertyGroupElement represents the PropertyGroup element in the MSBuild project.
External projects support
Initialize a parented ProjectPropertyGroupElement
Initialize an unparented ProjectPropertyGroupElement
Get any contained properties.
Get any contained properties.
Convenience method that picks a location based on a heuristic:
Adds a new property after the last property in this property group.
Convenience method that picks a location based on a heuristic:
If there is an existing property with the same name and no condition,
updates its value. Otherwise it adds a new property after the last property.
Creates an unparented ProjectPropertyGroupElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectPropertyElement class represents the Property element in the MSBuild project.
We do not need to use or set the PropertyType enumeration in the CM.
The CM does not know about Environment or Global properties, and does not create Output properties.
We can just verify that we haven't read a PropertyType.Reserved property ourselves.
So the CM only represents Normal properties.
External projects support
Initialize a parented ProjectPropertyElement
Initialize an unparented ProjectPropertyElement
Gets or sets the property name.
Gets or sets the unevaluated value.
Returns empty string if it is not present.
Creates an unparented ProjectPropertyElement, wrapping an unparented XmlElement.
Validates name.
Caller should then ensure the element is added to the XmlDocument in the appropriate location.
Changes the name.
The implementation has to actually replace the element to do this.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectTargetElement represents the Target element in the MSBuild project.
External projects support
Target name cached for performance
Initialize a parented ProjectTargetElement
Initialize an unparented ProjectTargetElement
Get an enumerator over any child item groups
Get an enumerator over any child property groups
Get an enumerator over any child tasks
Get an enumerator over any child onerrors
Gets and sets the name of the target element.
Gets or sets the Inputs value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Gets or sets the Outputs value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Gets or sets the TrimDuplicateOutputs value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Gets or sets the DependsOnTargets value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Gets or sets the BeforeTargets value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Gets or sets the AfterTargets value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Gets or sets the Returns value.
Returns null if the attribute is not present -- empty string is an allowable
value for both getting and setting.
Removes the attribute only if the value is set to null.
Location of the Name attribute
Location of the Inputs attribute
Location of the Outputs attribute
Location of the TrimDuplicateOutputs attribute
Location of the DependsOnTargets attribute
Location of the BeforeTargets attribute
Location of the Returns attribute
Location of the AfterTargets attribute
A cache of the last instance which was created from this target.
Convenience method that picks a location based on a heuristic:
Adds an item group after the last child.
Convenience method that picks a location based on a heuristic:
Adds a property group after the last child.
Convenience method to add a task to this target.
Adds after any existing task.
Creates an unparented ProjectTargetElement, wrapping an unparented XmlElement.
Validates the name.
Caller should then ensure the element is added to a parent.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Marks this element as dirty.
ProjectTaskElement represents the Task element in the MSBuild project.
External projects support
The parameters (excepting condition and continue-on-error)
Protection for the parameters cache
Initialize a parented ProjectTaskElement
Initialize an unparented ProjectTaskElement
Gets or sets the continue on error value.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Gets or sets the runtime value for the task.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Gets or sets the architecture value for the task.
Returns empty string if it is not present.
Removes the attribute if the value to set is empty.
Gets the task name
Gets any output children.
Enumerable over the unevaluated parameters on the task.
Attributes with their own properties, such as ContinueOnError, are not included in this collection.
If parameters differ only by case only the last one will be returned. MSBuild uses only this one.
Hosts can still remove the other parameters by using RemoveAllParameters().
Enumerable over the locations of parameters on the task.
Condition and ContinueOnError, which have their own properties, are not included in this collection.
If parameters differ only by case only the last one will be returned. MSBuild uses only this one.
Hosts can still remove the other parameters by using RemoveAllParameters().
Location of the "ContinueOnError" attribute on this element, if any.
If there is no such attribute, returns null;
Location of the "MSBuildRuntime" attribute on this element, if any.
If there is no such attribute, returns null;
Location of the "MSBuildArchitecture" attribute on this element, if any.
If there is no such attribute, returns null;
Retrieves a copy of the parameters as used during evaluation.
Convenience method to add an Output Item to this task.
Adds after the last child.
Convenience method to add a conditioned Output Item to this task.
Adds after the last child.
Convenience method to add an Output Property to this task.
Adds after the last child.
Convenience method to add a conditioned Output Property to this task.
Adds after the last child.
Gets the value of the parameter with the specified name,
or empty string if it is not present.
Adds (or modifies the value of) a parameter on this task
Removes any parameter on this task with the specified name.
If there is no such parameter, does nothing.
Removes all parameters from the task.
Does not remove any "special" parameters: ContinueOnError, Condition, etc.
Creates an unparented ProjectTaskElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to the XmlDocument in the appropriate location.
Any legal XML element name is allowed. We can't easily verify if the name is a legal XML element name,
so this will specifically throw XmlException if it isn't.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Initialize parameters cache.
Must be called within the lock.
ProjectUsingTaskElement represents the Import element in the MSBuild project.
External projects support
Initialize a parented ProjectUsingTaskElement
Initialize an unparented ProjectUsingTaskElement
Gets the value of the AssemblyFile attribute.
Returns empty string if it is not present.
Gets and sets the value of the AssemblyName attribute.
Returns empty string if it is not present.
Gets and sets the value of the TaskName attribute.
Gets and sets the value of the TaskFactory attribute.
Gets and sets the value of the Runtime attribute.
Gets and sets the value of the Architecture attribute.
Get any contained TaskElement.
Get any contained ParameterGroup.
Location of the task name attribute
Location of the assembly file attribute, if any
Location of the assembly name attribute, if any
Location of the Runtime attribute, if any
Location of the Architecture attribute, if any
Location of the TaskFactory attribute, if any
Convenience method that picks a location based on a heuristic:
Adds a new ParameterGroup to the using task to the end of the using task element
Convenience method that picks a location based on a heuristic:
Adds a new TaskBody to the using task to the end of the using task element
Creates an unparented ProjectUsingTaskElement, wrapping an unparented XmlElement.
Validates the parameters.
Exactly one of assembly file and assembly name must have a value.
Caller should then ensure the element is added to a parent
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Event handler for the event fired after this project file is named or renamed.
If the project file has not previously had a name, oldFullPath is null.
ProjectRootElement class represents an MSBuild project, an MSBuild targets file or any other file that conforms to MSBuild
project file schema.
This class and its related classes allow a complete MSBuild project or targets file to be read and written.
Comments and whitespace cannot be edited through this model at present.
Each project root element is associated with exactly one ProjectCollection. This allows the owner of that project collection
to control its lifetime and not be surprised by edits via another project collection.
Constants for default (empty) project file.
The singleton delegate that loads projects into the ProjectRootElement
Used to determine if a file is an empty XML file if it ONLY contains an XML declaration like <?xml version="1.0" encoding="utf-8"?>.
The default encoding to use / assume for a new project.
A global counter used to ensure each project version is distinct from every other.
This number is static so that it is unique across the appdomain. That is so that a host
can know when a ProjectRootElement has been unloaded (perhaps after modification) and
reloaded -- the version won't reset to '0'.
Version number of this object that was last saved to disk, or last loaded from disk.
Used to figure whether this object is dirty for saving.
Saving to or loading from a provided stream reader does not modify this value, only saving to or loading from disk.
The actual value is meaningless (since the counter is shared with all projects) --
it should only be compared to a stored value.
Immediately after loading from disk, this has the same value as version.
The encoding of the project that was (if applicable) loaded off disk, and that will be used to save the project.
Defaults to UTF8 for new projects.
XML namespace specified and used by this project file. If a namespace was not specified in the project file, this
value will be string.Empty.
The project file's location. It can be null if the project is not directly loaded from a file.
The project file's full path, escaped.
The directory that the project is in.
Essential for evaluating relative paths.
If the project is not loaded from disk, returns the current-directory from
the time the project was loaded - this is the same behavior as Whidbey/Orcas.
The time that this object was last changed. If it hasn't
been changed since being loaded or created, its value is .
Stored as UTC as this is faster when there are a large number of rapid edits.
The last-write-time of the file that was read, when it was read.
This can be used to see whether the file has been changed on disk
by an external means.
Reason it was last marked dirty; unlocalized, for debugging
Parameter to be formatted into the dirty reason
External projects support
Initialize a ProjectRootElement instance from a XmlReader.
May throw InvalidProjectFileException.
Leaves the project dirty, indicating there are unsaved changes.
Used to create a root element for solutions loaded by the 3.5 version of the solution wrapper.
Initialize an in-memory, empty ProjectRootElement instance that can be saved later.
Leaves the project dirty, indicating there are unsaved changes.
Initialize a ProjectRootElement instance over a project with the specified file path.
Assumes path is already normalized.
May throw InvalidProjectFileException.
Initialize a ProjectRootElement instance from an existing document.
May throw InvalidProjectFileException.
Leaves the project dirty, indicating there are unsaved changes.
Do not make public: we do not wish to expose particular XML API's.
Initialize a ProjectRootElement instance from an existing document.
Helper constructor for the > mehtod which needs to check if the document parses
Do not make public: we do not wish to expose particular XML API's.
Event raised after this project is renamed
Event raised after the project XML is changed.
Condition should never be set, but the getter returns null instead of throwing
because a nonexistent condition is implicitly true
Get a read-only collection of the child chooses, if any
The name is inconsistent to make it more understandable, per API review.
Get a read-only collection of the child item definition groups, if any
Get a read-only collection of the child item definitions, if any, in all item definition groups anywhere in the project file.
Get a read-only collection over the child item groups, if any.
Does not include any that may not be at the root, i.e. inside Choose elements.
Get a read-only collection of the child items, if any, in all item groups anywhere in the project file.
Not restricted to root item groups: traverses through Choose elements.
Get a read-only collection of the child import groups, if any.
Get a read-only collection of the child imports
Get a read-only collection of the child property groups, if any.
Does not include any that may not be at the root, i.e. inside Choose elements.
Geta read-only collection of the child properties, if any, in all property groups anywhere in the project file.
Not restricted to root property groups: traverses through Choose elements.
Get a read-only collection of the child targets
Get a read-only collection of the child usingtasks, if any
Get a read-only collection of the child item groups, if any, in reverse order
Get a read-only collection of the child item definition groups, if any, in reverse order
Get a read-only collection of the child import groups, if any, in reverse order
Get a read-only collection of the child property groups, if any, in reverse order
The directory that the project is in.
Essential for evaluating relative paths.
Is never null, even if the FullPath does not contain directory information.
If the project has not been loaded from disk and has not been given a path, returns the current-directory from
the time the project was loaded - this is the same behavior as Whidbey/Orcas.
If the project has not been loaded from disk but has been given a path, this path may not exist.
Full path to the project file.
If the project has not been loaded from disk and has not been given a path, returns null.
If the project has not been loaded from disk but has been given a path, this path may not exist.
Setter renames the project, if it already had a name.
Updates the ProjectRootElement cache.
Encoding that the project file is saved in, or will be saved in, unless
otherwise specified.
Returns the encoding from the Xml declaration if any, otherwise UTF8.
Gets or sets the value of DefaultTargets. If there is no DefaultTargets, returns empty string.
If the value is null or empty, removes the attribute.
Gets or sets the value of InitialTargets. If there is no InitialTargets, returns empty string.
If the value is null or empty, removes the attribute.
Gets or sets a semicolon delimited list of software development kits (SDK) that the project uses.
If a value is specified, an Sdk.props is simplicity imported at the top of the project and an
Sdk.targets is simplicity imported at the bottom from the specified SDK.
If the value is null or empty, removes the attribute.
Gets or sets the value of TreatAsLocalProperty. If there is no tag, returns empty string.
If the value being set is null or empty, removes the attribute.
Gets or sets the value of ToolsVersion. If there is no ToolsVersion, returns empty string.
If the value is null or empty, removes the attribute.
Gets the XML representing this project as a string.
Does not remove any dirty flag.
Useful for debugging.
Note that we do not expose an XmlDocument or any other specific XML API.
Whether the XML has been modified since it was last loaded or saved.
Whether the XML is preserving formatting or not.
Version number of this object.
A host can compare this to a stored version number to determine whether
a project's XML has changed, even if it has also been saved since.
The actual value is meaningless: an edit may increment it more than once,
so it should only be compared to a stored value.
Used by the Project class to figure whether changes have occurred that
it might want to pick up by reevaluation.
Used by the ProjectRootElement class to determine whether it needs to save.
This number is unique to the appdomain. That means that it is possible
to know when a ProjectRootElement has been unloaded (perhaps after modification) and
reloaded -- the version won't reset to '0'.
We're assuming we don't have over 2 billion edits.
The time that this object was last changed. If it hasn't
been changed since being loaded or created, its value is .
This is used by the VB/C# project system.
The last-write-time of the file that was read, when it was read.
This can be used to see whether the file has been changed on disk
by an external means.
This does not allow conditions, so it should not be called.
Location of the originating file itself, not any specific content within it.
If the file has not been given a name, returns an empty location.
This is a case where it is legitimate to "not have a location".
Location of the toolsversion attribute, if any
Location of the defaulttargets attribute, if any
Location of the initialtargets attribute, if any
Location of the Sdk attribute, if any
Location of the TreatAsLocalProperty attribute, if any
Has the project root element been explicitly loaded for a build or has it been implicitly loaded
as part of building another project.
Internal code that wants to set this to true should call .
The setter is private to make it more difficult to downgrade an existing PRE to an implicitly loaded state, which should never happen.
Retrieves the root element cache with which this root element is associated.
Gets a value indicating whether this PRE is known by its containing collection.
Indicates whether there are any targets in this project
that use the "Returns" attribute. If so, then this project file
is automatically assumed to be "Returns-enabled", and the default behavior
for targets without Returns attributes changes from using the Outputs to
returning nothing by default.
Gets the ProjectExtensions child, if any, otherwise null.
Not public as we do not wish to encourage the use of ProjectExtensions.
Returns an unlocalized indication of how this file was last dirtied.
This is for debugging purposes only.
String formatting only occurs when retrieved.
Initialize an in-memory, empty ProjectRootElement instance that can be saved later.
Uses the global project collection.
Initialize an in-memory, empty ProjectRootElement instance that can be saved later using the specified .
Uses the global project collection.
Initialize an in-memory, empty ProjectRootElement instance that can be saved later.
Uses the specified project collection.
Initialize an in-memory, empty ProjectRootElement instance that can be saved later using the specified and .
Initialize an in-memory, empty ProjectRootElement instance that can be saved later.
Uses the global project collection.
Initialize an in-memory, empty ProjectRootElement instance that can be saved later using the specified path and .
Uses the global project collection.
Initialize an in-memory, empty ProjectRootElement instance that can be saved later.
Uses the specified project collection.
Initialize an in-memory, empty ProjectRootElement instance that can be saved later.
Uses the specified project collection.
Initialize a ProjectRootElement instance from an XmlReader.
Uses the global project collection.
May throw InvalidProjectFileException.
Initialize a ProjectRootElement instance from an XmlReader.
Uses the specified project collection.
May throw InvalidProjectFileException.
Initialize a ProjectRootElement instance from an XmlReader.
Uses the specified project collection.
May throw InvalidProjectFileException.
Initialize a ProjectRootElement instance by loading from the specified file path.
Uses the global project collection.
May throw InvalidProjectFileException.
Initialize a ProjectRootElement instance by loading from the specified file path.
Uses the specified project collection.
May throw InvalidProjectFileException.
Initialize a ProjectRootElement instance by loading from the specified file path.
Uses the specified project collection and preserves the formatting of the document if specified.
Returns the ProjectRootElement for the given path if it has been loaded, or null if it is not currently in memory.
Uses the global project collection.
The path of the ProjectRootElement, cannot be null.
The loaded ProjectRootElement, or null if it is not currently in memory.
It is possible for ProjectRootElements to be brought into memory and discarded due to memory pressure. Therefore
this method returning false does not indicate that it has never been loaded, only that it is not currently in memory.
Returns the ProjectRootElement for the given path if it has been loaded, or null if it is not currently in memory.
Uses the specified project collection.
The path of the ProjectRootElement, cannot be null.
The to load the project into.
The loaded ProjectRootElement, or null if it is not currently in memory.
It is possible for ProjectRootElements to be brought into memory and discarded due to memory pressure. Therefore
this method returning false does not indicate that it has never been loaded, only that it is not currently in memory.
Returns the ProjectRootElement for the given path if it has been loaded, or null if it is not currently in memory.
Uses the specified project collection.
The path of the ProjectRootElement, cannot be null.
The to load the project into.
The formatting to open with. Must match the formatting in the collection to succeed.
The loaded ProjectRootElement, or null if it is not currently in memory.
It is possible for ProjectRootElements to be brought into memory and discarded due to memory pressure. Therefore
this method returning false does not indicate that it has never been loaded, only that it is not currently in memory.
Convenience method that picks a location based on a heuristic:
If import groups exist, inserts into the last one without a condition on it.
Otherwise, creates an import at the end of the project.
Convenience method that picks a location based on a heuristic:
Creates an import group at the end of the project.
Convenience method that picks a location based on a heuristic:
Finds item group with no condition with at least one item of same type, or else adds a new item group;
adds the item to that item group with items of the same type, ordered by include.
Per the previous implementation, it actually finds the last suitable item group, not the first.
Convenience method that picks a location based on a heuristic:
Finds first item group with no condition with at least one item of same type, or else an empty item group; or else adds a new item group;
adds the item to that item group with items of the same type, ordered by include.
Does not attempt to check whether the item matches an existing wildcard expression; that is only possible
in the evaluated world.
Per the previous implementation, it actually finds the last suitable item group, not the first.
Convenience method that picks a location based on a heuristic:
Adds an item group after the last existing item group, if any; otherwise
adds an item group after the last existing property group, if any; otherwise
adds a new item group at the end of the project.
Convenience method that picks a location based on a heuristic:
Finds first item definition group with no condition with at least one item definition of same item type, or else adds a new item definition group.
Convenience method that picks a location based on a heuristic:
Adds an item definition group after the last existing item definition group, if any; otherwise
adds an item definition group after the last existing property group, if any; otherwise
adds a new item definition group at the end of the project.
Convenience method that picks a location based on a heuristic:
Adds a new property group after the last existing property group, if any; otherwise
at the start of the project.
Convenience method that picks a location based on a heuristic.
Updates the last existing property with the specified name that has no condition on itself or its property group, if any.
Otherwise, adds a new property in the first property group without a condition, creating a property group if necessary after
the last existing property group, else at the start of the project.
Convenience method that picks a location based on a heuristic:
Creates a target at the end of the project.
Convenience method that picks a location based on a heuristic:
Creates a usingtask at the end of the project.
Exactly one of assemblyName or assemblyFile must be null.
Creates a choose.
Caller must add it to the location of choice in the project.
Creates an import.
Caller must add it to the location of choice in the project.
Creates an item node.
Caller must add it to the location of choice in the project.
Creates an item node with an include.
Caller must add it to the location of choice in the project.
Creates an item definition.
Caller must add it to the location of choice in the project.
Creates an item definition group.
Caller must add it to the location of choice in the project.
Creates an item group.
Caller must add it to the location of choice in the project.
Creates an import group.
Caller must add it to the location of choice in the project.
Creates a metadata node.
Caller must add it to the location of choice in the project.
Creates a metadata node.
Caller must add it to the location of choice in the project.
Creates an on error node.
Caller must add it to the location of choice in the project.
Creates an otherwise node.
Caller must add it to the location of choice in the project.
Creates an output node.
Exactly one of itemType and propertyName must be specified.
Caller must add it to the location of choice in the project.
Creates a project extensions node.
Caller must add it to the location of choice in the project.
Creates a property group.
Caller must add it to the location of choice in the project.
Creates a property.
Caller must add it to the location of choice in the project.
Creates a target.
Caller must add it to the location of choice in this project.
Creates a task.
Caller must add it to the location of choice in this project.
Creates a using task.
Caller must add it to the location of choice in the project.
Exactly one of assembly file and assembly name must be provided.
Creates a using task.
Caller must add it to the location of choice in the project.
Exactly one of assembly file and assembly name must be provided.
Also allows providing optional runtime and architecture specifiers. Null is OK.
Creates a ParameterGroup for use in a using task.
Caller must add it to the location of choice in the project under a using task.
Creates a Parameter for use in a using ParameterGroup.
Caller must add it to the location of choice in the project under a using task.
Creates a Task element for use in a using task.
Caller must add it to the location of choice in the project under a using task.
Creates a when.
Caller must add it to the location of choice in this project.
Creates a project SDK element attached to this project.
Save the project to the file system, if dirty.
Uses the Encoding returned by the Encoding property.
Creates any necessary directories.
May throw IO-related exceptions.
Clears the dirty flag.
Save the project to the file system, if dirty.
Creates any necessary directories.
May throw IO-related exceptions.
Clears the dirty flag.
Save the project to the file system, if dirty or the path is different.
Creates any necessary directories.
May throw IO related exceptions.
Clears the Dirty flag.
Save the project to the file system, if dirty or the path is different.
Creates any necessary directories.
May throw IO related exceptions.
Clears the Dirty flag.
Save the project to the provided TextWriter, whether or not it is dirty.
Uses the encoding of the TextWriter.
Clears the Dirty flag.
Returns a clone of this project.
The cloned element.
Reload the existing project root element from its file.
An is thrown if the project root element is not associated with any file on disk.
See
Reload the existing project root element from the given path
An is thrown if the path does not exist.
See
Reload the existing project root element from the given
A reload operation completely replaces the state of this object. This operation marks the
object as dirty (see for side effects).
If the new state has invalid XML or MSBuild syntax, then this method throws an .
When this happens, the state of this object does not change.
Reloading from an XMLReader will retain the previous root element location (, , ).
Reader to read from
If set to false, the reload operation will discard any unsaved changes.
Otherwise, an is thrown when unsaved changes are present.
Whether the reload should preserve formatting or not. A null value causes the reload to reuse the existing value.
Initialize an in-memory, empty ProjectRootElement instance that can be saved later.
Uses the specified project root element cache.
Initialize a ProjectRootElement instance by loading from the specified file path.
Assumes path is already normalized.
Uses the specified project root element cache.
May throw InvalidProjectFileException.
Initialize a ProjectRootElement instance from an existing document.
Uses the global project collection.
May throw InvalidProjectFileException.
This is ultimately for unit testing.
Do not make public: we do not wish to expose particular XML API's.
Gets a ProjectRootElement representing an MSBuild file.
Path provided must be a canonicalized full path.
May throw InvalidProjectFileException or an IO-related exception.
Creates a XmlElement with the specified name in the document
containing this project.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Marks this project as dirty.
Typically called by child elements to indicate that they themselves have become dirty.
Accepts a reason for debugging purposes only, and optional reason parameter.
This is sealed because it is virtual and called in a constructor; by sealing it we
satisfy FXCop that nobody will override it to do something that would rely on
unconstructed state.
Should be protected+internal.
Bubbles a Project dirty notification up to the ProjectRootElementCacheBase and ultimately to the ProjectCollection.
The dirtied project.
Sets the property to true to indicate that this PRE
should not be removed from the cache until it is explicitly unloaded by some MSBuild client.
Creates and returns a list of nodes which are implicitly
referenced by the Project.
Current project
An containing details of the SDKs referenced by the project.
Determines if the specified file is an empty XML file meaning it has no contents, contains only whitespace, or
only an XML declaration. If the file does not exist, it is not considered empty.
The full path to a file to check.
true if the file is an empty XML file, otherwise false.
Returns a new instance of ProjectRootElement that is affiliated with the same ProjectRootElementCache.
The factory to use for creating the new instance.
Creates a new ProjectRootElement for a specific PRE cache
The path to the file to load.
The cache to load the PRE into.
Creates a ProjectRootElement representing a file, where the file may be a .sln instead of
an MSBuild format file.
Assumes path is already normalized.
If the file is in MSBuild format, may throw InvalidProjectFileException.
If the file is a solution, will throw an IO-related exception if the file cannot be read.
Constructor helper to load an XmlDocumentWithLocation from a path.
Assumes path is already normalized.
May throw InvalidProjectFileException.
Never returns null.
Does NOT add to the ProjectRootElementCache. Caller should add after verifying subsequent MSBuild parsing succeeds.
The full path to the document to load.
true to preserve the formatting of the document, otherwise false.
Whether to load the file in read-only mode.
Constructor helper to load an XmlDocumentWithLocation from an XmlReader.
May throw InvalidProjectFileException.
Never returns null.
Boost the appdomain-unique version counter for this object.
This is done when it is modified, and also when it is loaded.
ProjectChooseElement represents the Choose element in the MSBuild project.
Currently it does not allow a Condition.
External projects support
Initialize a parented ProjectChooseElement
Initialize an unparented ProjectChooseElement
Condition should never be set, but the getter returns null instead of throwing
because a nonexistent condition is implicitly true
Get the When children.
Will contain at least one entry.
Get any Otherwise child.
May be null.
This does not allow conditions, so it should not be called.
Creates an unparented ProjectChooseElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent
Sets the parent of this element if it is a valid parent,
otherwise throws.
ProjectWhenElement represents the When element in the MSBuild project.
External projects support
Initialize a parented ProjectWhenElement
Initialize an unparented ProjectWhenElement
Get an enumerator over any child chooses
Get an enumerator over any child item groups
Get an enumerator over any child property groups
Creates an unparented ProjectPropertyGroupElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
UsingTaskParameterGroupElement represents a ParameterGroup under the using task.
External projects support
Initialize a parented UsingTaskParameterGroupElement
Initialize an unparented UsingTaskParameterGroupElement
Condition should never be set, but the getter returns null instead of throwing
because a nonexistent condition is implicitly true
Get any contained parameters.
This does not allow conditions, so it should not be called.
Convenience method that picks a location based on a heuristic:
Convenience method that picks a location based on a heuristic:
Creates an unparented UsingTaskParameterGroupElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Verify the parent is a usingTaskElement and that the taskFactory attribute is set
UsingTaskParameterElement class represents the Parameter element in the MSBuild project.
External projects support
Initialize a parented UsingTaskParameterElement instance
Initialize an unparented UsingTaskParameterElement instance
Condition should never be set, but the getter returns null instead of throwing
because a nonexistent condition is implicitly true
Gets and sets the name of the parameter's name
Gets or sets the Type attribute returns "System.String" if not set.
If null or empty is set the attribute will be removed from the element.
Gets or sets the output attribute
Gets or sets the required attribute
This does not allow conditions, so it should not be called.
Location of the Type attribute.
If there is no such attribute, returns the location of the element,
in lieu of the default value it uses for the attribute.
Location of the Output attribute.
If there is no such attribute, returns the location of the element,
in lieu of the default value it uses for the attribute.
Location of the Required attribute.
If there is no such attribute, returns the location of the element,
in lieu of the default value it uses for the attribute.
Creates an unparented UsingTaskParameterElement, wrapping an unparented XmlElement.
Caller should then ensure the element is added to a parent.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
ProjectUsingTaskBodyElement class represents the Task element under the using task element in the MSBuild project.
External projects support
Initialize a parented ProjectUsingTaskBodyElement
Initialize an unparented ProjectUsingTaskBodyElement
Condition should never be set, but the getter returns null instead of throwing
because a nonexistent condition is implicitly true
Gets or sets the unevaluated value of the contents of the task xml
Returns empty string if it is not present.
Gets the value of the Evaluate attribute.
Returns true if it is not present.
This does not allow conditions, so it should not be called.
Location of the "Condition" attribute on this element, if any.
If there is no such attribute, returns the location of the element,
in lieu of the default value it uses for the attribute.
Creates an unparented ProjectUsingTaskBodyElement, wrapping an unparented XmlElement.
Validates name.
Caller should then ensure the element is added to the XmlDocument in the appropriate location.
Overridden to verify that the potential parent and siblings
are acceptable. Throws InvalidOperationException if they are not.
Verify the parent is a usingTaskElement and that the taskFactory attribute is set
This represents an entry for a solution configuration
Default separator between configuration and platform in configuration
full names
Constructor
The configuration part of this configuration - e.g. "Debug", "Release"
The platform part of this configuration - e.g. "Any CPU", "Win32"
The full name of this configuration - e.g. "Debug|Any CPU"
Given a configuration name and a platform name, compute the full name
of this configuration
This class represents an entry for a project configuration in a solution configuration.
Constructor
The configuration part of this configuration - e.g. "Debug", "Release"
The platform part of this configuration - e.g. "Any CPU", "Win32"
The full name of this configuration - e.g. "Debug|Any CPU"
True if this project configuration should be built as part of its parent solution configuration
This is a hacky method to remove the space in the "Any CPU" platform in project configurations.
The problem is that this platform is stored as "AnyCPU" in project files, but the project system
reports it as "Any CPU" to the solution configuration manager. Because of that all solution configurations
contain the version with a space in it, and when we try and give that name to actual projects,
they have no clue what we're talking about. We need to remove the space in project platforms so that
the platform name matches the one used in projects.
An enumeration defining the different types of projects we might find in an SLN.
Everything else besides the below well-known project types.
C#, VB, F#, and VJ# projects
Solution folders appear in the .sln file, but aren't buildable projects.
ASP.NET projects
Web Deployment (.wdproj) projects
Project inside an Enterprise Template project
A shared project represents a collection of shared files that is not buildable on its own.
This class represents a project (or SLN folder) that is read in from a solution file.
Characters that need to be cleansed from a project name.
Project names that need to be disambiguated when forming a target name
Character that will be used to replace 'unclean' ones.
The project configuration in given solution configuration
K: full solution configuration name (cfg + platform)
V: project configuration
This project's name
The path to this project file, relative to the solution location
Returns the absolute path for this project
The unique guid associated with this project, in "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" form
The guid, in "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" form, of this project's
parent project, if any.
List of guids, in "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" form, mapping to projects
that this project has a build order dependency on, as defined in the solution file.
Configurations for this project, keyed off the configuration's full name, e.g. "Debug|x86"
They contain only the project configurations from the solution file that fully matched (configuration and platform) against the solution configurations.
Extension of the project file, if any
This project's type.
Only applies to websites -- for other project types, references are
either specified as Dependencies above, or as ProjectReferences in the
project file, which the solution doesn't have insight into.
Add the guid of a referenced project to our dependencies list.
Set the requested project configuration.
Looks at the project file node and determines (roughly) if the project file is in the MSBuild format.
The results are cached in case this method is called multiple times.
Detailed error message in case we encounter critical problems reading the file
Find the unique name for this project, e.g. SolutionFolder\SubSolutionFolder\Project_Name
Gets the original project name with the parent project as it is declared in the solution file, e.g. SolutionFolder\SubSolutionFolder\Project.Name
Changes the unique name of the project.
Cleanse the project name, by replacing characters like '@', '$' with '_'
The name to be cleansed
string
If the unique project name provided collides with one of the standard Solution project
entry point targets (Build, Rebuild, Clean, Publish), then disambiguate it by prepending the string "Solution:"
The unique name for the project
string
Check a Project element for known invalid namespace definitions.
Project XML Element
True if the element contains known invalid namespace definitions
This class contains the functionality to parse a solution file and return a corresponding
MSBuild project file containing the projects and dependencies defined in the solution.
Constructor
This property returns the list of warnings that were generated during solution parsing
This property returns the list of comments that were generated during the solution parsing
This property returns the list of error codes for warnings/errors that were generated during solution parsing.
Returns the actual major version of the parsed solution file
Returns Visual Studio major version
Returns true if the solution contains any web projects
Returns true if the solution contains any .wdproj projects. Used to determine
whether we need to load up any projects to examine dependencies.
All projects in this solution, in the order they appeared in the solution file
The collection of projects in this solution, accessible by their guids as a
string in "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}" form
This is the read/write accessor for the solution file which we will parse. This
must be set before calling any other methods on this class.
For unit-testing only.
The list of all full solution configurations (configuration + platform) in this solution
This method takes a path to a solution file, parses the projects and project dependencies
in the solution file, and creates internal data structures representing the projects within
the SLN.
Returns "true" if it's a project that's expected to be buildable, or false if it's
not (e.g. a solution folder)
The project in the solution
Whether the project is expected to be buildable
Given a solution file, parses the header and returns the major version numbers of the solution file
and the visual studio.
Throws InvalidProjectFileException if the solution header is invalid, or if the version is less than
our minimum version.
Adds a configuration to this solution
Reads a line from the StreamReader, trimming leading and trailing whitespace.
This method takes a path to a solution file, parses the projects and project dependencies
in the solution file, and creates internal data structures representing the projects within
the SLN. Used for conversion, which means it allows situations that we refuse to actually build.
This method takes a path to a solution file, parses the projects and project dependencies
in the solution file, and creates internal data structures representing the projects within
the SLN.
Parses the SLN file represented by the StreamReader in this.reader, and populates internal
data structures based on the SLN file contents.
This method searches the first two lines of the solution file opened by the specified
StreamReader for the solution file header. An exception is thrown if it is not found.
The solution file header looks like this:
Microsoft Visual Studio Solution File, Format Version 9.00
This method parses the Visual Studio version in Dev 12 solution files
The version line looks like this:
VisualStudioVersion = 12.0.20311.0 VSPRO_PLATFORM
If such a line is found, the version is stored in this.currentVisualStudioVersion
This method extracts the whole part of the version number from the specified line
containing the solution file format header, and throws an exception if the version number
is outside of the valid range.
The solution file header looks like this:
Microsoft Visual Studio Solution File, Format Version 9.00
This method processes a "Project" section in the solution file opened by the specified
StreamReader, and returns a populated ProjectInSolution instance, if successful.
An exception is thrown if the solution file is invalid.
The format of the parts of a Project section that we care about is as follows:
Project("{Project type GUID}") = "Project name", "Relative path to project file", "{Project GUID}"
ProjectSection(ProjectDependencies) = postProject
{Parent project unique name} = {Parent project unique name}
...
EndProjectSection
EndProject
This method will parse a .etp project recursively and
add all the projects found to projects and projectsInOrder
ETP Project
Adds a given project to the project collections of this class
proj
Checks whether a given project has a .etp extension.
Validate relative path of a project
proj
Takes a property name / value that comes from the SLN file for a Venus project, and
stores it appropriately in our data structures.
Strips a single pair of leading/trailing double-quotes from a string.
Parse the first line of a Project section of a solution file. This line should look like:
Project("{Project type GUID}") = "Project name", "Relative path to project file", "{Project GUID}"
Read nested projects section.
This is required to find a unique name for each project's target
Read solution configuration section.
A sample section:
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
Read project configurations in solution configurations section.
A sample (incomplete) section:
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6185CC21-BE89-448A-B3C0-D1C27112E595}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6185CC21-BE89-448A-B3C0-D1C27112E595}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6185CC21-BE89-448A-B3C0-D1C27112E595}.Debug|Mixed Platforms.ActiveCfg = Release|Any CPU
{6185CC21-BE89-448A-B3C0-D1C27112E595}.Debug|Mixed Platforms.Build.0 = Release|Any CPU
{6185CC21-BE89-448A-B3C0-D1C27112E595}.Debug|Win32.ActiveCfg = Debug|Any CPU
{A6F99D27-47B9-4EA4-BFC9-25157CBDC281}.Release|Any CPU.ActiveCfg = Release|Win32
{A6F99D27-47B9-4EA4-BFC9-25157CBDC281}.Release|Mixed Platforms.ActiveCfg = Release|Win32
{A6F99D27-47B9-4EA4-BFC9-25157CBDC281}.Release|Mixed Platforms.Build.0 = Release|Win32
{A6F99D27-47B9-4EA4-BFC9-25157CBDC281}.Release|Win32.ActiveCfg = Release|Win32
{A6F99D27-47B9-4EA4-BFC9-25157CBDC281}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
An unprocessed hashtable of entries in this section
Read the project configuration information for every project in the solution, using pre-cached
solution section data.
Cached data from the project configuration section
Gets the default configuration name for this solution. Usually it's Debug, unless it's not present
in which case it's the first configuration name we find.
Gets the default platform name for this solution. Usually it's Mixed Platforms, unless it's not present
in which case it's the first platform name we find.
This method takes a string representing one of the project's unique names (guid), and
returns the corresponding "friendly" name for this project.
This method takes a string representing one of the project's unique names (guid), and
returns the corresponding relative path to this project.
The location of an XML node in a file.
Any editing of the project XML through the MSBuild API's will invalidate locations in that XML until the XML is reloaded.
This object is IMMUTABLE, so that it can be passed around arbitrarily.
DO NOT make these objects any larger. There are huge numbers of them and they are transmitted between nodes.
The singleton empty element location.
The file from which this particular element originated. It may
differ from the ProjectFile if, for instance, it was part of
an import or originated in a targets file.
If not known, returns empty string.
The line number where this element exists in its file.
The first line is numbered 1.
Zero indicates "unknown location".
The column number where this element exists in its file.
The first column is numbered 1.
Zero indicates "unknown location".
The location in a form suitable for replacement
into a message.
Example: "c:\foo\bar.csproj (12,34)"
Calling this creates and formats a new string.
PREFER TO PUT THE LOCATION INFORMATION AT THE START OF THE MESSAGE INSTEAD.
Only in rare cases should the location go within the message itself.
Gets the empty element location.
This is not to be used when something is "missing": that should have a null location.
It is to be used for the project location when the project has not been given a name.
In that case, it exists, but can't have a specific location.
Get reasonable hash code.
Override Equals so that identical
fields imply equal objects.
Location of element.
Writes the packet to the serializer.
Always send as ints, even if ushorts are being used: otherwise it'd
need a byte to discriminate and the savings would be microscopic.
Factory for serialization.
Custom factory is needed because this class is abstract and uses a factory pattern.
Constructor for when we only know the file and nothing else.
This is the case when we are creating a new item, for example, and it has
not been evaluated from some XML.
Constructor for the case where we have most or all information.
Numerical values must be 1-based, non-negative; 0 indicates unknown
File may be null, indicating the file was not loaded from disk.
In AG there are 600 locations that have a file but zero line and column.
In theory yet another derived class could be made for these to save 4 bytes each.
The location in a form suitable for replacement
into a message.
Example: "c:\foo\bar.csproj (12,34)"
Calling this creates and formats a new string.
PREFER TO PUT THE LOCATION INFORMATION AT THE START OF THE MESSAGE INSTEAD.
Only in rare cases should the location go within the message itself.
Rarer variation for when the line and column won't each fit in a ushort.
The source file.
The source line.
The source column.
Constructor for the case where we have most or all information.
Numerical values must be 1-based, non-negative; 0 indicates unknown
File may be null, indicating the file was not loaded from disk.
The file from which this particular element originated. It may
differ from the ProjectFile if, for instance, it was part of
an import or originated in a targets file.
If not known, returns empty string.
The line number where this element exists in its file.
The first line is numbered 1.
Zero indicates "unknown location".
The column number where this element exists in its file.
The first column is numbered 1.
Zero indicates "unknown location".
For when the line and column each fit in a short - under 65536
(almost always will: microsoft.common.targets is less than 5000 lines long)
When loading Australian Government, for example, there are over 31,000 ElementLocation
objects so this saves 4 bytes each = 123KB
A "very small" variation that used two bytes (or halves of a short) would fit about half of them
and save 4 more bytes each, but the CLR packs each field to 4 bytes, so it isn't actually any smaller.
The source file.
The source line.
The source column.
Constructor for the case where we have most or all information.
Numerical values must be 1-based, non-negative; 0 indicates unknown
File may be null or empty, indicating the file was not loaded from disk.
The file from which this particular element originated. It may
differ from the ProjectFile if, for instance, it was part of
an import or originated in a targets file.
If not known, returns empty string.
The line number where this element exists in its file.
The first line is numbered 1.
Zero indicates "unknown location".
The column number where this element exists in its file.
The first column is numbered 1.
Zero indicates "unknown location".
The location something in the registry
This object is IMMUTABLE, so that it can be passed around arbitrarily.
This is not public because the current implementation only provides correct data for unedited projects.
DO NOT make it public without considering a solution to this problem.
The location.
Constructor taking the registry location.
Private constructor for deserialization
Not relevant, returns empty string.
Not relevant, returns 0.
Not relevant, returns 0.
The location in a form suitable for replacement
into a message.
Reads or writes the packet to the serializer.
Factory for serialization.
Derivation of XmlAttribute to implement IXmlLineInfo
Line, column, file information
Constructor without location information
Constructor with location information
Returns the line number if available, else 0.
IXmlLineInfo member.
Returns the column number if available, else 0.
IXmlLineInfo member.
Provides an ElementLocation for this attribute.
Should have at least the file name if the containing project has been given a file name,
even if it wasn't loaded from disk, or has been edited since. That's because we set that
path on our XmlDocumentWithLocation wrapper class.
Whether location is available.
IXmlLineInfo member.
Improvement to XmlDocument that during load attaches location information to all elements and attributes.
We don't need a real XmlDocument, as we are careful not to expose Xml types in our public API.
XmlDocument has many members, and this can't substitute for all of them. Location finding probably won't work if
certain XmlDocument members are used. So for extra robustness, this could wrap an XmlDocument instead,
and expose the small number of members that the MSBuild code actually uses.
Used to cache strings used in attribute values and comments.
Used to cache tag names in loaded files.
Whether we can selectively load as read-only (eg just when in program files directory)
Reader we've hooked
Path to the file loaded, if any, otherwise null.
Easier to intercept and store than to derive it from the XmlDocument.BaseUri property.
Local cache of strings for attribute values and comments. Used for testing.
Whether we can expect to never save this file.
In such a case, we can discard as much as possible on load, like comments and whitespace.
Constructor
Constructor
Whether to load files read only
Not determined
Always load writeable
Always load read-only, to save memory
Load read only selectively, Eg., just when file names begin with "Microsoft."
Path to the file loaded if any, otherwise null.
If the XmlDocument hasn't been loaded from a file, we wouldn't have a full path.
However the project might actually have been given a path - it might even have been saved.
In order to allow created elements to be able to provide a location with at least
that path, the setter here should be called when the project is given a path.
It may be set to null.
Sets or gets the string cache used by this XmlDocument.
When a particular instance has not been set will use the global string cache. The ability
to use a particular instance is useful for tests.
Loads from an XmlReader, intercepting the reader.
This method is called within XmlDocument by all other
Load(..) overloads, and by LoadXml(..), so however the client loads XML,
we will grab the reader.
Grab the path to the file, for use in our location information.
Called during load, to add an element.
We create our own kind of element, that we can give location information to.
Called during load, to add an attribute.
We create our own kind of attribute, that we can give location information to.
Create a whitespace node.
Overridden to cache attribute values.
Create a whitespace node. The definition of "significant" whitespace is obscure
and does not include whitespace in text values in element content, which we always want to keep.
Overridden to cache attribute values.
Create a text node.
Overridden to cache attribute values.
Create a comment node.
Overridden in order to cache comment strings.
Override Save to verify file was not loaded as readonly
Override Save to verify file was not loaded as readonly
Override Save to verify file was not loaded as readonly
Override Save to verify file was not loaded as readonly
Override IsReadOnly property to correctly indicate the mode to callers
Reset state for unit tests that want to set the env var
Called when the XmlDocument is unloaded to remove this XML's
contribution to the string interning cache.
Does NOT zombie the ProjectRootElement or anything else.
Determine whether we should load this file read only.
We decide yes if it is in program files or the OS directory, and the file name starts with "microsoft", else no.
We are very selective because we don't want to load files read only that the host might want to save, nor
any files in which comments within property/metadata values might be significant - MSBuild does not discard those, normally.
Determine whether we would ever load read only
Throw if this was loaded read only
Derivation of XmlElement to implement IXmlLineInfo
It would be nice to add some helper overloads of base class members that
downcast their return values to XmlElement/AttributeWithLocation. However
C# doesn't currently allow covariance in method overloading, only on delegates.
The caller must bravely downcast.
Line, column, file information
Constructor without location information
Constructor with location information
Returns the line number if available, else 0.
IXmlLineInfo member.
Returns the column number if available, else 0.
IXmlLineInfo member.
Provides an ElementLocation for this element, using the path to the file containing
this element as the project file entry.
Element location may be incorrect, if it was not loaded from disk.
Does not return null.
Should have at least the file name if the containing project has been given a file name,
even if it wasn't loaded from disk, or has been edited since. That's because we set that
path on our XmlDocumentWithLocation wrapper class.
Whether location is available.
IXmlLineInfo member.
Returns the XmlAttribute with the specified name or null if a matching attribute was not found.
Overridden to convert the display of the element from open form (separate open and closed tags) to closed form
(single closed tag) if the last child is being removed. This is simply for tidiness of the project file.
For example, removing the only piece of metadata from an item will leave behind one tag instead of two.
Gets the location of any attribute on this element with the specified name.
If there is no such attribute, returns null.
XmlNameTable that is thread safe for concurrent users.
Fortunately the standard implementation has only four accessible members
and all of them are virtual so we can easily add locks.
Synchronization object.
Add a string to the table.
Add a string to the table, passed in as
an extent in a char array.
Get a string from the table.
Get a string from the table, passed in as
an extent in a char array.
Parses a project from raw XML into strongly typed objects
Maximum nesting level of Choose elements. No reasonable project needs more than this
Valid attribute list when only Condition and Label are valid
Valid attribute list for item
Valid attributes list for item which is case-insensitive.
Valid attributes on import element
Valid attributes on usingtask element
Valid attributes on target element
Valid attributes on error element
Valid attributes on output element
Valid attributes on UsingTaskParameter element
Valid attributes on UsingTaskTask element
The ProjectRootElement to parse into
The document to parse from
Whether a ProjectExtensions node has been encountered already.
It's not supposed to appear more than once.
Private constructor to give static semantics
Parses the document into the provided ProjectRootElement.
Throws InvalidProjectFileExceptions for syntax errors.
The code markers here used to be around the Project class constructor in the old code.
In the new code, that's not very interesting; we are repurposing to wrap parsing the XML.
Parses the project into the ProjectRootElement
Parse a ProjectPropertyGroupElement from the element
Parse a ProjectItemGroupElement
Parse a ProjectItemElement
Parse a ProjectMetadataElement
Parse a ProjectImportGroupElement
The XML element to parse
The parent .
A ProjectImportGroupElement derived from the XML element passed in
Parse a ProjectImportElement that is contained in an ImportGroup
Parse a UsingTaskParameterGroupElement from the element
Parse a ProjectUsingTaskElement
Parse a ProjectTargetElement
Parse a ProjectTaskElement
Parse a ProjectOutputElement
Parse a ProjectItemDefinitionGroupElement
Pasre a ProjectItemDefinitionElement
Parse a ProjectChooseElement
Parse a ProjectWhenElement
Parse a ProjectOtherwiseElement
Parse the children of a When or Otherwise
Parse a ProjectExtensionsElement
Parse a ProjectSdkElement
This class will cache string values for loaded Xml files.
Start off with a large size as there are very many strings in common scenarios and resizing is expensive.
Note that there is a single instance of this cache for the lifetime of the process (albeit cleared out on XML unload)
Australian Govt has about 3000 strings; a single VC project with all its various XML files has about 4000 strings.
Store interned strings, and also a ref count, one per document using them.
Store all the strings a document is using, so their ref count can be decremented.
Locking object for this shared cache
Public constructor.
Obtain the number of entries contained in the cache.
Add the given string to the cache or return the existing string if it is already
in the cache.
Constant time operation.
Find the matching string in the cache.
Constant time operation.
String to find in the cache.
Existing string in the cache, or null if it is not contained.
Indicates that a document's entries should be removed.
If document is unknown, does nothing.
Complexity proportional to the number of strings in the document,
if the document is anywhere in the cache, otherwise O(1).
Verifies that each string entry has only one instance in the system.
Enable the conditional if and while you make any modifications to the class, then disable as it is very slow.
Handle event that is fired when an entry in the project root element cache is removed
from its strong cache.
When an entry is removed from a project root element cache's strong cache, we will remove
its entries from our string cache. Otherwise the string cache ends up being the only one
holding references to the Xml documents that have already been dropped.
Represents an entry in the ProjectStringCache.
Can't be a struct because the copy-by-value and the ref counting don't go well together.
Cached string
Number of XmlDocuments where this string is included.
Constructor.
Caller must then do Increment().
Key to find it
Number of documents using this string
Get the cached string.
Indicates that this entry is included in the given document.
Callers must verify that we were not already adreffed for this document.
Removes a container for this entry.
Callers must verify that this was not already reffed and not subsequently dereffed.
Common constructor arguments.
Global properties to evaluate with.
Tools version to evaluate with
Sub-toolset version to explicitly evaluate the toolset with.
The the project is added to. Default is />
The to use for evaluation.
The to use for evaluation.
An exception representing the case where the build was aborted by request, as opposed to being
unceremoniously shut down due to another kind of error exception.
This is public because it may be returned in the Exceptions collection of a BuildResult.
If you add fields to this class, add a custom serialization constructor and override GetObjectData().
Constructs a standard BuildAbortedException.
Constructs a BuildAbortedException with an additional message attached.
Constructs a BuildAbortedException with an additional message attached and an inner exception.
Protected constructor used for (de)serialization.
If we ever add new members to this class, we'll need to update this.
Gets the error code (if any) associated with the exception message.
Error code string, or null.
ISerializable method which we must override since Exception implements this interface
If we ever add new members to this class, we'll need to update this.
An exception representing the case where a BuildRequest has caused a circular project dependency. This is used to
terminate the request builder which initiated the failure path.
If you add fields to this class, add a custom serialization constructor and override GetObjectData().
Constructs a standard BuildAbortedException.
Constructor for deserialization.
This exception is used to wrap an unhandled exception from a logger. This exception aborts the build, and it can only be
thrown by the MSBuild engine.
Default constructor.
This constructor only exists to satisfy .NET coding guidelines. Use the rich constructor instead.
Creates an instance of this exception using the specified error message.
This constructor only exists to satisfy .NET coding guidelines. Use the rich constructor instead.
Creates an instance of this exception using the specified error message and inner exception.
This constructor only exists to satisfy .NET coding guidelines. Use the rich constructor instead.
Creates an instance of this exception using rich error information.
Internal for unit testing
This is the only usable constructor.
Can be null.
Protected constructor used for (de)serialization.
If we ever add new members to this class, we'll need to update this.
ISerializable method which we must override since Exception implements this interface
If we ever add new members to this class, we'll need to update this.
Provide default values for optional members
Don't actually have anything to do in the method, but the method is required when implementing an optional field
Gets the details of the build event (if any) that was being logged.
The build event args, or null.
Gets the error code associated with this exception's message (not the inner exception).
The error code string.
Gets the F1-help keyword associated with this error, for the host IDE.
The keyword string.
True if the exception occurred during logger initialization
Throws an instance of this exception using rich error information.
Can be null.
This exception is thrown whenever there is a problem with the user's XML project file. The problem might be semantic or
syntactical. The latter would be of a type typically caught by XSD validation (if it was performed by the project writer).
Default constructor.
This constructor only exists to satisfy .NET coding guidelines. Use a rich constructor whenever possible.
Creates an instance of this exception using the specified error message.
This constructor only exists to satisfy .NET coding guidelines. Use a rich constructor whenever possible.
Creates an instance of this exception using the specified error message and inner exception.
This constructor only exists to satisfy .NET coding guidelines. Use a rich constructor whenever possible.
Creates an instance of this exception using the specified error message and inner invalid project file exception.
This is used in order to wrap and exception rather than rethrow it verbatim, which would reset the callstack.
The assumption is that all the metadata for the outer exception comes from the inner exception, eg., they have the same error code.
Protected constructor used for (de)serialization.
If we ever add new members to this class, we'll need to update this.
ISerializable method which we must override since Exception implements this interface
If we ever add new members to this class, we'll need to update this.
Creates an instance of this exception using rich error information.
This constructor is preferred over the basic constructors.
The invalid project file (can be empty string).
The invalid line number in the project (set to zero if not available).
The invalid column number in the project (set to zero if not available).
The end of a range of invalid lines in the project (set to zero if not available).
The end of a range of invalid columns in the project (set to zero if not available).
Error message for exception.
Error sub-category that describes the error (can be null).
The error code (can be null).
The F1-help keyword for the host IDE (can be null).
Creates an instance of this exception using rich error information.
This constructor is preferred over the basic constructors.
The invalid project file (can be empty string).
The invalid line number in the project (set to zero if not available).
The invalid column number in the project (set to zero if not available).
The end of a range of invalid lines in the project (set to zero if not available).
The end of a range of invalid columns in the project (set to zero if not available).
Error message for exception.
Error sub-category that describes the error (can be null).
The error code (can be null).
The F1-help keyword for the host IDE (can be null).
Any inner exception. May be null.
Gets the exception message including the affected project file (if any).
The complete message string.
Gets the exception message not including the project file.
The error message string only.
Gets the file (if any) associated with this exception.
This may be an imported file.
The name is poorly chosen as this may be a targets file,
but the name has shipped now.
Project filename/path string, or null.
Gets the invalid line number (if any) in the project.
The invalid line number, or zero.
Gets the invalid column number (if any) in the project.
The invalid column number, or zero.
Gets the last line number (if any) of a range of invalid lines in the project.
The last invalid line number, or zero.
Gets the last column number (if any) of a range of invalid columns in the project.
The last invalid column number, or zero.
Gets the error sub-category (if any) that describes the type of this error.
The sub-category string, or null.
Gets the error code (if any) associated with the exception message.
Error code string, or null.
Gets the F1-help keyword (if any) associated with this error, for the host IDE.
The keyword string, or null.
Whether the exception has already been logged. Allows the exception to be logged at the
most appropriate location, but continue to be propagated.
Exception subclass that ToolsetReaders should throw.
The MSBuild error code corresponding with this exception.
Basic constructor.
Basic constructor.
Basic constructor.
Basic constructor.
Constructor that takes an MSBuild error code
Constructor that takes an MSBuild error code
ISerializable method which we must override since Exception implements this interface
If we ever add new members to this class, we'll need to update this.
The MSBuild error code corresponding with this exception, or
null if none was specified.
Throws an InvalidToolsetDefinitionException.
PERF WARNING: calling a method that takes a variable number of arguments
is expensive, because memory is allocated for the array of arguments -- do
not call this method repeatedly in performance-critical scenarios
Throws an InvalidToolsetDefinitionException including a specified inner exception,
which may be interesting to hosts.
PERF WARNING: calling a method that takes a variable number of arguments
is expensive, because memory is allocated for the array of arguments -- do
not call this method repeatedly in performance-critical scenarios
Generic exception used to wrap exceptions thrown during Registry access.
Basic constructor.
Basic constructor.
Basic constructor.
Constructor that takes a string description of the registry
key or value causing the error.
Since this class implements Iserializable this constructor is required to be implemented.
Constructor that takes a string description of the registry
key or value causing the error.
A Composite glob
The direct children of this composite
Constructor
Children globs. Input gets shallow cloned
Constructor
Children globs. Input gets shallow cloned
Extensions for
Retrieve all the objects from the given composite.
A glob composite
A glob with gaps. The gaps are represented as other globs.
For example, to express a glob that matches all .cs files except the ones containing "foo" and the ones under bin directories, one can use:
new MSBuildGlobWithGaps(
MSBuildGlob.Parse("**/*.cs"), // matches all .cs files
new CompositeGlob( // a composite glob to combine all the gaps
MSBuildGlob.Parse("**/*foo*.cs"), // matches .cs files containing "foo"
MSBuildGlob.Parse("**/bin/**/*.cs") // matches .cs files under bin directories
)
)
The main glob used for globbing operations.
Glob which will be subtracted from the .
Constructor
The main glob
The gap glob
Constructor
The main glob
The gap glob
Represents a parsed MSBuild glob.
An MSBuild glob is composed of three parts:
- fixed directory part: "a/b/" in "a/b/**/*test*/**/*.cs"
- wildcard directory part: "**/*test*/**/" in "a/b/**/*test*/**/*.cs"
- file name part: "*.cs" in "a/b/**/*test*/**/*.cs"
The fixed directory part.
The wildcard directory part
The file name part
Whether the glob was parsed sucsesfully from a string.
Illegal glob strings contain:
- invalid path characters (other than the wildcard characters themselves)
- "..."
- ":"
In addition, the wildcard directory part:
- cannot contain ".."
- if ** is present it must appear alone between slashes
Similar to but also provides the match groups for the glob parts
Parse the given into a using a given
.
The root of the glob.
The fixed directory part of the glob and the match arguments ( and )
will get normalized against this root.
If empty, the current working directory is used.
Cannot be null, and cannot contain invalid path arguments.
The string to parse
See .
The glob root, if the glob is not fully qualified, will be the current working directory.
Return type of
Whether the argument was matched against the glob
The fixed directory part match
The wildcard directory part match
The file name part match
Exposes the globbing semantics of the MSBuild engine.
Matches the given against the glob.
Matching is path aware:
- slashes are normalized
- arguments representing relative paths are normalized against the glob's root.
For example, the glob **/*.cs does not match ../a.cs, since ../a.cs points outside of the glob root.
Returns false if contains invalid path or file characters>
The string to match. If the string represents a relative path, it will get normalized against the glob's root. Cannot be null.