SolutionTask Class

Summary

Compiles VS.NET solutions (or sets of projects), automatically determining project dependencies from inter-project references.
Assembly
NAnt.VSNet.dll
Namespace
NAnt.VSNet.Tasks
Interfaces
Base Types
graph BT Type-->Base0["Task"] click Base0 "/api/NAnt.Core/Task" Base0-->Base1["Element"] click Base1 "/api/NAnt.Core/Element" Base1-->Base2["Object"] Type-.->Interface0["IConditional"] click Interface0 "/api/NAnt.Core/IConditional" Type-.->Interface1["IPluginConsumer"] click Interface1 "/api/NAnt.Core.Extensibility/IPluginConsumer" Type["SolutionTask"] class Type type-node

Syntax

[Serializable()]
[TaskName("solution")]
[PluginConsumer(typeof(IProjectBuildProvider))]
[PluginConsumer(typeof(ISolutionBuildProvider))]
public class SolutionTask : Task, IConditional, IPluginConsumer

Examples

Compiles all of the projects in test.sln, in release mode, in the proper order.

<solution configuration="release" solutionfile="test.sln" />

Compiles all of the projects in projects.txt, in the proper order.

    <solution configuration="release">
    <projects>
        <includesfile name="projects.txt" />
   </projects>
</solution>

Compiles projects A, B and C, using the output of project X as a reference.

    <solution configuration="release">
    <projects>
        <include name="A\A.csproj" />
        <include name="B\b.vbproj" />
        <include name="C\c.csproj" />
    </projects>
    <referenceprojects>
        <include name="X\x.csproj" />
    </referenceprojects>
</solution>

Compiles all of the projects in the solution except for project A.

    <solution solutionfile="test.sln" configuration="release">
    <excludeprojects>
        <include name="A\A.csproj" />
    </excludeprojects>
</solution>

Compiles all of the projects in the solution mapping the specific project at http://localhost/A/A.csproj to c:\inetpub\wwwroot\A\A.csproj and any URLs under http://localhost/B/[remainder] to c:\other\B\[remainder]. This allows the build to work without WebDAV.

    <solution solutionfile="test.sln" configuration="release">
    <webmap>
        <map url="http://localhost/A/A.csproj" path="c:\inetpub\wwwroot\A\A.csproj" />
        <map url="http://localhost/B" path="c:\other\B" />
    </webmap>
</solution>

Compiles all of the projects in the solution placing compiled outputs in c:\temp.

<solution solutionfile="test.sln" configuration="release" outputdir="c:\temp" />

Remarks

This task support the following projects:

  • Visual Basic .NET
  • Visual C# .NET
  • Visual J# .NET
  • Visual C++ .NET
Right now, only Microsoft Visual Studio .NET 2002 and 2003 solutions and projects are supported. Support for .NET Compact Framework projects is also not available at this time.

The NAnt.VSNet.Tasks.SolutionTask also supports the model of referencing projects by their output filenames, rather than referencing them inside the solution. It will automatically detect the existence of a file reference and convert it to a project reference. For example, if project "A" references the file in the release output directory of project "B", the NAnt.VSNet.Tasks.SolutionTask will automatically convert this to a project dependency on project "B" and will reference the appropriate configuration output directory at the final build time (ie: reference the debug version of "B" if the solution is built as debug).

The NAnt.VSNet.Tasks.SolutionTask expects all project files to be valid XML files.

Resx Files

When building a project for a down-level target framework, special care should be given to resx files. Resx files (can) contain references to a specific version of CLR types, and as such are only upward compatible.

For example: if you want to be able to build a project both as a .NET 1.0 and .NET 1.1 assembly, the resx files should only contain references to .NET 1.0 CLR types. Failure to do this may result in a System.InvalidCastException failure at runtime on machines with only the .NET Framework 1.0 installed.

Attributes

Type Description
SerializableAttribute
TaskNameAttribute Indicates that class should be treated as a task.
PluginConsumerAttribute
PluginConsumerAttribute

Constructors

Name Summary
SolutionTask() Initializes a new instance of the NAnt.VSNet.Tasks.SolutionTask class.

Properties

Name Value Summary
AssemblyFolderList StringCollection
Gets the list of folders to scan for assembly references.
AssemblyFolders FileSet
Set of folders where references are searched when not found in path from project file (HintPath).
Configuration string
The name of the solution configuration to build.
CustomProperties ArrayList
Set of properties set at solution level. Builders for projects in solution may or may not use them.
CustomXmlProcessing bool
Gets a value indicating whether the element is performing additional processing using the NAnt.Core.Element.XmlNode that was used to initialize the element.
Inherited from Element
EnableWebDav bool
Allow the task to use WebDAV for retrieving/compiling the projects within solution. Use of NAnt.VSNet.Types.WebMap is preferred over WebDAV. The default is false.
ExcludeProjects FileSet
Fileset of projects to exclude.
FailOnError bool
Determines if task failure stops the build, or is just reported. The default is true.
Inherited from Task
IfDefined bool
If true then the task will be executed; otherwise, skipped. The default is true.
Inherited from Task
IncludeVSFolders bool
Includes Visual Studio search folders in reference search path. The default is true.
Location Location
Gets or sets the location in the build file where the element is defined.
Inherited from Element
LogPrefix string
The prefix used when sending messages to the log.
Inherited from Task
Name string
The name of the task.
Inherited from Task
NamespaceManager XmlNamespaceManager
Gets or sets the System.Xml.XmlNamespaceManager.
Inherited from Element
OutputDir DirectoryInfo
The directory where compiled targets will be placed. This overrides path settings contained in the solution/project.
Parent Object
Gets or sets the parent of the element.
Inherited from Element
Platform string
The name of platform to build the solution for.
Project Project
Gets or sets the NAnt.Core.Element.Project to which this element belongs.
Inherited from Element
Projects FileSet
The projects to build.
Properties PropertyDictionary
Gets the properties local to this NAnt.Core.Element and the NAnt.Core.Element.Project.
Inherited from Element
ReferenceProjects FileSet
The projects to scan, but not build.
SolutionConfig Configuration
Gets the solution configuration to build.
SolutionFile FileInfo
The name of the VS.NET solution file to build.
Threshold Level
Gets or sets the log threshold for this NAnt.Core.Task. By default the threshold of a task is NAnt.Core.Level.Debug, causing no messages to be filtered in the task itself.
Inherited from Task
UnlessDefined bool
Opposite of NAnt.Core.Task.IfDefined. If false then the task will be executed; otherwise, skipped. The default is false.
Inherited from Task
Verbose bool
Determines whether the task should report detailed build log messages. The default is false.
Inherited from Task
WebMaps WebMapCollection
WebMap of URL's to project references.
XmlNode XmlNode
Gets or sets the XML node of the element.
Inherited from Element

Methods

Name Value Summary
CopyTo(Element) void
Copies all instance data of the NAnt.Core.Element to a given NAnt.Core.Element.
Inherited from Element
Execute() void
Executes the task unless it is skipped.
Inherited from Task
ExecuteTask() void
Executes the task.
GetAttributeConfigurationNode(FrameworkInfo, string) XmlNode
Locates the XML node for the specified attribute in either the configuration section of the extension assembly or the.project.
Inherited from Task
GetAttributeConfigurationNode(XmlNode, FrameworkInfo, string) XmlNode
Inherited from Element
GetLocation() Location
Retrieves the location in the build file where the element is defined.
Inherited from Element
Initialize() void
Initializes the task.
Inherited from Task
Initialize(XmlNode) void
Performs default initialization.
Inherited from Element
InitializeBuildElement(Element, XmlNode, Element, Type) Element
Initializes the build element.
Inherited from Element
static
InitializeElement(XmlNode) void
Derived classes should override to this method to provide extra initialization and validation not covered by the base class.
Inherited from Element
InitializeTask(XmlNode) void
Initializes the task.
Inherited from Task
InitializeTaskConfiguration() void
Initializes the configuration of the task using configuration settings retrieved from the NAnt configuration file.
Inherited from Task
InitializeXml(XmlNode, PropertyDictionary, FrameworkInfo) void
Initializes all build attributes and child elements.
Inherited from Element
IsLogEnabledFor(Level) bool
Determines whether build output is enabled for the given NAnt.Core.Level.
Inherited from Task
Log(Level, string) void
Logs a message with the given priority.
Inherited from Task
Log(Level, string, Object[]) void
Logs a formatted message with the given priority.
Inherited from Task