Note: This constructor is new in the .NET Framework version 2.0.
Initializes a new instance of the
Engine class.
Namespace: Microsoft.Build.BuildEngine
Assembly: Microsoft.Build.Engine (in microsoft.build.engine.dll)
Visual Basic (Declaration)
Dim instance As New Engine
public function Engine ()
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.
Module Module1
'You need to add references to Microsoft.Build.Framework and
'Microsoft.Build.BuildEngine
Sub Main()
'Create a new Engine object
Dim engine As 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 a build log
Dim logger As 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 the project file
Dim success As Boolean = engine.BuildProjectFile("c:\temp\validate.proj")
If success Then
Console.WriteLine("Build successful")
Else
Console.WriteLine("Build failed - view the log")
End If
End Sub
End Module
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");
}
}
}
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .
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