C# Class NAnt.Core.Project

ファイルを表示 Open project: skolima/NAnt Class Usage Examples

Private Properties

Property Type Description
ConfigurePlatformProperties void
CreateCircularException BuildException
CtorHelper void
GetConfigurationNode System.Xml.XmlNode
GetFrameworks NAnt.Core.FrameworkInfo[]
InitializeProjectDocument void
LoadBuildFile System.Xml.XmlDocument
Project System
Project System
TopologicalTargetSort void
UpdateTargetFrameworkProperties void

Public Methods

Method Description
AttachBuildListeners ( BuildListenerCollection listeners ) : void

Attaches the specified build listeners to the Project.

The currently attached IBuildListener instances will be detached before the new IBuildListener instances are attached.

CreateDataTypeBase ( XmlNode elementNode ) : DataTypeBase
CreateDefaultLogger ( ) : void

Creates the default IBuildLogger and attaches it to the Project.

CreateTask ( XmlNode taskNode ) : NAnt.Core.Task

Creates a new from the given XmlNode.

CreateTask ( XmlNode taskNode, Target target ) : NAnt.Core.Task

Creates a new Task from the given XmlNode within a Target.

DetachBuildListeners ( ) : void

Detaches the currently attached IBuildListener instances from the Project.

Execute ( ) : void

Executes the default target.

No top level error handling is done. Any BuildException will be passed onto the caller.

Execute ( string targetName ) : void

Executes a specific target, and its dependencies.

Global tasks are not executed.

Execute ( string targetName, bool forceDependencies ) : void

Executes a specific target.

Global tasks are not executed.

ExpandProperties ( string input, Location location ) : string

Expands a string from known properties.

GetFullPath ( string path ) : string

Combines the specified path with the BaseDirectory of the Project to form a full path to file or directory.

GetLocation ( XmlNode node ) : Location

Returns the Location of the given node in an XML file loaded by NAnt.

The node must be from an XmlDocument that has been loaded by NAnt.

NAnt also does not process any of the following node types:

XmlNodeType.Whitespace XmlNodeType.EndElement XmlNodeType.ProcessingInstruction XmlNodeType.XmlDeclaration XmlNodeType.DocumentType

As a result, no location information is available for these nodes.

Indent ( ) : void

Increases the IndentationLevel of the Project.

Log ( Level messageLevel, string message ) : void

Writes a Project level message to the build log with the given Level.

Log ( Target target, Level messageLevel, string message ) : void

Writes a Target level message to the build log with the given Level.

Log ( NAnt.Core.Task task, Level messageLevel, string message ) : void

Writes a Task task level message to the build log with the given Level.

OnBuildFinished ( object sender, BuildEventArgs e ) : void

Dispatches a BuildFinished event to the build listeners for this Project.

OnBuildStarted ( object sender, BuildEventArgs e ) : void

Dispatches a BuildStarted event to the build listeners for this Project.

OnMessageLogged ( BuildEventArgs e ) : void

Dispatches a MessageLogged event to the build listeners for this Project.

OnTargetFinished ( object sender, BuildEventArgs e ) : void

Dispatches a TargetFinished event to the build listeners for this Project.

OnTargetStarted ( object sender, BuildEventArgs e ) : void

Dispatches a TargetStarted event to the build listeners for this Project.

OnTaskFinished ( object sender, BuildEventArgs e ) : void

Dispatches the TaskFinished event to the build listeners for this Project.

OnTaskStarted ( object sender, BuildEventArgs e ) : void

Dispatches a TaskStarted event to the build listeners for this Project.

Project ( XmlDocument doc, Level threshold, int indentLevel ) : System

Initializes a new Project class with the given document, message threshold and indentation level.

Project ( XmlDocument doc, Level threshold, int indentLevel, XmlNode configurationNode ) : System

Initializes a new Project class with the given document, message threshold and indentation level, and using the specified XmlNode to load internal configuration settings.

This constructor is useful for developers using NAnt as a class library.

Project ( string uriOrFilePath, Level threshold, int indentLevel ) : System

Initializes a new Project class with the given source, message threshold and indentation level.

If the source is a uri of form 'file:///path' then use the path part.

Project ( string uriOrFilePath, Level threshold, int indentLevel, XmlNode configurationNode ) : System

Initializes a new Project class with the given source, message threshold and indentation level, and using the specified XmlNode to load internal configuration settings.

If the source is a uri of form 'file:///path' then use the path part.

Run ( ) : bool

Executes the default target and wraps in error handling and time stamping.

TopologicalTargetSort ( string root, TargetCollection targets ) : TargetCollection

Topologically sorts a set of targets.

Unindent ( ) : void

Decreases the IndentationLevel of the Project.

Private Methods

Method Description
ConfigurePlatformProperties ( ) : void

Configures the platform properties for the current platform.

CreateCircularException ( string end, Stack stack ) : BuildException

Builds an appropriate exception detailing a specified circular dependency.

CtorHelper ( XmlDocument doc, Level threshold, int indentLevel, Optimizations optimization ) : void

Inits stuff:

TypeFactory: Calls Initialize and AddProject

Log.IndentSize set to 12

Project properties are initialized ("nant.* stuff set")

NAnt Props: nant.filename nant.version nant.location nant.project.name nant.project.buildfile (if doc has baseuri) nant.project.basedir nant.project.default = defaultTarget

GetConfigurationNode ( ) : XmlNode
GetFrameworks ( FrameworkTypes types ) : NAnt.Core.FrameworkInfo[]

Gets the list of supported frameworks filtered by the specified FrameworkTypes parameter.

InitializeProjectDocument ( XmlDocument doc ) : void

This method is only meant to be used by the Project class and T:NAnt.Core.Tasks.IncludeTask.

LoadBuildFile ( string uriOrFilePath ) : XmlDocument

Creates a new XmlDocument based on the project definition.

Project ( XmlDocument doc ) : System

Initializes a Project with Threshold set to Level.None, and IndentationLevel set to 0.

Optimized for framework initialization projects, by skipping automatic discovery of extension assemblies and framework configuration.

Project ( string uriOrFilePath, Project parent ) : System

Initializes a Project as subproject of the specified Project.

Optimized for framework initialization projects, by skipping automatic discovery of extension assemblies and framework configuration.

TopologicalTargetSort ( string root, TargetCollection targets, Hashtable state, Stack visiting, TargetCollection executeTargets ) : void

Performs a single step in a recursive depth-first-search traversal of the target dependency tree.

The current target is first set to the "visiting" state, and pushed onto the "visiting" stack.

An exception is then thrown if any child of the current node is in the visiting state, as that implies a circular dependency. The exception contains details of the cycle, using elements of the "visiting" stack.

If any child has not already been "visited", this method is called recursively on it.

The current target is then added to the ordered list of targets. Note that this is performed after the children have been visited in order to get the correct order. The current target is set to the "visited" state.

By the time this method returns, the ordered list contains the sequence of targets up to and including the current target.

UpdateTargetFrameworkProperties ( ) : void

Updates dependent properties when the TargetFramework is set.

Method Details

AttachBuildListeners() public method

Attaches the specified build listeners to the Project.
The currently attached IBuildListener instances will be detached before the new IBuildListener instances are attached.
public AttachBuildListeners ( BuildListenerCollection listeners ) : void
listeners BuildListenerCollection The instances to attach to the .
return void

CreateDataTypeBase() public method

public CreateDataTypeBase ( XmlNode elementNode ) : DataTypeBase
elementNode System.Xml.XmlNode
return DataTypeBase

CreateDefaultLogger() public method

Creates the default IBuildLogger and attaches it to the Project.
public CreateDefaultLogger ( ) : void
return void

CreateTask() public method

Creates a new from the given XmlNode.
public CreateTask ( XmlNode taskNode ) : NAnt.Core.Task
taskNode System.Xml.XmlNode The definition.
return NAnt.Core.Task

CreateTask() public method

Creates a new Task from the given XmlNode within a Target.
public CreateTask ( XmlNode taskNode, Target target ) : NAnt.Core.Task
taskNode System.Xml.XmlNode The definition.
target Target The owner .
return NAnt.Core.Task

DetachBuildListeners() public method

Detaches the currently attached IBuildListener instances from the Project.
public DetachBuildListeners ( ) : void
return void

Execute() public method

Executes the default target.
No top level error handling is done. Any BuildException will be passed onto the caller.
public Execute ( ) : void
return void

Execute() public method

Executes a specific target, and its dependencies.
Global tasks are not executed.
public Execute ( string targetName ) : void
targetName string The name of the target to execute.
return void

Execute() public method

Executes a specific target.
Global tasks are not executed.
public Execute ( string targetName, bool forceDependencies ) : void
targetName string The name of the target to execute.
forceDependencies bool Whether dependencies should be forced to execute
return void

ExpandProperties() public method

Expands a string from known properties.
public ExpandProperties ( string input, Location location ) : string
input string The with replacement tokens.
location Location The location in the build file. Used to throw more accurate exceptions.
return string

GetFullPath() public method

Combines the specified path with the BaseDirectory of the Project to form a full path to file or directory.
public GetFullPath ( string path ) : string
path string The relative or absolute path.
return string

GetLocation() public method

Returns the Location of the given node in an XML file loaded by NAnt.

The node must be from an XmlDocument that has been loaded by NAnt.

NAnt also does not process any of the following node types:

XmlNodeType.Whitespace XmlNodeType.EndElement XmlNodeType.ProcessingInstruction XmlNodeType.XmlDeclaration XmlNodeType.DocumentType

As a result, no location information is available for these nodes.

/// is from an XML file that was not loaded by NAnt. /// -or /// was not processed by NAnt (eg. an XML declaration). ///
public GetLocation ( XmlNode node ) : Location
node System.Xml.XmlNode The to get the for.
return Location

Indent() public method

Increases the IndentationLevel of the Project.
public Indent ( ) : void
return void

Log() public method

Writes a Project level message to the build log with the given Level.
public Log ( Level messageLevel, string message ) : void
messageLevel Level The to log at.
message string The message to log.
return void

Log() public method

Writes a Target level message to the build log with the given Level.
public Log ( Target target, Level messageLevel, string message ) : void
target Target The from which the message orignated.
messageLevel Level The level to log at.
message string The message to log.
return void

Log() public method

Writes a Task task level message to the build log with the given Level.
public Log ( NAnt.Core.Task task, Level messageLevel, string message ) : void
task NAnt.Core.Task The from which the message originated.
messageLevel Level The to log at.
message string The message to log.
return void

OnBuildFinished() public method

Dispatches a BuildFinished event to the build listeners for this Project.
public OnBuildFinished ( object sender, BuildEventArgs e ) : void
sender object The source of the event.
e BuildEventArgs A that contains the event data.
return void

OnBuildStarted() public method

Dispatches a BuildStarted event to the build listeners for this Project.
public OnBuildStarted ( object sender, BuildEventArgs e ) : void
sender object The source of the event.
e BuildEventArgs A that contains the event data.
return void

OnMessageLogged() public method

Dispatches a MessageLogged event to the build listeners for this Project.
public OnMessageLogged ( BuildEventArgs e ) : void
e BuildEventArgs A that contains the event data.
return void

OnTargetFinished() public method

Dispatches a TargetFinished event to the build listeners for this Project.
public OnTargetFinished ( object sender, BuildEventArgs e ) : void
sender object The source of the event.
e BuildEventArgs A that contains the event data.
return void

OnTargetStarted() public method

Dispatches a TargetStarted event to the build listeners for this Project.
public OnTargetStarted ( object sender, BuildEventArgs e ) : void
sender object The source of the event.
e BuildEventArgs A that contains the event data.
return void

OnTaskFinished() public method

Dispatches the TaskFinished event to the build listeners for this Project.
public OnTaskFinished ( object sender, BuildEventArgs e ) : void
sender object The source of the event.
e BuildEventArgs A that contains the event data.
return void

OnTaskStarted() public method

Dispatches a TaskStarted event to the build listeners for this Project.
public OnTaskStarted ( object sender, BuildEventArgs e ) : void
sender object The source of the event.
e BuildEventArgs A that contains the event data.
return void

Project() public method

Initializes a new Project class with the given document, message threshold and indentation level.
public Project ( XmlDocument doc, Level threshold, int indentLevel ) : System
doc System.Xml.XmlDocument Any valid build format will do.
threshold Level The message threshold.
indentLevel int The project indentation level.
return System

Project() public method

Initializes a new Project class with the given document, message threshold and indentation level, and using the specified XmlNode to load internal configuration settings.
This constructor is useful for developers using NAnt as a class library.
public Project ( XmlDocument doc, Level threshold, int indentLevel, XmlNode configurationNode ) : System
doc System.Xml.XmlDocument Any valid build format will do.
threshold Level The message threshold.
indentLevel int The project indentation level.
configurationNode System.Xml.XmlNode The NAnt should use to initialize configuration settings.
return System

Project() public method

Initializes a new Project class with the given source, message threshold and indentation level.
If the source is a uri of form 'file:///path' then use the path part.
public Project ( string uriOrFilePath, Level threshold, int indentLevel ) : System
uriOrFilePath string /// The full path to the build file. /// This can be of any form that accepts. ///
threshold Level The message threshold.
indentLevel int The project indentation level.
return System

Project() public method

Initializes a new Project class with the given source, message threshold and indentation level, and using the specified XmlNode to load internal configuration settings.
If the source is a uri of form 'file:///path' then use the path part.
is .
public Project ( string uriOrFilePath, Level threshold, int indentLevel, XmlNode configurationNode ) : System
uriOrFilePath string /// The full path to the build file. /// This can be of any form that accepts. ///
threshold Level The message threshold.
indentLevel int The project indentation level.
configurationNode System.Xml.XmlNode The NAnt should use to initialize configuration settings.
return System

Run() public method

Executes the default target and wraps in error handling and time stamping.
public Run ( ) : bool
return bool

TopologicalTargetSort() public method

Topologically sorts a set of targets.
There is a cyclic dependecy among the targets, or a named target does not exist.
public TopologicalTargetSort ( string root, TargetCollection targets ) : TargetCollection
root string The name of the root target. The sort is created in such a way that the sequence of targets up to the root target is the minimum possible such sequence. Must not be .
targets TargetCollection A collection of instances.
return TargetCollection

Unindent() public method

Decreases the IndentationLevel of the Project.
public Unindent ( ) : void
return void