Export (0) Print
Expand All
0 out of 3 rated this helpful - Rate this topic

Engine Class

Note: This class is new in the .NET Framework version 2.0.

Represents the MSBuild engine.

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

public class Engine
public class Engine
public class Engine

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 correct path that contains the 2.0 clr/tools
            engine.BinPath = @"c:\windows\microsoft.net\framework\v2.0.xxxxx";

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

            // Set 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");

            if (success)
                Console.WriteLine("Success!");
            else
                Console.WriteLine("Build failed - look at c:\temp\build.log for details");
        }
    }
}

System.Object
  Microsoft.Build.BuildEngine.Engine
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.