Engine Class

Note: This API is now obsolete.

Represents the MSBuild engine.

System.Object
  Microsoft.Build.BuildEngine.Engine

Namespace:  Microsoft.Build.BuildEngine
Assembly:  Microsoft.Build.Engine (in Microsoft.Build.Engine.dll)

[ObsoleteAttribute("This class has been deprecated. Please use Microsoft.Build.Evaluation.ProjectCollection from the Microsoft.Build assembly instead.")]
public class Engine

The Engine type exposes the following members.

  NameDescription
Public methodEngine()Initializes a new instance of the Engine class.
Public methodEngine(BuildPropertyGroup)Initializes a new instance of the Engine class.
Public methodEngine(String) Obsolete. Initializes a new instance of the Engine class that has the specified BinPath.
Public methodEngine(ToolsetDefinitionLocations)Initializes a new instance of the Engine class.
Public methodEngine(BuildPropertyGroup, ToolsetDefinitionLocations)Initializes a new instance of the Engine class.
Public methodEngine(BuildPropertyGroup, ToolsetDefinitionLocations, Int32, String)Initializes a new instance of the Engine class.
Top

  NameDescription
Public propertyBinPath Obsolete. Gets or sets the path to MSBuild.exe.
Public propertyBuildEnabledGets or sets a value that indicates whether the building of targets in the project is enabled.
Public propertyDefaultToolsVersionThe default ToolsVersion of this build engine.
Public propertyStatic memberGlobalEngineGets the Engine that is global (shared) for this AppDomain.
Public propertyGlobalPropertiesGets or sets a collection of the global properties for the project.
Public propertyIsBuildingGets whether a project is currently being built.
Public propertyOnlyLogCriticalEventsGets or sets a value that indicates whether to only log critical events, such as warnings and errors, during the build.
Public propertyToolsetsSets or Gets the collection of Toolsets that are recognized by this build engine instance.
Public propertyStatic memberVersionGets the version of the Engine.
Top

  NameDescription
Public methodBuildProject(Project)Builds the specified Project.
Public methodBuildProject(Project, String)Builds the specified target of the specified Project.
Public methodBuildProject(Project, String[])Builds the specified targets of the specified Project.
Public methodBuildProject(Project, String[], IDictionary)Builds the specified targets of the specified Project, and returns the outputs of the targets.
Public methodBuildProject(Project, String[], IDictionary, BuildSettings)Builds the specified targets of the specified Project with the specified BuildSettings, and returns the outputs of the targets.
Public methodBuildProjectFile(String)Loads the specified project file and builds the project.
Public methodBuildProjectFile(String, String)Loads the specified project file and builds the specified target of the project.
Public methodBuildProjectFile(String, String[])Loads the specified project file and builds the specified targets of the project.
Public methodBuildProjectFile(String, String[], BuildPropertyGroup)Loads the specified project file and builds the specified targets of the project with the specified GlobalProperties, and returns the outputs of the targets.
Public methodBuildProjectFile(String, String[], BuildPropertyGroup, IDictionary)Loads the specified project file and builds the specified targets of the project with the specified GlobalProperties, and returns the outputs of the targets.
Public methodBuildProjectFile(String, String[], BuildPropertyGroup, IDictionary, BuildSettings)Loads the specified project file and builds the specified targets of the project with the specified BuildSettings and GlobalProperties, and returns the outputs of the targets.
Public methodBuildProjectFile(String, String[], BuildPropertyGroup, IDictionary, BuildSettings, String)Loads a project file from disk and builds the given targets.
Public methodBuildProjectFilesLoads a set of project files from disk and then builds the given list of targets for each project.
Public methodCreateNewProjectCreates an empty Project object that is associated with this Engine.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLoadedProjectReturns the Project object that is associated with the specified project file.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodRegisterDistributedLoggerRegisters distributed loggers with the build engine.
Public methodRegisterLoggerRegisters the specified logger with the Engine.
Public methodShutdownCalled when the host is finished with this build engine. It unregisters loggers and shuts down nodes.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Public methodUnloadAllProjectsRemoves all references to Project objects from the Engine.
Public methodUnloadProjectRemoves the reference to the specified Project from the Engine.
Public methodUnregisterAllLoggersUnregisters all loggers from the Engine.
Top

In a system of project-to-project dependencies, the Engine maintains the building projects, making it possible to avoid building the same target in the same project more than once in a given build.

The following example creates an Engine object and uses the BuildProjectFile method to build a project file. The FileLogger class is used to log information to a file.

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Build.BuildEngine;

namespace BuildAProjectCS
{
    class Program
    {       
        static void Main(string[] args)
        {
            // Instantiate a new Engine object
            Engine engine = new Engine();

            // Point to the path that contains the .NET Framework 2.0 CLR and tools
            engine.BinPath = @"c:\windows\microsoft.net\framework\v2.0.xxxxx";


            // Instantiate a new FileLogger to generate build log
            FileLogger logger = new FileLogger();

            // Set the logfile parameter to indicate the log destination
            logger.Parameters = @"logfile=C:\temp\build.log";

            // Register the logger with the engine
            engine.RegisterLogger(logger);

            // Build a project file 
            bool success = engine.BuildProjectFile(@"c:\temp\validate.proj");

            //Unregister all loggers to close the log file
            engine.UnregisterAllLoggers();

            if (success)
                Console.WriteLine("Build succeeded.");
            else
                Console.WriteLine(@"Build failed. View C:\temp\build.log for details");

        }
    }
}

.NET Framework

Supported in: 3.5, 3.0, 2.0
Obsolete (compiler warning) in 4.6
Obsolete (compiler warning) in 4.5
Obsolete (compiler warning) in 4.5.1
Obsolete (compiler warning) in 4.5.2
Obsolete (compiler warning) in 4

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft