Engine.BuildProjectFile Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Loads the specified project file and builds the project.
Overloads
BuildProjectFile(String, String[], BuildPropertyGroup, IDictionary, BuildSettings, String) |
Loads a project file from disk and builds the given targets. |
BuildProjectFile(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. |
BuildProjectFile(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. |
BuildProjectFile(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. |
BuildProjectFile(String, String) |
Loads the specified project file and builds the specified target of the project. |
BuildProjectFile(String) |
Loads the specified project file and builds the project. |
BuildProjectFile(String, String[]) |
Loads the specified project file and builds the specified targets of the project. |
Examples
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");
}
}
}
Module Module1
'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 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 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")
'Unregister all loggers to close the log file
engine.UnregisterAllLoggers()
If success Then
Console.WriteLine("Build succeeded.")
Else
Console.WriteLine("Build failed. View C:\temp\build.log for details.")
End If
End Sub
End Module
BuildProjectFile(String, String[], BuildPropertyGroup, IDictionary, BuildSettings, String)
Loads a project file from disk and builds the given targets.
public:
bool BuildProjectFile(System::String ^ projectFile, cli::array <System::String ^> ^ targetNames, Microsoft::Build::BuildEngine::BuildPropertyGroup ^ globalProperties, System::Collections::IDictionary ^ targetOutputs, Microsoft::Build::BuildEngine::BuildSettings buildFlags, System::String ^ toolsVersion);
public bool BuildProjectFile (string projectFile, string[] targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties, System.Collections.IDictionary targetOutputs, Microsoft.Build.BuildEngine.BuildSettings buildFlags, string toolsVersion);
member this.BuildProjectFile : string * string[] * Microsoft.Build.BuildEngine.BuildPropertyGroup * System.Collections.IDictionary * Microsoft.Build.BuildEngine.BuildSettings * string -> bool
Public Function BuildProjectFile (projectFile As String, targetNames As String(), globalProperties As BuildPropertyGroup, targetOutputs As IDictionary, buildFlags As BuildSettings, toolsVersion As String) As Boolean
Parameters
- projectFile
- String
The name of the project to build.
- targetNames
- String[]
A BuildPropertyGroup array of targets for each project. Can be null
if you want to build the default targets for the project.
- globalProperties
- BuildPropertyGroup
An IDictionary array of properties for each project. Can be null
if no global properties are required.
- targetOutputs
- IDictionary
A BuildSettings array of tables for target outputs. Can be null
if outputs are not required.
- buildFlags
- BuildSettings
A string array of additional build flags.
- toolsVersion
- String
The ToolsVersion to impose on the project in this build.
Returns
true
if the build succeeds; otherwise, false
.
Remarks
This overload takes a set of global properties for each project to use for the build, returns the target outputs, and also enables the caller to specify additional build flags.
Applies to
BuildProjectFile(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:
bool BuildProjectFile(System::String ^ projectFile, cli::array <System::String ^> ^ targetNames, Microsoft::Build::BuildEngine::BuildPropertyGroup ^ globalProperties, System::Collections::IDictionary ^ targetOutputs, Microsoft::Build::BuildEngine::BuildSettings buildFlags);
public bool BuildProjectFile (string projectFile, string[] targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties, System.Collections.IDictionary targetOutputs, Microsoft.Build.BuildEngine.BuildSettings buildFlags);
member this.BuildProjectFile : string * string[] * Microsoft.Build.BuildEngine.BuildPropertyGroup * System.Collections.IDictionary * Microsoft.Build.BuildEngine.BuildSettings -> bool
Public Function BuildProjectFile (projectFile As String, targetNames As String(), globalProperties As BuildPropertyGroup, targetOutputs As IDictionary, buildFlags As BuildSettings) As Boolean
Parameters
- projectFile
- String
The project file to load and build.
- targetNames
- String[]
An array that contains the Name
attributes of the Target elements to build.
- globalProperties
- BuildPropertyGroup
The GlobalProperties to apply to the build.
- targetOutputs
- IDictionary
The outputs of the built targets. This parameter can be a null reference (Nothing
in Visual Basic) if outputs are not required.
- buildFlags
- BuildSettings
The BuildSettings to apply to the build.
Returns
true
if the build was successful; otherwise, false
.
Applies to
BuildProjectFile(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:
bool BuildProjectFile(System::String ^ projectFile, cli::array <System::String ^> ^ targetNames, Microsoft::Build::BuildEngine::BuildPropertyGroup ^ globalProperties);
public bool BuildProjectFile (string projectFile, string[] targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties);
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public bool BuildProjectFile (string projectFile, string[] targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties);
member this.BuildProjectFile : string * string[] * Microsoft.Build.BuildEngine.BuildPropertyGroup -> bool
[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]
member this.BuildProjectFile : string * string[] * Microsoft.Build.BuildEngine.BuildPropertyGroup -> bool
Public Function BuildProjectFile (projectFile As String, targetNames As String(), globalProperties As BuildPropertyGroup) As Boolean
Parameters
- projectFile
- String
The project file to load and build.
- targetNames
- String[]
An array that contains the Name
attributes of the Target elements to build.
- globalProperties
- BuildPropertyGroup
The GlobalProperties to apply to the build.
Returns
true
if the build was successful; otherwise, false
.
- Attributes
Applies to
BuildProjectFile(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:
bool BuildProjectFile(System::String ^ projectFile, cli::array <System::String ^> ^ targetNames, Microsoft::Build::BuildEngine::BuildPropertyGroup ^ globalProperties, System::Collections::IDictionary ^ targetOutputs);
public bool BuildProjectFile (string projectFile, string[] targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties, System.Collections.IDictionary targetOutputs);
[System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")]
public bool BuildProjectFile (string projectFile, string[] targetNames, Microsoft.Build.BuildEngine.BuildPropertyGroup globalProperties, System.Collections.IDictionary targetOutputs);
member this.BuildProjectFile : string * string[] * Microsoft.Build.BuildEngine.BuildPropertyGroup * System.Collections.IDictionary -> bool
[<System.Runtime.TargetedPatchingOptOut("Performance critical to inline this type of method across NGen image boundaries")>]
member this.BuildProjectFile : string * string[] * Microsoft.Build.BuildEngine.BuildPropertyGroup * System.Collections.IDictionary -> bool
Public Function BuildProjectFile (projectFile As String, targetNames As String(), globalProperties As BuildPropertyGroup, targetOutputs As IDictionary) As Boolean
Parameters
- projectFile
- String
The project file to load and build.
- targetNames
- String[]
An array that contains the Name
attributes of the Target elements to build.
- globalProperties
- BuildPropertyGroup
The GlobalProperties to apply to the build.
- targetOutputs
- IDictionary
The outputs of the built targets. This parameter can be a null reference (Nothing
in Visual Basic) if outputs are not required.
Returns
true
if the build was successful; otherwise, false
.
- Attributes
Applies to
BuildProjectFile(String, String)
Loads the specified project file and builds the specified target of the project.
public:
bool BuildProjectFile(System::String ^ projectFile, System::String ^ targetName);
public bool BuildProjectFile (string projectFile, string targetName);
member this.BuildProjectFile : string * string -> bool
Public Function BuildProjectFile (projectFile As String, targetName As String) As Boolean
Parameters
- projectFile
- String
The project file to load and build.
- targetName
- String
The Name
attribute of the Target element to build.
Returns
true
if the build was successful; otherwise, false
.
Applies to
BuildProjectFile(String)
Loads the specified project file and builds the project.
public:
bool BuildProjectFile(System::String ^ projectFile);
public bool BuildProjectFile (string projectFile);
member this.BuildProjectFile : string -> bool
Public Function BuildProjectFile (projectFile As String) As Boolean
Parameters
- projectFile
- String
The project file to load and build.
Returns
true
if the build was successful; otherwise, false
.
Examples
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");
}
}
}
Module Module1
'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 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 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")
'Unregister all loggers to close the log file
engine.UnregisterAllLoggers()
If success Then
Console.WriteLine("Build succeeded.")
Else
Console.WriteLine("Build failed. View C:\temp\build.log for details.")
End If
End Sub
End Module
Applies to
BuildProjectFile(String, String[])
Loads the specified project file and builds the specified targets of the project.
public:
bool BuildProjectFile(System::String ^ projectFile, cli::array <System::String ^> ^ targetNames);
public bool BuildProjectFile (string projectFile, string[] targetNames);
member this.BuildProjectFile : string * string[] -> bool
Public Function BuildProjectFile (projectFile As String, targetNames As String()) As Boolean
Parameters
- projectFile
- String
The project file to load and build.
- targetNames
- String[]
An array that contains the Name
attributes of the Target elements to build.
Returns
true
if the build was successful; otherwise, false
.