Engine Class
.NET Framework 3.5
Represents the MSBuild engine.
Assembly: Microsoft.Build.Engine (in Microsoft.Build.Engine.dll)
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"); } } }
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
how to compile C# project using Engine class ?
Visual Studio 2008 and .net 3.5 framework is used to build code.
If I send file path of *.vcproj in the below mention function. It works perfectly fine. Code is compiled and binary is generated.
bool success = engine.BuildProjectFile(@"c:\temp\validate.vcproj");
While If I send path of *.csproj project in below mention code . It generates the error.
bool success = engine.BuildProjectFile(@"c:\temp\validate.csproj");
So, help me to build c# project using above mention code?
- 1/9/2012
- BondMaverick
- 1/10/2012
- BondMaverick
engine.BinPath is deprecated
BinPath is supposed to be deprecated.
They should change the sample code here.
They should change the sample code here.
- 8/3/2009
- sebastian gomez
- 8/3/2009
- Thomas Lee